mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 09:47:11 +00:00
zebra: extract neigbor processing from zevpn_gw_macip_add
extract the neighbor part of process_remote_macip_add into a new function zebra_evpn_neigh_gw_macip_add in zebra_evpn_neigh.c. Signed-off-by: Pat Ruddy <pat@voltanet.io>
This commit is contained in:
parent
036daaca3e
commit
224315f3e4
@ -137,6 +137,9 @@ static inline struct interface *zevpn_map_to_svi(zebra_evpn_t *zevpn)
|
||||
return zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
|
||||
}
|
||||
|
||||
int advertise_gw_macip_enabled(zebra_evpn_t *zevpn);
|
||||
int advertise_svi_macip_enabled(zebra_evpn_t *zevpn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -2285,3 +2285,66 @@ void process_neigh_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
|
||||
/* Update seq number. */
|
||||
n->rem_seq = seq;
|
||||
}
|
||||
|
||||
int zebra_evpn_neigh_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
struct ipaddr *ip, zebra_mac_t *mac)
|
||||
{
|
||||
zebra_neigh_t *n;
|
||||
char buf[ETHER_ADDR_STRLEN];
|
||||
char buf2[INET6_ADDRSTRLEN];
|
||||
|
||||
|
||||
n = zebra_evpn_neigh_lookup(zevpn, ip);
|
||||
if (!n) {
|
||||
n = zebra_evpn_neigh_add(zevpn, ip, &mac->macaddr, mac, 0);
|
||||
if (!n) {
|
||||
flog_err(
|
||||
EC_ZEBRA_MAC_ADD_FAILED,
|
||||
"Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u",
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)),
|
||||
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
|
||||
ifp->name, ifp->ifindex, zevpn->vni);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set "local" forwarding info. */
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL);
|
||||
ZEBRA_NEIGH_SET_ACTIVE(n);
|
||||
memcpy(&n->emac, &mac->macaddr, ETH_ALEN);
|
||||
n->ifindex = ifp->ifindex;
|
||||
|
||||
/* Only advertise in BGP if the knob is enabled */
|
||||
if (advertise_gw_macip_enabled(zevpn)) {
|
||||
|
||||
SET_FLAG(mac->flags, ZEBRA_MAC_DEF_GW);
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW);
|
||||
/* Set Router flag (R-bit) */
|
||||
if (ip->ipa_type == IPADDR_V6)
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG);
|
||||
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"SVI %s(%u) L2-VNI %u, sending GW MAC %s IP %s add to BGP with flags 0x%x",
|
||||
ifp->name, ifp->ifindex, zevpn->vni,
|
||||
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)), n->flags);
|
||||
|
||||
zebra_evpn_neigh_send_add_to_client(
|
||||
zevpn->vni, ip, &n->emac, n->mac, n->flags, n->loc_seq);
|
||||
} else if (advertise_svi_macip_enabled(zevpn)) {
|
||||
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_SVI_IP);
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"SVI %s(%u) L2-VNI %u, sending SVI MAC %s IP %s add to BGP with flags 0x%x",
|
||||
ifp->name, ifp->ifindex, zevpn->vni,
|
||||
prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)), n->flags);
|
||||
|
||||
zebra_evpn_neigh_send_add_to_client(
|
||||
zevpn->vni, ip, &n->emac, n->mac, n->flags, n->loc_seq);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -279,6 +279,8 @@ void process_neigh_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
|
||||
struct ipaddr *ipaddr, zebra_mac_t *mac,
|
||||
struct in_addr vtep_ip, uint8_t flags,
|
||||
uint32_t seq);
|
||||
int zebra_evpn_neigh_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
struct ipaddr *ip, zebra_mac_t *mac);
|
||||
|
||||
zebra_neigh_t *zebra_evpn_neigh_add(zebra_evpn_t *zevpn, struct ipaddr *ip,
|
||||
struct ethaddr *mac, zebra_mac_t *zmac,
|
||||
|
@ -151,8 +151,6 @@ static int zevpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
static int zevpn_gw_macip_del(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
struct ipaddr *ip);
|
||||
struct interface *zebra_get_vrr_intf_for_svi(struct interface *ifp);
|
||||
static int advertise_gw_macip_enabled(zebra_evpn_t *zevpn);
|
||||
static int advertise_svi_macip_enabled(zebra_evpn_t *zevpn);
|
||||
static unsigned int zebra_vxlan_sg_hash_key_make(const void *p);
|
||||
static bool zebra_vxlan_sg_hash_eq(const void *p1, const void *p2);
|
||||
static void zebra_vxlan_sg_do_deref(struct zebra_vrf *zvrf,
|
||||
@ -211,7 +209,7 @@ static uint32_t rb_host_count(struct host_rb_tree_entry *hrbe)
|
||||
return count;
|
||||
}
|
||||
|
||||
static int advertise_gw_macip_enabled(zebra_evpn_t *zevpn)
|
||||
int advertise_gw_macip_enabled(zebra_evpn_t *zevpn)
|
||||
{
|
||||
struct zebra_vrf *zvrf;
|
||||
|
||||
@ -225,7 +223,7 @@ static int advertise_gw_macip_enabled(zebra_evpn_t *zevpn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int advertise_svi_macip_enabled(zebra_evpn_t *zevpn)
|
||||
int advertise_svi_macip_enabled(zebra_evpn_t *zevpn)
|
||||
{
|
||||
struct zebra_vrf *zvrf;
|
||||
|
||||
@ -1174,9 +1172,6 @@ static int zevpn_advertise_subnet(zebra_evpn_t *zevpn, struct interface *ifp,
|
||||
static int zevpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
struct ethaddr *macaddr, struct ipaddr *ip)
|
||||
{
|
||||
char buf[ETHER_ADDR_STRLEN];
|
||||
char buf2[INET6_ADDRSTRLEN];
|
||||
zebra_neigh_t *n = NULL;
|
||||
zebra_mac_t *mac = NULL;
|
||||
struct zebra_if *zif = NULL;
|
||||
struct zebra_l2info_vxlan *vxl = NULL;
|
||||
@ -1192,59 +1187,7 @@ static int zevpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
|
||||
!= 0)
|
||||
return -1;
|
||||
|
||||
n = zebra_evpn_neigh_lookup(zevpn, ip);
|
||||
if (!n) {
|
||||
n = zebra_evpn_neigh_add(zevpn, ip, macaddr, mac, 0);
|
||||
if (!n) {
|
||||
flog_err(
|
||||
EC_ZEBRA_MAC_ADD_FAILED,
|
||||
"Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u",
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)),
|
||||
prefix_mac2str(macaddr, buf, sizeof(buf)),
|
||||
ifp->name, ifp->ifindex, zevpn->vni);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set "local" forwarding info. */
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL);
|
||||
ZEBRA_NEIGH_SET_ACTIVE(n);
|
||||
memcpy(&n->emac, macaddr, ETH_ALEN);
|
||||
n->ifindex = ifp->ifindex;
|
||||
|
||||
/* Only advertise in BGP if the knob is enabled */
|
||||
if (advertise_gw_macip_enabled(zevpn)) {
|
||||
|
||||
SET_FLAG(mac->flags, ZEBRA_MAC_DEF_GW);
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW);
|
||||
/* Set Router flag (R-bit) */
|
||||
if (ip->ipa_type == IPADDR_V6)
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG);
|
||||
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"SVI %s(%u) L2-VNI %u, sending GW MAC %s IP %s add to BGP with flags 0x%x",
|
||||
ifp->name, ifp->ifindex, zevpn->vni,
|
||||
prefix_mac2str(macaddr, buf, sizeof(buf)),
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)), n->flags);
|
||||
|
||||
zebra_evpn_neigh_send_add_to_client(
|
||||
zevpn->vni, ip, &n->emac, n->mac, n->flags, n->loc_seq);
|
||||
} else if (advertise_svi_macip_enabled(zevpn)) {
|
||||
|
||||
SET_FLAG(n->flags, ZEBRA_NEIGH_SVI_IP);
|
||||
if (IS_ZEBRA_DEBUG_VXLAN)
|
||||
zlog_debug(
|
||||
"SVI %s(%u) L2-VNI %u, sending SVI MAC %s IP %s add to BGP with flags 0x%x",
|
||||
ifp->name, ifp->ifindex, zevpn->vni,
|
||||
prefix_mac2str(macaddr, buf, sizeof(buf)),
|
||||
ipaddr2str(ip, buf2, sizeof(buf2)), n->flags);
|
||||
|
||||
zebra_evpn_neigh_send_add_to_client(
|
||||
zevpn->vni, ip, &n->emac, n->mac, n->flags, n->loc_seq);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return zebra_evpn_neigh_gw_macip_add(ifp, zevpn, ip, mac);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user