mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 14:29:47 +00:00
*: 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:
parent
a97e5c1a80
commit
4a7371e9e2
@ -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) &&
|
||||
|
@ -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;
|
||||
|
@ -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],
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
20
zebra/rib.h
20
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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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. */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user