The rtnetlink rtmsg rtm_table variable can hold route table IDs no higher than UCHAR_MAX.
Use the rtnetlink RTA_TABLE route attribute for table IDs larger than UCHAR_MAX, which can represent a 32 bit integer worth of route tables. While RTA_TABLE support was added to the kernel in commit [0] and has been supported since 2006 starting from v2.6.19, we retain a backward compatible approach for consistency with the existing code for reading route table back from the kernel [1]. 0: https://github.com/torvalds/linux/commit/9e762a4a89b302cb3b26a1f9bb33eff459eaeca9 1: https://github.com/openvswitch/ovs/blob/8b7f1eb8db1aa99ccf7b542662129450caff65e0/lib/route-table.c#L284-L287 Signed-off-by: Frode Nordahl <[email protected]> --- lib/route-table.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/route-table.c b/lib/route-table.c index 1703b69b4..180da1632 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -198,7 +198,7 @@ route_table_wait(void) } static bool -route_table_dump_one_table(unsigned char id) +route_table_dump_one_table(uint32_t id) { uint64_t reply_stub[NL_DUMP_BUFSIZE / 8]; struct ofpbuf request, reply, buf; @@ -212,7 +212,13 @@ route_table_dump_one_table(unsigned char id) rq_msg = ofpbuf_put_zeros(&request, sizeof *rq_msg); rq_msg->rtm_family = AF_UNSPEC; - rq_msg->rtm_table = id; + + if (id > UCHAR_MAX) { + rq_msg->rtm_table = RT_TABLE_UNSPEC; + nl_msg_put_u32(&request, RTA_TABLE, id); + } else { + rq_msg->rtm_table = id; + } nl_dump_start(&dump, NETLINK_ROUTE, &request); ofpbuf_uninit(&request); @@ -241,7 +247,7 @@ route_table_dump_one_table(unsigned char id) static void route_table_reset(void) { - unsigned char tables[] = { + uint32_t tables[] = { RT_TABLE_DEFAULT, RT_TABLE_MAIN, RT_TABLE_LOCAL, -- 2.47.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
