From 3f2d845d5224fe7b845b18b9b7f0823b04d847e1 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Fri, 6 Dec 2024 21:26:40 +0100 Subject: [PATCH] route-table: Export route table dump function. Along with dependent data structures this function is useful for external programs to make use of functionality provided by the route-table module. Signed-off-by: Frode Nordahl Signed-off-by: 0-day Robot --- lib/route-table.c | 35 +---------------------------------- lib/route-table.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/route-table.c b/lib/route-table.c index cd2f3583f92..35b0a2b18a2 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -48,39 +48,6 @@ VLOG_DEFINE_THIS_MODULE(route_table); COVERAGE_DEFINE(route_table_dump); -struct route_data_nexthop { - struct ovs_list nexthop_node; - - sa_family_t family; - struct in6_addr addr; - char ifname[IFNAMSIZ]; /* Interface name. */ -}; - -struct route_data { - struct ovs_list nexthops; - - /* Copied from struct rtmsg. */ - unsigned char rtm_dst_len; - unsigned char rtm_protocol; - bool local; - - /* Extracted from Netlink attributes. */ - struct in6_addr rta_dst; /* 0 if missing. */ - struct in6_addr rta_prefsrc; /* 0 if missing. */ - uint32_t mark; - uint32_t rta_table_id; /* 0 if missing. */ - uint32_t rta_priority; /* 0 if missing. */ -}; - - -/* A digested version of a route message sent down by the kernel to indicate - * that a route has changed. */ -struct route_table_msg { - bool relevant; /* Should this message be processed? */ - int nlmsg_type; /* e.g. RTM_NEWROUTE, RTM_DELROUTE. */ - struct route_data rd; /* Data parsed from this message. */ -}; - static struct ovs_mutex route_table_mutex = OVS_MUTEX_INITIALIZER; static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); @@ -189,7 +156,7 @@ route_table_wait(void) ovs_mutex_unlock(&route_table_mutex); } -static bool +bool route_table_dump_one_table( uint32_t id, void (*handle_msg)(const struct route_table_msg *, void *), diff --git a/lib/route-table.h b/lib/route-table.h index 3a02d737aea..592ad557098 100644 --- a/lib/route-table.h +++ b/lib/route-table.h @@ -24,8 +24,41 @@ #include #include +#include "openvswitch/list.h" #include "openvswitch/types.h" +struct route_data_nexthop { + struct ovs_list nexthop_node; + + sa_family_t family; + struct in6_addr addr; + char ifname[IFNAMSIZ]; /* Interface name. */ +}; + +struct route_data { + struct ovs_list nexthops; + + /* Copied from struct rtmsg. */ + unsigned char rtm_dst_len; + unsigned char rtm_protocol; + bool local; + + /* Extracted from Netlink attributes. */ + struct in6_addr rta_dst; /* 0 if missing. */ + struct in6_addr rta_prefsrc; /* 0 if missing. */ + uint32_t mark; + uint32_t rta_table_id; /* 0 if missing. */ + uint32_t rta_priority; /* 0 if missing. */ +}; + +/* A digested version of a route message sent down by the kernel to indicate + * that a route has changed. */ +struct route_table_msg { + bool relevant; /* Should this message be processed? */ + int nlmsg_type; /* e.g. RTM_NEWROUTE, RTM_DELROUTE. */ + struct route_data rd; /* Data parsed from this message. */ +}; + uint64_t route_table_get_change_seq(void); void route_table_init(void); void route_table_run(void); @@ -33,4 +66,8 @@ void route_table_wait(void); bool route_table_fallback_lookup(const struct in6_addr *ip6_dst, char name[], struct in6_addr *gw6); +bool route_table_dump_one_table( + uint32_t id, + void (*handle_msg)(const struct route_table_msg *, void *), + void *data); #endif /* route-table.h */