diff options
Diffstat (limited to 'zebra/interface.c')
| -rw-r--r-- | zebra/interface.c | 170 |
1 files changed, 116 insertions, 54 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 59563834ef..2e6ee65e92 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -228,6 +228,7 @@ static int if_zebra_delete_hook(struct interface *ifp) rtadv_if_fini(zebra_if); + zebra_l2_bridge_if_cleanup(ifp); zebra_evpn_if_cleanup(zebra_if); zebra_evpn_mac_ifp_del(ifp); @@ -806,12 +807,12 @@ void if_delete_update(struct interface **pifp) /* Reset some zebra interface params to default values. */ zif = ifp->info; if (zif) { + zebra_evpn_if_cleanup(zif); zif->zif_type = ZEBRA_IF_OTHER; zif->zif_slave_type = ZEBRA_IF_SLAVE_NONE; memset(&zif->l2info, 0, sizeof(union zebra_l2if_info)); memset(&zif->brslave_info, 0, sizeof(struct zebra_l2info_brslave)); - zebra_evpn_if_cleanup(zif); zebra_evpn_mac_ifp_del(ifp); } @@ -1889,6 +1890,63 @@ static inline bool if_is_protodown_applicable(struct interface *ifp) return true; } +static void zebra_vxlan_if_vni_dump_vty(struct vty *vty, + struct zebra_vxlan_vni *vni) +{ + char str[INET6_ADDRSTRLEN]; + + vty_out(vty, " VxLAN Id %u", vni->vni); + if (vni->access_vlan) + vty_out(vty, " Access VLAN Id %u\n", vni->access_vlan); + + if (vni->mcast_grp.s_addr != INADDR_ANY) + vty_out(vty, " Mcast Group %s", + inet_ntop(AF_INET, &vni->mcast_grp, str, sizeof(str))); +} + +static void zebra_vxlan_if_vni_hash_dump_vty(struct hash_bucket *bucket, + void *ctxt) +{ + struct vty *vty; + struct zebra_vxlan_vni *vni; + + vni = (struct zebra_vxlan_vni *)bucket->data; + vty = (struct vty *)ctxt; + + zebra_vxlan_if_vni_dump_vty(vty, vni); +} + +static void zebra_vxlan_if_dump_vty(struct vty *vty, struct zebra_if *zebra_if) +{ + struct zebra_l2info_vxlan *vxlan_info; + struct zebra_vxlan_vni_info *vni_info; + + vxlan_info = &zebra_if->l2info.vxl; + vni_info = &vxlan_info->vni_info; + + if (vxlan_info->vtep_ip.s_addr != INADDR_ANY) + vty_out(vty, " VTEP IP: %pI4", &vxlan_info->vtep_ip); + + if (vxlan_info->ifindex_link && (vxlan_info->link_nsid != NS_UNKNOWN)) { + struct interface *ifp; + + ifp = if_lookup_by_index_per_ns( + zebra_ns_lookup(vxlan_info->link_nsid), + vxlan_info->ifindex_link); + vty_out(vty, " Link Interface %s", + ifp == NULL ? "Unknown" : ifp->name); + } + + if (IS_ZEBRA_VXLAN_IF_VNI(zebra_if)) { + zebra_vxlan_if_vni_dump_vty(vty, &vni_info->vni); + } else { + hash_iterate(vni_info->vni_table, + zebra_vxlan_if_vni_hash_dump_vty, vty); + } + + vty_out(vty, "\n"); +} + /* Interface's information print out to vty interface. */ static void if_dump_vty(struct vty *vty, struct interface *ifp) { @@ -1997,42 +2055,15 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) zebra_zifslavetype_2str(zebra_if->zif_slave_type)); if (IS_ZEBRA_IF_BRIDGE(ifp)) { - struct zebra_l2info_bridge *bridge_info; - - bridge_info = &zebra_if->l2info.br; vty_out(vty, " Bridge VLAN-aware: %s\n", - bridge_info->vlan_aware ? "yes" : "no"); + IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zebra_if) ? "yes" : "no"); } else if (IS_ZEBRA_IF_VLAN(ifp)) { struct zebra_l2info_vlan *vlan_info; vlan_info = &zebra_if->l2info.vl; vty_out(vty, " VLAN Id %u\n", vlan_info->vid); } else if (IS_ZEBRA_IF_VXLAN(ifp)) { - struct zebra_l2info_vxlan *vxlan_info; - - vxlan_info = &zebra_if->l2info.vxl; - vty_out(vty, " VxLAN Id %u", vxlan_info->vni); - if (vxlan_info->vtep_ip.s_addr != INADDR_ANY) - vty_out(vty, " VTEP IP: %pI4", - &vxlan_info->vtep_ip); - if (vxlan_info->access_vlan) - vty_out(vty, " Access VLAN Id %u\n", - vxlan_info->access_vlan); - if (vxlan_info->mcast_grp.s_addr != INADDR_ANY) - vty_out(vty, " Mcast Group %pI4", - &vxlan_info->mcast_grp); - if (vxlan_info->ifindex_link && - (vxlan_info->link_nsid != NS_UNKNOWN)) { - struct interface *ifp; - - ifp = if_lookup_by_index_per_ns( - zebra_ns_lookup(vxlan_info->link_nsid), - vxlan_info->ifindex_link); - vty_out(vty, " Link Interface %s", - ifp == NULL ? "Unknown" : - ifp->name); - } - vty_out(vty, "\n"); + zebra_vxlan_if_dump_vty(vty, zebra_if); } else if (IS_ZEBRA_IF_GRE(ifp)) { struct zebra_l2info_gre *gre_info; @@ -2225,6 +2256,59 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) #endif /* HAVE_NET_RT_IFLIST */ } +static void zebra_vxlan_if_vni_dump_vty_json(json_object *json_if, + struct zebra_vxlan_vni *vni) +{ + json_object_int_add(json_if, "vxlanId", vni->vni); + if (vni->access_vlan) + json_object_int_add(json_if, "accessVlanId", vni->access_vlan); + if (vni->mcast_grp.s_addr != INADDR_ANY) + json_object_string_addf(json_if, "mcastGroup", "%pI4", + &vni->mcast_grp); +} + +static void zebra_vxlan_if_vni_hash_dump_vty_json(struct hash_bucket *bucket, + void *ctxt) +{ + json_object *json_if; + struct zebra_vxlan_vni *vni; + + vni = (struct zebra_vxlan_vni *)bucket->data; + json_if = (json_object *)ctxt; + + zebra_vxlan_if_vni_dump_vty_json(json_if, vni); +} + +static void zebra_vxlan_if_dump_vty_json(json_object *json_if, + struct zebra_if *zebra_if) +{ + struct zebra_l2info_vxlan *vxlan_info; + struct zebra_vxlan_vni_info *vni_info; + + vxlan_info = &zebra_if->l2info.vxl; + vni_info = &vxlan_info->vni_info; + + if (vxlan_info->vtep_ip.s_addr != INADDR_ANY) + json_object_string_addf(json_if, "vtepIp", "%pI4", + &vxlan_info->vtep_ip); + + if (vxlan_info->ifindex_link && (vxlan_info->link_nsid != NS_UNKNOWN)) { + struct interface *ifp; + + ifp = if_lookup_by_index_per_ns( + zebra_ns_lookup(vxlan_info->link_nsid), + vxlan_info->ifindex_link); + json_object_string_add(json_if, "linkInterface", + ifp == NULL ? "Unknown" : ifp->name); + } + if (IS_ZEBRA_VXLAN_IF_VNI(zebra_if)) { + zebra_vxlan_if_vni_dump_vty_json(json_if, &vni_info->vni); + } else { + hash_iterate(vni_info->vni_table, + zebra_vxlan_if_vni_hash_dump_vty_json, json_if); + } +} + static void if_dump_vty_json(struct vty *vty, struct interface *ifp, json_object *json) { @@ -2352,37 +2436,15 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, bridge_info = &zebra_if->l2info.br; json_object_boolean_add(json_if, "bridgeVlanAware", - bridge_info->vlan_aware); + bridge_info->bridge.vlan_aware); } else if (IS_ZEBRA_IF_VLAN(ifp)) { struct zebra_l2info_vlan *vlan_info; vlan_info = &zebra_if->l2info.vl; json_object_int_add(json_if, "vlanId", vlan_info->vid); } else if (IS_ZEBRA_IF_VXLAN(ifp)) { - struct zebra_l2info_vxlan *vxlan_info; - - vxlan_info = &zebra_if->l2info.vxl; - json_object_int_add(json_if, "vxlanId", vxlan_info->vni); - if (vxlan_info->vtep_ip.s_addr != INADDR_ANY) - json_object_string_addf(json_if, "vtepIp", "%pI4", - &vxlan_info->vtep_ip); - if (vxlan_info->access_vlan) - json_object_int_add(json_if, "accessVlanId", - vxlan_info->access_vlan); - if (vxlan_info->mcast_grp.s_addr != INADDR_ANY) - json_object_string_addf(json_if, "mcastGroup", "%pI4", - &vxlan_info->mcast_grp); - if (vxlan_info->ifindex_link - && (vxlan_info->link_nsid != NS_UNKNOWN)) { - struct interface *ifp; + zebra_vxlan_if_dump_vty_json(json_if, zebra_if); - ifp = if_lookup_by_index_per_ns( - zebra_ns_lookup(vxlan_info->link_nsid), - vxlan_info->ifindex_link); - json_object_string_add(json_if, "linkInterface", - ifp == NULL ? "Unknown" - : ifp->name); - } } else if (IS_ZEBRA_IF_GRE(ifp)) { struct zebra_l2info_gre *gre_info; |
