]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_l2.c
Merge pull request #5706 from mjstapp/fix_nh_debug_show
[mirror_frr.git] / zebra / zebra_l2.c
index 529fc48edfcd21410f02d544f5b1bd1b1d19beaf..e549d80a5c05ae2524a7a1eaf0d53bd5e8399fb7 100644 (file)
@@ -99,6 +99,26 @@ void zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave)
        br_slave->br_if = NULL;
 }
 
+void zebra_l2_map_slave_to_bond(struct zebra_l2info_bondslave *bond_slave,
+                               vrf_id_t vrf_id)
+{
+       struct interface *bond_if;
+
+       /* TODO: Handle change of master */
+       bond_if = if_lookup_by_index_all_vrf(bond_slave->bond_ifindex);
+       if (bond_if)
+               bond_slave->bond_if = bond_if;
+       else
+               bond_slave->bond_if = if_create_ifindex(bond_slave->bond_ifindex,
+                                                       vrf_id);
+}
+
+void zebra_l2_unmap_slave_from_bond(struct zebra_l2info_bondslave *bond_slave)
+{
+       if (bond_slave != NULL)
+               bond_slave->bond_if = NULL;
+}
+
 /*
  * Handle Bridge interface add or update. Update relevant info,
  * map slaves (if any) to the bridge.
@@ -155,6 +175,7 @@ void zebra_l2_vxlanif_add_update(struct interface *ifp,
 {
        struct zebra_if *zif;
        struct in_addr old_vtep_ip;
+       uint16_t chgflags = 0;
 
        zif = ifp->info;
        assert(zif);
@@ -166,11 +187,20 @@ void zebra_l2_vxlanif_add_update(struct interface *ifp,
        }
 
        old_vtep_ip = zif->l2info.vxl.vtep_ip;
-       if (IPV4_ADDR_SAME(&old_vtep_ip, &vxlan_info->vtep_ip))
-               return;
 
-       zif->l2info.vxl.vtep_ip = vxlan_info->vtep_ip;
-       zebra_vxlan_if_update(ifp, ZEBRA_VXLIF_LOCAL_IP_CHANGE);
+       if (!IPV4_ADDR_SAME(&old_vtep_ip, &vxlan_info->vtep_ip)) {
+               chgflags |= ZEBRA_VXLIF_LOCAL_IP_CHANGE;
+               zif->l2info.vxl.vtep_ip = vxlan_info->vtep_ip;
+       }
+
+       if (!IPV4_ADDR_SAME(&zif->l2info.vxl.mcast_grp,
+                               &vxlan_info->mcast_grp)) {
+               chgflags |= ZEBRA_VXLIF_MCAST_GRP_CHANGE;
+               zif->l2info.vxl.mcast_grp = vxlan_info->mcast_grp;
+       }
+
+       if (chgflags)
+               zebra_vxlan_if_update(ifp, chgflags);
 }
 
 /*
@@ -238,3 +268,24 @@ void zebra_l2if_update_bridge_slave(struct interface *ifp,
                zebra_l2_unmap_slave_from_bridge(&zif->brslave_info);
        }
 }
+
+void zebra_l2if_update_bond_slave(struct interface *ifp, ifindex_t bond_ifindex)
+{
+       struct zebra_if *zif;
+       ifindex_t old_bond_ifindex;
+
+       zif = ifp->info;
+       assert(zif);
+
+       old_bond_ifindex = zif->bondslave_info.bond_ifindex;
+       if (old_bond_ifindex == bond_ifindex)
+               return;
+
+       zif->bondslave_info.bond_ifindex = bond_ifindex;
+
+       /* Set up or remove link with master */
+       if (bond_ifindex != IFINDEX_INTERNAL)
+               zebra_l2_map_slave_to_bond(&zif->bondslave_info, ifp->vrf_id);
+       else if (old_bond_ifindex != IFINDEX_INTERNAL)
+               zebra_l2_unmap_slave_from_bond(&zif->bondslave_info);
+}