summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--babeld/kernel.c5
-rw-r--r--bgpd/bgp_zebra.c4
-rw-r--r--bgpd/rfapi/vnc_zebra.c2
-rw-r--r--eigrpd/eigrp_zebra.c3
-rw-r--r--isisd/isis_zebra.c4
-rw-r--r--lib/nexthop.c1
-rw-r--r--lib/nexthop.h5
-rw-r--r--lib/zclient.c8
-rw-r--r--lib/zclient.h3
-rw-r--r--nhrpd/nhrp_route.c2
-rw-r--r--ospf6d/ospf6_route.c1
-rw-r--r--ospf6d/ospf6_zebra.c3
-rw-r--r--ospfd/ospf_zebra.c5
-rw-r--r--ripd/rip_zebra.c2
-rw-r--r--ripngd/ripng_zebra.c2
-rw-r--r--sharpd/sharp_zebra.c3
-rw-r--r--zebra/connected.c18
-rw-r--r--zebra/kernel_socket.c6
-rw-r--r--zebra/rib.h20
-rw-r--r--zebra/rt_netlink.c38
-rw-r--r--zebra/rtread_getmsg.c6
-rw-r--r--zebra/zebra_mpls.c20
-rw-r--r--zebra/zebra_rib.c48
-rw-r--r--zebra/zebra_rnh.c1
-rw-r--r--zebra/zebra_routemap.c2
-rw-r--r--zebra/zebra_static.c31
-rw-r--r--zebra/zebra_vty.c43
-rw-r--r--zebra/zserv.c51
28 files changed, 185 insertions, 152 deletions
diff --git a/babeld/kernel.c b/babeld/kernel.c
index 6b673c487c..8b1b80665c 100644
--- a/babeld/kernel.c
+++ b/babeld/kernel.c
@@ -166,7 +166,6 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen,
api.type = ZEBRA_ROUTE_BABEL;
api.safi = SAFI_UNICAST;
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.prefix = quagga_prefix;
if(metric >= KERNEL_INFINITY) {
@@ -175,8 +174,8 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen,
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1;
api_nh->ifindex = ifindex;
-
- switch (family) {
+ api_nh->vrf_id = VRF_DEFAULT;
+ switch (family) {
case AF_INET:
uchar_to_inaddr(&api_nh->gate.ipv4, gate);
if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) &&
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index e0bd74a206..acc66d0465 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1001,7 +1001,6 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
memset(&api, 0, sizeof(api));
memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr));
api.vrf_id = bgp->vrf_id;
- api.nh_vrf_id = bgp->vrf_id;
api.type = ZEBRA_ROUTE_BGP;
api.safi = safi;
api.prefix = *p;
@@ -1081,7 +1080,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
api_nh = &api.nexthops[valid_nh_count];
api_nh->gate.ipv4 = *nexthop;
-
+ api_nh->vrf_id = bgp->vrf_id;
/* EVPN type-2 routes are
programmed as onlink on l3-vni SVI
*/
@@ -1255,7 +1254,6 @@ void bgp_zebra_withdraw(struct prefix *p, struct bgp_info *info, safi_t safi)
memset(&api, 0, sizeof(api));
memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr));
api.vrf_id = peer->bgp->vrf_id;
- api.nh_vrf_id = peer->bgp->vrf_id;
api.type = ZEBRA_ROUTE_BGP;
api.safi = safi;
api.prefix = *p;
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 92d7e6fc76..6afcd21a10 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -396,7 +396,6 @@ static void vnc_zebra_route_msg(struct prefix *p, unsigned int nhp_count,
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_VNC;
api.safi = SAFI_UNICAST;
api.prefix = *p;
@@ -407,6 +406,7 @@ static void vnc_zebra_route_msg(struct prefix *p, unsigned int nhp_count,
for (i = 0; i < api.nexthop_num; i++) {
api_nh = &api.nexthops[i];
+ api_nh->vrf_id = VRF_DEFAULT;
switch (p->family) {
case AF_INET:
memcpy(&api_nh->gate.ipv4, nhp_ary4[i],
diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c
index f18d39d575..3759c64148 100644
--- a/eigrpd/eigrp_zebra.c
+++ b/eigrpd/eigrp_zebra.c
@@ -366,7 +366,6 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_EIGRP;
api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p));
@@ -378,6 +377,7 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors)
if (count >= MULTIPATH_NUM)
break;
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = VRF_DEFAULT;
if (te->adv_router->src.s_addr) {
api_nh->gate.ipv4 = te->adv_router->src;
api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
@@ -408,7 +408,6 @@ void eigrp_zebra_route_delete(struct prefix *p)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_EIGRP;
api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p));
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 0512a18a2a..ac640c5e49 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -261,7 +261,6 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_ISIS;
api.safi = SAFI_UNICAST;
api.prefix = *prefix;
@@ -281,6 +280,7 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
if (count >= MULTIPATH_NUM)
break;
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = VRF_DEFAULT;
/* FIXME: can it be ? */
if (nexthop->ip.s_addr != INADDR_ANY) {
api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
@@ -303,6 +303,7 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
}
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv6 = nexthop6->ip6;
api_nh->ifindex = nexthop6->ifindex;
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
@@ -330,7 +331,6 @@ static void isis_zebra_route_del_route(struct prefix *prefix,
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_ISIS;
api.safi = SAFI_UNICAST;
api.prefix = *prefix;
diff --git a/lib/nexthop.c b/lib/nexthop.c
index f531f27302..a094c0e38d 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -167,6 +167,7 @@ void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
for (nh1 = nh; nh1; nh1 = nh1->next) {
nexthop = nexthop_new();
+ nexthop->vrf_id = nh1->vrf_id;
nexthop->ifindex = nh1->ifindex;
nexthop->type = nh1->type;
nexthop->flags = nh1->flags;
diff --git a/lib/nexthop.h b/lib/nexthop.h
index 753e66643d..ee4f569e83 100644
--- a/lib/nexthop.h
+++ b/lib/nexthop.h
@@ -60,6 +60,11 @@ struct nexthop {
struct nexthop *next;
struct nexthop *prev;
+ /*
+ * What vrf is this nexthop associated with?
+ */
+ vrf_id_t vrf_id;
+
/* Interface index. */
ifindex_t ifindex;
diff --git a/lib/zclient.c b/lib/zclient.c
index 0c29b523bf..6882a7ecc5 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -975,12 +975,11 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
}
stream_putw(s, api->nexthop_num);
- if (api->nexthop_num)
- stream_putl(s, api->nh_vrf_id);
for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i];
+ stream_putl(s, api_nh->vrf_id);
stream_putc(s, api_nh->type);
switch (api_nh->type) {
case NEXTHOP_TYPE_BLACKHOLE:
@@ -1126,12 +1125,10 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
return -1;
}
- if (api->nexthop_num)
- STREAM_GETL(s, api->nh_vrf_id);
-
for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i];
+ STREAM_GETL(s, api_nh->vrf_id);
STREAM_GETC(s, api_nh->type);
switch (api_nh->type) {
case NEXTHOP_TYPE_BLACKHOLE:
@@ -1217,6 +1214,7 @@ struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh)
struct nexthop *n = nexthop_new();
n->type = znh->type;
+ n->vrf_id = znh->vrf_id;
n->ifindex = znh->ifindex;
n->gate = znh->gate;
diff --git a/lib/zclient.h b/lib/zclient.h
index 5c7c5d6d5b..910d25aa2f 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -239,6 +239,7 @@ struct zserv_header {
struct zapi_nexthop {
enum nexthop_types_t type;
+ vrf_id_t vrf_id;
ifindex_t ifindex;
union {
union g_addr gate;
@@ -286,7 +287,6 @@ struct zapi_route {
u_int32_t mtu;
vrf_id_t vrf_id;
- vrf_id_t nh_vrf_id;
struct ethaddr rmac;
};
@@ -505,6 +505,7 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
{
api->nexthop_num = 1;
api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
+ api->nexthops[0].vrf_id = VRF_DEFAULT;
api->nexthops[0].bh_type = bh_type;
SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
};
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index 2f084f8422..d43aa4929e 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -96,7 +96,6 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix
api.type = ZEBRA_ROUTE_NHRP;
api.safi = SAFI_UNICAST;
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.prefix = *p;
switch (type) {
@@ -120,6 +119,7 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1;
api_nh = &api.nexthops[0];
+ api_nh->vrf_id = VRF_DEFAULT;
switch (api.prefix.family) {
case AF_INET:
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 735b28a693..19eb9a3fe6 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -315,6 +315,7 @@ void ospf6_route_zebra_copy_nexthops(struct ospf6_route *route,
if (i >= entries)
return;
+ nexthops[i].vrf_id = VRF_DEFAULT;
nexthops[i].ifindex = nh->ifindex;
if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) {
nexthops[i].gate.ipv6 = nh->address;
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 2a419ddfc6..cc87c499ee 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -337,7 +337,6 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
@@ -388,7 +387,6 @@ void ospf6_zebra_add_discard(struct ospf6_route *request)
if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
@@ -422,7 +420,6 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request)
if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 58e8a921d5..93aa603908 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -389,7 +389,6 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
- api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
@@ -442,6 +441,7 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,
api_nh->ifindex = path->ifindex;
api_nh->type = NEXTHOP_TYPE_IFINDEX;
}
+ api_nh->vrf_id = ospf->vrf_id;
count++;
if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
@@ -467,7 +467,6 @@ void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p,
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
- api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
@@ -489,7 +488,6 @@ void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p)
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
- api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
@@ -509,7 +507,6 @@ void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p)
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
- api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index 52a5d93c4f..4f02daed42 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -48,7 +48,6 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIP;
api.safi = SAFI_UNICAST;
@@ -57,6 +56,7 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd)
if (count >= MULTIPATH_NUM)
break;
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate = rinfo->nh.gate;
api_nh->type = NEXTHOP_TYPE_IPV4;
if (cmd == ZEBRA_ROUTE_ADD)
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index ea069d877f..6c9d911a6a 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -48,7 +48,6 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIPNG;
api.safi = SAFI_UNICAST;
api.prefix = rp->p;
@@ -58,6 +57,7 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd)
if (count >= MULTIPATH_NUM)
break;
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv6 = rinfo->nexthop;
api_nh->ifindex = rinfo->ifindex;
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 25bb512a8b..10e48ac628 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -159,7 +159,6 @@ void route_add(struct prefix *p, struct nexthop *nh)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_SHARP;
api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p));
@@ -167,6 +166,7 @@ void route_add(struct prefix *p, struct nexthop *nh)
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api_nh = &api.nexthops[0];
+ api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv4 = nh->gate.ipv4;
api_nh->type = nh->type;
api_nh->ifindex = nh->ifindex;
@@ -181,7 +181,6 @@ void route_delete(struct prefix *p)
memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT;
- api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_SHARP;
api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p));
diff --git a/zebra/connected.c b/zebra/connected.c
index d34fd9021a..e28ec8d09b 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -203,7 +203,9 @@ void connected_up(struct interface *ifp, struct connected *ifc)
afi_t afi;
struct prefix p;
struct nexthop nh = {
- .type = NEXTHOP_TYPE_IFINDEX, .ifindex = ifp->ifindex,
+ .type = NEXTHOP_TYPE_IFINDEX,
+ .ifindex = ifp->ifindex,
+ .vrf_id = ifp->vrf_id,
};
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
@@ -238,13 +240,11 @@ void connected_up(struct interface *ifp, struct connected *ifc)
break;
}
- rib_add(afi, SAFI_UNICAST, ifp->vrf_id, ifp->vrf_id,
- ZEBRA_ROUTE_CONNECT, 0, 0,
- &p, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
+ rib_add(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p,
+ NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
- rib_add(afi, SAFI_MULTICAST, ifp->vrf_id, ifp->vrf_id,
- ZEBRA_ROUTE_CONNECT, 0, 0,
- &p, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
+ rib_add(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p,
+ NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
if (IS_ZEBRA_DEBUG_RIB_DETAILED) {
char buf[PREFIX_STRLEN];
@@ -362,7 +362,9 @@ void connected_down(struct interface *ifp, struct connected *ifc)
afi_t afi;
struct prefix p;
struct nexthop nh = {
- .type = NEXTHOP_TYPE_IFINDEX, .ifindex = ifp->ifindex,
+ .type = NEXTHOP_TYPE_IFINDEX,
+ .ifindex = ifp->ifindex,
+ .vrf_id = ifp->vrf_id,
};
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 2a3b95058e..7a64b48964 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -907,6 +907,8 @@ void rtm_read(struct rt_msghdr *rtm)
SET_FLAG(zebra_flags, ZEBRA_FLAG_STATIC);
memset(&nh, 0, sizeof(nh));
+
+ nh.vrf_id = VRF_DEFAULT;
/* This is a reject or blackhole route */
if (flags & RTF_REJECT) {
nh.type = NEXTHOP_TYPE_BLACKHOLE;
@@ -1049,7 +1051,7 @@ void rtm_read(struct rt_msghdr *rtm)
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
- rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, VRF_DEFAULT,
+ rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
&nh, 0, 0, 0, 0, 0);
else
@@ -1097,7 +1099,7 @@ void rtm_read(struct rt_msghdr *rtm)
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
- rib_add(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT, VRF_DEFAULT,
+ rib_add(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
&nh, 0, 0, 0, 0, 0);
else
diff --git a/zebra/rib.h b/zebra/rib.h
index 664afd01b8..9a5d88ed15 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -59,7 +59,6 @@ struct route_entry {
/* VRF identifier. */
vrf_id_t vrf_id;
- vrf_id_t nh_vrf_id;
/* Which routing table */
uint32_t table;
@@ -231,22 +230,27 @@ typedef enum {
} rib_update_event_t;
extern struct nexthop *route_entry_nexthop_ifindex_add(struct route_entry *,
- ifindex_t);
+ ifindex_t,
+ vrf_id_t nh_vrf_id);
extern struct nexthop *route_entry_nexthop_blackhole_add(struct route_entry *,
enum blackhole_type);
extern struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *,
struct in_addr *,
- struct in_addr *);
+ struct in_addr *,
+ vrf_id_t nh_vrf_id);
extern struct nexthop *
route_entry_nexthop_ipv4_ifindex_add(struct route_entry *, struct in_addr *,
- struct in_addr *, ifindex_t);
+ struct in_addr *, ifindex_t,
+ vrf_id_t nh_vrf_id);
extern void route_entry_nexthop_delete(struct route_entry *re,
struct nexthop *nexthop);
extern struct nexthop *route_entry_nexthop_ipv6_add(struct route_entry *,
- struct in6_addr *);
+ struct in6_addr *,
+ vrf_id_t nh_vrf_id);
extern struct nexthop *
route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re,
- struct in6_addr *ipv6, ifindex_t ifindex);
+ struct in6_addr *ipv6, ifindex_t ifindex,
+ vrf_id_t nh_vrf_id);
extern void route_entry_nexthop_add(struct route_entry *re,
struct nexthop *nexthop);
extern void route_entry_copy_nexthops(struct route_entry *re,
@@ -294,8 +298,8 @@ extern void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re);
/* NOTE:
* All rib_add function will not just add prefix into RIB, but
* also implicitly withdraw equal prefix of same type. */
-extern int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, vrf_id_t nh_vrf_id,
- int type, u_short instance, int flags, struct prefix *p,
+extern int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
+ u_short instance, int flags, struct prefix *p,
struct prefix_ipv6 *src_p, const struct nexthop *nh,
u_int32_t table_id, u_int32_t metric, u_int32_t mtu,
uint8_t distance, route_tag_t tag);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 20cc292e11..b8011c2a76 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -443,10 +443,10 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
if (ifp)
nh_vrf_id = ifp->vrf_id;
}
+ nh.vrf_id = nh_vrf_id;
- rib_add(afi, SAFI_UNICAST, vrf_id, nh_vrf_id, proto,
- 0, flags, &p, NULL, &nh, table, metric,
- mtu, distance, tag);
+ rib_add(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, &p,
+ NULL, &nh, table, metric, mtu, distance, tag);
} else {
/* This is a multipath route */
@@ -463,13 +463,13 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
re->metric = metric;
re->mtu = mtu;
re->vrf_id = vrf_id;
- re->nh_vrf_id = vrf_id;
re->table = table;
re->nexthop_num = 0;
re->uptime = time(NULL);
re->tag = tag;
for (;;) {
+ vrf_id_t nh_vrf_id;
if (len < (int)sizeof(*rtnh)
|| rtnh->rtnh_len > len)
break;
@@ -485,8 +485,17 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
ifp = if_lookup_by_index(index,
VRF_UNKNOWN);
if (ifp)
- re->nh_vrf_id = ifp->vrf_id;
- }
+ nh_vrf_id = ifp->vrf_id;
+ else {
+ zlog_warn(
+ "%s: Unknown interface %u specified, defaulting to VRF_DEFAULT",
+ __PRETTY_FUNCTION__,
+ index);
+ nh_vrf_id = VRF_DEFAULT;
+ }
+ } else
+ nh_vrf_id = vrf_id;
+
gate = 0;
if (rtnh->rtnh_len > sizeof(*rtnh)) {
memset(tb, 0, sizeof(tb));
@@ -503,24 +512,27 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
if (index)
route_entry_nexthop_ipv4_ifindex_add(
re, gate,
- prefsrc, index);
+ prefsrc, index,
+ nh_vrf_id);
else
route_entry_nexthop_ipv4_add(
re, gate,
- prefsrc);
+ prefsrc,
+ nh_vrf_id);
} else if (rtm->rtm_family
== AF_INET6) {
if (index)
route_entry_nexthop_ipv6_ifindex_add(
- re, gate,
- index);
+ re, gate, index,
+ nh_vrf_id);
else
route_entry_nexthop_ipv6_add(
- re, gate);
+ re, gate,
+ nh_vrf_id);
}
} else
- route_entry_nexthop_ifindex_add(re,
- index);
+ route_entry_nexthop_ifindex_add(
+ re, index, nh_vrf_id);
len -= NLMSG_ALIGN(rtnh->rtnh_len);
rtnh = RTNH_NEXT(rtnh);
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index ba45f54ad2..95bc8db1c9 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -94,12 +94,12 @@ static void handle_route_entry(mib2_ipRouteEntry_t *routeEntry)
prefix.prefixlen = ip_masklen(tmpaddr);
memset(&nh, 0, sizeof(nh));
+ nh.vrf_id = VRF_DEFAULT;
nh.type = NEXTHOP_TYPE_IPV4;
nh.gate.ipv4.s_addr = routeEntry->ipRouteNextHop;
- rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, VRF_DEFAULT,
- ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &prefix, NULL,
- &nh, 0, 0, 0, 0, 0);
+ rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0,
+ zebra_flags, &prefix, NULL, &nh, 0, 0, 0, 0, 0);
}
void route_read(struct zebra_ns *zns)
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 22c81b5784..485488d567 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -614,7 +614,7 @@ static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,
struct route_entry *match;
struct nexthop *match_nh;
- table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, nexthop->vrf_id);
if (!table)
return 0;
@@ -663,7 +663,7 @@ static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,
struct route_node *rn;
struct route_entry *match;
- table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, nexthop->vrf_id);
if (!table)
return 0;
@@ -728,7 +728,8 @@ static int nhlfe_nexthop_active(zebra_nhlfe_t *nhlfe)
case NEXTHOP_TYPE_IPV6_IFINDEX:
if (IN6_IS_ADDR_LINKLOCAL(&nexthop->gate.ipv6)) {
- ifp = if_lookup_by_index(nexthop->ifindex, VRF_DEFAULT);
+ ifp = if_lookup_by_index(nexthop->ifindex,
+ nexthop->vrf_id);
if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
@@ -1149,6 +1150,7 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
}
nexthop_add_labels(nexthop, lsp_type, 1, &out_label);
+ nexthop->vrf_id = VRF_DEFAULT;
nexthop->type = gtype;
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
@@ -1324,9 +1326,9 @@ static json_object *nhlfe_json(zebra_nhlfe_t *nhlfe)
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex)
- json_object_string_add(
- json_nhlfe, "interface",
- ifindex2ifname(nexthop->ifindex, VRF_DEFAULT));
+ json_object_string_add(json_nhlfe, "interface",
+ ifindex2ifname(nexthop->ifindex,
+ nexthop->vrf_id));
break;
default:
break;
@@ -1356,7 +1358,8 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty)
vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4));
if (nexthop->ifindex)
vty_out(vty, " dev %s",
- ifindex2ifname(nexthop->ifindex, VRF_DEFAULT));
+ ifindex2ifname(nexthop->ifindex,
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -1364,7 +1367,8 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty)
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex)
vty_out(vty, " dev %s",
- ifindex2ifname(nexthop->ifindex, VRF_DEFAULT));
+ ifindex2ifname(nexthop->ifindex,
+ nexthop->vrf_id));
break;
default:
break;
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index b7b4a159da..81244db9bf 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -212,13 +212,15 @@ void route_entry_nexthop_delete(struct route_entry *re, struct nexthop *nexthop)
struct nexthop *route_entry_nexthop_ifindex_add(struct route_entry *re,
- ifindex_t ifindex)
+ ifindex_t ifindex,
+ vrf_id_t nh_vrf_id)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IFINDEX;
nexthop->ifindex = ifindex;
+ nexthop->vrf_id = nh_vrf_id;
route_entry_nexthop_add(re, nexthop);
@@ -227,12 +229,14 @@ struct nexthop *route_entry_nexthop_ifindex_add(struct route_entry *re,
struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *re,
struct in_addr *ipv4,
- struct in_addr *src)
+ struct in_addr *src,
+ vrf_id_t nh_vrf_id)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IPV4;
+ nexthop->vrf_id = nh_vrf_id;
nexthop->gate.ipv4 = *ipv4;
if (src)
nexthop->src.ipv4 = *src;
@@ -245,18 +249,20 @@ struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *re,
struct nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re,
struct in_addr *ipv4,
struct in_addr *src,
- ifindex_t ifindex)
+ ifindex_t ifindex,
+ vrf_id_t nh_vrf_id)
{
struct nexthop *nexthop;
struct interface *ifp;
nexthop = nexthop_new();
+ nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
nexthop->gate.ipv4 = *ipv4;
if (src)
nexthop->src.ipv4 = *src;
nexthop->ifindex = ifindex;
- ifp = if_lookup_by_index(nexthop->ifindex, re->nh_vrf_id);
+ ifp = if_lookup_by_index(nexthop->ifindex, nh_vrf_id);
/*Pending: need to think if null ifp here is ok during bootup?
There was a crash because ifp here was coming to be NULL */
if (ifp)
@@ -271,11 +277,13 @@ struct nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re,
}
struct nexthop *route_entry_nexthop_ipv6_add(struct route_entry *re,
- struct in6_addr *ipv6)
+ struct in6_addr *ipv6,
+ vrf_id_t nh_vrf_id)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
+ nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV6;
nexthop->gate.ipv6 = *ipv6;
@@ -286,11 +294,13 @@ struct nexthop *route_entry_nexthop_ipv6_add(struct route_entry *re,
struct nexthop *route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re,
struct in6_addr *ipv6,
- ifindex_t ifindex)
+ ifindex_t ifindex,
+ vrf_id_t nh_vrf_id)
{
struct nexthop *nexthop;
nexthop = nexthop_new();
+ nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
nexthop->gate.ipv6 = *ipv6;
nexthop->ifindex = ifindex;
@@ -306,6 +316,7 @@ struct nexthop *route_entry_nexthop_blackhole_add(struct route_entry *re,
struct nexthop *nexthop;
nexthop = nexthop_new();
+ nexthop->vrf_id = VRF_DEFAULT;
nexthop->type = NEXTHOP_TYPE_BLACKHOLE;
nexthop->bh_type = bh_type;
@@ -322,6 +333,7 @@ static void nexthop_set_resolved(afi_t afi, struct nexthop *newhop,
resolved_hop = nexthop_new();
SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
+ resolved_hop->vrf_id = nexthop->vrf_id;
switch (newhop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
@@ -403,7 +415,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (set) {
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
- zebra_deregister_rnh_static_nexthops(re->nh_vrf_id,
+ zebra_deregister_rnh_static_nexthops(nexthop->vrf_id,
nexthop->resolved, top);
nexthops_free(nexthop->resolved);
nexthop->resolved = NULL;
@@ -422,7 +434,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
* address in the routing table.
*/
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) {
- ifp = if_lookup_by_index(nexthop->ifindex, re->nh_vrf_id);
+ ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
if (ifp && connected_is_unnumbered(ifp)) {
if (if_is_operative(ifp))
return 1;
@@ -450,7 +462,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
break;
}
/* Lookup table. */
- table = zebra_vrf_table(afi, SAFI_UNICAST, re->nh_vrf_id);
+ table = zebra_vrf_table(afi, SAFI_UNICAST, nexthop->vrf_id);
if (!table)
return 0;
@@ -838,7 +850,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
family = 0;
switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
- ifp = if_lookup_by_index(nexthop->ifindex, re->nh_vrf_id);
+ ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
@@ -867,7 +879,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
family = AFI_IP6;
if (IN6_IS_ADDR_LINKLOCAL(&nexthop->gate.ipv6)) {
ifp = if_lookup_by_index(nexthop->ifindex,
- re->nh_vrf_id);
+ nexthop->vrf_id);
if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
@@ -910,8 +922,8 @@ static unsigned nexthop_active_check(struct route_node *rn,
memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr));
/* It'll get set if required inside */
- ret = zebra_route_map_check(family, re->type, p, nexthop, re->nh_vrf_id,
- re->tag);
+ ret = zebra_route_map_check(family, re->type, p, nexthop,
+ nexthop->vrf_id, re->tag);
if (ret == RMAP_DENYMATCH) {
if (IS_ZEBRA_DEBUG_RIB) {
srcdest_rnode2str(rn, buf, sizeof(buf));
@@ -919,7 +931,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
"%u:%s: Filtering out with NH out %s due to route map",
re->vrf_id, buf,
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
}
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
}
@@ -2554,10 +2566,9 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
}
-int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, vrf_id_t nh_vrf_id,
- int type, u_short instance, int flags, struct prefix *p,
- struct prefix_ipv6 *src_p, const struct nexthop *nh,
- u_int32_t table_id, u_int32_t metric,
+int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance,
+ int flags, struct prefix *p, struct prefix_ipv6 *src_p,
+ const struct nexthop *nh, u_int32_t table_id, u_int32_t metric,
u_int32_t mtu, uint8_t distance, route_tag_t tag)
{
struct route_entry *re;
@@ -2573,7 +2584,6 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, vrf_id_t nh_vrf_id,
re->mtu = mtu;
re->table = table_id;
re->vrf_id = vrf_id;
- re->nh_vrf_id = nh_vrf_id;
re->nexthop_num = 0;
re->uptime = time(NULL);
re->tag = tag;
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index cea46ffc18..dfac8807aa 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -952,7 +952,6 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
state->distance = re->distance;
state->metric = re->metric;
state->vrf_id = re->vrf_id;
- state->nh_vrf_id = re->vrf_id;
route_entry_copy_nexthops(state, re->nexthop);
rnh->state = state;
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 4c619e5782..882a03f844 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1329,7 +1329,7 @@ route_map_result_t zebra_nht_route_map_check(int family, int client_proto,
struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop;
- nh_obj.vrf_id = re->nh_vrf_id;
+ nh_obj.vrf_id = nexthop->vrf_id;
nh_obj.source_protocol = re->type;
nh_obj.metric = re->metric;
nh_obj.tag = re->tag;
diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c
index 2e8ab11b04..b42bd818af 100644
--- a/zebra/zebra_static.c
+++ b/zebra/zebra_static.c
@@ -87,7 +87,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
switch (si->type) {
case STATIC_IPV4_GATEWAY:
nexthop = route_entry_nexthop_ipv4_add(
- re, &si->addr.ipv4, NULL);
+ re, &si->addr.ipv4, NULL, si->nh_vrf_id);
nh_p.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4;
@@ -95,19 +95,20 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
break;
case STATIC_IPV4_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv4_ifindex_add(
- re, &si->addr.ipv4, NULL, si->ifindex);
+ re, &si->addr.ipv4, NULL, si->ifindex,
+ si->nh_vrf_id);
break;
case STATIC_IFNAME:
- nexthop = route_entry_nexthop_ifindex_add(re,
- si->ifindex);
+ nexthop = route_entry_nexthop_ifindex_add(
+ re, si->ifindex, si->nh_vrf_id);
break;
case STATIC_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add(
re, bh_type);
break;
case STATIC_IPV6_GATEWAY:
- nexthop = route_entry_nexthop_ipv6_add(re,
- &si->addr.ipv6);
+ nexthop = route_entry_nexthop_ipv6_add(
+ re, &si->addr.ipv6, si->nh_vrf_id);
nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6;
@@ -115,7 +116,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
break;
case STATIC_IPV6_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv6_ifindex_add(
- re, &si->addr.ipv6, si->ifindex);
+ re, &si->addr.ipv6, si->ifindex, si->nh_vrf_id);
break;
}
/* Update label(s), if present. */
@@ -155,7 +156,6 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
re->metric = 0;
re->mtu = 0;
re->vrf_id = si->vrf_id;
- re->nh_vrf_id = si->nh_vrf_id;
re->table =
(si->vrf_id != VRF_DEFAULT)
? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id
@@ -166,7 +166,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
switch (si->type) {
case STATIC_IPV4_GATEWAY:
nexthop = route_entry_nexthop_ipv4_add(
- re, &si->addr.ipv4, NULL);
+ re, &si->addr.ipv4, NULL, si->nh_vrf_id);
nh_p.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4;
@@ -174,19 +174,20 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
break;
case STATIC_IPV4_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv4_ifindex_add(
- re, &si->addr.ipv4, NULL, si->ifindex);
+ re, &si->addr.ipv4, NULL, si->ifindex,
+ si->nh_vrf_id);
break;
case STATIC_IFNAME:
- nexthop = route_entry_nexthop_ifindex_add(re,
- si->ifindex);
+ nexthop = route_entry_nexthop_ifindex_add(
+ re, si->ifindex, si->nh_vrf_id);
break;
case STATIC_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add(
re, bh_type);
break;
case STATIC_IPV6_GATEWAY:
- nexthop = route_entry_nexthop_ipv6_add(re,
- &si->addr.ipv6);
+ nexthop = route_entry_nexthop_ipv6_add(
+ re, &si->addr.ipv6, si->nh_vrf_id);
nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6;
@@ -194,7 +195,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
break;
case STATIC_IPV6_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv6_ifindex_add(
- re, &si->addr.ipv6, si->ifindex);
+ re, &si->addr.ipv6, si->ifindex, si->nh_vrf_id);
break;
}
/* Update label(s), if present. */
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 93397afa79..3f6db5986f 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -770,8 +770,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
inet_ntoa(nexthop->gate.ipv4));
if (nexthop->ifindex)
vty_out(vty, ", via %s",
- ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ ifindex2ifname(
+ nexthop->ifindex,
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -780,13 +781,14 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
buf, sizeof buf));
if (nexthop->ifindex)
vty_out(vty, ", via %s",
- ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ ifindex2ifname(
+ nexthop->ifindex,
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, " directly connected, %s",
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, " unreachable");
@@ -809,9 +811,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
break;
}
- if (re->vrf_id != re->nh_vrf_id) {
+ if (re->vrf_id != nexthop->vrf_id) {
struct vrf *vrf =
- vrf_lookup_by_id(re->nh_vrf_id);
+ vrf_lookup_by_id(nexthop->vrf_id);
vty_out(vty, "(vrf %s)", vrf->name);
}
@@ -954,8 +956,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
nexthop->ifindex);
json_object_string_add(
json_nexthop, "interfaceName",
- ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ ifindex2ifname(
+ nexthop->ifindex,
+ nexthop->vrf_id));
}
break;
case NEXTHOP_TYPE_IPV6:
@@ -973,8 +976,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
nexthop->ifindex);
json_object_string_add(
json_nexthop, "interfaceName",
- ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ ifindex2ifname(
+ nexthop->ifindex,
+ nexthop->vrf_id));
}
break;
@@ -987,7 +991,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_string_add(
json_nexthop, "interfaceName",
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
json_object_boolean_true_add(json_nexthop,
@@ -1014,9 +1018,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
break;
}
- if (re->nh_vrf_id != re->vrf_id) {
+ if (nexthop->vrf_id != re->vrf_id) {
struct vrf *vrf =
- vrf_lookup_by_id(re->nh_vrf_id);
+ vrf_lookup_by_id(nexthop->vrf_id);
json_object_string_add(json_nexthop,
"vrf",
@@ -1129,7 +1133,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (nexthop->ifindex)
vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -1139,13 +1143,13 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (nexthop->ifindex)
vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, " is directly connected, %s",
ifindex2ifname(nexthop->ifindex,
- re->nh_vrf_id));
+ nexthop->vrf_id));
break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, " unreachable");
@@ -1167,9 +1171,8 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
break;
}
- if (re->nh_vrf_id != re->vrf_id) {
- struct vrf *vrf =
- vrf_lookup_by_id(re->nh_vrf_id);
+ if (nexthop->vrf_id != re->vrf_id) {
+ struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id);
vty_out(vty, "(vrf %s)", vrf->name);
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 71437bab15..9da8d593e5 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -592,7 +592,6 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
memset(&api, 0, sizeof(api));
api.vrf_id = re->vrf_id;
- api.nh_vrf_id = re->nh_vrf_id;
api.type = re->type;
api.instance = re->instance;
api.flags = re->flags;
@@ -614,6 +613,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
continue;
api_nh = &api.nexthops[count];
+ api_nh->vrf_id = nexthop->vrf_id;
api_nh->type = nexthop->type;
switch (nexthop->type) {
case NEXTHOP_TYPE_BLACKHOLE:
@@ -1137,7 +1137,6 @@ static int zread_route_add(struct zserv *client, u_short length,
re->flags = api.flags;
re->uptime = time(NULL);
re->vrf_id = vrf_id;
- re->nh_vrf_id = api.nh_vrf_id;
re->table = zvrf->table_id;
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
@@ -1148,11 +1147,12 @@ static int zread_route_add(struct zserv *client, u_short length,
switch (api_nh->type) {
case NEXTHOP_TYPE_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add(
- re, api_nh->ifindex);
+ re, api_nh->ifindex, re->vrf_id);
break;
case NEXTHOP_TYPE_IPV4:
nexthop = route_entry_nexthop_ipv4_add(
- re, &api_nh->gate.ipv4, NULL);
+ re, &api_nh->gate.ipv4, NULL,
+ re->vrf_id);
break;
case NEXTHOP_TYPE_IPV4_IFINDEX: {
@@ -1168,8 +1168,8 @@ static int zread_route_add(struct zserv *client, u_short length,
}
nexthop = route_entry_nexthop_ipv4_ifindex_add(
- re, &api_nh->gate.ipv4, NULL,
- ifindex);
+ re, &api_nh->gate.ipv4, NULL, ifindex,
+ re->vrf_id);
/* if this an EVPN route entry,
program the nh as neigh
@@ -1192,12 +1192,12 @@ static int zread_route_add(struct zserv *client, u_short length,
}
case NEXTHOP_TYPE_IPV6:
nexthop = route_entry_nexthop_ipv6_add(
- re, &api_nh->gate.ipv6);
+ re, &api_nh->gate.ipv6, re->vrf_id);
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
nexthop = route_entry_nexthop_ipv6_ifindex_add(
- re, &api_nh->gate.ipv6,
- api_nh->ifindex);
+ re, &api_nh->gate.ipv6, api_nh->ifindex,
+ re->vrf_id);
break;
case NEXTHOP_TYPE_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add(
@@ -1364,7 +1364,6 @@ static int zread_ipv4_add(struct zserv *client, u_short length,
/* VRF ID */
re->vrf_id = zvrf_id(zvrf);
- re->nh_vrf_id = zvrf_id(zvrf);
/* Nexthop parse. */
if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
@@ -1381,13 +1380,14 @@ static int zread_ipv4_add(struct zserv *client, u_short length,
switch (nexthop_type) {
case NEXTHOP_TYPE_IFINDEX:
STREAM_GETL(s, ifindex);
- route_entry_nexthop_ifindex_add(re, ifindex);
+ route_entry_nexthop_ifindex_add(re, ifindex,
+ re->vrf_id);
break;
case NEXTHOP_TYPE_IPV4:
STREAM_GET(&nhop_addr.s_addr, s,
IPV4_MAX_BYTELEN);
nexthop = route_entry_nexthop_ipv4_add(
- re, &nhop_addr, NULL);
+ re, &nhop_addr, NULL, re->vrf_id);
/* For labeled-unicast, each nexthop is followed
* by label. */
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL)) {
@@ -1401,7 +1401,8 @@ static int zread_ipv4_add(struct zserv *client, u_short length,
IPV4_MAX_BYTELEN);
STREAM_GETL(s, ifindex);
route_entry_nexthop_ipv4_ifindex_add(
- re, &nhop_addr, NULL, ifindex);
+ re, &nhop_addr, NULL, ifindex,
+ re->vrf_id);
break;
case NEXTHOP_TYPE_IPV6:
zlog_warn("%s: Please use ZEBRA_ROUTE_ADD if you want to pass v6 nexthops",
@@ -1574,7 +1575,6 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,
/* VRF ID */
re->vrf_id = zvrf_id(zvrf);
- re->nh_vrf_id = zvrf_id(zvrf);
/* We need to give nh-addr, nh-ifindex with the same next-hop object
* to the re to ensure that IPv6 multipathing works; need to coalesce
@@ -1635,10 +1635,11 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,
nexthop =
route_entry_nexthop_ipv6_ifindex_add(
re, &nexthops[i],
- ifindices[i]);
+ ifindices[i],
+ re->vrf_id);
else
nexthop = route_entry_nexthop_ipv6_add(
- re, &nexthops[i]);
+ re, &nexthops[i], re->vrf_id);
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels(nexthop, label_type,
@@ -1646,7 +1647,7 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,
} else {
if ((i < if_count) && ifindices[i])
route_entry_nexthop_ifindex_add(
- re, ifindices[i]);
+ re, ifindices[i], re->vrf_id);
}
}
}
@@ -1760,6 +1761,9 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
} else
src_pp = NULL;
+ /* VRF ID */
+ re->vrf_id = zvrf_id(zvrf);
+
/* We need to give nh-addr, nh-ifindex with the same next-hop object
* to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of
@@ -1797,7 +1801,7 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
STREAM_GET(&nhop_addr, s, 16);
STREAM_GETL(s, ifindex);
route_entry_nexthop_ipv6_ifindex_add(
- re, &nhop_addr, ifindex);
+ re, &nhop_addr, ifindex, re->vrf_id);
break;
case NEXTHOP_TYPE_IFINDEX:
if (if_count < multipath_num) {
@@ -1824,17 +1828,18 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
nexthop =
route_entry_nexthop_ipv6_ifindex_add(
re, &nexthops[i],
- ifindices[i]);
+ ifindices[i],
+ re->vrf_id);
else
nexthop = route_entry_nexthop_ipv6_add(
- re, &nexthops[i]);
+ re, &nexthops[i], re->vrf_id);
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels(nexthop, label_type,
1, &labels[i]);
} else {
if ((i < if_count) && ifindices[i])
route_entry_nexthop_ifindex_add(
- re, ifindices[i]);
+ re, ifindices[i], re->vrf_id);
}
}
}
@@ -1858,10 +1863,6 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
else
re->mtu = 0;
- /* VRF ID */
- re->vrf_id = zvrf_id(zvrf);
- re->nh_vrf_id = zvrf_id(zvrf);
-
re->table = zvrf->table_id;
ret = rib_add_multipath(AFI_IP6, safi, &p, src_pp, re);