]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_evpn.c
Merge pull request #3409 from opensourcerouting/feature/cleanup-topotest-docker-docs
[mirror_frr.git] / bgpd / bgp_evpn.c
index cff050a9ef391edb836584b49bcde41a70ee23c5..7be79377866a7f82824434a3e23f055efbb73f27 100644 (file)
@@ -47,6 +47,7 @@
 #include "bgpd/bgp_aspath.h"
 #include "bgpd/bgp_zebra.h"
 #include "bgpd/bgp_nexthop.h"
+#include "bgpd/bgp_addpath.h"
 
 /*
  * Definitions and external declarations.
@@ -1059,7 +1060,7 @@ static int evpn_es_route_select_install(struct bgp *bgp,
            && old_select->sub_type == BGP_ROUTE_IMPORTED
            && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
            && !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
-           && !bgp->addpath_tx_used[afi][safi]) {
+           && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
                if (bgp_zebra_has_route_changed(rn, old_select)) {
                        ret = evpn_es_install_vtep(bgp, es,
                                                   (struct prefix_evpn *)&rn->p,
@@ -1142,7 +1143,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
            && old_select->sub_type == BGP_ROUTE_IMPORTED
            && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
            && !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
-           && !bgp->addpath_tx_used[afi][safi]) {
+           && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
                if (bgp_zebra_has_route_changed(rn, old_select)) {
                        if (old_select->attr->sticky)
                                SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);
@@ -3395,10 +3396,20 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,
  */
 static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
 {
+       /* Delete ipv4 default route and withdraw from peers */
+       if (evpn_default_originate_set(bgp_vrf, AFI_IP, SAFI_UNICAST))
+               bgp_evpn_install_uninstall_default_route(bgp_vrf, AFI_IP,
+                                                        SAFI_UNICAST, false);
+
        /* delete all ipv4 routes and withdraw from peers */
        if (advertise_type5_routes(bgp_vrf, AFI_IP))
                bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
 
+       /* Delete ipv6 default route and withdraw from peers */
+       if (evpn_default_originate_set(bgp_vrf, AFI_IP6, SAFI_UNICAST))
+               bgp_evpn_install_uninstall_default_route(bgp_vrf, AFI_IP6,
+                                                        SAFI_UNICAST, false);
+
        /* delete all ipv6 routes and withdraw from peers */
        if (advertise_type5_routes(bgp_vrf, AFI_IP6))
                bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
@@ -3414,9 +3425,20 @@ static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
        if (advertise_type5_routes(bgp_vrf, AFI_IP))
                bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
 
+       /* update ipv4 default route and withdraw from peers */
+       if (evpn_default_originate_set(bgp_vrf, AFI_IP, SAFI_UNICAST))
+               bgp_evpn_install_uninstall_default_route(bgp_vrf, AFI_IP,
+                                                        SAFI_UNICAST, true);
+
        /* update all ipv6 routes */
        if (advertise_type5_routes(bgp_vrf, AFI_IP6))
                bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
+
+       /* update ipv6 default route and withdraw from peers */
+       if (evpn_default_originate_set(bgp_vrf, AFI_IP6, SAFI_UNICAST))
+               bgp_evpn_install_uninstall_default_route(bgp_vrf, AFI_IP6,
+                                                        SAFI_UNICAST, true);
+
 }
 
 /*
@@ -4217,6 +4239,28 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)
        }
 }
 
+/*
+ * evpn - enable advertisement of default g/w
+ */
+void bgp_evpn_install_uninstall_default_route(struct bgp *bgp_vrf, afi_t afi,
+                                             safi_t safi, bool add)
+{
+       struct prefix ip_prefix;
+
+       /* form the default prefix 0.0.0.0/0 */
+       memset(&ip_prefix, 0, sizeof(struct prefix));
+       ip_prefix.family = afi2family(afi);
+
+       if (add) {
+               bgp_evpn_advertise_type5_route(bgp_vrf, &ip_prefix,
+                                              NULL, afi, safi);
+       } else {
+               bgp_evpn_withdraw_type5_route(bgp_vrf, &ip_prefix,
+                                             afi, safi);
+       }
+}
+
+
 /*
  * Advertise IP prefix as type-5 route. The afi/safi and src_attr passed
  * to this function correspond to those of the source IP prefix (best
@@ -5801,6 +5845,21 @@ 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;
+               /* Initialize zebra vxlan */
+               bgp_zebra_dup_addr_detection(bgp);
+       }
 
        /* Default BUM handling is to do head-end replication. */
        bgp->vxlan_flood_ctrl = VXLAN_FLOOD_HEAD_END_REPL;