]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: extract gateway mac add from zebra_vxlan.c
authorPat Ruddy <pat@voltanet.io>
Wed, 22 Apr 2020 15:30:52 +0000 (16:30 +0100)
committerPat Ruddy <pat@voltanet.io>
Wed, 12 Aug 2020 11:39:34 +0000 (12:39 +0100)
extract mac_gateway add code from zevi_gw_macip_add and move it to
a new generic function zebra_evpn_mac_gw_macip_add in zebra_evpn_mac.c

Signed-off-by: Pat Ruddy <pat@voltanet.io>
zebra/zebra_evpn_mac.c
zebra/zebra_evpn_mac.h
zebra/zebra_vxlan.c

index d02fd7a898e13d5b19c07936885c08528a15512f..085dc9c661af429a726b0243710e3d9110261f08 100644 (file)
@@ -2196,3 +2196,35 @@ int zebra_evpn_del_local_mac(zebra_evpn_t *zevpn, struct ethaddr *macaddr,
 
        return 0;
 }
+
+int zebra_evpn_mac_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
+                               struct ipaddr *ip, zebra_mac_t **macp,
+                               struct ethaddr *macaddr, vlanid_t vlan_id)
+{
+       char buf[ETHER_ADDR_STRLEN];
+       zebra_mac_t *mac;
+
+       mac = zebra_evpn_mac_lookup(zevpn, macaddr);
+       if (!mac) {
+               mac = zebra_evpn_mac_add(zevpn, macaddr);
+               if (!mac) {
+                       flog_err(EC_ZEBRA_MAC_ADD_FAILED,
+                                "Failed to add MAC %s intf %s(%u) VID %u",
+                                prefix_mac2str(macaddr, buf, sizeof(buf)),
+                                ifp->name, ifp->ifindex, vlan_id);
+                       return -1;
+               }
+       }
+
+       /* Set "local" forwarding info. */
+       SET_FLAG(mac->flags, ZEBRA_MAC_LOCAL);
+       SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
+       SET_FLAG(mac->flags, ZEBRA_MAC_DEF_GW);
+       memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
+       mac->fwd_info.local.ifindex = ifp->ifindex;
+       mac->fwd_info.local.vid = vlan_id;
+
+       *macp = mac;
+
+       return 0;
+}
index b6ee9d8f307cdf0592e064f197d7c7af5c6ddd49..39aaf1fb308098a130370b469b357aa28cb7da05 100644 (file)
@@ -252,6 +252,9 @@ int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf, zebra_evpn_t *zevpn,
                                    bool dp_static);
 int zebra_evpn_del_local_mac(zebra_evpn_t *zevpn, struct ethaddr *macaddr,
                             struct interface *ifp);
+int zebra_evpn_mac_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
+                               struct ipaddr *ip, zebra_mac_t **macp,
+                               struct ethaddr *macaddr, vlanid_t vlan_id);
 
 #ifdef __cplusplus
 }
index 4b69ac244779672a2d55439c48e64085b0cf8981..67c178dcbfb9f3715591dcda2c21abd94172f884 100644 (file)
@@ -2251,25 +2251,10 @@ static int zevpn_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
 
        vxl = &zif->l2info.vxl;
 
-       mac = zebra_evpn_mac_lookup(zevpn, macaddr);
-       if (!mac) {
-               mac = zebra_evpn_mac_add(zevpn, macaddr);
-               if (!mac) {
-                       flog_err(EC_ZEBRA_MAC_ADD_FAILED,
-                                "Failed to add MAC %s intf %s(%u) VID %u",
-                                prefix_mac2str(macaddr, buf, sizeof(buf)),
-                                ifp->name, ifp->ifindex, vxl->access_vlan);
-                       return -1;
-               }
-       }
-
-       /* Set "local" forwarding info. */
-       SET_FLAG(mac->flags, ZEBRA_MAC_LOCAL);
-       SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
-       SET_FLAG(mac->flags, ZEBRA_MAC_DEF_GW);
-       memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
-       mac->fwd_info.local.ifindex = ifp->ifindex;
-       mac->fwd_info.local.vid = vxl->access_vlan;
+       if (zebra_evpn_mac_gw_macip_add(ifp, zevpn, ip, &mac, macaddr,
+                                       vxl->access_vlan)
+           != 0)
+               return -1;
 
        n = zevpn_neigh_lookup(zevpn, ip);
        if (!n) {