diff options
Diffstat (limited to 'zebra/interface.c')
| -rw-r--r-- | zebra/interface.c | 112 |
1 files changed, 40 insertions, 72 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 49a1e49175..8b5dbabb92 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -584,7 +584,7 @@ void if_add_update(struct interface *ifp) { struct zebra_if *if_data; struct zebra_ns *zns; - struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id); + struct zebra_vrf *zvrf = ifp->vrf->info; /* case interface populate before vrf enabled */ if (zvrf->zns) @@ -611,8 +611,8 @@ void if_add_update(struct interface *ifp) if (IS_ZEBRA_DEBUG_KERNEL) { zlog_debug( "interface %s vrf %s(%u) index %d is shutdown. Won't wake it up.", - ifp->name, VRF_LOGNAME(zvrf->vrf), - ifp->vrf_id, ifp->ifindex); + ifp->name, ifp->vrf->name, + ifp->vrf->vrf_id, ifp->ifindex); } return; @@ -623,14 +623,14 @@ void if_add_update(struct interface *ifp) if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug( "interface %s vrf %s(%u) index %d becomes active.", - ifp->name, VRF_LOGNAME(zvrf->vrf), ifp->vrf_id, + ifp->name, ifp->vrf->name, ifp->vrf->vrf_id, ifp->ifindex); } else { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("interface %s vrf %s(%u) index %d is added.", - ifp->name, VRF_LOGNAME(zvrf->vrf), - ifp->vrf_id, ifp->ifindex); + ifp->name, ifp->vrf->name, ifp->vrf->vrf_id, + ifp->ifindex); } } @@ -769,12 +769,11 @@ void if_delete_update(struct interface *ifp) struct zebra_if *zif; if (if_is_up(ifp)) { - struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id); - flog_err( EC_LIB_INTERFACE, "interface %s vrf %s(%u) index %d is still up while being deleted.", - ifp->name, VRF_LOGNAME(vrf), ifp->vrf_id, ifp->ifindex); + ifp->name, ifp->vrf->name, ifp->vrf->vrf_id, + ifp->ifindex); return; } @@ -784,13 +783,10 @@ void if_delete_update(struct interface *ifp) /* Mark interface as inactive */ UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE); - if (IS_ZEBRA_DEBUG_KERNEL) { - struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id); - + if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("interface %s vrf %s(%u) index %d is now inactive.", - ifp->name, VRF_LOGNAME(vrf), ifp->vrf_id, + ifp->name, ifp->vrf->name, ifp->vrf->vrf_id, ifp->ifindex); - } /* Delete connected routes from the kernel. */ if_delete_connected(ifp); @@ -814,7 +810,7 @@ void if_delete_update(struct interface *ifp) * occur with this implementation whereas it is not possible with * vrf-lite). */ - if (ifp->vrf_id && !vrf_is_backend_netns()) + if (ifp->vrf->vrf_id && !vrf_is_backend_netns()) if_handle_vrf_change(ifp, VRF_DEFAULT); /* Reset some zebra interface params to default values. */ @@ -842,7 +838,7 @@ void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id) { vrf_id_t old_vrf_id; - old_vrf_id = ifp->vrf_id; + old_vrf_id = ifp->vrf->vrf_id; /* Uninstall connected routes. */ if_uninstall_connected(ifp); @@ -884,7 +880,7 @@ void if_nbr_mac_to_ipv4ll_neigh_update(struct interface *ifp, struct in6_addr *address, int add) { - struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id); + struct zebra_vrf *zvrf = ifp->vrf->info; struct zebra_if *zif = ifp->info; char buf[16] = "169.254.0.1"; struct in_addr ipv4_ll; @@ -1022,7 +1018,7 @@ void if_up(struct interface *ifp) { struct zebra_if *zif; struct interface *link_if; - struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id); + struct zebra_vrf *zvrf = ifp->vrf->info; zif = ifp->info; zif->up_count++; @@ -1086,7 +1082,7 @@ void if_down(struct interface *ifp) { struct zebra_if *zif; struct interface *link_if; - struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id); + struct zebra_vrf *zvrf = ifp->vrf->info; zif = ifp->info; zif->down_count++; @@ -1175,7 +1171,7 @@ void zebra_if_update_all_links(struct zebra_ns *zns) zlog_debug("bond mbr %s map to bond %d", zif->ifp->name, zif->bondslave_info.bond_ifindex); - zebra_l2_map_slave_to_bond(zif, ifp->vrf_id); + zebra_l2_map_slave_to_bond(zif, ifp->vrf->vrf_id); } /* update SVI linkages */ @@ -1314,7 +1310,6 @@ static void connected_dump_vty(struct vty *vty, json_object *json, { struct prefix *p; json_object *json_addr = NULL; - char buf[PREFIX2STR_BUFFER]; /* Print interface address. */ p = connected->address; @@ -1322,8 +1317,7 @@ static void connected_dump_vty(struct vty *vty, json_object *json, if (json) { json_addr = json_object_new_object(); json_object_array_add(json, json_addr); - json_object_string_add(json_addr, "address", - prefix2str(p, buf, sizeof(buf))); + json_object_string_addf(json_addr, "address", "%pFX", p); } else { vty_out(vty, " %s %pFX", prefix_family_str(p), p); } @@ -1331,10 +1325,8 @@ static void connected_dump_vty(struct vty *vty, json_object *json, /* If there is destination address, print it. */ if (CONNECTED_PEER(connected) && connected->destination) { if (json) { - json_object_string_add( - json_addr, "peer", - prefix2str(connected->destination, buf, - sizeof(buf))); + json_object_string_addf(json_addr, "peer", "%pFX", + connected->destination); } else { vty_out(vty, " peer %pFX", connected->destination); } @@ -2062,18 +2054,14 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, 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_add(json_if, "vtepIp", - inet_ntop(AF_INET, - &vxlan_info->vtep_ip, - buf, sizeof(buf))); + 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_add(json_if, "mcastGroup", - inet_ntop(AF_INET, - &vxlan_info->mcast_grp, - buf, sizeof(buf))); + 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; @@ -2090,16 +2078,12 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, gre_info = &zebra_if->l2info.gre; if (gre_info->vtep_ip.s_addr != INADDR_ANY) { - json_object_string_add(json_if, "vtepIp", - inet_ntop(AF_INET, - &gre_info->vtep_ip, - buf, sizeof(buf))); + json_object_string_addf(json_if, "vtepIp", "%pI4", + &gre_info->vtep_ip); if (gre_info->vtep_ip_remote.s_addr != INADDR_ANY) - json_object_string_add( - json_if, "vtepRemoteIp", - inet_ntop(AF_INET, - &gre_info->vtep_ip_remote, - buf, sizeof(buf))); + json_object_string_addf( + json_if, "vtepRemoteIp", "%pI4", + &gre_info->vtep_ip_remote); } if (gre_info->ifindex_link && (gre_info->link_nsid != NS_UNKNOWN)) { @@ -2233,9 +2217,8 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, json_object_double_add(json_te, "utilizedBandwidth", iflp->use_bw); if (IS_PARAM_SET(iflp, LP_RMT_AS)) - json_object_string_add(json_te, "neighborAsbrIp", - inet_ntop(AF_INET, &iflp->rmt_ip, - buf, sizeof(buf))); + json_object_string_addf(json_te, "neighborAsbrIp", + "%pI4", &iflp->rmt_ip); json_object_int_add(json_te, "neighborAsbrAs", iflp->rmt_as); } @@ -2361,12 +2344,8 @@ DEFPY(show_interface, show_interface_cmd, } } - if (json) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (json) + vty_json(vty, json); return CMD_SUCCESS; } @@ -2408,12 +2387,8 @@ DEFPY (show_interface_vrf_all, } } - if (json) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (json) + vty_json(vty, json); return CMD_SUCCESS; } @@ -2461,12 +2436,8 @@ DEFPY (show_interface_name_vrf, else if_dump_vty(vty, ifp); - if (json) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (json) + vty_json(vty, json); return CMD_SUCCESS; } @@ -2526,12 +2497,8 @@ DEFPY (show_interface_name_vrf_all, else if_dump_vty(vty, ifp); - if (json) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (json) + vty_json(vty, json); return CMD_SUCCESS; } @@ -2905,6 +2872,7 @@ struct cmd_node link_params_node = { .node = LINK_PARAMS_NODE, .parent_node = INTERFACE_NODE, .prompt = "%s(config-link-params)# ", + .no_xpath = true, }; static void link_param_cmd_set_uint32(struct interface *ifp, uint32_t *field, @@ -4239,7 +4207,7 @@ static int if_config_write(struct vty *vty) if_data = ifp->info; - if (ifp->vrf_id == VRF_DEFAULT) + if (ifp->vrf->vrf_id == VRF_DEFAULT) vty_frame(vty, "interface %s\n", ifp->name); else vty_frame(vty, "interface %s vrf %s\n", |
