zebra: extract evpn mac functions from zebra_vxlan.c

Move MAC dB specific functions to zebra_evpn_mac.c

Signed-off-by: Pat Ruddy <pat@voltanet.io>
This commit is contained in:
Pat Ruddy 2020-07-23 14:58:45 -07:00
parent 24268cd07e
commit b299808662
9 changed files with 1266 additions and 13224 deletions

View File

@ -44,6 +44,8 @@
#include "zebra/interface.h"
#include "zebra/zebra_dplane.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_evpn.h"
#include "zebra/zebra_evpn_mac.h"
#include "zebra/zebra_vxlan_private.h"
#include "zebra/kernel_netlink.h"
#include "zebra/rt_netlink.h"

View File

@ -80,6 +80,7 @@ zebra_zebra_SOURCES = \
zebra/zebra_errors.c \
zebra/zebra_gr.c \
zebra/zebra_l2.c \
zebra/zebra_evpn_mac.c \
zebra/zebra_mlag.c \
zebra/zebra_mlag_vty.c \
zebra/zebra_memory.c \
@ -147,6 +148,9 @@ noinst_HEADERS += \
zebra/zapi_msg.h \
zebra/zebra_dplane.h \
zebra/zebra_errors.h \
zebra/zebra_evpn.h \
zebra/zebra_evpn_mac.h \
zebra/zebra_evpn_neigh.h \
zebra/zebra_fpm_private.h \
zebra/zebra_l2.h \
zebra/zebra_memory.h \

118
zebra/zebra_evpn.h Normal file
View File

@ -0,0 +1,118 @@
/*
* Zebra EVPN Data structures and definitions
* These are "internal" to this function.
* Copyright (C) 2016, 2017 Cumulus Networks, Inc.
* Copyright (C) 2020 Volta Networks.
*
* This file is part of FRR.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _ZEBRA_EVPN_H
#define _ZEBRA_EVPN_H
#include <zebra.h>
#include "if.h"
#include "linklist.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zebra_evpn_t_ zebra_evpn_t;
typedef struct zebra_vtep_t_ zebra_vtep_t;
RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
zebra_es_evi_rb_cmp);
/*
* VTEP info
*
* Right now, this just has each remote VTEP's IP address.
*/
struct zebra_vtep_t_ {
/* Remote IP. */
/* NOTE: Can only be IPv4 right now. */
struct in_addr vtep_ip;
/* Flood mode (one of enum vxlan_flood_control) based on the PMSI
* tunnel type advertised by the remote VTEP
*/
int flood_control;
/* Links. */
struct zebra_vtep_t_ *next;
struct zebra_vtep_t_ *prev;
};
/*
* VNI hash table
*
* Contains information pertaining to a VNI:
* - the list of remote VTEPs (with this VNI)
*/
struct zebra_evpn_t_ {
/* VNI - key */
vni_t vni;
/* ES flags */
uint32_t flags;
#define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
/* Flag for advertising gw macip */
uint8_t advertise_gw_macip;
/* Flag for advertising svi macip */
uint8_t advertise_svi_macip;
/* Flag for advertising gw macip */
uint8_t advertise_subnet;
/* Corresponding VxLAN interface. */
struct interface *vxlan_if;
/* List of remote VTEPs */
zebra_vtep_t *vteps;
/* Local IP */
struct in_addr local_vtep_ip;
/* PIM-SM MDT group for BUM flooding */
struct in_addr mcast_grp;
/* tenant VRF, if any */
vrf_id_t vrf_id;
/* List of local or remote MAC */
struct hash *mac_table;
/* List of local or remote neighbors (MAC+IP) */
struct hash *neigh_table;
/* RB tree of ES-EVIs */
struct zebra_es_evi_rb_head es_evi_rb_tree;
/* List of local ESs */
struct list *local_es_evi_list;
};
#ifdef __cplusplus
}
#endif
#endif /*_ZEBRA_EVPN_H */

File diff suppressed because it is too large Load Diff

258
zebra/zebra_evpn_mac.h Normal file
View File

@ -0,0 +1,258 @@
/*
* Zebra EVPN MAC Data structures and definitions
* These are "internal" to this function.
* Copyright (C) 2016, 2017 Cumulus Networks, Inc.
* Copyright (C) 2020 Volta Networks.
*
* This file is part of FRR.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _ZEBRA_EVPN_MAC_H
#define _ZEBRA_EVPN_MAC_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zebra_mac_t_ zebra_mac_t;
struct host_rb_entry {
RB_ENTRY(host_rb_entry) hl_entry;
struct prefix p;
};
RB_HEAD(host_rb_tree_entry, host_rb_entry);
RB_PROTOTYPE(host_rb_tree_entry, host_rb_entry, hl_entry,
host_rb_entry_compare);
/*
* MAC hash table.
*
* This table contains the MAC addresses pertaining to this VNI.
* This includes local MACs learnt on an attached VLAN that maps
* to this VNI as well as remote MACs learnt and installed by BGP.
* Local MACs will be known either on a VLAN sub-interface or
* on (port, VLAN); however, it is sufficient for zebra to maintain
* against the VNI i.e., it does not need to retain the local "port"
* information. The correct VNI will be obtained as zebra maintains
* the mapping (of VLAN to VNI).
*/
struct zebra_mac_t_ {
/* MAC address. */
struct ethaddr macaddr;
uint32_t flags;
#define ZEBRA_MAC_LOCAL 0x01
#define ZEBRA_MAC_REMOTE 0x02
#define ZEBRA_MAC_AUTO 0x04 /* Auto created for neighbor. */
#define ZEBRA_MAC_STICKY 0x08 /* Static MAC */
#define ZEBRA_MAC_REMOTE_RMAC 0x10 /* remote router mac */
#define ZEBRA_MAC_DEF_GW 0x20
/* remote VTEP advertised MAC as default GW */
#define ZEBRA_MAC_REMOTE_DEF_GW 0x40
#define ZEBRA_MAC_DUPLICATE 0x80
#define ZEBRA_MAC_FPM_SENT 0x100 /* whether or not this entry was sent. */
/* MAC is locally active on an ethernet segment peer */
#define ZEBRA_MAC_ES_PEER_ACTIVE 0x200
/* MAC has been proxy-advertised by peers. This means we need to
* keep the entry for forwarding but cannot advertise it
*/
#define ZEBRA_MAC_ES_PEER_PROXY 0x400
/* We have not been able to independently establish that the host is
* local connected but one or more ES peers claims it is.
* We will maintain the entry for forwarding purposes and continue
* to advertise it as locally attached but with a "proxy" flag
*/
#define ZEBRA_MAC_LOCAL_INACTIVE 0x800
#define ZEBRA_MAC_ALL_LOCAL_FLAGS (ZEBRA_MAC_LOCAL | ZEBRA_MAC_LOCAL_INACTIVE)
#define ZEBRA_MAC_ALL_PEER_FLAGS \
(ZEBRA_MAC_ES_PEER_PROXY | ZEBRA_MAC_ES_PEER_ACTIVE)
/* back pointer to zevpn */
zebra_evpn_t *zevpn;
/* Local or remote info. */
union {
struct {
ifindex_t ifindex;
vlanid_t vid;
} local;
struct in_addr r_vtep_ip;
} fwd_info;
/* Local or remote ES */
struct zebra_evpn_es *es;
/* memory used to link the mac to the es */
struct listnode es_listnode;
/* Mobility sequence numbers associated with this entry. */
uint32_t rem_seq;
uint32_t loc_seq;
/* List of neigh associated with this mac */
struct list *neigh_list;
/* list of hosts pointing to this remote RMAC */
struct host_rb_tree_entry host_rb;
/* Duplicate mac detection */
uint32_t dad_count;
struct thread *dad_mac_auto_recovery_timer;
struct timeval detect_start_time;
time_t dad_dup_detect_time;
/* used for ageing out the PEER_ACTIVE flag */
struct thread *hold_timer;
/* number of neigh entries (using this mac) that have
* ZEBRA_MAC_ES_PEER_ACTIVE or ZEBRA_NEIGH_ES_PEER_PROXY
*/
uint32_t sync_neigh_cnt;
};
/*
* Context for MAC hash walk - used by callbacks.
*/
struct mac_walk_ctx {
zebra_evpn_t *zevpn; /* EVPN hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
uint32_t flags;
#define DEL_LOCAL_MAC 0x1
#define DEL_REMOTE_MAC 0x2
#define DEL_ALL_MAC (DEL_LOCAL_MAC | DEL_REMOTE_MAC)
#define DEL_REMOTE_MAC_FROM_VTEP 0x4
#define SHOW_REMOTE_MAC_FROM_VTEP 0x8
struct in_addr r_vtep_ip; /* To walk MACs from specific VTEP */
struct vty *vty; /* Used by VTY handlers */
uint32_t count; /* Used by VTY handlers */
struct json_object *json; /* Used for JSON Output */
bool print_dup; /* Used to print dup addr list */
};
struct rmac_walk_ctx {
struct vty *vty;
struct json_object *json;
};
/* temporary datastruct to pass info between the mac-update and
* neigh-update while handling mac-ip routes
*/
struct sync_mac_ip_ctx {
bool ignore_macip;
bool mac_created;
bool mac_inactive;
bool mac_dp_update_deferred;
zebra_mac_t *mac;
};
/**************************** SYNC MAC handling *****************************/
/* if the mac has been added of a mac-route from the peer
* or if it is being referenced by a neigh added by the
* peer we cannot let it age out i.e. we set the static bit
* in the dataplane
*/
void zebra_evpn_mac_stop_hold_timer(zebra_mac_t *mac);
static inline bool zebra_evpn_mac_is_static(zebra_mac_t *mac)
{
return ((mac->flags & ZEBRA_MAC_ALL_PEER_FLAGS) || mac->sync_neigh_cnt);
}
/* mac needs to be locally active or active on an ES peer */
static inline bool zebra_evpn_mac_is_ready_for_bgp(uint32_t flags)
{
return (flags & ZEBRA_MAC_LOCAL)
&& (!(flags & ZEBRA_MAC_LOCAL_INACTIVE)
|| (flags & ZEBRA_MAC_ES_PEER_ACTIVE));
}
static inline void zebra_evpn_mac_clear_sync_info(zebra_mac_t *mac)
{
UNSET_FLAG(mac->flags, ZEBRA_MAC_ALL_PEER_FLAGS);
zebra_evpn_mac_stop_hold_timer(mac);
}
struct hash *zebra_mac_db_create(const char *desc);
uint32_t num_valid_macs(zebra_evpn_t *zevi);
uint32_t num_dup_detected_macs(zebra_evpn_t *zevi);
int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac);
int zebra_evpn_rem_mac_install(zebra_evpn_t *zevi, zebra_mac_t *mac,
bool was_static);
void zebra_evpn_deref_ip2mac(zebra_evpn_t *zevi, zebra_mac_t *mac);
void zebra_evpn_mac_get_access_info(zebra_mac_t *mac, struct interface **ifpP,
vlanid_t *vid);
zebra_mac_t *zebra_evpn_mac_lookup(zebra_evpn_t *zevi, struct ethaddr *mac);
zebra_mac_t *zebra_evpn_mac_add(zebra_evpn_t *zevi, struct ethaddr *macaddr);
int zebra_evpn_mac_del(zebra_evpn_t *zevi, zebra_mac_t *mac);
int zebra_evpn_macip_send_msg_to_client(uint32_t id, struct ethaddr *macaddr,
struct ipaddr *ip, uint8_t flags,
uint32_t seq, int state,
struct zebra_evpn_es *es, uint16_t cmd);
void zebra_evpn_mac_send_add_del_to_client(zebra_mac_t *mac, bool old_bgp_ready,
bool new_bgp_ready);
void zebra_evpn_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
zebra_mac_t *mac,
struct in_addr vtep_ip, bool do_dad,
bool *is_dup_detect, bool is_local);
void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json);
void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt);
void zebra_evpn_print_mac_hash_detail(struct hash_bucket *bucket, void *ctxt);
void zebra_evpn_sync_mac_dp_install(zebra_mac_t *mac, bool set_inactive,
bool force_clear_static,
const char *caller);
void zebra_evpn_mac_del_all(zebra_evpn_t *zevi, int uninstall, int upd_client,
uint32_t flags);
int zebra_evpn_mac_send_add_to_client(vni_t vni, struct ethaddr *macaddr,
uint32_t mac_flags, uint32_t seq,
struct zebra_evpn_es *es);
int zebra_evpn_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr,
uint32_t flags, bool force);
void zebra_evpn_send_mac_list_to_client(zebra_evpn_t *zevi);
zebra_mac_t *
zebra_evpn_proc_sync_mac_update(zebra_evpn_t *zevi, struct ethaddr *macaddr,
uint16_t ipa_len, struct ipaddr *ipaddr,
uint8_t flags, uint32_t seq, esi_t *esi,
struct sync_mac_ip_ctx *ctx);
void zebra_evpn_sync_mac_del(zebra_mac_t *mac);
void zebra_evpn_rem_mac_del(zebra_evpn_t *zevi, zebra_mac_t *mac);
void zebra_evpn_print_dad_mac_hash(struct hash_bucket *bucket, void *ctxt);
void zebra_evpn_print_dad_mac_hash_detail(struct hash_bucket *bucket,
void *ctxt);
// remove later
void zebra_evpn_mac_send_add_del_to_client(zebra_mac_t *mac, bool old_bgp_ready,
bool new_bgp_ready);
bool zebra_evpn_local_mac_update_fwd_info(zebra_mac_t *mac,
struct interface *ifp, vlanid_t vid);
#ifdef __cplusplus
}
#endif
#endif /*_ZEBRA_EVPN_MAC_H */

View File

@ -44,6 +44,8 @@
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"
#include "zebra/zebra_evpn.h"
#include "zebra/zebra_evpn_mac.h"
#include "zebra/zebra_vxlan_private.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_evpn_mh.h"
@ -1296,9 +1298,9 @@ static void zebra_evpn_es_local_mac_update(struct zebra_evpn_es *es,
for (ALL_LIST_ELEMENTS_RO(es->mac_list, node, mac)) {
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_ACTIVE)) {
zebra_vxlan_sync_mac_dp_install(mac,
false /* set_inactive */,
force_clear_static, __func__);
zebra_evpn_sync_mac_dp_install(
mac, false /* set_inactive */,
force_clear_static, __func__);
}
}
}

162
zebra/zebra_evpn_neigh.h Normal file
View File

@ -0,0 +1,162 @@
/*
* Zebra EVPN Neighbor Data structures and definitions
* These are "internal" to this function.
* Copyright (C) 2016, 2017 Cumulus Networks, Inc.
* Copyright (C) 2020 Volta Networks.
*
* This file is part of FRR.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FRR; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _ZEBRA_EVPN_NEIGH_H
#define _ZEBRA_EVPN_NEIGH_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zebra_neigh_t_ zebra_neigh_t;
#define IS_ZEBRA_NEIGH_ACTIVE(n) (n->state == ZEBRA_NEIGH_ACTIVE)
#define IS_ZEBRA_NEIGH_INACTIVE(n) (n->state == ZEBRA_NEIGH_INACTIVE)
#define ZEBRA_NEIGH_SET_ACTIVE(n) n->state = ZEBRA_NEIGH_ACTIVE
#define ZEBRA_NEIGH_SET_INACTIVE(n) n->state = ZEBRA_NEIGH_INACTIVE
/*
* Neighbor hash table.
*
* This table contains the neighbors (IP to MAC bindings) pertaining to
* this VNI. This includes local neighbors learnt on the attached VLAN
* device that maps to this VNI as well as remote neighbors learnt and
* installed by BGP.
* Local neighbors will be known against the VLAN device (SVI); however,
* it is sufficient for zebra to maintain against the VNI. The correct
* VNI will be obtained as zebra maintains the mapping (of VLAN to VNI).
*/
struct zebra_neigh_t_ {
/* IP address. */
struct ipaddr ip;
/* MAC address. */
struct ethaddr emac;
/* Back pointer to MAC. Only applicable to hosts in a L2-VNI. */
zebra_mac_t *mac;
/* Underlying interface. */
ifindex_t ifindex;
zebra_evpn_t *zevpn;
uint32_t flags;
#define ZEBRA_NEIGH_LOCAL 0x01
#define ZEBRA_NEIGH_REMOTE 0x02
#define ZEBRA_NEIGH_REMOTE_NH 0x04 /* neigh entry for remote vtep */
#define ZEBRA_NEIGH_DEF_GW 0x08
#define ZEBRA_NEIGH_ROUTER_FLAG 0x10
#define ZEBRA_NEIGH_DUPLICATE 0x20
#define ZEBRA_NEIGH_SVI_IP 0x40
/* rxed from an ES peer */
#define ZEBRA_NEIGH_ES_PEER_ACTIVE 0x80
/* rxed from an ES peer as a proxy advertisement */
#define ZEBRA_NEIGH_ES_PEER_PROXY 0x100
/* We have not been able to independently establish that the host
* is local connected
*/
#define ZEBRA_NEIGH_LOCAL_INACTIVE 0x200
#define ZEBRA_NEIGH_ALL_LOCAL_FLAGS \
(ZEBRA_NEIGH_LOCAL | ZEBRA_NEIGH_LOCAL_INACTIVE)
#define ZEBRA_NEIGH_ALL_PEER_FLAGS \
(ZEBRA_NEIGH_ES_PEER_PROXY | ZEBRA_NEIGH_ES_PEER_ACTIVE)
enum zebra_neigh_state state;
/* Remote VTEP IP - applicable only for remote neighbors. */
struct in_addr r_vtep_ip;
/*
* Mobility sequence numbers associated with this entry. The rem_seq
* represents the sequence number from the client (BGP) for the most
* recent add or update of this entry while the loc_seq represents
* the sequence number informed (or to be informed) by zebra to BGP
* for this entry.
*/
uint32_t rem_seq;
uint32_t loc_seq;
/* list of hosts pointing to this remote NH entry */
struct host_rb_tree_entry host_rb;
/* Duplicate ip detection */
uint32_t dad_count;
struct thread *dad_ip_auto_recovery_timer;
struct timeval detect_start_time;
time_t dad_dup_detect_time;
/* used for ageing out the PEER_ACTIVE flag */
struct thread *hold_timer;
};
/*
* Context for neighbor hash walk - used by callbacks.
*/
struct neigh_walk_ctx {
zebra_evpn_t *zevpn; /* VNI hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
uint32_t flags;
#define DEL_LOCAL_NEIGH 0x1
#define DEL_REMOTE_NEIGH 0x2
#define DEL_ALL_NEIGH (DEL_LOCAL_NEIGH | DEL_REMOTE_NEIGH)
#define DEL_REMOTE_NEIGH_FROM_VTEP 0x4
#define SHOW_REMOTE_NEIGH_FROM_VTEP 0x8
struct in_addr r_vtep_ip; /* To walk neighbors from specific VTEP */
struct vty *vty; /* Used by VTY handlers */
uint32_t count; /* Used by VTY handlers */
uint8_t addr_width; /* Used by VTY handlers */
struct json_object *json; /* Used for JSON Output */
};
int remote_neigh_count(zebra_mac_t *zmac);
int neigh_list_cmp(void *p1, void *p2);
int zebra_evpn_rem_neigh_install(zebra_evpn_t *zevpn, zebra_neigh_t *n,
bool was_static);
void zebra_evpn_process_neigh_on_remote_mac_add(zebra_evpn_t *zevpn,
zebra_mac_t *zmac);
void zebra_evpn_process_neigh_on_local_mac_change(zebra_evpn_t *zevpn,
zebra_mac_t *zmac,
bool seq_change,
bool es_change);
void zebra_evpn_process_neigh_on_remote_mac_del(zebra_evpn_t *zevpn,
zebra_mac_t *zmac);
#ifdef __cplusplus
}
#endif
#endif /*_ZEBRA_EVPN_NEIGH_H */

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,8 @@
#include "if.h"
#include "linklist.h"
#include "zebra_vxlan.h"
#include "zebra_evpn.h"
#include "zebra_evpn_mac.h"
#ifdef __cplusplus
extern "C" {
@ -37,85 +39,8 @@ extern "C" {
#define ERR_STR_SZ 256
/* definitions */
typedef struct zebra_evpn_t_ zebra_evpn_t;
typedef struct zebra_vtep_t_ zebra_vtep_t;
typedef struct zebra_mac_t_ zebra_mac_t;
typedef struct zebra_neigh_t_ zebra_neigh_t;
typedef struct zebra_l3vni_t_ zebra_l3vni_t;
/*
* VTEP info
*
* Right now, this just has each remote VTEP's IP address.
*/
struct zebra_vtep_t_ {
/* Remote IP. */
/* NOTE: Can only be IPv4 right now. */
struct in_addr vtep_ip;
/* Flood mode (one of enum vxlan_flood_control) based on the PMSI
* tunnel type advertised by the remote VTEP
*/
int flood_control;
/* Links. */
struct zebra_vtep_t_ *next;
struct zebra_vtep_t_ *prev;
};
RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
zebra_es_evi_rb_cmp);
/*
* VNI hash table
*
* Contains information pertaining to a VNI:
* - the list of remote VTEPs (with this VNI)
*/
struct zebra_evpn_t_ {
/* VNI - key */
vni_t vni;
/* ES flags */
uint32_t flags;
#define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
/* Flag for advertising gw macip */
uint8_t advertise_gw_macip;
/* Flag for advertising svi macip */
uint8_t advertise_svi_macip;
/* Flag for advertising gw macip */
uint8_t advertise_subnet;
/* Corresponding VxLAN interface. */
struct interface *vxlan_if;
/* List of remote VTEPs */
zebra_vtep_t *vteps;
/* Local IP */
struct in_addr local_vtep_ip;
/* PIM-SM MDT group for BUM flooding */
struct in_addr mcast_grp;
/* tenant VRF, if any */
vrf_id_t vrf_id;
/* List of local or remote MAC */
struct hash *mac_table;
/* List of local or remote neighbors (MAC+IP) */
struct hash *neigh_table;
/* RB tree of ES-EVIs */
struct zebra_es_evi_rb_head es_evi_rb_tree;
/* List of local ESs */
struct list *local_es_evi_list;
};
/* L3 VNI hash table */
struct zebra_l3vni_t_ {
@ -279,255 +204,6 @@ static inline void zl3vni_get_svi_rmac(zebra_l3vni_t *zl3vni,
memcpy(rmac->octet, zl3vni->svi_if->hw_addr, ETH_ALEN);
}
struct host_rb_entry {
RB_ENTRY(host_rb_entry) hl_entry;
struct prefix p;
};
RB_HEAD(host_rb_tree_entry, host_rb_entry);
RB_PROTOTYPE(host_rb_tree_entry, host_rb_entry, hl_entry,
host_rb_entry_compare);
/*
* MAC hash table.
*
* This table contains the MAC addresses pertaining to this VNI.
* This includes local MACs learnt on an attached VLAN that maps
* to this VNI as well as remote MACs learnt and installed by BGP.
* Local MACs will be known either on a VLAN sub-interface or
* on (port, VLAN); however, it is sufficient for zebra to maintain
* against the VNI i.e., it does not need to retain the local "port"
* information. The correct VNI will be obtained as zebra maintains
* the mapping (of VLAN to VNI).
*/
struct zebra_mac_t_ {
/* MAC address. */
struct ethaddr macaddr;
uint32_t flags;
#define ZEBRA_MAC_LOCAL 0x01
#define ZEBRA_MAC_REMOTE 0x02
#define ZEBRA_MAC_AUTO 0x04 /* Auto created for neighbor. */
#define ZEBRA_MAC_STICKY 0x08 /* Static MAC */
#define ZEBRA_MAC_REMOTE_RMAC 0x10 /* remote router mac */
#define ZEBRA_MAC_DEF_GW 0x20
/* remote VTEP advertised MAC as default GW */
#define ZEBRA_MAC_REMOTE_DEF_GW 0x40
#define ZEBRA_MAC_DUPLICATE 0x80
#define ZEBRA_MAC_FPM_SENT 0x100 /* whether or not this entry was sent. */
/* MAC is locally active on an ethernet segment peer */
#define ZEBRA_MAC_ES_PEER_ACTIVE 0x200
/* MAC has been proxy-advertised by peers. This means we need to
* keep the entry for forwarding but cannot advertise it
*/
#define ZEBRA_MAC_ES_PEER_PROXY 0x400
/* We have not been able to independently establish that the host is
* local connected but one or more ES peers claims it is.
* We will maintain the entry for forwarding purposes and continue
* to advertise it as locally attached but with a "proxy" flag
*/
#define ZEBRA_MAC_LOCAL_INACTIVE 0x800
#define ZEBRA_MAC_ALL_LOCAL_FLAGS (ZEBRA_MAC_LOCAL |\
ZEBRA_MAC_LOCAL_INACTIVE)
#define ZEBRA_MAC_ALL_PEER_FLAGS (ZEBRA_MAC_ES_PEER_PROXY |\
ZEBRA_MAC_ES_PEER_ACTIVE)
/* back pointer to zevpn */
zebra_evpn_t *zevpn;
/* Local or remote info. */
union {
struct {
ifindex_t ifindex;
vlanid_t vid;
} local;
struct in_addr r_vtep_ip;
} fwd_info;
/* Local or remote ES */
struct zebra_evpn_es *es;
/* memory used to link the mac to the es */
struct listnode es_listnode;
/* Mobility sequence numbers associated with this entry. */
uint32_t rem_seq;
uint32_t loc_seq;
/* List of neigh associated with this mac */
struct list *neigh_list;
/* list of hosts pointing to this remote RMAC */
struct host_rb_tree_entry host_rb;
/* Duplicate mac detection */
uint32_t dad_count;
struct thread *dad_mac_auto_recovery_timer;
struct timeval detect_start_time;
time_t dad_dup_detect_time;
/* used for ageing out the PEER_ACTIVE flag */
struct thread *hold_timer;
/* number of neigh entries (using this mac) that have
* ZEBRA_MAC_ES_PEER_ACTIVE or ZEBRA_NEIGH_ES_PEER_PROXY
*/
uint32_t sync_neigh_cnt;
};
/*
* Context for MAC hash walk - used by callbacks.
*/
struct mac_walk_ctx {
zebra_evpn_t *zevpn; /* EVPN hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
uint32_t flags;
#define DEL_LOCAL_MAC 0x1
#define DEL_REMOTE_MAC 0x2
#define DEL_ALL_MAC (DEL_LOCAL_MAC | DEL_REMOTE_MAC)
#define DEL_REMOTE_MAC_FROM_VTEP 0x4
#define SHOW_REMOTE_MAC_FROM_VTEP 0x8
struct in_addr r_vtep_ip; /* To walk MACs from specific VTEP */
struct vty *vty; /* Used by VTY handlers */
uint32_t count; /* Used by VTY handlers */
struct json_object *json; /* Used for JSON Output */
bool print_dup; /* Used to print dup addr list */
};
struct rmac_walk_ctx {
struct vty *vty;
struct json_object *json;
};
/* temporary datastruct to pass info between the mac-update and
* neigh-update while handling mac-ip routes
*/
struct sync_mac_ip_ctx {
bool ignore_macip;
bool mac_created;
bool mac_inactive;
bool mac_dp_update_deferred;
zebra_mac_t *mac;
};
#define IS_ZEBRA_NEIGH_ACTIVE(n) (n->state == ZEBRA_NEIGH_ACTIVE)
#define IS_ZEBRA_NEIGH_INACTIVE(n) (n->state == ZEBRA_NEIGH_INACTIVE)
#define ZEBRA_NEIGH_SET_ACTIVE(n) n->state = ZEBRA_NEIGH_ACTIVE
#define ZEBRA_NEIGH_SET_INACTIVE(n) n->state = ZEBRA_NEIGH_INACTIVE
/*
* Neighbor hash table.
*
* This table contains the neighbors (IP to MAC bindings) pertaining to
* this VNI. This includes local neighbors learnt on the attached VLAN
* device that maps to this VNI as well as remote neighbors learnt and
* installed by BGP.
* Local neighbors will be known against the VLAN device (SVI); however,
* it is sufficient for zebra to maintain against the VNI. The correct
* VNI will be obtained as zebra maintains the mapping (of VLAN to VNI).
*/
struct zebra_neigh_t_ {
/* IP address. */
struct ipaddr ip;
/* MAC address. */
struct ethaddr emac;
/* Back pointer to MAC. Only applicable to hosts in a L2-VNI. */
zebra_mac_t *mac;
/* Underlying interface. */
ifindex_t ifindex;
zebra_evpn_t *zevpn;
uint32_t flags;
#define ZEBRA_NEIGH_LOCAL 0x01
#define ZEBRA_NEIGH_REMOTE 0x02
#define ZEBRA_NEIGH_REMOTE_NH 0x04 /* neigh entry for remote vtep */
#define ZEBRA_NEIGH_DEF_GW 0x08
#define ZEBRA_NEIGH_ROUTER_FLAG 0x10
#define ZEBRA_NEIGH_DUPLICATE 0x20
#define ZEBRA_NEIGH_SVI_IP 0x40
/* rxed from an ES peer */
#define ZEBRA_NEIGH_ES_PEER_ACTIVE 0x80
/* rxed from an ES peer as a proxy advertisement */
#define ZEBRA_NEIGH_ES_PEER_PROXY 0x100
/* We have not been able to independently establish that the host
* is local connected
*/
#define ZEBRA_NEIGH_LOCAL_INACTIVE 0x200
#define ZEBRA_NEIGH_ALL_LOCAL_FLAGS (ZEBRA_NEIGH_LOCAL |\
ZEBRA_NEIGH_LOCAL_INACTIVE)
#define ZEBRA_NEIGH_ALL_PEER_FLAGS (ZEBRA_NEIGH_ES_PEER_PROXY |\
ZEBRA_NEIGH_ES_PEER_ACTIVE)
enum zebra_neigh_state state;
/* Remote VTEP IP - applicable only for remote neighbors. */
struct in_addr r_vtep_ip;
/*
* Mobility sequence numbers associated with this entry. The rem_seq
* represents the sequence number from the client (BGP) for the most
* recent add or update of this entry while the loc_seq represents
* the sequence number informed (or to be informed) by zebra to BGP
* for this entry.
*/
uint32_t rem_seq;
uint32_t loc_seq;
/* list of hosts pointing to this remote NH entry */
struct host_rb_tree_entry host_rb;
/* Duplicate ip detection */
uint32_t dad_count;
struct thread *dad_ip_auto_recovery_timer;
struct timeval detect_start_time;
time_t dad_dup_detect_time;
/* used for ageing out the PEER_ACTIVE flag */
struct thread *hold_timer;
};
/*
* Context for neighbor hash walk - used by callbacks.
*/
struct neigh_walk_ctx {
zebra_evpn_t *zevpn; /* VNI hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
uint32_t flags;
#define DEL_LOCAL_NEIGH 0x1
#define DEL_REMOTE_NEIGH 0x2
#define DEL_ALL_NEIGH (DEL_LOCAL_NEIGH | DEL_REMOTE_NEIGH)
#define DEL_REMOTE_NEIGH_FROM_VTEP 0x4
#define SHOW_REMOTE_NEIGH_FROM_VTEP 0x8
struct in_addr r_vtep_ip; /* To walk neighbors from specific VTEP */
struct vty *vty; /* Used by VTY handlers */
uint32_t count; /* Used by VTY handlers */
uint8_t addr_width; /* Used by VTY handlers */
struct json_object *json; /* Used for JSON Output */
};
/* context for neigh hash walk - update l3vni and rmac */
struct neigh_l3info_walk_ctx {