From 7e1b56ba98c22bb26cd798b289a214abfb32a8e2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 6 Nov 2023 08:56:50 -0500 Subject: [PATCH] zebra: When using Nexthop groups, use v6 RR semantics The nexthop group route replace operation was made consistent across all versions of the kernel. A v6 route replacement does not need to do a delete than add when using nexthop groups Signed-off-by: Donald Sharp --- zebra/rt_netlink.c | 6 ++++-- zebra/zebra_vty.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 3351b0395073..58116c656375 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2209,7 +2209,8 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx req->n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; if (((cmd == RTM_NEWROUTE) && - ((p->family == AF_INET) || zrouter.v6_rr_semantics)) || + ((p->family == AF_INET) || kernel_nexthops_supported() || + zrouter.v6_rr_semantics)) || force_rr) req->n.nlmsg_flags |= NLM_F_REPLACE; @@ -3095,7 +3096,8 @@ netlink_put_route_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx) } else if (dplane_ctx_get_op(ctx) == DPLANE_OP_ROUTE_INSTALL) { cmd = RTM_NEWROUTE; } else if (dplane_ctx_get_op(ctx) == DPLANE_OP_ROUTE_UPDATE) { - if (p->family == AF_INET || zrouter.v6_rr_semantics) { + if (p->family == AF_INET || kernel_nexthops_supported() || + zrouter.v6_rr_semantics) { /* Single 'replace' operation */ /* diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index fce358f9ff6c..8c9724873728 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -4028,6 +4028,17 @@ static int config_write_protocol(struct vty *vty) return 1; } +static inline bool zebra_vty_v6_rr_semantics_used(void) +{ + if (zebra_nhg_kernel_nexthops_enabled()) + return true; + + if (zrouter.v6_rr_semantics) + return true; + + return false; +} + DEFUN (show_zebra, show_zebra_cmd, "show zebra", @@ -4048,7 +4059,8 @@ DEFUN (show_zebra, ttable_add_row(table, "EVPN|%s", is_evpn_enabled() ? "On" : "Off"); ttable_add_row(table, "Kernel socket buffer size|%d", rcvbufsize); ttable_add_row(table, "v6 Route Replace Semantics|%s", - zrouter.v6_rr_semantics ? "Replace" : "Delete then Add"); + zebra_vty_v6_rr_semantics_used() ? "Replace" + : "Delete then Add"); #ifdef GNU_LINUX if (!vrf_is_backend_netns())