Skip to content

Commit

Permalink
route-table: Allow parsing routes without nexthop.
Browse files Browse the repository at this point in the history
A recent commit[0] added condition to "route_table_parse__" function that
causes it to throw error when parsing route without "nexthop
information" (either RTA_OIF, RTA_GATEWAY, RTA_VIA or RTA_MULTIPATH). While
this requirement is reasonable for regular routes, there are some route types
that don't need nexthop. One of these types is "blackhole" route, that we intend
to use in OVN for route advertising (RTN_BLACKHOLE)[1].

This change does not enforce the above-mentioned condition for those special
route types that don't require "nexthop information".

[0] openvswitch@91fc511
[1] https://mail.openvswitch.org/pipermail/ovs-dev/2025-January/419383.html

Signed-off-by: Martin Kalcok <[email protected]>
Signed-off-by: 0-day Robot <[email protected]>
  • Loading branch information
mkalcok authored and ovsrobot committed Jan 17, 2025
1 parent caed64d commit 242a553
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/route-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ route_table_reset(void)
}
}


/* Returns true if the given route requires nexhop information (output
interface, nexthop IP, ...). Returns false for special route types, like
blackhole, that don't need this information.
*/
static bool
route_needs_nexthop(const struct rtmsg *rtm) {
switch (rtm->rtm_type) {
case RTN_BLACKHOLE:
case RTN_THROW:
case RTN_UNREACHABLE:
case RTN_PROHIBIT:
return false;
default:
return true;
}
}

static int
route_table_parse__(struct ofpbuf *buf, size_t ofs,
const struct nlmsghdr *nlmsg,
Expand Down Expand Up @@ -430,7 +448,7 @@ route_table_parse__(struct ofpbuf *buf, size_t ofs,
&mp_change.rd.nexthops);
}
}
if (!attrs[RTA_OIF] && !attrs[RTA_GATEWAY]
if (route_needs_nexthop(rtm) && !attrs[RTA_OIF] && !attrs[RTA_GATEWAY]
&& !attrs[RTA_VIA] && !attrs[RTA_MULTIPATH]) {
VLOG_DBG_RL(&rl, "route message needs an RTA_OIF, RTA_GATEWAY, "
"RTA_VIA or RTA_MULTIPATH attribute");
Expand Down

0 comments on commit 242a553

Please sign in to comment.