]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd/zebra: fix bgpd crash happening in mac mobility code path
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Wed, 21 Jun 2017 19:55:29 +0000 (12:55 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 8 Aug 2017 14:09:37 +0000 (10:09 -0400)
Ticket: CM-16216
Review: CCR-6210
Unit-test: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_evpn.c
zebra/zebra_vxlan.c

index fe311832a2fcc25762b353b9750e9bc76adfa2a2..7a5e370bcf9655a50c2ecabb3934fd61bbc862c8 100644 (file)
@@ -347,9 +347,9 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
        s = zclient->obuf;
        stream_reset(s);
 
-       zclient_create_header(
-               s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL,
-               bgp->vrf_id);
+       zclient_create_header(s, add ? ZEBRA_REMOTE_MACIP_ADD
+                                    : ZEBRA_REMOTE_MACIP_DEL,
+                             bgp->vrf_id);
        stream_putl(s, vpn->vni);
        stream_put(s, &p->prefix.mac.octet, ETH_ALEN); /* Mac Addr */
        /* IP address length and IP address, if any. */
@@ -400,9 +400,9 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
        s = zclient->obuf;
        stream_reset(s);
 
-       zclient_create_header(
-               s, add ? ZEBRA_REMOTE_VTEP_ADD : ZEBRA_REMOTE_VTEP_DEL,
-               bgp->vrf_id);
+       zclient_create_header(s, add ? ZEBRA_REMOTE_VTEP_ADD
+                                    : ZEBRA_REMOTE_VTEP_DEL,
+                             bgp->vrf_id);
        stream_putl(s, vpn->vni);
        if (IS_EVPN_PREFIX_IPADDR_V4(p))
                stream_put_in_addr(s, &p->prefix.ip.ipaddr_v4);
@@ -472,7 +472,7 @@ static void add_mac_mobility_to_attr(u_int32_t seq_num, struct attr *attr)
 {
        struct ecommunity ecom_tmp;
        struct ecommunity_val eval;
-       struct ecommunity *ecom_mm;
+       u_int8_t *ecom_val_ptr;
        int i;
        u_int8_t *pnt;
        int type = 0;
@@ -482,7 +482,7 @@ static void add_mac_mobility_to_attr(u_int32_t seq_num, struct attr *attr)
        encode_mac_mobility_extcomm(0, seq_num, &eval);
 
        /* Find current MM ecommunity */
-       ecom_mm = NULL;
+       ecom_val_ptr = NULL;
 
        if (attr->ecommunity) {
                for (i = 0; i < attr->ecommunity->size; i++) {
@@ -493,17 +493,17 @@ static void add_mac_mobility_to_attr(u_int32_t seq_num, struct attr *attr)
                        if (type == ECOMMUNITY_ENCODE_EVPN
                            && sub_type
                                       == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) {
-                               ecom_mm = (struct ecommunity *)
-                                                 attr->ecommunity->val
-                                         + (i * 8);
+                               ecom_val_ptr =
+                                       (u_int8_t *)(attr->ecommunity->val
+                                                    + (i * 8));
                                break;
                        }
                }
        }
 
        /* Update the existing MM ecommunity */
-       if (ecom_mm) {
-               memcpy(ecom_mm->val, eval.val, sizeof(char) * ECOMMUNITY_SIZE);
+       if (ecom_val_ptr) {
+               memcpy(ecom_val_ptr, eval.val, sizeof(char) * ECOMMUNITY_SIZE);
        }
        /* Add MM to existing */
        else {
index 7d265af30971f1246e887247aadee8288c7e49f5..542b66898b2fa83a27fefa36c341d6716c229a14 100644 (file)
@@ -2601,6 +2601,20 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
                        }
 
                        add = 0; /* This is an update of local interface. */
+               } else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) {
+                       /*
+                        * If we have already learned the MAC as a remote sticky
+                        * MAC,
+                        * this is a operator error and we must log a warning
+                        */
+                       if (CHECK_FLAG(mac->flags, ZEBRA_MAC_STICKY))
+                               zlog_warn(
+                                       "MAC %s is already learnt as a remote sticky mac behind VTEP %s VNI %d",
+                                       prefix_mac2str(macaddr, buf,
+                                                      sizeof(buf)),
+                                       inet_ntoa(mac->fwd_info.r_vtep_ip),
+                                       zvni->vni);
+                       return 0;
                }
        }