]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Add nh_vrf_id to 'struct route_entry`
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 12 Jan 2018 14:20:30 +0000 (09:20 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 12 Jan 2018 14:20:30 +0000 (09:20 -0500)
With VRF route-leaking we need to know what vrf
the nexthops are in compared to this vrf.  This
code adds the nh_vrf_id to the route entry and
sets it up correctly for the non-route-leaking
case.

The assumption here is that future commits
will make the nh_vrf_id *different* than
the vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rib.h
zebra/rt_netlink.c
zebra/zebra_rib.c
zebra/zebra_rnh.c
zebra/zebra_static.c
zebra/zserv.c

index c7e83480caa37d17ee72b2944c68c93a7f10a2b0..c92f5407717f35141d925f76d338e73c8f098950 100644 (file)
@@ -59,6 +59,7 @@ struct route_entry {
 
        /* VRF identifier. */
        vrf_id_t vrf_id;
+       vrf_id_t nh_vrf_id;
 
        /* Which routing table */
        uint32_t table;
index a77814668d4518d179abf30db4d5ea2b3081678d..cb3f598eb9599ae849971922ac9bf3b56a4bec20 100644 (file)
@@ -453,6 +453,7 @@ 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);
index 41e14459b1426cd0e9e9b67a30ea768a0d9952c7..8caa39427bd7ff24d818c6694386279b520370f9 100644 (file)
@@ -2514,6 +2514,7 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance,
        re->mtu = mtu;
        re->table = table_id;
        re->vrf_id = vrf_id;
+       re->nh_vrf_id = vrf_id;
        re->nexthop_num = 0;
        re->uptime = time(NULL);
        re->tag = tag;
index 33d0b3a641efef6a33cefbd6d45123cd057bf147..3fc496ebb748860e88714bd804912e8e153534b7 100644 (file)
@@ -951,6 +951,8 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
        state->type = re->type;
        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;
index 751ea08a381eecbf0e0348b1351bd7ae77d53aa8..7fdc4908b4c27d9156af2f099665c674c616bb75 100644 (file)
@@ -155,6 +155,7 @@ 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->vrf_id;
                re->table =
                        si->vrf_id
                                ? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id
index 7eded89f6dc8233f03529ab6c5902bff14c4e4c4..6c453516bda2a6dead3ef202ede27964a8081229 100644 (file)
@@ -1146,6 +1146,7 @@ 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 = vrf_id;
        re->table = zvrf->table_id;
 
        if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
@@ -1372,6 +1373,7 @@ 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)) {
@@ -1581,6 +1583,7 @@ 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
@@ -1866,6 +1869,8 @@ static int zread_ipv6_add(struct zserv *client, u_short length,
 
        /* 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);