summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-06-22 19:35:45 +0200
committerGitHub <noreply@github.com>2019-06-22 19:35:45 +0200
commita12bb225a6681b7e7eb0aac105cbc8b745675131 (patch)
treeadb8d7935dcb1da93d6cf4082f903e412e292640 /zebra
parentMerge pull request #4294 from adharkar/frr-master-fpm_rmac (diff)
parent*: change interface structure, from vrf_id to vrf (diff)
downloadfrr-a12bb225a6681b7e7eb0aac105cbc8b745675131.tar.xz
frr-a12bb225a6681b7e7eb0aac105cbc8b745675131.zip
Merge pull request #3775 from pguibert6WIND/ospf_missing_interface_handling_2
Ospf missing interface handling 2
Diffstat (limited to 'zebra')
-rw-r--r--zebra/connected.c24
-rw-r--r--zebra/if_ioctl.c11
-rw-r--r--zebra/if_ioctl_solaris.c3
-rw-r--r--zebra/if_netlink.c29
-rw-r--r--zebra/interface.c72
-rw-r--r--zebra/ioctl.c12
-rw-r--r--zebra/kernel_socket.c8
-rw-r--r--zebra/redistribute.c18
-rw-r--r--zebra/router-id.c4
-rw-r--r--zebra/rt_netlink.c14
-rw-r--r--zebra/rtadv.c14
-rw-r--r--zebra/zapi_msg.c20
-rw-r--r--zebra/zebra_dplane.c8
-rw-r--r--zebra/zebra_ptm.c2
-rw-r--r--zebra/zebra_vrf.h9
-rw-r--r--zebra/zebra_vty.c5
-rw-r--r--zebra/zebra_vxlan.c47
17 files changed, 164 insertions, 136 deletions
diff --git a/zebra/connected.c b/zebra/connected.c
index bba221c2c..bd4f9b66a 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -207,16 +207,16 @@ void connected_up(struct interface *ifp, struct connected *ifc)
struct nexthop nh = {
.type = NEXTHOP_TYPE_IFINDEX,
.ifindex = ifp->ifindex,
- .vrf_id = ifp->vrf_id,
+ .vrf_id = vrf_to_id(ifp->vrf),
};
struct zebra_vrf *zvrf;
uint32_t metric;
- zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+ zvrf = zebra_vrf_lookup_by_id(ifp->vrf->vrf_id);
if (!zvrf) {
flog_err(EC_ZEBRA_VRF_NOT_FOUND,
"%s: Received Up for interface but no associated zvrf: %d",
- __PRETTY_FUNCTION__, ifp->vrf_id);
+ __PRETTY_FUNCTION__, ifp->vrf->vrf_id);
return;
}
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
@@ -265,7 +265,7 @@ void connected_up(struct interface *ifp, struct connected *ifc)
zlog_debug(
"%u: IF %s address %s add/up, scheduling RIB processing",
- ifp->vrf_id, ifp->name,
+ vrf_to_id(ifp->vrf), ifp->name,
prefix2str(&p, buf, sizeof(buf)));
}
rib_update(zvrf->vrf->vrf_id, RIB_UPDATE_IF_CHANGE);
@@ -383,15 +383,15 @@ void connected_down(struct interface *ifp, struct connected *ifc)
struct nexthop nh = {
.type = NEXTHOP_TYPE_IFINDEX,
.ifindex = ifp->ifindex,
- .vrf_id = ifp->vrf_id,
+ .vrf_id = vrf_to_id(ifp->vrf),
};
struct zebra_vrf *zvrf;
- zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+ zvrf = zebra_vrf_lookup_by_id(ifp->vrf->vrf_id);
if (!zvrf) {
flog_err(EC_ZEBRA_VRF_NOT_FOUND,
"%s: Received Up for interface but no associated zvrf: %d",
- __PRETTY_FUNCTION__, ifp->vrf_id);
+ __PRETTY_FUNCTION__, ifp->vrf->vrf_id);
return;
}
@@ -473,22 +473,22 @@ static void connected_delete_helper(struct connected *ifc, struct prefix *p)
zlog_debug(
"%u: IF %s IP %s address del, scheduling RIB processing",
- ifp->vrf_id, ifp->name,
+ vrf_to_id(ifp->vrf), ifp->name,
prefix2str(p, buf, sizeof(buf)));
}
- rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
+ rib_update(vrf_to_id(ifp->vrf), RIB_UPDATE_IF_CHANGE);
/* Schedule LSP forwarding entries for processing, if appropriate. */
- if (ifp->vrf_id == VRF_DEFAULT) {
+ if (vrf_to_id(ifp->vrf) == VRF_DEFAULT) {
if (IS_ZEBRA_DEBUG_MPLS) {
char buf[PREFIX_STRLEN];
zlog_debug(
"%u: IF %s IP %s address delete, scheduling MPLS processing",
- ifp->vrf_id, ifp->name,
+ vrf_to_id(ifp->vrf), ifp->name,
prefix2str(p, buf, sizeof(buf)));
}
- mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id), p);
+ mpls_mark_lsps_for_processing(zvrf_info_lookup(ifp->vrf), p);
}
}
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 8bec25635..6ce566262 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -54,6 +54,7 @@ static int interface_list_ioctl(void)
struct interface *ifp;
int n;
int lastlen;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
/* Normally SIOCGIFCONF works with AF_INET socket. */
sock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -110,7 +111,7 @@ static int interface_list_ioctl(void)
unsigned int size;
ifreq = (struct ifreq *)((caddr_t)ifconf.ifc_req + n);
- ifp = if_get_by_name(ifreq->ifr_name, VRF_DEFAULT);
+ ifp = if_get_by_name(ifreq->ifr_name, vrf);
if_add_update(ifp);
size = ifreq->ifr_addr.sa_len;
if (size < sizeof(ifreq->ifr_addr))
@@ -120,7 +121,7 @@ static int interface_list_ioctl(void)
}
#else
for (n = 0; n < ifconf.ifc_len; n += sizeof(struct ifreq)) {
- ifp = if_get_by_name(ifreq->ifr_name, VRF_DEFAULT);
+ ifp = if_get_by_name(ifreq->ifr_name, vrf);
if_add_update(ifp);
ifreq++;
}
@@ -151,7 +152,8 @@ static int if_get_hwaddr(struct interface *ifp)
ifreq.ifr_addr.sa_family = AF_INET;
/* Fetch Hardware address if available. */
- ret = vrf_if_ioctl(SIOCGIFHWADDR, (caddr_t)&ifreq, ifp->vrf_id);
+ ret = vrf_if_ioctl(SIOCGIFHWADDR, (caddr_t)&ifreq,
+ vrf_to_id(ifp->vrf));
if (ret < 0)
ifp->hw_addr_len = 0;
else {
@@ -195,7 +197,8 @@ static int if_getaddrs(void)
continue;
}
- ifp = if_lookup_by_name(ifap->ifa_name, VRF_DEFAULT);
+ ifp = if_lookup_by_name(ifap->ifa_name,
+ vrf_lookup_by_id(VRF_DEFAULT));
if (ifp == NULL) {
flog_err(EC_LIB_INTERFACE,
"if_getaddrs(): Can't lookup interface %s\n",
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 8b539a904..1ed75bfa5 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -59,6 +59,7 @@ static int interface_list_ioctl(int af)
int n;
size_t needed, lastneeded = 0;
char *buf = NULL;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
frr_elevate_privs(&zserv_privs) {
sock = socket(af, SOCK_DGRAM, 0);
@@ -156,7 +157,7 @@ calculate_lifc_len:
&& (*(lifreq->lifr_name + normallen) != ':'))
normallen++;
- ifp = if_get_by_name(lifreq->lifr_name, VRF_DEFAULT);
+ ifp = if_get_by_name(lifreq->lifr_name, vrf);
if (lifreq->lifr_addr.ss_family == AF_INET)
ifp->flags |= IFF_IPV4;
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index df8d4bfe1..4b6000c94 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -387,7 +387,7 @@ static int get_iflink_speed(struct interface *interface)
/* use ioctl to get IP address of an interface */
frr_elevate_privs(&zserv_privs) {
sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP,
- interface->vrf_id,
+ vrf_to_id(interface->vrf),
NULL);
if (sd < 0) {
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -396,7 +396,7 @@ static int get_iflink_speed(struct interface *interface)
return 0;
}
/* Get the current link state for the interface */
- rc = vrf_ioctl(interface->vrf_id, sd, SIOCETHTOOL,
+ rc = vrf_ioctl(vrf_to_id(interface->vrf), sd, SIOCETHTOOL,
(char *)&ifdata);
}
if (rc < 0) {
@@ -598,6 +598,7 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifindex_t link_ifindex = IFINDEX_INTERNAL;
ifindex_t bond_ifindex = IFINDEX_INTERNAL;
struct zebra_if *zif;
+ struct vrf *vrf;
zns = zebra_ns_lookup(ns_id);
ifi = NLMSG_DATA(h);
@@ -664,6 +665,8 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
&& !vrf_is_backend_netns()) {
zif_slave_type = ZEBRA_IF_SLAVE_VRF;
vrf_id = *(uint32_t *)RTA_DATA(tb[IFLA_MASTER]);
+ /* vrf can be needed before vrf netlink discovery */
+ vrf_get(vrf_id, NULL);
} else if (slave_kind && (strcmp(slave_kind, "bridge") == 0)) {
zif_slave_type = ZEBRA_IF_SLAVE_BRIDGE;
bridge_ifindex =
@@ -676,13 +679,13 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
}
if (vrf_is_backend_netns())
vrf_id = (vrf_id_t)ns_id;
-
+ vrf = vrf_lookup_by_id(vrf_id);
/* If linking to another interface, note it. */
if (tb[IFLA_LINK])
link_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_LINK]);
/* Add interface. */
- ifp = if_get_by_name(name, vrf_id);
+ ifp = if_get_by_name(name, vrf);
set_ifindex(ifp, ifi->ifi_index, zns);
ifp->flags = ifi->ifi_flags & 0x0000fffff;
ifp->mtu6 = ifp->mtu = *(uint32_t *)RTA_DATA(tb[IFLA_MTU]);
@@ -1109,6 +1112,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifindex_t link_ifindex = IFINDEX_INTERNAL;
uint8_t old_hw_addr[INTERFACE_HWADDR_MAX];
struct zebra_if *zif;
+ struct vrf *vrf;
zns = zebra_ns_lookup(ns_id);
ifi = NLMSG_DATA(h);
@@ -1209,6 +1213,9 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
}
if (vrf_is_backend_netns())
vrf_id = (vrf_id_t)ns_id;
+
+ vrf = vrf_lookup_by_id(vrf_id);
+
if (ifp == NULL
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
/* Add interface notification from kernel */
@@ -1222,11 +1229,11 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if (ifp == NULL) {
/* unknown interface */
- ifp = if_get_by_name(name, vrf_id);
+ ifp = if_get_by_name(name, vrf);
} else {
/* pre-configured interface, learnt now */
- if (ifp->vrf_id != vrf_id)
- if_update_to_new_vrf(ifp, vrf_id);
+ if (ifp->vrf != vrf)
+ if_update_to_new_vrf(ifp, vrf);
}
/* Update interface information. */
@@ -1265,16 +1272,16 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
bridge_ifindex);
else if (IS_ZEBRA_IF_BOND_SLAVE(ifp))
zebra_l2if_update_bond_slave(ifp, bond_ifindex);
- } else if (ifp->vrf_id != vrf_id) {
+ } else if (ifp->vrf != vrf) {
/* VRF change for an interface. */
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"RTM_NEWLINK vrf-change for %s(%u) "
"vrf_id %u -> %u flags 0x%x",
- name, ifp->ifindex, ifp->vrf_id, vrf_id,
- ifi->ifi_flags);
+ name, ifp->ifindex, vrf_to_id(ifp->vrf),
+ vrf_id, ifi->ifi_flags);
- if_handle_vrf_change(ifp, vrf_id);
+ if_handle_vrf_change(ifp, vrf->vrf_id);
} else {
bool was_bridge_slave, was_bond_slave;
diff --git a/zebra/interface.c b/zebra/interface.c
index 719cf05db..34bdd54b8 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -530,7 +530,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 = zvrf_info_lookup(ifp->vrf);
/* case interface populate before vrf enabled */
if (zvrf->zns)
@@ -558,7 +558,8 @@ void if_add_update(struct interface *ifp)
zlog_debug(
"interface %s vrf %u index %d is shutdown. "
"Won't wake it up.",
- ifp->name, ifp->vrf_id, ifp->ifindex);
+ ifp->name, vrf_to_id(ifp->vrf),
+ ifp->ifindex);
return;
}
@@ -567,12 +568,13 @@ void if_add_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"interface %s vrf %u index %d becomes active.",
- ifp->name, ifp->vrf_id, ifp->ifindex);
+ ifp->name, vrf_to_id(ifp->vrf), ifp->ifindex);
} else {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("interface %s vrf %u index %d is added.",
- ifp->name, ifp->vrf_id, ifp->ifindex);
+ ifp->name, vrf_to_id(ifp->vrf),
+ ifp->ifindex);
}
}
@@ -714,7 +716,7 @@ void if_delete_update(struct interface *ifp)
flog_err(
EC_LIB_INTERFACE,
"interface %s vrf %u index %d is still up while being deleted.",
- ifp->name, ifp->vrf_id, ifp->ifindex);
+ ifp->name, vrf_to_id(ifp->vrf), ifp->ifindex);
return;
}
@@ -726,7 +728,7 @@ void if_delete_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("interface %s vrf %u index %d is now inactive.",
- ifp->name, ifp->vrf_id, ifp->ifindex);
+ ifp->name, vrf_to_id(ifp->vrf), ifp->ifindex);
/* Delete connected routes from the kernel. */
if_delete_connected(ifp);
@@ -750,7 +752,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. */
@@ -768,8 +770,9 @@ void if_delete_update(struct interface *ifp)
void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
{
vrf_id_t old_vrf_id;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
- old_vrf_id = ifp->vrf_id;
+ old_vrf_id = vrf_to_id(ifp->vrf);
/* Uninstall connected routes. */
if_uninstall_connected(ifp);
@@ -785,7 +788,7 @@ void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
zebra_interface_vrf_update_del(ifp, vrf_id);
/* update VRF */
- if_update_to_new_vrf(ifp, vrf_id);
+ if_update_to_new_vrf(ifp, vrf);
/* Send out notification on interface VRF change. */
/* This is to issue an ADD, if needed. */
@@ -800,9 +803,9 @@ void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
*/
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%u: IF %s VRF change, scheduling RIB processing",
- ifp->vrf_id, ifp->name);
+ vrf_to_id(ifp->vrf), ifp->name);
rib_update(old_vrf_id, RIB_UPDATE_IF_CHANGE);
- rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
+ rib_update(vrf_to_id(ifp->vrf), RIB_UPDATE_IF_CHANGE);
}
static void ipv6_ll_address_to_mac(struct in6_addr *address, uint8_t *mac)
@@ -820,7 +823,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 = zvrf_info_lookup(ifp->vrf);
struct zebra_if *zif = ifp->info;
char buf[16] = "169.254.0.1";
struct in_addr ipv4_ll;
@@ -916,7 +919,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 = zvrf_info_lookup(ifp->vrf);
zif = ifp->info;
zif->up_count++;
@@ -947,8 +950,8 @@ void if_up(struct interface *ifp)
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%u: IF %s up, scheduling RIB processing",
- ifp->vrf_id, ifp->name);
- rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
+ vrf_to_id(ifp->vrf), ifp->name);
+ rib_update(vrf_to_id(ifp->vrf), RIB_UPDATE_IF_CHANGE);
/* Handle interface up for specific types for EVPN. Non-VxLAN interfaces
* are checked to see if (remote) neighbor entries need to be installed
@@ -973,7 +976,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 = zvrf_info_lookup(ifp->vrf);
zif = ifp->info;
zif->down_count++;
@@ -1005,8 +1008,8 @@ void if_down(struct interface *ifp)
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%u: IF %s down, scheduling RIB processing",
- ifp->vrf_id, ifp->name);
- rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
+ vrf_to_id(ifp->vrf), ifp->name);
+ rib_update(vrf_to_id(ifp->vrf), RIB_UPDATE_IF_CHANGE);
if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp);
@@ -1307,7 +1310,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
zebra_ptm_show_status(vty, ifp);
- vrf = vrf_lookup_by_id(ifp->vrf_id);
+ vrf = ifp->vrf;
vty_out(vty, " vrf: %s\n", vrf->name);
if (ifp->desc)
@@ -1569,17 +1572,15 @@ DEFPY(show_interface, show_interface_cmd,
VRF_CMD_HELP_STR
"Interface status and configuration summary\n")
{
- struct vrf *vrf;
+ struct vrf *vrf = NULL;
struct interface *ifp;
- vrf_id_t vrf_id = VRF_DEFAULT;
interface_update_stats();
if (name)
- VRF_GET_ID(vrf_id, name, false);
+ VRF_GET_INSTANCE(vrf, name, false, false);
/* All interface print. */
- vrf = vrf_lookup_by_id(vrf_id);
if (brief) {
ifs_dump_brief_vty(vty, vrf);
} else {
@@ -1632,14 +1633,14 @@ DEFUN (show_interface_name_vrf,
int idx_ifname = 2;
int idx_name = 4;
struct interface *ifp;
- vrf_id_t vrf_id;
+ struct vrf *vrf;
interface_update_stats();
- VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
+ VRF_GET_INSTANCE(vrf, argv[idx_name]->arg, false, false);
/* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
+ ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf);
if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n",
argv[idx_ifname]->arg);
@@ -1669,7 +1670,7 @@ DEFUN (show_interface_name_vrf_all,
/* All interface print. */
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
/* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf->vrf_id);
+ ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf);
if (ifp) {
if_dump_vty(vty, ifp);
found++;
@@ -1686,9 +1687,8 @@ DEFUN (show_interface_name_vrf_all,
}
-static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
+static void if_show_description(struct vty *vty, struct vrf *vrf)
{
- struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
vty_out(vty, "Interface Status Protocol Description\n");
@@ -1742,12 +1742,14 @@ DEFUN (show_interface_desc,
"Interface description\n"
VRF_CMD_HELP_STR)
{
- vrf_id_t vrf_id = VRF_DEFAULT;
+ struct vrf *vrf;
if (argc > 3)
- VRF_GET_ID(vrf_id, argv[4]->arg, false);
+ VRF_GET_INSTANCE(vrf, argv[4]->arg, false, false);
+ else
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
- if_show_description(vty, vrf_id);
+ if_show_description(vty, vrf);
return CMD_SUCCESS;
}
@@ -1766,7 +1768,7 @@ DEFUN (show_interface_desc_vrf_all,
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {
vty_out(vty, "\n\tVRF %u\n\n", vrf->vrf_id);
- if_show_description(vty, vrf->vrf_id);
+ if_show_description(vty, vrf);
}
return CMD_SUCCESS;
@@ -3120,9 +3122,9 @@ static int if_config_write(struct vty *vty)
struct vrf *vrf;
if_data = ifp->info;
- vrf = vrf_lookup_by_id(ifp->vrf_id);
+ vrf = ifp->vrf;
- if (ifp->vrf_id == VRF_DEFAULT)
+ if (vrf->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", ifp->name);
else
vty_frame(vty, "interface %s vrf %s\n",
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 8202e076a..628be6563 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -142,7 +142,8 @@ void if_get_metric(struct interface *ifp)
ifreq_set_name(&ifreq, ifp);
- if (vrf_if_ioctl(SIOCGIFMETRIC, (caddr_t)&ifreq, ifp->vrf_id) < 0)
+ if (vrf_if_ioctl(SIOCGIFMETRIC, (caddr_t)&ifreq,
+ vrf_to_id(ifp->vrf)) < 0)
return;
ifp->metric = ifreq.ifr_metric;
if (ifp->metric == 0)
@@ -160,7 +161,8 @@ void if_get_mtu(struct interface *ifp)
ifreq_set_name(&ifreq, ifp);
#if defined(SIOCGIFMTU)
- if (vrf_if_ioctl(SIOCGIFMTU, (caddr_t)&ifreq, ifp->vrf_id) < 0) {
+ if (vrf_if_ioctl(SIOCGIFMTU, (caddr_t)&ifreq,
+ vrf_to_id(ifp->vrf)) < 0) {
zlog_info("Can't lookup mtu by ioctl(SIOCGIFMTU)");
ifp->mtu6 = ifp->mtu = -1;
return;
@@ -427,7 +429,7 @@ void if_get_flags(struct interface *ifp)
ifreq_set_name(&ifreq, ifp);
- ret = vrf_if_ioctl(SIOCGIFFLAGS, (caddr_t)&ifreq, ifp->vrf_id);
+ ret = vrf_if_ioctl(SIOCGIFFLAGS, (caddr_t)&ifreq, vrf_to_id(ifp->vrf));
if (ret < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"vrf_if_ioctl(SIOCGIFFLAGS) failed: %s",
@@ -477,7 +479,7 @@ int if_set_flags(struct interface *ifp, uint64_t flags)
ifreq.ifr_flags = ifp->flags;
ifreq.ifr_flags |= flags;
- ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, ifp->vrf_id);
+ ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, vrf_to_id(ifp->vrf));
if (ret < 0) {
zlog_info("can't set interface flags");
@@ -498,7 +500,7 @@ int if_unset_flags(struct interface *ifp, uint64_t flags)
ifreq.ifr_flags = ifp->flags;
ifreq.ifr_flags &= ~flags;
- ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, ifp->vrf_id);
+ ret = vrf_if_ioctl(SIOCSIFFLAGS, (caddr_t)&ifreq, vrf_to_id(ifp->vrf));
if (ret < 0) {
zlog_info("can't unset interface flags");
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 156ce5072..be1191bac 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -435,6 +435,7 @@ static void rtm_flag_dump(int flag)
static int ifan_read(struct if_announcemsghdr *ifan)
{
struct interface *ifp;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
ifp = if_lookup_by_index(ifan->ifan_index, VRF_DEFAULT);
@@ -450,7 +451,7 @@ static int ifan_read(struct if_announcemsghdr *ifan)
__func__, ifan->ifan_index, ifan->ifan_name);
/* Create Interface */
- ifp = if_get_by_name(ifan->ifan_name, VRF_DEFAULT);
+ ifp = if_get_by_name(ifan->ifan_name, vrf);
if_set_index(ifp, ifan->ifan_index);
if_get_metric(ifp);
@@ -529,6 +530,7 @@ int ifm_read(struct if_msghdr *ifm)
int maskbit;
caddr_t cp;
char fbuf[64];
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
/* terminate ifname at head (for strnlen) and tail (for safety) */
ifname[IFNAMSIZ - 1] = '\0';
@@ -614,7 +616,7 @@ int ifm_read(struct if_msghdr *ifm)
* be filled in.
*/
if ((ifp == NULL) && ifnlen)
- ifp = if_lookup_by_name(ifname, VRF_DEFAULT);
+ ifp = if_lookup_by_name(ifname, vrf);
/*
* If ifp still does not exist or has an invalid index
@@ -643,7 +645,7 @@ int ifm_read(struct if_msghdr *ifm)
if (ifp == NULL) {
/* Interface that zebra was not previously aware of, so
* create. */
- ifp = if_create(ifname, VRF_DEFAULT);
+ ifp = if_create(ifname, vrf);
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: creating ifp for ifindex %d",
__func__, ifm->ifm_index);
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index b13f1170c..7b3332e58 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -402,7 +402,7 @@ void zebra_interface_up_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("MESSAGE: ZEBRA_INTERFACE_UP %s(%u)",
- ifp->name, ifp->vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf));
if (ifp->ptm_status || !ifp->ptm_enable) {
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode,
@@ -422,7 +422,7 @@ void zebra_interface_down_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("MESSAGE: ZEBRA_INTERFACE_DOWN %s(%u)",
- ifp->name, ifp->vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf));
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
@@ -437,7 +437,7 @@ void zebra_interface_add_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADD %s(%u)", ifp->name,
- ifp->vrf_id);
+ vrf_to_id(ifp->vrf));
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
client->ifadd_cnt++;
@@ -453,7 +453,7 @@ void zebra_interface_delete_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("MESSAGE: ZEBRA_INTERFACE_DELETE %s(%u)",
- ifp->name, ifp->vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf));
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
client->ifdel_cnt++;
@@ -475,7 +475,7 @@ void zebra_interface_address_add_update(struct interface *ifp,
p = ifc->address;
zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s(%u)",
prefix2str(p, buf, sizeof(buf)), ifp->name,
- ifp->vrf_id);
+ vrf_to_id(ifp->vrf));
}
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
@@ -509,7 +509,7 @@ void zebra_interface_address_delete_update(struct interface *ifp,
p = ifc->address;
zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s(%u)",
prefix2str(p, buf, sizeof(buf)),
- ifp->name, ifp->vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf));
}
zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 0);
@@ -535,7 +535,7 @@ void zebra_interface_vrf_update_del(struct interface *ifp, vrf_id_t new_vrf_id)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
"MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL %s VRF Id %u -> %u",
- ifp->name, ifp->vrf_id, new_vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf), new_vrf_id);
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
/* Need to delete if the client is not interested in the new
@@ -558,7 +558,7 @@ void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
"MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD %s VRF Id %u -> %u",
- ifp->name, old_vrf_id, ifp->vrf_id);
+ ifp->name, old_vrf_id, vrf_to_id(ifp->vrf));
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
/* Need to add if the client is interested in the new VRF. */
@@ -816,7 +816,7 @@ void zebra_interface_parameters_update(struct interface *ifp)
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("MESSAGE: ZEBRA_INTERFACE_LINK_PARAMS %s(%u)",
- ifp->name, ifp->vrf_id);
+ ifp->name, vrf_to_id(ifp->vrf));
for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
zsend_interface_link_params(client, ifp);
diff --git a/zebra/router-id.c b/zebra/router-id.c
index 569ffbab4..b5a8860c4 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -122,7 +122,7 @@ void router_id_add_address(struct connected *ifc)
struct prefix before;
struct prefix after;
struct zserv *client;
- struct zebra_vrf *zvrf = vrf_info_get(ifc->ifp->vrf_id);
+ struct zebra_vrf *zvrf = vrf_info_get(vrf_to_id(ifc->ifp->vrf));
if (router_id_bad_address(ifc))
return;
@@ -154,7 +154,7 @@ void router_id_del_address(struct connected *ifc)
struct prefix before;
struct listnode *node;
struct zserv *client;
- struct zebra_vrf *zvrf = vrf_info_get(ifc->ifp->vrf_id);
+ struct zebra_vrf *zvrf = vrf_info_get(vrf_to_id(ifc->ifp->vrf));
if (router_id_bad_address(ifc))
return;
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index d594accf4..c4654510b 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -549,7 +549,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
zebra_ns_lookup(ns_id),
index);
if (ifp)
- nh_vrf_id = ifp->vrf_id;
+ nh_vrf_id = vrf_to_id(ifp->vrf);
}
nh.vrf_id = nh_vrf_id;
@@ -609,7 +609,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
zebra_ns_lookup(ns_id),
index);
if (ifp)
- nh_vrf_id = ifp->vrf_id;
+ nh_vrf_id = vrf_to_id(ifp->vrf);
else {
flog_warn(
EC_ZEBRA_UNKNOWN_INTERFACE,
@@ -1893,7 +1893,7 @@ static int netlink_vxlan_flood_list_update(struct interface *ifp,
char buf[256];
} req;
uint8_t dst_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
- struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+ struct zebra_vrf *zvrf = zvrf_info_lookup(ifp->vrf);
zns = zvrf->zns;
memset(&req, 0, sizeof(req));
@@ -2291,7 +2291,7 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
int vid_present = 0;
char vid_buf[20];
char dst_buf[30];
- struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+ struct zebra_vrf *zvrf = zvrf_info_lookup(ifp->vrf);
zns = zvrf->zns;
zif = ifp->info;
@@ -2640,7 +2640,7 @@ int netlink_neigh_read_specific_ip(struct ipaddr *ip,
{
int ret = 0;
struct zebra_ns *zns;
- struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(vlan_if->vrf_id);
+ struct zebra_vrf *zvrf = zvrf_info_lookup(vlan_if->vrf);
char buf[INET6_ADDRSTRLEN];
struct zebra_dplane_info dp_info;
@@ -2653,7 +2653,7 @@ int netlink_neigh_read_specific_ip(struct ipaddr *ip,
__PRETTY_FUNCTION__, vlan_if->name,
vlan_if->ifindex,
ipaddr2str(ip, buf, sizeof(buf)),
- vlan_if->vrf_id);
+ vrf_to_id(vlan_if->vrf));
ret = netlink_request_specific_neigh_in_vlan(zns, RTM_GETNEIGH, ip,
vlan_if->ifindex);
@@ -2718,7 +2718,7 @@ static int netlink_neigh_update2(struct interface *ifp, struct ipaddr *ip,
struct zebra_ns *zns;
char buf[INET6_ADDRSTRLEN];
char buf2[ETHER_ADDR_STRLEN];
- struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+ struct zebra_vrf *zvrf = zvrf_info_lookup(ifp->vrf);
zns = zvrf->zns;
memset(&req, 0, sizeof(req));
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 5841c44b0..33d0022a9 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -534,7 +534,7 @@ static int rtadv_timer(struct thread *thread)
static void rtadv_process_solicit(struct interface *ifp)
{
- struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
+ struct zebra_vrf *zvrf = zvrf_info_lookup(ifp->vrf);
assert(zvrf);
rtadv_send_packet(rtadv_get_socket(zvrf), ifp);
@@ -884,7 +884,7 @@ static void ipv6_nd_suppress_ra_set(struct interface *ifp,
struct zebra_vrf *zvrf;
zif = ifp->info;
- zvrf = vrf_info_lookup(ifp->vrf_id);
+ zvrf = zvrf_info_lookup(ifp->vrf);
if (status == RA_SUPPRESS) {
/* RA is currently enabled */
@@ -957,11 +957,11 @@ static void zebra_interface_radv_set(ZAPI_HANDLER_ARGS, int enable)
zebra_route_string(client->proto));
return;
}
- if (ifp->vrf_id != zvrf_id(zvrf)) {
+ if (ifp->vrf != zvrf->vrf) {
zlog_debug(
"%u: IF %u RA %s client %s - VRF mismatch, IF VRF %u",
zvrf_id(zvrf), ifindex, enable ? "enable" : "disable",
- zebra_route_string(client->proto), ifp->vrf_id);
+ zebra_route_string(client->proto), vrf_to_id(ifp->vrf));
return;
}
@@ -1058,7 +1058,7 @@ DEFUN (ipv6_nd_ra_interval_msec,
struct zebra_if *zif = ifp->info;
struct zebra_vrf *zvrf;
- zvrf = vrf_info_lookup(ifp->vrf_id);
+ zvrf = zvrf_info_lookup(ifp->vrf);
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
@@ -1096,7 +1096,7 @@ DEFUN (ipv6_nd_ra_interval,
struct zebra_if *zif = ifp->info;
struct zebra_vrf *zvrf;
- zvrf = vrf_info_lookup(ifp->vrf_id);
+ zvrf = zvrf_info_lookup(ifp->vrf);
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
@@ -1135,7 +1135,7 @@ DEFUN (no_ipv6_nd_ra_interval,
struct zebra_if *zif = ifp->info;
struct zebra_vrf *zvrf = NULL;
- zvrf = vrf_info_lookup(ifp->vrf_id);
+ zvrf = zvrf_info_lookup(ifp->vrf);
if (zif->rtadv.MaxRtrAdvInterval % 1000)
zvrf->rtadv.adv_msec_if_count--;
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 61200806b..2f41f7133 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -165,7 +165,7 @@ int zsend_interface_add(struct zserv *client, struct interface *ifp)
{
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, ZEBRA_INTERFACE_ADD, ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_INTERFACE_ADD, vrf_to_id(ifp->vrf));
zserv_encode_interface(s, ifp);
client->ifadd_cnt++;
@@ -177,7 +177,7 @@ int zsend_interface_delete(struct zserv *client, struct interface *ifp)
{
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, ZEBRA_INTERFACE_DELETE, ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_INTERFACE_DELETE, vrf_to_id(ifp->vrf));
zserv_encode_interface(s, ifp);
client->ifdel_cnt++;
@@ -217,7 +217,8 @@ int zsend_interface_link_params(struct zserv *client, struct interface *ifp)
return 0;
}
- zclient_create_header(s, ZEBRA_INTERFACE_LINK_PARAMS, ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_INTERFACE_LINK_PARAMS,
+ vrf_to_id(ifp->vrf));
/* Add Interface Index */
stream_putl(s, ifp->ifindex);
@@ -279,7 +280,7 @@ int zsend_interface_address(int cmd, struct zserv *client,
struct prefix *p;
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, cmd, ifp->vrf_id);
+ zclient_create_header(s, cmd, vrf_to_id(ifp->vrf));
stream_putl(s, ifp->ifindex);
/* Interface address flag. */
@@ -321,7 +322,7 @@ static int zsend_interface_nbr_address(int cmd, struct zserv *client,
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
struct prefix *p;
- zclient_create_header(s, cmd, ifp->vrf_id);
+ zclient_create_header(s, cmd, vrf_to_id(ifp->vrf));
stream_putl(s, ifp->ifindex);
/* Prefix information. */
@@ -429,7 +430,8 @@ int zsend_interface_vrf_update(struct zserv *client, struct interface *ifp,
{
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, ZEBRA_INTERFACE_VRF_UPDATE, ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_INTERFACE_VRF_UPDATE,
+ vrf_to_id(ifp->vrf));
/* Fill in the name of the interface and its new VRF (id) */
stream_put(s, ifp->name, INTERFACE_NAMSIZ);
@@ -504,7 +506,7 @@ int zsend_interface_update(int cmd, struct zserv *client, struct interface *ifp)
{
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, cmd, ifp->vrf_id);
+ zclient_create_header(s, cmd, vrf_to_id(ifp->vrf));
zserv_encode_interface(s, ifp);
if (cmd == ZEBRA_INTERFACE_UP)
@@ -2207,9 +2209,9 @@ static void zread_vrf_label(ZAPI_HANDLER_ARGS)
STREAM_GETC(s, ltype);
if (zvrf->vrf->vrf_id != VRF_DEFAULT)
- ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf->vrf_id);
+ ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf);
else
- ifp = if_lookup_by_name("lo", VRF_DEFAULT);
+ ifp = if_lookup_by_name("lo", vrf_lookup_by_id(VRF_DEFAULT));
if (!ifp) {
zlog_debug("Unable to find specified Interface for %s",
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index f93562b31..e2128b1c8 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -1920,7 +1920,7 @@ enum zebra_dplane_result dplane_intf_addr_set(const struct interface *ifp,
struct prefix_ipv4 *p;
p = (struct prefix_ipv4 *)ifc->address;
- rib_lookup_and_pushup(p, ifp->vrf_id);
+ rib_lookup_and_pushup(p, ifp->vrf->vrf_id);
}
#endif
@@ -1951,7 +1951,7 @@ static enum zebra_dplane_result intf_addr_update_internal(
prefix2str(ifc->address, addr_str, sizeof(addr_str));
zlog_debug("init intf ctx %s: idx %d, addr %u:%s",
- dplane_op2str(op), ifp->ifindex, ifp->vrf_id,
+ dplane_op2str(op), ifp->ifindex, ifp->vrf->vrf_id,
addr_str);
}
@@ -1959,9 +1959,9 @@ static enum zebra_dplane_result intf_addr_update_internal(
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
- ctx->zd_vrf_id = ifp->vrf_id;
+ ctx->zd_vrf_id = ifp->vrf->vrf_id;
- zns = zebra_ns_lookup(ifp->vrf_id);
+ zns = zebra_ns_lookup(ifp->vrf->vrf_id);
dplane_ctx_ns_init(ctx, zns, false);
/* Init the interface-addr-specific area */
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index 46f138552..636bceb98 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -522,7 +522,7 @@ static int zebra_ptm_handle_bfd_msg(void *arg, void *in_ctxt,
}
if (!strcmp(ZEBRA_PTM_INVALID_VRF, vrf_str) && ifp) {
- vrf_id = ifp->vrf_id;
+ vrf_id = vrf_to_id(ifp->vrf);
} else {
vrf_id = vrf_name_to_id(vrf_str);
}
diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h
index 972fe381c..1b8766950 100644
--- a/zebra/zebra_vrf.h
+++ b/zebra/zebra_vrf.h
@@ -193,6 +193,15 @@ static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf)
return zvrf->vrf->vrf_id;
}
+static inline struct zebra_vrf *zvrf_info_lookup(struct vrf *vrf)
+{
+ struct zebra_vrf *zvrf = NULL;
+
+ if (vrf)
+ zvrf = (struct zebra_vrf *)vrf->info;
+ return zvrf;
+}
+
static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf)
{
if (!zvrf->vrf || !zvrf->vrf->ns_ctxt)
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 1f8eec9ca..a38d060bd 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -970,10 +970,9 @@ DEFPY (show_route_table_vrf,
afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
struct zebra_vrf *zvrf;
struct route_table *t;
- vrf_id_t vrf_id = VRF_DEFAULT;
+ vrf_id_t vrf_id;
- if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name, !!json);
+ VRF_GET_ID(vrf_id, vrf_name, !!json);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
t = zebra_router_find_table(zvrf, table, afi, SAFI_UNICAST);
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 4289f4b6f..c058fdce6 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -2358,7 +2358,7 @@ static void zvni_process_neigh_on_local_mac_change(zebra_vni_t *zvni,
struct zebra_vrf *zvrf = NULL;
char buf[ETHER_ADDR_STRLEN];
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("Processing neighbors on local MAC %s %s, VNI %u",
@@ -2617,7 +2617,7 @@ struct interface *zebra_get_vrr_intf_for_svi(struct interface *ifp)
struct interface *tmp_if = NULL;
struct zebra_if *zif = NULL;
- zvrf = vrf_info_lookup(ifp->vrf_id);
+ zvrf = zvrf_info_lookup(ifp->vrf);
assert(zvrf);
FOR_ALL_INTERFACES (zvrf->vrf, tmp_if) {
@@ -2721,10 +2721,10 @@ static int zvni_advertise_subnet(zebra_vni_t *zvni, struct interface *ifp,
apply_mask(&p);
if (advertise)
- ip_prefix_send_to_client(ifp->vrf_id, &p,
+ ip_prefix_send_to_client(vrf_to_id(ifp->vrf), &p,
ZEBRA_IP_PREFIX_ROUTE_ADD);
else
- ip_prefix_send_to_client(ifp->vrf_id, &p,
+ ip_prefix_send_to_client(vrf_to_id(ifp->vrf), &p,
ZEBRA_IP_PREFIX_ROUTE_DEL);
}
return 0;
@@ -2843,7 +2843,7 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP",
- ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni,
+ vrf_to_id(ifp->vrf), ifp->name, ifp->ifindex, zvni->vni,
prefix_mac2str(&(n->emac), buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)));
@@ -3030,11 +3030,11 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
}
}
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
if (!zvrf) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("\tUnable to find vrf for: %d",
- zvni->vxlan_if->vrf_id);
+ zlog_debug("\tUnable to find vrf for: %s",
+ zvni->vxlan_if->vrf->name);
return -1;
}
@@ -4091,8 +4091,9 @@ static void zvni_build_hash_table(void)
vlan_if = zvni_map_to_svi(vxl->access_vlan,
zif->brslave_info.br_if);
if (vlan_if) {
- zvni->vrf_id = vlan_if->vrf_id;
- zl3vni = zl3vni_from_vrf(vlan_if->vrf_id);
+ zvni->vrf_id = vrf_to_id(vlan_if->vrf);
+ zl3vni = zl3vni_from_vrf(
+ vrf_to_id(vlan_if->vrf));
if (zl3vni)
listnode_add_sort(zl3vni->l2vnis, zvni);
}
@@ -5257,7 +5258,7 @@ static void process_remote_macip_add(vni_t vni,
return;
}
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
if (!zvrf)
return;
@@ -5585,7 +5586,7 @@ static void process_remote_macip_del(vni_t vni,
if (!mac && !n)
return;
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
/* Ignore the delete if this mac is a gateway mac-ip */
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL)
@@ -7272,7 +7273,7 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
return 0;
}
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
if (!zvrf) {
zlog_debug("%s: VNI %u vrf lookup failed.",
__PRETTY_FUNCTION__, zvni->vni);
@@ -7695,11 +7696,11 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
return -1;
}
- zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
+ zvrf = zvrf_info_lookup(zvni->vxlan_if->vrf);
if (!zvrf) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("\tNo Vrf found for vrf_id: %d",
- zvni->vxlan_if->vrf_id);
+ zlog_debug("\tNo Vrf found for vrf_id: %s",
+ zvni->vxlan_if->vrf->name);
return -1;
}
@@ -8231,10 +8232,10 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)
zlog_debug(
"SVI %s(%u) VNI %u VRF %s is UP, installing neighbors",
ifp->name, ifp->ifindex, zvni->vni,
- vrf_id_to_name(ifp->vrf_id));
+ vrf_to_name(ifp->vrf));
/* update the vrf information for l2-vni and inform bgp */
- zvni->vrf_id = ifp->vrf_id;
+ zvni->vrf_id = vrf_to_id(ifp->vrf);
zvni_send_add_to_client(zvni);
/* Install any remote neighbors for this VNI. */
@@ -8360,8 +8361,8 @@ int zebra_vxlan_if_up(struct interface *ifp)
vlan_if = zvni_map_to_svi(vxl->access_vlan,
zif->brslave_info.br_if);
if (vlan_if) {
- zvni->vrf_id = vlan_if->vrf_id;
- zl3vni = zl3vni_from_vrf(vlan_if->vrf_id);
+ zvni->vrf_id = vrf_to_id(vlan_if->vrf);
+ zl3vni = zl3vni_from_vrf(vrf_to_id(vlan_if->vrf));
if (zl3vni)
listnode_add_sort(zl3vni->l2vnis, zvni);
}
@@ -8689,8 +8690,8 @@ int zebra_vxlan_if_add(struct interface *ifp)
vlan_if = zvni_map_to_svi(vxl->access_vlan,
zif->brslave_info.br_if);
if (vlan_if) {
- zvni->vrf_id = vlan_if->vrf_id;
- zl3vni = zl3vni_from_vrf(vlan_if->vrf_id);
+ zvni->vrf_id = vrf_to_id(vlan_if->vrf);
+ zl3vni = zl3vni_from_vrf(vrf_to_id(vlan_if->vrf));
if (zl3vni)
listnode_add_sort(zl3vni->l2vnis, zvni);
}
@@ -8707,7 +8708,7 @@ int zebra_vxlan_if_add(struct interface *ifp)
zlog_debug(
"Add L2-VNI %u VRF %s intf %s(%u) VLAN %u local IP %s mcast_grp %s master %u",
vni,
- vlan_if ? vrf_id_to_name(vlan_if->vrf_id)
+ vlan_if ? vrf_to_name(vlan_if->vrf)
: VRF_DEFAULT_NAME,
ifp->name, ifp->ifindex, vxl->access_vlan,
addr_buf1, addr_buf2,