Skip to content

Commit

Permalink
route-table: Export route table dump function.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: 0-day Robot <[email protected]>
  • Loading branch information
fnordahl authored and ovsrobot committed Dec 6, 2024
1 parent 603e11e commit 3f2d845
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
35 changes: 1 addition & 34 deletions lib/route-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 *),
Expand Down
37 changes: 37 additions & 0 deletions lib/route-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,50 @@
#include <stdbool.h>
#include <stdint.h>

#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);
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 */

0 comments on commit 3f2d845

Please sign in to comment.