mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 15:10:38 +00:00
zebra: extract neighbor processing from kernel_neigh_del
extract the neighbor uninstall part of zebra_vxlan_handle_kernel_neigh_del into a new function zebra_evpn_neigh_del_ip in zebra_evpn_neigh.c. Signed-off-by: Pat Ruddy <pat@voltanet.io>
This commit is contained in:
parent
32fe7dfd9b
commit
33064a6289
@ -243,9 +243,10 @@ static void zebra_evpn_local_neigh_ref_mac(zebra_neigh_t *n,
|
||||
}
|
||||
|
||||
/* sync-path that is active on an ES peer */
|
||||
void zebra_evpn_sync_neigh_dp_install(zebra_neigh_t *n, bool set_inactive,
|
||||
bool force_clear_static,
|
||||
const char *caller)
|
||||
static void zebra_evpn_sync_neigh_dp_install(zebra_neigh_t *n,
|
||||
bool set_inactive,
|
||||
bool force_clear_static,
|
||||
const char *caller)
|
||||
{
|
||||
char macbuf[ETHER_ADDR_STRLEN];
|
||||
char ipbuf[INET6_ADDRSTRLEN];
|
||||
@ -349,9 +350,9 @@ int zebra_evpn_neigh_send_del_to_client(vni_t vni, struct ipaddr *ip,
|
||||
vni, macaddr, ip, flags, 0, state, NULL, ZEBRA_MACIP_DEL);
|
||||
}
|
||||
|
||||
void zebra_evpn_neigh_send_add_del_to_client(zebra_neigh_t *n,
|
||||
bool old_bgp_ready,
|
||||
bool new_bgp_ready)
|
||||
static void zebra_evpn_neigh_send_add_del_to_client(zebra_neigh_t *n,
|
||||
bool old_bgp_ready,
|
||||
bool new_bgp_ready)
|
||||
{
|
||||
if (new_bgp_ready)
|
||||
zebra_evpn_neigh_send_add_to_client(n->zevpn->vni, &n->ip,
|
||||
@ -2387,3 +2388,95 @@ void zebra_evpn_neigh_remote_uninstall(zebra_evpn_t *zevpn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int zebra_evpn_neigh_del_ip(zebra_evpn_t *zevpn, struct ipaddr *ip)
|
||||
{
|
||||
zebra_neigh_t *n;
|
||||
zebra_mac_t *zmac;
|
||||
bool old_bgp_ready;
|
||||
bool new_bgp_ready;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
char buf2[ETHER_ADDR_STRLEN];
|
||||
struct zebra_vrf *zvrf;
|
||||
|
||||
/* If entry doesn't exist, nothing to do. */
|
||||
n = zebra_evpn_neigh_lookup(zevpn, ip);
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
zmac = zebra_evpn_mac_lookup(zevpn, &n->emac);
|
||||
if (!zmac) {
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"Trying to del a neigh %s without a mac %s on VNI %u",
|
||||
ipaddr2str(ip, buf, sizeof(buf)),
|
||||
prefix_mac2str(&n->emac, buf2, sizeof(buf2)),
|
||||
zevpn->vni);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If it is a remote entry, the kernel has aged this out or someone has
|
||||
* deleted it, it needs to be re-installed as Quagga is the owner.
|
||||
*/
|
||||
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {
|
||||
zebra_evpn_rem_neigh_install(zevpn, n, false /*was_static*/);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if this is a sync entry it cannot be dropped re-install it in
|
||||
* the dataplane
|
||||
*/
|
||||
old_bgp_ready = zebra_evpn_neigh_is_ready_for_bgp(n);
|
||||
if (zebra_evpn_neigh_is_static(n)) {
|
||||
if (IS_ZEBRA_DEBUG_EVPN_MH_NEIGH)
|
||||
zlog_debug("re-add sync neigh vni %u ip %s mac %s 0x%x",
|
||||
n->zevpn->vni,
|
||||
ipaddr2str(&n->ip, buf, sizeof(buf)),
|
||||
prefix_mac2str(&n->emac, buf2, sizeof(buf2)),
|
||||
n->flags);
|
||||
|
||||
if (!CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL_INACTIVE))
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL_INACTIVE);
|
||||
/* inform-bgp about change in local-activity if any */
|
||||
new_bgp_ready = zebra_evpn_neigh_is_ready_for_bgp(n);
|
||||
zebra_evpn_neigh_send_add_del_to_client(n, old_bgp_ready,
|
||||
new_bgp_ready);
|
||||
|
||||
/* re-install the entry in the kernel */
|
||||
zebra_evpn_sync_neigh_dp_install(n, false /* set_inactive */,
|
||||
false /* force_clear_static */,
|
||||
__func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
zvrf = vrf_info_lookup(zevpn->vxlan_if->vrf_id);
|
||||
if (!zvrf) {
|
||||
zlog_debug("%s: VNI %u vrf lookup failed.", __func__,
|
||||
zevpn->vni);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* In case of feeze action, if local neigh is in duplicate state,
|
||||
* Mark the Neigh as inactive before sending delete request to BGPd,
|
||||
* If BGPd has remote entry, it will re-install
|
||||
*/
|
||||
if (zvrf->dad_freeze && CHECK_FLAG(n->flags, ZEBRA_NEIGH_DUPLICATE))
|
||||
ZEBRA_NEIGH_SET_INACTIVE(n);
|
||||
|
||||
/* Remove neighbor from BGP. */
|
||||
zebra_evpn_neigh_send_del_to_client(zevpn->vni, &n->ip, &n->emac,
|
||||
n->flags, n->state,
|
||||
false /* force */);
|
||||
|
||||
/* Delete this neighbor entry. */
|
||||
zebra_evpn_neigh_del(zevpn, n);
|
||||
|
||||
/* see if the AUTO mac needs to be deleted */
|
||||
if (CHECK_FLAG(zmac->flags, ZEBRA_MAC_AUTO)
|
||||
&& !listcount(zmac->neigh_list))
|
||||
zebra_evpn_mac_del(zevpn, zmac);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -284,13 +284,8 @@ int zebra_evpn_neigh_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
void zebra_evpn_neigh_remote_uninstall(zebra_evpn_t *zevpn,
|
||||
struct zebra_vrf *zvrf, zebra_neigh_t *n,
|
||||
zebra_mac_t *mac, struct ipaddr *ipaddr);
|
||||
int zebra_evpn_neigh_del_ip(zebra_evpn_t *zevpn, struct ipaddr *ip);
|
||||
|
||||
void zebra_evpn_neigh_send_add_del_to_client(zebra_neigh_t *n,
|
||||
bool old_bgp_ready,
|
||||
bool new_bgp_ready);
|
||||
void zebra_evpn_sync_neigh_dp_install(zebra_neigh_t *n, bool set_inactive,
|
||||
bool force_clear_static,
|
||||
const char *caller);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -4966,14 +4966,8 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
|
||||
struct ipaddr *ip)
|
||||
{
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
char buf2[ETHER_ADDR_STRLEN];
|
||||
zebra_neigh_t *n = NULL;
|
||||
zebra_evpn_t *zevpn = NULL;
|
||||
zebra_mac_t *zmac = NULL;
|
||||
zebra_l3vni_t *zl3vni = NULL;
|
||||
struct zebra_vrf *zvrf;
|
||||
bool old_bgp_ready;
|
||||
bool new_bgp_ready;
|
||||
|
||||
/* check if this is a remote neigh entry corresponding to remote
|
||||
* next-hop
|
||||
@ -5007,88 +5001,7 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
|
||||
ipaddr2str(ip, buf, sizeof(buf)), ifp->name,
|
||||
ifp->ifindex, zevpn->vni);
|
||||
|
||||
/* If entry doesn't exist, nothing to do. */
|
||||
n = zebra_evpn_neigh_lookup(zevpn, ip);
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
zmac = zebra_evpn_mac_lookup(zevpn, &n->emac);
|
||||
if (!zmac) {
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"Trying to del a neigh %s without a mac %s on VNI %u",
|
||||
ipaddr2str(ip, buf, sizeof(buf)),
|
||||
prefix_mac2str(&n->emac, buf2, sizeof(buf2)),
|
||||
zevpn->vni);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If it is a remote entry, the kernel has aged this out or someone has
|
||||
* deleted it, it needs to be re-installed as Quagga is the owner.
|
||||
*/
|
||||
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {
|
||||
zebra_evpn_rem_neigh_install(zevpn, n, false /*was_static*/);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if this is a sync entry it cannot be dropped re-install it in
|
||||
* the dataplane
|
||||
*/
|
||||
old_bgp_ready = zebra_evpn_neigh_is_ready_for_bgp(n);
|
||||
if (zebra_evpn_neigh_is_static(n)) {
|
||||
if (IS_ZEBRA_DEBUG_EVPN_MH_NEIGH)
|
||||
zlog_debug("re-add sync neigh vni %u ip %s mac %s 0x%x",
|
||||
n->zevpn->vni,
|
||||
ipaddr2str(&n->ip, buf, sizeof(buf)),
|
||||
prefix_mac2str(&n->emac, buf2,
|
||||
sizeof(buf2)),
|
||||
n->flags);
|
||||
|
||||
if (!CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL_INACTIVE))
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL_INACTIVE);
|
||||
/* inform-bgp about change in local-activity if any */
|
||||
new_bgp_ready = zebra_evpn_neigh_is_ready_for_bgp(n);
|
||||
zebra_evpn_neigh_send_add_del_to_client(n, old_bgp_ready,
|
||||
new_bgp_ready);
|
||||
|
||||
/* re-install the entry in the kernel */
|
||||
zebra_evpn_sync_neigh_dp_install(n, false /* set_inactive */,
|
||||
false /* force_clear_static */,
|
||||
__func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
zvrf = vrf_info_lookup(zevpn->vxlan_if->vrf_id);
|
||||
if (!zvrf) {
|
||||
zlog_debug("%s: VNI %u vrf lookup failed.", __func__,
|
||||
zevpn->vni);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* In case of feeze action, if local neigh is in duplicate state,
|
||||
* Mark the Neigh as inactive before sending delete request to BGPd,
|
||||
* If BGPd has remote entry, it will re-install
|
||||
*/
|
||||
if (zvrf->dad_freeze &&
|
||||
CHECK_FLAG(n->flags, ZEBRA_NEIGH_DUPLICATE))
|
||||
ZEBRA_NEIGH_SET_INACTIVE(n);
|
||||
|
||||
/* Remove neighbor from BGP. */
|
||||
zebra_evpn_neigh_send_del_to_client(zevpn->vni, &n->ip, &n->emac,
|
||||
n->flags, n->state,
|
||||
false /* force */);
|
||||
|
||||
/* Delete this neighbor entry. */
|
||||
zebra_evpn_neigh_del(zevpn, n);
|
||||
|
||||
/* see if the AUTO mac needs to be deleted */
|
||||
if (CHECK_FLAG(zmac->flags, ZEBRA_MAC_AUTO)
|
||||
&& !listcount(zmac->neigh_list))
|
||||
zebra_evpn_mac_del(zevpn, zmac);
|
||||
|
||||
return 0;
|
||||
return zebra_evpn_neigh_del_ip(zevpn, ip);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user