From 88217099de3d7ddaa7508d7506b12fd260fc3acb Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 5 Apr 2021 21:40:37 +0200 Subject: [PATCH] zebra, lib: replace ZEBRA_ROUTE_NEIGH with simplified version do not add a new route type, and consider 0 as a value meaning that zebra should be the owner. Signed-off-by: Philippe Guibert --- lib/route_types.txt | 2 -- zebra/rt_netlink.c | 19 +++++++++++++++---- zebra/zebra_dplane.c | 12 ++++++------ zebra/zebra_rib.c | 1 - 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/route_types.txt b/lib/route_types.txt index 32c7a89d3d..c48391545d 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -85,7 +85,6 @@ ZEBRA_ROUTE_BFD, bfd, bfdd, '-', 0, 0, 0, "BFD", bf ZEBRA_ROUTE_OPENFABRIC, openfabric, fabricd, 'f', 1, 1, 1, "OpenFabric", fabricd ZEBRA_ROUTE_VRRP, vrrp, vrrpd, '-', 0, 0, 0, "VRRP", vrrpd ZEBRA_ROUTE_NHG, zebra, none, '-', 0, 0, 0, "Nexthop Group", none -ZEBRA_ROUTE_NEIGH, neigh, none, '-', 0, 0, 0, "Neigh Entry", none ZEBRA_ROUTE_SRTE, srte, none, '-', 0, 0, 0, "SR-TE", none ZEBRA_ROUTE_ALL, wildcard, none, '-', 0, 0, 0, "-", none @@ -117,4 +116,3 @@ ZEBRA_ROUTE_BFD, "Bidirectional Fowarding Detection (BFD)" ZEBRA_ROUTE_VRRP, "Virtual Router Redundancy Protocol (VRRP)" ZEBRA_ROUTE_OPENFABRIC, "OpenFabric Routing Protocol" ZEBRA_ROUTE_NHG, "Zebra Nexthop Groups (NHG)" -ZEBRA_ROUTE_NEIGH, "Zebra Neighbor Entry" diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index dc0c839674..d2ec7da57c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -258,7 +258,6 @@ static inline int zebra2proto(int proto) break; case ZEBRA_ROUTE_TABLE: case ZEBRA_ROUTE_NHG: - case ZEBRA_ROUTE_NEIGH: proto = RTPROT_ZEBRA; break; case ZEBRA_ROUTE_CONNECT: @@ -2831,13 +2830,17 @@ netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx, int cmd, void *buf, size_t buflen) { struct ethaddr dst_mac = {.octet = {0}}; + int proto = RTPROT_ZEBRA; + + if (dplane_ctx_get_type(ctx) != 0) + proto = zebra2proto(dplane_ctx_get_type(ctx)); return netlink_neigh_update_msg_encode( ctx, cmd, (const void *)&dst_mac, ETH_ALEN, dplane_ctx_neigh_get_ipaddr(ctx), false, PF_BRIDGE, 0, NTF_SELF, (NUD_NOARP | NUD_PERMANENT), 0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, false /*ext*/, 0 /*ext_flags*/, buf, buflen, - zebra2proto(dplane_ctx_get_type(ctx))); + proto); } #ifndef NDA_RTA @@ -3203,6 +3206,10 @@ ssize_t netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx, void *data, uint32_t update_flags; bool nfy = false; uint8_t nfy_flags = 0; + int proto = RTPROT_ZEBRA; + + if (dplane_ctx_get_type(ctx) != 0) + proto = zebra2proto(dplane_ctx_get_type(ctx)); cmd = dplane_ctx_get_op(ctx) == DPLANE_OP_MAC_INSTALL ? RTM_NEWNEIGH : RTM_DELNEIGH; @@ -3272,7 +3279,7 @@ ssize_t netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx, void *data, ctx, cmd, (const void *)dplane_ctx_mac_get_addr(ctx), ETH_ALEN, &vtep_ip, true, AF_BRIDGE, 0, flags, state, nhg_id, nfy, nfy_flags, false /*ext*/, 0 /*ext_flags*/, data, datalen, - zebra2proto(dplane_ctx_get_type(ctx))); + proto); return total; } @@ -3727,6 +3734,10 @@ static ssize_t netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx, uint32_t update_flags; uint32_t ext_flags = 0; bool ext = false; + int proto = RTPROT_ZEBRA; + + if (dplane_ctx_get_type(ctx) != 0) + proto = zebra2proto(dplane_ctx_get_type(ctx)); ip = dplane_ctx_neigh_get_ipaddr(ctx); @@ -3777,7 +3788,7 @@ static ssize_t netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx, return netlink_neigh_update_msg_encode( ctx, cmd, link_ptr, llalen, ip, true, family, RTN_UNICAST, flags, state, 0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, ext, - ext_flags, buf, buflen, zebra2proto(dplane_ctx_get_type(ctx))); + ext_flags, buf, buflen, proto); } static int netlink_neigh_table_update_ctx(const struct zebra_dplane_ctx *ctx, diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index c7f396ebf9..c8ee8f9051 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -3688,7 +3688,7 @@ enum zebra_dplane_result dplane_rem_neigh_add(const struct interface *ifp, result = neigh_update_internal( DPLANE_OP_NEIGH_INSTALL, ifp, (const void *)mac, AF_ETHERNET, - ip, flags, DPLANE_NUD_NOARP, update_flags, ZEBRA_ROUTE_NEIGH); + ip, flags, DPLANE_NUD_NOARP, update_flags, 0); return result; } @@ -3722,7 +3722,7 @@ enum zebra_dplane_result dplane_local_neigh_add(const struct interface *ifp, result = neigh_update_internal(DPLANE_OP_NEIGH_INSTALL, ifp, (const void *)mac, AF_ETHERNET, ip, ntf, - state, update_flags, ZEBRA_ROUTE_NEIGH); + state, update_flags, 0); return result; } @@ -3739,7 +3739,7 @@ enum zebra_dplane_result dplane_rem_neigh_delete(const struct interface *ifp, update_flags |= DPLANE_NEIGH_REMOTE; result = neigh_update_internal(DPLANE_OP_NEIGH_DELETE, ifp, NULL, - AF_ETHERNET, ip, 0, 0, update_flags, ZEBRA_ROUTE_NEIGH); + AF_ETHERNET, ip, 0, 0, update_flags, 0); return result; } @@ -3763,7 +3763,7 @@ enum zebra_dplane_result dplane_vtep_add(const struct interface *ifp, addr.ipaddr_v4 = *ip; result = neigh_update_internal(DPLANE_OP_VTEP_ADD, ifp, &mac, - AF_ETHERNET, &addr, 0, 0, 0, ZEBRA_ROUTE_NEIGH); + AF_ETHERNET, &addr, 0, 0, 0, 0); return result; } @@ -3789,7 +3789,7 @@ enum zebra_dplane_result dplane_vtep_delete(const struct interface *ifp, result = neigh_update_internal(DPLANE_OP_VTEP_DELETE, ifp, (const void *)&mac, AF_ETHERNET, &addr, - 0, 0, 0, ZEBRA_ROUTE_NEIGH); + 0, 0, 0, 0); return result; } @@ -3801,7 +3801,7 @@ enum zebra_dplane_result dplane_neigh_discover(const struct interface *ifp, result = neigh_update_internal(DPLANE_OP_NEIGH_DISCOVER, ifp, NULL, AF_ETHERNET, ip, DPLANE_NTF_USE, - DPLANE_NUD_INCOMPLETE, 0, ZEBRA_ROUTE_NEIGH); + DPLANE_NUD_INCOMPLETE, 0, 0); return result; } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 11bc0a2c90..82a0e6d015 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -112,7 +112,6 @@ static const struct { [ZEBRA_ROUTE_OPENFABRIC] = {ZEBRA_ROUTE_OPENFABRIC, 115, 4}, [ZEBRA_ROUTE_VRRP] = {ZEBRA_ROUTE_VRRP, 255, 6}, [ZEBRA_ROUTE_SRTE] = {ZEBRA_ROUTE_SRTE, 255, 6}, - [ZEBRA_ROUTE_NEIGH] = {ZEBRA_ROUTE_NEIGH, 255, 6}, /* Any new route type added to zebra, should be mirrored here */ /* no entry/default: 150 */ -- 2.39.5