*: Track vrfs per nexthop not per route entry

Track the vfrs on a per nexthop basis instead
of on a per route entry basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-02-08 09:12:12 -05:00
parent a97e5c1a80
commit 4a7371e9e2
28 changed files with 185 additions and 152 deletions

View File

@ -166,7 +166,6 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen,
api.type = ZEBRA_ROUTE_BABEL; api.type = ZEBRA_ROUTE_BABEL;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.prefix = quagga_prefix; api.prefix = quagga_prefix;
if(metric >= KERNEL_INFINITY) { 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); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1; api.nexthop_num = 1;
api_nh->ifindex = ifindex; api_nh->ifindex = ifindex;
api_nh->vrf_id = VRF_DEFAULT;
switch (family) { switch (family) {
case AF_INET: case AF_INET:
uchar_to_inaddr(&api_nh->gate.ipv4, gate); uchar_to_inaddr(&api_nh->gate.ipv4, gate);
if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) && if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) &&

View File

@ -1001,7 +1001,6 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr)); memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr));
api.vrf_id = bgp->vrf_id; api.vrf_id = bgp->vrf_id;
api.nh_vrf_id = bgp->vrf_id;
api.type = ZEBRA_ROUTE_BGP; api.type = ZEBRA_ROUTE_BGP;
api.safi = safi; api.safi = safi;
api.prefix = *p; 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 = &api.nexthops[valid_nh_count];
api_nh->gate.ipv4 = *nexthop; api_nh->gate.ipv4 = *nexthop;
api_nh->vrf_id = bgp->vrf_id;
/* EVPN type-2 routes are /* EVPN type-2 routes are
programmed as onlink on l3-vni SVI 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)); memset(&api, 0, sizeof(api));
memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr)); memcpy(&api.rmac, &(info->attr->rmac), sizeof(struct ethaddr));
api.vrf_id = peer->bgp->vrf_id; api.vrf_id = peer->bgp->vrf_id;
api.nh_vrf_id = peer->bgp->vrf_id;
api.type = ZEBRA_ROUTE_BGP; api.type = ZEBRA_ROUTE_BGP;
api.safi = safi; api.safi = safi;
api.prefix = *p; api.prefix = *p;

View File

@ -396,7 +396,6 @@ static void vnc_zebra_route_msg(struct prefix *p, unsigned int nhp_count,
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_VNC; api.type = ZEBRA_ROUTE_VNC;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *p; 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++) { for (i = 0; i < api.nexthop_num; i++) {
api_nh = &api.nexthops[i]; api_nh = &api.nexthops[i];
api_nh->vrf_id = VRF_DEFAULT;
switch (p->family) { switch (p->family) {
case AF_INET: case AF_INET:
memcpy(&api_nh->gate.ipv4, nhp_ary4[i], memcpy(&api_nh->gate.ipv4, nhp_ary4[i],

View File

@ -366,7 +366,6 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_EIGRP; api.type = ZEBRA_ROUTE_EIGRP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p)); 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) if (count >= MULTIPATH_NUM)
break; break;
api_nh = &api.nexthops[count]; api_nh = &api.nexthops[count];
api_nh->vrf_id = VRF_DEFAULT;
if (te->adv_router->src.s_addr) { if (te->adv_router->src.s_addr) {
api_nh->gate.ipv4 = te->adv_router->src; api_nh->gate.ipv4 = te->adv_router->src;
api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
@ -408,7 +408,6 @@ void eigrp_zebra_route_delete(struct prefix *p)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_EIGRP; api.type = ZEBRA_ROUTE_EIGRP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p)); memcpy(&api.prefix, p, sizeof(*p));

View File

@ -261,7 +261,6 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_ISIS; api.type = ZEBRA_ROUTE_ISIS;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *prefix; api.prefix = *prefix;
@ -281,6 +280,7 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
if (count >= MULTIPATH_NUM) if (count >= MULTIPATH_NUM)
break; break;
api_nh = &api.nexthops[count]; api_nh = &api.nexthops[count];
api_nh->vrf_id = VRF_DEFAULT;
/* FIXME: can it be ? */ /* FIXME: can it be ? */
if (nexthop->ip.s_addr != INADDR_ANY) { if (nexthop->ip.s_addr != INADDR_ANY) {
api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; 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 = &api.nexthops[count];
api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv6 = nexthop6->ip6; api_nh->gate.ipv6 = nexthop6->ip6;
api_nh->ifindex = nexthop6->ifindex; api_nh->ifindex = nexthop6->ifindex;
api_nh->type = NEXTHOP_TYPE_IPV6_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)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_ISIS; api.type = ZEBRA_ROUTE_ISIS;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *prefix; api.prefix = *prefix;

View File

@ -167,6 +167,7 @@ void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
for (nh1 = nh; nh1; nh1 = nh1->next) { for (nh1 = nh; nh1; nh1 = nh1->next) {
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->vrf_id = nh1->vrf_id;
nexthop->ifindex = nh1->ifindex; nexthop->ifindex = nh1->ifindex;
nexthop->type = nh1->type; nexthop->type = nh1->type;
nexthop->flags = nh1->flags; nexthop->flags = nh1->flags;

View File

@ -60,6 +60,11 @@ struct nexthop {
struct nexthop *next; struct nexthop *next;
struct nexthop *prev; struct nexthop *prev;
/*
* What vrf is this nexthop associated with?
*/
vrf_id_t vrf_id;
/* Interface index. */ /* Interface index. */
ifindex_t ifindex; ifindex_t ifindex;

View File

@ -975,12 +975,11 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
} }
stream_putw(s, api->nexthop_num); 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++) { for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i]; api_nh = &api->nexthops[i];
stream_putl(s, api_nh->vrf_id);
stream_putc(s, api_nh->type); stream_putc(s, api_nh->type);
switch (api_nh->type) { switch (api_nh->type) {
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
@ -1126,12 +1125,10 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
return -1; return -1;
} }
if (api->nexthop_num)
STREAM_GETL(s, api->nh_vrf_id);
for (i = 0; i < api->nexthop_num; i++) { for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i]; api_nh = &api->nexthops[i];
STREAM_GETL(s, api_nh->vrf_id);
STREAM_GETC(s, api_nh->type); STREAM_GETC(s, api_nh->type);
switch (api_nh->type) { switch (api_nh->type) {
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
@ -1217,6 +1214,7 @@ struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh)
struct nexthop *n = nexthop_new(); struct nexthop *n = nexthop_new();
n->type = znh->type; n->type = znh->type;
n->vrf_id = znh->vrf_id;
n->ifindex = znh->ifindex; n->ifindex = znh->ifindex;
n->gate = znh->gate; n->gate = znh->gate;

View File

@ -239,6 +239,7 @@ struct zserv_header {
struct zapi_nexthop { struct zapi_nexthop {
enum nexthop_types_t type; enum nexthop_types_t type;
vrf_id_t vrf_id;
ifindex_t ifindex; ifindex_t ifindex;
union { union {
union g_addr gate; union g_addr gate;
@ -286,7 +287,6 @@ struct zapi_route {
u_int32_t mtu; u_int32_t mtu;
vrf_id_t vrf_id; vrf_id_t vrf_id;
vrf_id_t nh_vrf_id;
struct ethaddr rmac; struct ethaddr rmac;
}; };
@ -505,6 +505,7 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
{ {
api->nexthop_num = 1; api->nexthop_num = 1;
api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE; api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
api->nexthops[0].vrf_id = VRF_DEFAULT;
api->nexthops[0].bh_type = bh_type; api->nexthops[0].bh_type = bh_type;
SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
}; };

View File

@ -96,7 +96,6 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix
api.type = ZEBRA_ROUTE_NHRP; api.type = ZEBRA_ROUTE_NHRP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.prefix = *p; api.prefix = *p;
switch (type) { 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); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1; api.nexthop_num = 1;
api_nh = &api.nexthops[0]; api_nh = &api.nexthops[0];
api_nh->vrf_id = VRF_DEFAULT;
switch (api.prefix.family) { switch (api.prefix.family) {
case AF_INET: case AF_INET:

View File

@ -315,6 +315,7 @@ void ospf6_route_zebra_copy_nexthops(struct ospf6_route *route,
if (i >= entries) if (i >= entries)
return; return;
nexthops[i].vrf_id = VRF_DEFAULT;
nexthops[i].ifindex = nh->ifindex; nexthops[i].ifindex = nh->ifindex;
if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) { if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) {
nexthops[i].gate.ipv6 = nh->address; nexthops[i].gate.ipv6 = nh->address;

View File

@ -337,7 +337,6 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; 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)) { if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; 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)) { if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6; api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = *dest; api.prefix = *dest;

View File

@ -389,7 +389,6 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id; api.vrf_id = ospf->vrf_id;
api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF; api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance; api.instance = ospf->instance;
api.safi = SAFI_UNICAST; 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->ifindex = path->ifindex;
api_nh->type = NEXTHOP_TYPE_IFINDEX; api_nh->type = NEXTHOP_TYPE_IFINDEX;
} }
api_nh->vrf_id = ospf->vrf_id;
count++; count++;
if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) { 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)); memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id; api.vrf_id = ospf->vrf_id;
api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF; api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance; api.instance = ospf->instance;
api.safi = SAFI_UNICAST; 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)); memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id; api.vrf_id = ospf->vrf_id;
api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF; api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance; api.instance = ospf->instance;
api.safi = SAFI_UNICAST; 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)); memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id; api.vrf_id = ospf->vrf_id;
api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF; api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance; api.instance = ospf->instance;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;

View File

@ -48,7 +48,6 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIP; api.type = ZEBRA_ROUTE_RIP;
api.safi = SAFI_UNICAST; 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) if (count >= MULTIPATH_NUM)
break; break;
api_nh = &api.nexthops[count]; api_nh = &api.nexthops[count];
api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate = rinfo->nh.gate; api_nh->gate = rinfo->nh.gate;
api_nh->type = NEXTHOP_TYPE_IPV4; api_nh->type = NEXTHOP_TYPE_IPV4;
if (cmd == ZEBRA_ROUTE_ADD) if (cmd == ZEBRA_ROUTE_ADD)

View File

@ -48,7 +48,6 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIPNG; api.type = ZEBRA_ROUTE_RIPNG;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = rp->p; 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) if (count >= MULTIPATH_NUM)
break; break;
api_nh = &api.nexthops[count]; api_nh = &api.nexthops[count];
api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv6 = rinfo->nexthop; api_nh->gate.ipv6 = rinfo->nexthop;
api_nh->ifindex = rinfo->ifindex; api_nh->ifindex = rinfo->ifindex;
api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX;

View File

@ -159,7 +159,6 @@ void route_add(struct prefix *p, struct nexthop *nh)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_SHARP; api.type = ZEBRA_ROUTE_SHARP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p)); 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); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
api_nh = &api.nexthops[0]; api_nh = &api.nexthops[0];
api_nh->vrf_id = VRF_DEFAULT;
api_nh->gate.ipv4 = nh->gate.ipv4; api_nh->gate.ipv4 = nh->gate.ipv4;
api_nh->type = nh->type; api_nh->type = nh->type;
api_nh->ifindex = nh->ifindex; api_nh->ifindex = nh->ifindex;
@ -181,7 +181,6 @@ void route_delete(struct prefix *p)
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = VRF_DEFAULT; api.vrf_id = VRF_DEFAULT;
api.nh_vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_SHARP; api.type = ZEBRA_ROUTE_SHARP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
memcpy(&api.prefix, p, sizeof(*p)); memcpy(&api.prefix, p, sizeof(*p));

View File

@ -203,7 +203,9 @@ void connected_up(struct interface *ifp, struct connected *ifc)
afi_t afi; afi_t afi;
struct prefix p; struct prefix p;
struct nexthop nh = { 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)) if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
@ -238,13 +240,11 @@ void connected_up(struct interface *ifp, struct connected *ifc)
break; break;
} }
rib_add(afi, SAFI_UNICAST, ifp->vrf_id, ifp->vrf_id, rib_add(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p,
ZEBRA_ROUTE_CONNECT, 0, 0, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
&p, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
rib_add(afi, SAFI_MULTICAST, ifp->vrf_id, ifp->vrf_id, rib_add(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p,
ZEBRA_ROUTE_CONNECT, 0, 0, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
&p, NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0);
if (IS_ZEBRA_DEBUG_RIB_DETAILED) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) {
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN];
@ -362,7 +362,9 @@ void connected_down(struct interface *ifp, struct connected *ifc)
afi_t afi; afi_t afi;
struct prefix p; struct prefix p;
struct nexthop nh = { 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)) if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))

View File

@ -907,6 +907,8 @@ void rtm_read(struct rt_msghdr *rtm)
SET_FLAG(zebra_flags, ZEBRA_FLAG_STATIC); SET_FLAG(zebra_flags, ZEBRA_FLAG_STATIC);
memset(&nh, 0, sizeof(nh)); memset(&nh, 0, sizeof(nh));
nh.vrf_id = VRF_DEFAULT;
/* This is a reject or blackhole route */ /* This is a reject or blackhole route */
if (flags & RTF_REJECT) { if (flags & RTF_REJECT) {
nh.type = NEXTHOP_TYPE_BLACKHOLE; 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 if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE) || 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, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
&nh, 0, 0, 0, 0, 0); &nh, 0, 0, 0, 0, 0);
else else
@ -1097,7 +1099,7 @@ void rtm_read(struct rt_msghdr *rtm)
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE) || 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, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
&nh, 0, 0, 0, 0, 0); &nh, 0, 0, 0, 0, 0);
else else

View File

@ -59,7 +59,6 @@ struct route_entry {
/* VRF identifier. */ /* VRF identifier. */
vrf_id_t vrf_id; vrf_id_t vrf_id;
vrf_id_t nh_vrf_id;
/* Which routing table */ /* Which routing table */
uint32_t table; uint32_t table;
@ -231,22 +230,27 @@ typedef enum {
} rib_update_event_t; } rib_update_event_t;
extern struct nexthop *route_entry_nexthop_ifindex_add(struct route_entry *, 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 *, extern struct nexthop *route_entry_nexthop_blackhole_add(struct route_entry *,
enum blackhole_type); enum blackhole_type);
extern struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *, extern struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *,
struct in_addr *, struct in_addr *,
struct in_addr *); struct in_addr *,
vrf_id_t nh_vrf_id);
extern struct nexthop * extern struct nexthop *
route_entry_nexthop_ipv4_ifindex_add(struct route_entry *, struct in_addr *, 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, extern void route_entry_nexthop_delete(struct route_entry *re,
struct nexthop *nexthop); struct nexthop *nexthop);
extern struct nexthop *route_entry_nexthop_ipv6_add(struct route_entry *, 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 * extern struct nexthop *
route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re, 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, extern void route_entry_nexthop_add(struct route_entry *re,
struct nexthop *nexthop); struct nexthop *nexthop);
extern void route_entry_copy_nexthops(struct route_entry *re, 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: /* NOTE:
* All rib_add function will not just add prefix into RIB, but * All rib_add function will not just add prefix into RIB, but
* also implicitly withdraw equal prefix of same type. */ * 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, extern int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
int type, u_short instance, int flags, struct prefix *p, u_short instance, int flags, struct prefix *p,
struct prefix_ipv6 *src_p, const struct nexthop *nh, struct prefix_ipv6 *src_p, const struct nexthop *nh,
u_int32_t table_id, u_int32_t metric, u_int32_t mtu, u_int32_t table_id, u_int32_t metric, u_int32_t mtu,
uint8_t distance, route_tag_t tag); uint8_t distance, route_tag_t tag);

View File

@ -443,10 +443,10 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
if (ifp) if (ifp)
nh_vrf_id = ifp->vrf_id; nh_vrf_id = ifp->vrf_id;
} }
nh.vrf_id = nh_vrf_id;
rib_add(afi, SAFI_UNICAST, vrf_id, nh_vrf_id, proto, rib_add(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, &p,
0, flags, &p, NULL, &nh, table, metric, NULL, &nh, table, metric, mtu, distance, tag);
mtu, distance, tag);
} else { } else {
/* This is a multipath route */ /* This is a multipath route */
@ -463,13 +463,13 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
re->metric = metric; re->metric = metric;
re->mtu = mtu; re->mtu = mtu;
re->vrf_id = vrf_id; re->vrf_id = vrf_id;
re->nh_vrf_id = vrf_id;
re->table = table; re->table = table;
re->nexthop_num = 0; re->nexthop_num = 0;
re->uptime = time(NULL); re->uptime = time(NULL);
re->tag = tag; re->tag = tag;
for (;;) { for (;;) {
vrf_id_t nh_vrf_id;
if (len < (int)sizeof(*rtnh) if (len < (int)sizeof(*rtnh)
|| rtnh->rtnh_len > len) || rtnh->rtnh_len > len)
break; break;
@ -485,8 +485,17 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
ifp = if_lookup_by_index(index, ifp = if_lookup_by_index(index,
VRF_UNKNOWN); VRF_UNKNOWN);
if (ifp) 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; gate = 0;
if (rtnh->rtnh_len > sizeof(*rtnh)) { if (rtnh->rtnh_len > sizeof(*rtnh)) {
memset(tb, 0, sizeof(tb)); memset(tb, 0, sizeof(tb));
@ -503,24 +512,27 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
if (index) if (index)
route_entry_nexthop_ipv4_ifindex_add( route_entry_nexthop_ipv4_ifindex_add(
re, gate, re, gate,
prefsrc, index); prefsrc, index,
nh_vrf_id);
else else
route_entry_nexthop_ipv4_add( route_entry_nexthop_ipv4_add(
re, gate, re, gate,
prefsrc); prefsrc,
nh_vrf_id);
} else if (rtm->rtm_family } else if (rtm->rtm_family
== AF_INET6) { == AF_INET6) {
if (index) if (index)
route_entry_nexthop_ipv6_ifindex_add( route_entry_nexthop_ipv6_ifindex_add(
re, gate, re, gate, index,
index); nh_vrf_id);
else else
route_entry_nexthop_ipv6_add( route_entry_nexthop_ipv6_add(
re, gate); re, gate,
nh_vrf_id);
} }
} else } else
route_entry_nexthop_ifindex_add(re, route_entry_nexthop_ifindex_add(
index); re, index, nh_vrf_id);
len -= NLMSG_ALIGN(rtnh->rtnh_len); len -= NLMSG_ALIGN(rtnh->rtnh_len);
rtnh = RTNH_NEXT(rtnh); rtnh = RTNH_NEXT(rtnh);

View File

@ -94,12 +94,12 @@ static void handle_route_entry(mib2_ipRouteEntry_t *routeEntry)
prefix.prefixlen = ip_masklen(tmpaddr); prefix.prefixlen = ip_masklen(tmpaddr);
memset(&nh, 0, sizeof(nh)); memset(&nh, 0, sizeof(nh));
nh.vrf_id = VRF_DEFAULT;
nh.type = NEXTHOP_TYPE_IPV4; nh.type = NEXTHOP_TYPE_IPV4;
nh.gate.ipv4.s_addr = routeEntry->ipRouteNextHop; nh.gate.ipv4.s_addr = routeEntry->ipRouteNextHop;
rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, VRF_DEFAULT, rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &prefix, NULL, zebra_flags, &prefix, NULL, &nh, 0, 0, 0, 0, 0);
&nh, 0, 0, 0, 0, 0);
} }
void route_read(struct zebra_ns *zns) void route_read(struct zebra_ns *zns)

View File

@ -614,7 +614,7 @@ static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,
struct route_entry *match; struct route_entry *match;
struct nexthop *match_nh; 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) if (!table)
return 0; return 0;
@ -663,7 +663,7 @@ static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,
struct route_node *rn; struct route_node *rn;
struct route_entry *match; 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) if (!table)
return 0; return 0;
@ -728,7 +728,8 @@ static int nhlfe_nexthop_active(zebra_nhlfe_t *nhlfe)
case NEXTHOP_TYPE_IPV6_IFINDEX: case NEXTHOP_TYPE_IPV6_IFINDEX:
if (IN6_IS_ADDR_LINKLOCAL(&nexthop->gate.ipv6)) { 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)) if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else 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_add_labels(nexthop, lsp_type, 1, &out_label);
nexthop->vrf_id = VRF_DEFAULT;
nexthop->type = gtype; nexthop->type = gtype;
switch (nexthop->type) { switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4: 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)); inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex) if (nexthop->ifindex)
json_object_string_add( json_object_string_add(json_nhlfe, "interface",
json_nhlfe, "interface", ifindex2ifname(nexthop->ifindex,
ifindex2ifname(nexthop->ifindex, VRF_DEFAULT)); nexthop->vrf_id));
break; break;
default: default:
break; 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)); vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4));
if (nexthop->ifindex) if (nexthop->ifindex)
vty_out(vty, " dev %s", vty_out(vty, " dev %s",
ifindex2ifname(nexthop->ifindex, VRF_DEFAULT)); ifindex2ifname(nexthop->ifindex,
nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX: 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)); inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
if (nexthop->ifindex) if (nexthop->ifindex)
vty_out(vty, " dev %s", vty_out(vty, " dev %s",
ifindex2ifname(nexthop->ifindex, VRF_DEFAULT)); ifindex2ifname(nexthop->ifindex,
nexthop->vrf_id));
break; break;
default: default:
break; break;

View File

@ -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, 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; struct nexthop *nexthop;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IFINDEX; nexthop->type = NEXTHOP_TYPE_IFINDEX;
nexthop->ifindex = ifindex; nexthop->ifindex = ifindex;
nexthop->vrf_id = nh_vrf_id;
route_entry_nexthop_add(re, nexthop); 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 nexthop *route_entry_nexthop_ipv4_add(struct route_entry *re,
struct in_addr *ipv4, struct in_addr *ipv4,
struct in_addr *src) struct in_addr *src,
vrf_id_t nh_vrf_id)
{ {
struct nexthop *nexthop; struct nexthop *nexthop;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IPV4; nexthop->type = NEXTHOP_TYPE_IPV4;
nexthop->vrf_id = nh_vrf_id;
nexthop->gate.ipv4 = *ipv4; nexthop->gate.ipv4 = *ipv4;
if (src) if (src)
nexthop->src.ipv4 = *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 nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re,
struct in_addr *ipv4, struct in_addr *ipv4,
struct in_addr *src, struct in_addr *src,
ifindex_t ifindex) ifindex_t ifindex,
vrf_id_t nh_vrf_id)
{ {
struct nexthop *nexthop; struct nexthop *nexthop;
struct interface *ifp; struct interface *ifp;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX; nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
nexthop->gate.ipv4 = *ipv4; nexthop->gate.ipv4 = *ipv4;
if (src) if (src)
nexthop->src.ipv4 = *src; nexthop->src.ipv4 = *src;
nexthop->ifindex = ifindex; 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? /*Pending: need to think if null ifp here is ok during bootup?
There was a crash because ifp here was coming to be NULL */ There was a crash because ifp here was coming to be NULL */
if (ifp) 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 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; struct nexthop *nexthop;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV6; nexthop->type = NEXTHOP_TYPE_IPV6;
nexthop->gate.ipv6 = *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 nexthop *route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re,
struct in6_addr *ipv6, struct in6_addr *ipv6,
ifindex_t ifindex) ifindex_t ifindex,
vrf_id_t nh_vrf_id)
{ {
struct nexthop *nexthop; struct nexthop *nexthop;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->vrf_id = nh_vrf_id;
nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX; nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
nexthop->gate.ipv6 = *ipv6; nexthop->gate.ipv6 = *ipv6;
nexthop->ifindex = ifindex; nexthop->ifindex = ifindex;
@ -306,6 +316,7 @@ struct nexthop *route_entry_nexthop_blackhole_add(struct route_entry *re,
struct nexthop *nexthop; struct nexthop *nexthop;
nexthop = nexthop_new(); nexthop = nexthop_new();
nexthop->vrf_id = VRF_DEFAULT;
nexthop->type = NEXTHOP_TYPE_BLACKHOLE; nexthop->type = NEXTHOP_TYPE_BLACKHOLE;
nexthop->bh_type = bh_type; nexthop->bh_type = bh_type;
@ -322,6 +333,7 @@ static void nexthop_set_resolved(afi_t afi, struct nexthop *newhop,
resolved_hop = nexthop_new(); resolved_hop = nexthop_new();
SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ACTIVE); SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
resolved_hop->vrf_id = nexthop->vrf_id;
switch (newhop->type) { switch (newhop->type) {
case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX:
@ -403,7 +415,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (set) { if (set) {
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE); 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); nexthop->resolved, top);
nexthops_free(nexthop->resolved); nexthops_free(nexthop->resolved);
nexthop->resolved = NULL; nexthop->resolved = NULL;
@ -422,7 +434,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
* address in the routing table. * address in the routing table.
*/ */
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) { 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 (ifp && connected_is_unnumbered(ifp)) {
if (if_is_operative(ifp)) if (if_is_operative(ifp))
return 1; return 1;
@ -450,7 +462,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
break; break;
} }
/* Lookup table. */ /* 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) if (!table)
return 0; return 0;
@ -838,7 +850,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
family = 0; family = 0;
switch (nexthop->type) { switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX: 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)) if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else else
@ -867,7 +879,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
family = AFI_IP6; family = AFI_IP6;
if (IN6_IS_ADDR_LINKLOCAL(&nexthop->gate.ipv6)) { if (IN6_IS_ADDR_LINKLOCAL(&nexthop->gate.ipv6)) {
ifp = if_lookup_by_index(nexthop->ifindex, ifp = if_lookup_by_index(nexthop->ifindex,
re->nh_vrf_id); nexthop->vrf_id);
if (ifp && if_is_operative(ifp)) if (ifp && if_is_operative(ifp))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else else
@ -910,8 +922,8 @@ static unsigned nexthop_active_check(struct route_node *rn,
memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr)); memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr));
/* It'll get set if required inside */ /* It'll get set if required inside */
ret = zebra_route_map_check(family, re->type, p, nexthop, re->nh_vrf_id, ret = zebra_route_map_check(family, re->type, p, nexthop,
re->tag); nexthop->vrf_id, re->tag);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
if (IS_ZEBRA_DEBUG_RIB) { if (IS_ZEBRA_DEBUG_RIB) {
srcdest_rnode2str(rn, buf, sizeof(buf)); 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", "%u:%s: Filtering out with NH out %s due to route map",
re->vrf_id, buf, re->vrf_id, buf,
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
} }
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); 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 rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance,
int type, u_short instance, int flags, struct prefix *p, int flags, struct prefix *p, struct prefix_ipv6 *src_p,
struct prefix_ipv6 *src_p, const struct nexthop *nh, const struct nexthop *nh, u_int32_t table_id, u_int32_t metric,
u_int32_t table_id, u_int32_t metric,
u_int32_t mtu, uint8_t distance, route_tag_t tag) u_int32_t mtu, uint8_t distance, route_tag_t tag)
{ {
struct route_entry *re; 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->mtu = mtu;
re->table = table_id; re->table = table_id;
re->vrf_id = vrf_id; re->vrf_id = vrf_id;
re->nh_vrf_id = nh_vrf_id;
re->nexthop_num = 0; re->nexthop_num = 0;
re->uptime = time(NULL); re->uptime = time(NULL);
re->tag = tag; re->tag = tag;

View File

@ -952,7 +952,6 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
state->distance = re->distance; state->distance = re->distance;
state->metric = re->metric; state->metric = re->metric;
state->vrf_id = re->vrf_id; state->vrf_id = re->vrf_id;
state->nh_vrf_id = re->vrf_id;
route_entry_copy_nexthops(state, re->nexthop); route_entry_copy_nexthops(state, re->nexthop);
rnh->state = state; rnh->state = state;

View File

@ -1329,7 +1329,7 @@ route_map_result_t zebra_nht_route_map_check(int family, int client_proto,
struct nh_rmap_obj nh_obj; struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop; 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.source_protocol = re->type;
nh_obj.metric = re->metric; nh_obj.metric = re->metric;
nh_obj.tag = re->tag; nh_obj.tag = re->tag;

View File

@ -87,7 +87,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
switch (si->type) { switch (si->type) {
case STATIC_IPV4_GATEWAY: case STATIC_IPV4_GATEWAY:
nexthop = route_entry_nexthop_ipv4_add( 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.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN; nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4; 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; break;
case STATIC_IPV4_GATEWAY_IFNAME: case STATIC_IPV4_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv4_ifindex_add( 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; break;
case STATIC_IFNAME: case STATIC_IFNAME:
nexthop = route_entry_nexthop_ifindex_add(re, nexthop = route_entry_nexthop_ifindex_add(
si->ifindex); re, si->ifindex, si->nh_vrf_id);
break; break;
case STATIC_BLACKHOLE: case STATIC_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add( nexthop = route_entry_nexthop_blackhole_add(
re, bh_type); re, bh_type);
break; break;
case STATIC_IPV6_GATEWAY: case STATIC_IPV6_GATEWAY:
nexthop = route_entry_nexthop_ipv6_add(re, nexthop = route_entry_nexthop_ipv6_add(
&si->addr.ipv6); re, &si->addr.ipv6, si->nh_vrf_id);
nh_p.family = AF_INET6; nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN; nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6; 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; break;
case STATIC_IPV6_GATEWAY_IFNAME: case STATIC_IPV6_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv6_ifindex_add( nexthop = route_entry_nexthop_ipv6_ifindex_add(
re, &si->addr.ipv6, si->ifindex); re, &si->addr.ipv6, si->ifindex, si->nh_vrf_id);
break; break;
} }
/* Update label(s), if present. */ /* 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->metric = 0;
re->mtu = 0; re->mtu = 0;
re->vrf_id = si->vrf_id; re->vrf_id = si->vrf_id;
re->nh_vrf_id = si->nh_vrf_id;
re->table = re->table =
(si->vrf_id != VRF_DEFAULT) (si->vrf_id != VRF_DEFAULT)
? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id ? (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) { switch (si->type) {
case STATIC_IPV4_GATEWAY: case STATIC_IPV4_GATEWAY:
nexthop = route_entry_nexthop_ipv4_add( 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.family = AF_INET;
nh_p.prefixlen = IPV4_MAX_BITLEN; nh_p.prefixlen = IPV4_MAX_BITLEN;
nh_p.u.prefix4 = si->addr.ipv4; 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; break;
case STATIC_IPV4_GATEWAY_IFNAME: case STATIC_IPV4_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv4_ifindex_add( 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; break;
case STATIC_IFNAME: case STATIC_IFNAME:
nexthop = route_entry_nexthop_ifindex_add(re, nexthop = route_entry_nexthop_ifindex_add(
si->ifindex); re, si->ifindex, si->nh_vrf_id);
break; break;
case STATIC_BLACKHOLE: case STATIC_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add( nexthop = route_entry_nexthop_blackhole_add(
re, bh_type); re, bh_type);
break; break;
case STATIC_IPV6_GATEWAY: case STATIC_IPV6_GATEWAY:
nexthop = route_entry_nexthop_ipv6_add(re, nexthop = route_entry_nexthop_ipv6_add(
&si->addr.ipv6); re, &si->addr.ipv6, si->nh_vrf_id);
nh_p.family = AF_INET6; nh_p.family = AF_INET6;
nh_p.prefixlen = IPV6_MAX_BITLEN; nh_p.prefixlen = IPV6_MAX_BITLEN;
nh_p.u.prefix6 = si->addr.ipv6; 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; break;
case STATIC_IPV6_GATEWAY_IFNAME: case STATIC_IPV6_GATEWAY_IFNAME:
nexthop = route_entry_nexthop_ipv6_ifindex_add( nexthop = route_entry_nexthop_ipv6_ifindex_add(
re, &si->addr.ipv6, si->ifindex); re, &si->addr.ipv6, si->ifindex, si->nh_vrf_id);
break; break;
} }
/* Update label(s), if present. */ /* Update label(s), if present. */

View File

@ -770,8 +770,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
inet_ntoa(nexthop->gate.ipv4)); inet_ntoa(nexthop->gate.ipv4));
if (nexthop->ifindex) if (nexthop->ifindex)
vty_out(vty, ", via %s", vty_out(vty, ", via %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(
re->nh_vrf_id)); nexthop->ifindex,
nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX: 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)); buf, sizeof buf));
if (nexthop->ifindex) if (nexthop->ifindex)
vty_out(vty, ", via %s", vty_out(vty, ", via %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(
re->nh_vrf_id)); nexthop->ifindex,
nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, " directly connected, %s", vty_out(vty, " directly connected, %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, " unreachable"); vty_out(vty, " unreachable");
@ -809,9 +811,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
break; break;
} }
if (re->vrf_id != re->nh_vrf_id) { if (re->vrf_id != nexthop->vrf_id) {
struct vrf *vrf = 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); 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); nexthop->ifindex);
json_object_string_add( json_object_string_add(
json_nexthop, "interfaceName", json_nexthop, "interfaceName",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(
re->nh_vrf_id)); nexthop->ifindex,
nexthop->vrf_id));
} }
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
@ -973,8 +976,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
nexthop->ifindex); nexthop->ifindex);
json_object_string_add( json_object_string_add(
json_nexthop, "interfaceName", json_nexthop, "interfaceName",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(
re->nh_vrf_id)); nexthop->ifindex,
nexthop->vrf_id));
} }
break; break;
@ -987,7 +991,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_string_add( json_object_string_add(
json_nexthop, "interfaceName", json_nexthop, "interfaceName",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
json_object_boolean_true_add(json_nexthop, 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; break;
} }
if (re->nh_vrf_id != re->vrf_id) { if (nexthop->vrf_id != re->vrf_id) {
struct vrf *vrf = struct vrf *vrf =
vrf_lookup_by_id(re->nh_vrf_id); vrf_lookup_by_id(nexthop->vrf_id);
json_object_string_add(json_nexthop, json_object_string_add(json_nexthop,
"vrf", "vrf",
@ -1129,7 +1133,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (nexthop->ifindex) if (nexthop->ifindex)
vty_out(vty, ", %s", vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX: 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) if (nexthop->ifindex)
vty_out(vty, ", %s", vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, " is directly connected, %s", vty_out(vty, " is directly connected, %s",
ifindex2ifname(nexthop->ifindex, ifindex2ifname(nexthop->ifindex,
re->nh_vrf_id)); nexthop->vrf_id));
break; break;
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, " unreachable"); vty_out(vty, " unreachable");
@ -1167,9 +1171,8 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
break; break;
} }
if (re->nh_vrf_id != re->vrf_id) { if (nexthop->vrf_id != re->vrf_id) {
struct vrf *vrf = struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id);
vrf_lookup_by_id(re->nh_vrf_id);
vty_out(vty, "(vrf %s)", vrf->name); vty_out(vty, "(vrf %s)", vrf->name);
} }

View File

@ -592,7 +592,6 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = re->vrf_id; api.vrf_id = re->vrf_id;
api.nh_vrf_id = re->nh_vrf_id;
api.type = re->type; api.type = re->type;
api.instance = re->instance; api.instance = re->instance;
api.flags = re->flags; api.flags = re->flags;
@ -614,6 +613,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
continue; continue;
api_nh = &api.nexthops[count]; api_nh = &api.nexthops[count];
api_nh->vrf_id = nexthop->vrf_id;
api_nh->type = nexthop->type; api_nh->type = nexthop->type;
switch (nexthop->type) { switch (nexthop->type) {
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
@ -1137,7 +1137,6 @@ static int zread_route_add(struct zserv *client, u_short length,
re->flags = api.flags; re->flags = api.flags;
re->uptime = time(NULL); re->uptime = time(NULL);
re->vrf_id = vrf_id; re->vrf_id = vrf_id;
re->nh_vrf_id = api.nh_vrf_id;
re->table = zvrf->table_id; re->table = zvrf->table_id;
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) { 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) { switch (api_nh->type) {
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add( nexthop = route_entry_nexthop_ifindex_add(
re, api_nh->ifindex); re, api_nh->ifindex, re->vrf_id);
break; break;
case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4:
nexthop = route_entry_nexthop_ipv4_add( nexthop = route_entry_nexthop_ipv4_add(
re, &api_nh->gate.ipv4, NULL); re, &api_nh->gate.ipv4, NULL,
re->vrf_id);
break; break;
case NEXTHOP_TYPE_IPV4_IFINDEX: { 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( nexthop = route_entry_nexthop_ipv4_ifindex_add(
re, &api_nh->gate.ipv4, NULL, re, &api_nh->gate.ipv4, NULL, ifindex,
ifindex); re->vrf_id);
/* if this an EVPN route entry, /* if this an EVPN route entry,
program the nh as neigh program the nh as neigh
@ -1192,12 +1192,12 @@ static int zread_route_add(struct zserv *client, u_short length,
} }
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
nexthop = route_entry_nexthop_ipv6_add( nexthop = route_entry_nexthop_ipv6_add(
re, &api_nh->gate.ipv6); re, &api_nh->gate.ipv6, re->vrf_id);
break; break;
case NEXTHOP_TYPE_IPV6_IFINDEX: case NEXTHOP_TYPE_IPV6_IFINDEX:
nexthop = route_entry_nexthop_ipv6_ifindex_add( nexthop = route_entry_nexthop_ipv6_ifindex_add(
re, &api_nh->gate.ipv6, re, &api_nh->gate.ipv6, api_nh->ifindex,
api_nh->ifindex); re->vrf_id);
break; break;
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
nexthop = route_entry_nexthop_blackhole_add( nexthop = route_entry_nexthop_blackhole_add(
@ -1364,7 +1364,6 @@ static int zread_ipv4_add(struct zserv *client, u_short length,
/* VRF ID */ /* VRF ID */
re->vrf_id = zvrf_id(zvrf); re->vrf_id = zvrf_id(zvrf);
re->nh_vrf_id = zvrf_id(zvrf);
/* Nexthop parse. */ /* Nexthop parse. */
if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) { 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) { switch (nexthop_type) {
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
STREAM_GETL(s, ifindex); STREAM_GETL(s, ifindex);
route_entry_nexthop_ifindex_add(re, ifindex); route_entry_nexthop_ifindex_add(re, ifindex,
re->vrf_id);
break; break;
case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4:
STREAM_GET(&nhop_addr.s_addr, s, STREAM_GET(&nhop_addr.s_addr, s,
IPV4_MAX_BYTELEN); IPV4_MAX_BYTELEN);
nexthop = route_entry_nexthop_ipv4_add( nexthop = route_entry_nexthop_ipv4_add(
re, &nhop_addr, NULL); re, &nhop_addr, NULL, re->vrf_id);
/* For labeled-unicast, each nexthop is followed /* For labeled-unicast, each nexthop is followed
* by label. */ * by label. */
if (CHECK_FLAG(message, ZAPI_MESSAGE_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); IPV4_MAX_BYTELEN);
STREAM_GETL(s, ifindex); STREAM_GETL(s, ifindex);
route_entry_nexthop_ipv4_ifindex_add( route_entry_nexthop_ipv4_ifindex_add(
re, &nhop_addr, NULL, ifindex); re, &nhop_addr, NULL, ifindex,
re->vrf_id);
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
zlog_warn("%s: Please use ZEBRA_ROUTE_ADD if you want to pass v6 nexthops", 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 */ /* VRF ID */
re->vrf_id = zvrf_id(zvrf); 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 /* 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 * 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 = nexthop =
route_entry_nexthop_ipv6_ifindex_add( route_entry_nexthop_ipv6_ifindex_add(
re, &nexthops[i], re, &nexthops[i],
ifindices[i]); ifindices[i],
re->vrf_id);
else else
nexthop = route_entry_nexthop_ipv6_add( nexthop = route_entry_nexthop_ipv6_add(
re, &nexthops[i]); re, &nexthops[i], re->vrf_id);
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL)) if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels(nexthop, label_type, nexthop_add_labels(nexthop, label_type,
@ -1646,7 +1647,7 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,
} else { } else {
if ((i < if_count) && ifindices[i]) if ((i < if_count) && ifindices[i])
route_entry_nexthop_ifindex_add( 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 } else
src_pp = NULL; 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 /* 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 * to the re to ensure that IPv6 multipathing works; need to coalesce
* these. Clients should send the same number of paired set of * 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_GET(&nhop_addr, s, 16);
STREAM_GETL(s, ifindex); STREAM_GETL(s, ifindex);
route_entry_nexthop_ipv6_ifindex_add( route_entry_nexthop_ipv6_ifindex_add(
re, &nhop_addr, ifindex); re, &nhop_addr, ifindex, re->vrf_id);
break; break;
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
if (if_count < multipath_num) { if (if_count < multipath_num) {
@ -1824,17 +1828,18 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
nexthop = nexthop =
route_entry_nexthop_ipv6_ifindex_add( route_entry_nexthop_ipv6_ifindex_add(
re, &nexthops[i], re, &nexthops[i],
ifindices[i]); ifindices[i],
re->vrf_id);
else else
nexthop = route_entry_nexthop_ipv6_add( nexthop = route_entry_nexthop_ipv6_add(
re, &nexthops[i]); re, &nexthops[i], re->vrf_id);
if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL)) if (CHECK_FLAG(message, ZAPI_MESSAGE_LABEL))
nexthop_add_labels(nexthop, label_type, nexthop_add_labels(nexthop, label_type,
1, &labels[i]); 1, &labels[i]);
} else { } else {
if ((i < if_count) && ifindices[i]) if ((i < if_count) && ifindices[i])
route_entry_nexthop_ifindex_add( 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 else
re->mtu = 0; re->mtu = 0;
/* VRF ID */
re->vrf_id = zvrf_id(zvrf);
re->nh_vrf_id = zvrf_id(zvrf);
re->table = zvrf->table_id; re->table = zvrf->table_id;
ret = rib_add_multipath(AFI_IP6, safi, &p, src_pp, re); ret = rib_add_multipath(AFI_IP6, safi, &p, src_pp, re);