Skip to content

Commit

Permalink
zebra: add support for maintaining local neigh entries
Browse files Browse the repository at this point in the history
Currently specific local neighbors (attached to SVIs) are maintatined
in an EVPN specific database. There is a need to maintain L3 neighbors
for other purposes including MAC resolution for PBR nexthops.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
   Cleanup compile and fix crash
Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
  • Loading branch information
AnuradhaKaruppiah authored and donaldsharp committed Jun 27, 2022
1 parent f646c17 commit 4cf4fad
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 6 deletions.
25 changes: 25 additions & 0 deletions zebra/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ unsigned long zebra_debug_mlag;
unsigned long zebra_debug_nexthop;
unsigned long zebra_debug_evpn_mh;
unsigned long zebra_debug_pbr;
unsigned long zebra_debug_neigh;

DEFINE_HOOK(zebra_debug_show_debugging, (struct vty *vty), (vty));

Expand Down Expand Up @@ -327,6 +328,22 @@ DEFUN (debug_zebra_pbr,
return CMD_SUCCESS;
}

DEFPY (debug_zebra_neigh,
debug_zebra_neigh_cmd,
"[no$no] debug zebra neigh",
NO_STR
DEBUG_STR
"Zebra configuration\n"
"Debug zebra neigh events\n")
{
if (no)
UNSET_FLAG(zebra_debug_neigh, ZEBRA_DEBUG_NEIGH);
else
SET_FLAG(zebra_debug_neigh, ZEBRA_DEBUG_NEIGH);

return CMD_SUCCESS;
}

DEFPY (debug_zebra_mlag,
debug_zebra_mlag_cmd,
"[no$no] debug zebra mlag",
Expand Down Expand Up @@ -694,6 +711,11 @@ static int config_write_debug(struct vty *vty)
write++;
}

if (IS_ZEBRA_DEBUG_NEIGH) {
vty_out(vty, "debug zebra neigh\n");
write++;
}

return write;
}

Expand All @@ -713,6 +735,7 @@ void zebra_debug_init(void)
zebra_debug_nht = 0;
zebra_debug_nexthop = 0;
zebra_debug_pbr = 0;
zebra_debug_neigh = 0;

install_node(&debug_node);

Expand All @@ -734,6 +757,7 @@ void zebra_debug_init(void)
install_element(ENABLE_NODE, &debug_zebra_mlag_cmd);
install_element(ENABLE_NODE, &debug_zebra_nexthop_cmd);
install_element(ENABLE_NODE, &debug_zebra_pbr_cmd);
install_element(ENABLE_NODE, &debug_zebra_neigh_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_events_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_nht_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_mpls_cmd);
Expand Down Expand Up @@ -764,6 +788,7 @@ void zebra_debug_init(void)
install_element(CONFIG_NODE, &debug_zebra_dplane_cmd);
install_element(CONFIG_NODE, &debug_zebra_nexthop_cmd);
install_element(CONFIG_NODE, &debug_zebra_pbr_cmd);
install_element(CONFIG_NODE, &debug_zebra_neigh_cmd);

install_element(CONFIG_NODE, &no_debug_zebra_events_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_nht_cmd);
Expand Down
5 changes: 5 additions & 0 deletions zebra/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ extern "C" {

#define ZEBRA_DEBUG_PBR 0x01

#define ZEBRA_DEBUG_NEIGH 0x01

/* Debug related macro. */
#define IS_ZEBRA_DEBUG_EVENT (zebra_debug_event & ZEBRA_DEBUG_EVENT)

Expand Down Expand Up @@ -121,6 +123,8 @@ extern "C" {

#define IS_ZEBRA_DEBUG_PBR (zebra_debug_pbr & ZEBRA_DEBUG_PBR)

#define IS_ZEBRA_DEBUG_NEIGH (zebra_debug_neigh & ZEBRA_DEBUG_NEIGH)

extern unsigned long zebra_debug_event;
extern unsigned long zebra_debug_packet;
extern unsigned long zebra_debug_kernel;
Expand All @@ -135,6 +139,7 @@ extern unsigned long zebra_debug_mlag;
extern unsigned long zebra_debug_nexthop;
extern unsigned long zebra_debug_evpn_mh;
extern unsigned long zebra_debug_pbr;
extern unsigned long zebra_debug_neigh;

extern void zebra_debug_init(void);

Expand Down
30 changes: 24 additions & 6 deletions zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include "zebra/zebra_errors.h"
#include "zebra/zebra_evpn_mh.h"
#include "zebra/zebra_trace.h"
#include "zebra/zebra_neigh.h"

#ifndef AF_MPLS
#define AF_MPLS 28
Expand Down Expand Up @@ -3882,10 +3883,10 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
} else if (IS_ZEBRA_IF_BRIDGE(ifp))
link_if = ifp;
else {
link_if = NULL;
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
" Neighbor Entry received is not on a VLAN or a BRIDGE, ignoring");
return 0;
}

memset(&mac, 0, sizeof(mac));
Expand Down Expand Up @@ -3949,12 +3950,25 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
*/
local_inactive = false;

return zebra_vxlan_handle_kernel_neigh_update(
ifp, link_if, &ip, &mac, ndm->ndm_state, is_ext,
is_router, local_inactive, dp_static);
/* Add local neighbors to the l3 interface database */
if (is_ext)
zebra_neigh_del(ifp, &ip);
else
zebra_neigh_add(ifp, &ip, &mac);

if (link_if)
zebra_vxlan_handle_kernel_neigh_update(
ifp, link_if, &ip, &mac, ndm->ndm_state,
is_ext, is_router, local_inactive,
dp_static);
return 0;
}

return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);

zebra_neigh_del(ifp, &ip);
if (link_if)
zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);
return 0;
}

if (IS_ZEBRA_DEBUG_KERNEL)
Expand All @@ -3967,7 +3981,11 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
/* Process the delete - it may result in re-adding the neighbor if it is
* a valid "remote" neighbor.
*/
return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);
zebra_neigh_del(ifp, &ip);
if (link_if)
zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);

return 0;
}

static int netlink_neigh_table(struct nlmsghdr *h, ns_id_t ns_id, int startup)
Expand Down
2 changes: 2 additions & 0 deletions zebra/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ zebra_zebra_SOURCES = \
zebra/zebra_vty.c \
zebra/zebra_vxlan.c \
zebra/zebra_evpn_mh.c \
zebra/zebra_neigh.c \
zebra/zserv.c \
# end

Expand Down Expand Up @@ -197,6 +198,7 @@ noinst_HEADERS += \
zebra/zebra_vxlan.h \
zebra/zebra_vxlan_private.h \
zebra/zebra_evpn_mh.h \
zebra/zebra_neigh.h \
zebra/zserv.h \
# end

Expand Down
Loading

0 comments on commit 4cf4fad

Please sign in to comment.