diff options
| author | Pat Ruddy <pat@voltanet.io> | 2020-04-22 16:30:52 +0100 |
|---|---|---|
| committer | Pat Ruddy <pat@voltanet.io> | 2020-08-12 12:39:34 +0100 |
| commit | 7bce35354ffe2cecec722ef9ab8c54b499f4f3c0 (patch) | |
| tree | 20464faf33657ebb4f3c39b336307fd7e035db8a /zebra/zebra_evpn_mac.c | |
| parent | ad6ca5f42303b42052baf3ea1a14f09c10c637ee (diff) | |
zebra: extract gateway mac add from zebra_vxlan.c
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>
Diffstat (limited to 'zebra/zebra_evpn_mac.c')
| -rw-r--r-- | zebra/zebra_evpn_mac.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index d02fd7a898..085dc9c661 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -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; +} |
