From 85c8d83b815a52eead1f661ed79ab794cfa815b5 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Wed, 31 Oct 2018 16:53:28 -0700 Subject: [PATCH] bgpd: dup addr detect data struct for cfg Enable/disable duplicate address detection there are 3 actions warning-only: Default action which generates only frr warning (syslog) to user for any duplicate detecton freeze: Permanently freezes address, manual intervene required. freeze with time: An address will recover once the time has expired (auto-recovery). Signed-off-by: Chirag Shah --- bgpd/bgp_evpn.c | 13 +++++++++++++ bgpd/bgp_evpn_private.h | 18 ++++++++++++++++++ bgpd/bgpd.c | 6 ++++++ bgpd/bgpd.h | 2 ++ 4 files changed, 39 insertions(+) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index fc3ac28723..b3a498bf57 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -5802,6 +5802,19 @@ void bgp_evpn_init(struct bgp *bgp) bgp->vrf_export_rtl->del = evpn_xxport_delete_ecomm; bgp->l2vnis = list_new(); bgp->l2vnis->cmp = vni_list_cmp; + /* By default Duplicate Address Dection is enabled. + * Max-moves (N) 5, detection time (M) 180 + * default action is warning-only + * freeze action permanently freezes address, + * and freeze time (auto-recovery) is disabled. + */ + if (bgp->evpn_info) { + bgp->evpn_info->dup_addr_detect = true; + bgp->evpn_info->dad_time = EVPN_DAD_DEFAULT_TIME; + bgp->evpn_info->dad_max_moves = EVPN_DAD_DEFAULT_MAX_MOVES; + bgp->evpn_info->dad_freeze = false; + bgp->evpn_info->dad_freeze_time = 0; + } /* Default BUM handling is to do head-end replication. */ bgp->vxlan_flood_ctrl = VXLAN_FLOOD_HEAD_END_REPL; diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index f0017f3533..b2f16fc284 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -161,6 +161,24 @@ struct vrf_irt_node { #define RT_TYPE_EXPORT 2 #define RT_TYPE_BOTH 3 +#define EVPN_DAD_DEFAULT_TIME 180 /* secs */ +#define EVPN_DAD_DEFAULT_MAX_MOVES 5 /* default from RFC 7432 */ +#define EVPN_DAD_DEFAULT_AUTO_RECOVERY_TIME 1800 /* secs */ + +struct bgp_evpn_info { + /* enable disable dup detect */ + bool dup_addr_detect; + + /* Detection time(M) */ + int dad_time; + /* Detection max moves(N) */ + uint32_t dad_max_moves; + /* Permanent freeze */ + bool dad_freeze; + /* Recovery time */ + uint32_t dad_freeze_time; +}; + static inline int is_vrf_rd_configured(struct bgp *bgp_vrf) { return (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD)); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index a078c4f587..7ff0dae200 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -86,8 +86,10 @@ #include "bgpd/bgp_labelpool.h" #include "bgpd/bgp_pbr.h" #include "bgpd/bgp_addpath.h" +#include "bgpd/bgp_evpn_private.h" DEFINE_MTYPE_STATIC(BGPD, PEER_TX_SHUTDOWN_MSG, "Peer shutdown message (TX)"); +DEFINE_MTYPE_STATIC(BGPD, BGP_EVPN_INFO, "BGP EVPN instance information"); DEFINE_QOBJ_TYPE(bgp_master) DEFINE_QOBJ_TYPE(bgp) DEFINE_QOBJ_TYPE(peer) @@ -2952,6 +2954,9 @@ static struct bgp *bgp_create(as_t *as, const char *name, /* assign a unique rd id for auto derivation of vrf's RD */ bf_assign_index(bm->rd_idspace, bgp->vrf_rd_id); + bgp->evpn_info = XCALLOC(MTYPE_BGP_EVPN_INFO, + sizeof(struct bgp_evpn_info)); + bgp_evpn_init(bgp); bgp_pbr_init(bgp); return bgp; @@ -3343,6 +3348,7 @@ void bgp_free(struct bgp *bgp) bgp_evpn_cleanup(bgp); bgp_pbr_cleanup(bgp); + XFREE(MTYPE_BGP_EVPN_INFO, bgp->evpn_info); for (afi = AFI_IP; afi < AFI_MAX; afi++) { vpn_policy_direction_t dir; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 70193104b4..216113dc67 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -482,6 +482,8 @@ struct bgp { /* EVPN enable - advertise local VNIs and their MACs etc. */ int advertise_all_vni; + struct bgp_evpn_info *evpn_info; + /* EVPN - use RFC 8365 to auto-derive RT */ int advertise_autort_rfc8365; -- 2.39.5