summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c12
-rw-r--r--lib/if.h7
-rw-r--r--lib/zclient.c5
-rw-r--r--lib/zclient.h6
4 files changed, 30 insertions, 0 deletions
diff --git a/lib/if.c b/lib/if.c
index 8e6a9a6968..fdcd563a5d 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -219,6 +219,18 @@ struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
struct vrf *vrf;
struct interface if_tmp;
+ if (vrf_id == VRF_UNKNOWN) {
+ struct interface *ifp;
+
+ RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) {
+ ifp = if_lookup_by_index(ifindex, vrf->vrf_id);
+ if (ifp)
+ return ifp;
+ }
+
+ return NULL;
+ }
+
vrf = vrf_lookup_by_id(vrf_id);
if (!vrf)
return NULL;
diff --git a/lib/if.h b/lib/if.h
index eb8af2041b..79f96a7c45 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -452,6 +452,13 @@ struct nbr_connected {
/* Prototypes. */
extern int if_cmp_name_func(char *, char *);
+/*
+ * Passing in VRF_UNKNOWN is a valid thing to do, unless we
+ * are creating a new interface.
+ *
+ * This is useful for vrf route-leaking. So more than anything
+ * else think before you use VRF_UNKNOWN
+ */
extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id);
extern struct interface *if_create(const char *name, vrf_id_t vrf_id);
extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);
diff --git a/lib/zclient.c b/lib/zclient.c
index d4a7b45b97..a4bd2bda32 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -942,6 +942,8 @@ 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_putw(s, api->nh_vrf_id);
for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i];
@@ -1091,6 +1093,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
return -1;
}
+ if (api->nexthop_num)
+ STREAM_GETW(s, api->nh_vrf_id);
+
for (i = 0; i < api->nexthop_num; i++) {
api_nh = &api->nexthops[i];
diff --git a/lib/zclient.h b/lib/zclient.h
index 00ad692718..c24f2b2a4e 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -281,6 +281,7 @@ struct zapi_route {
u_int32_t mtu;
vrf_id_t vrf_id;
+ vrf_id_t nh_vrf_id;
struct ethaddr rmac;
};
@@ -420,6 +421,11 @@ extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
vrf_id_t *new_vrf_id);
extern void zebra_interface_if_set_value(struct stream *, struct interface *);
extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);
+
+#if CONFDATE > 20180823
+CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");
+#endif
+
extern int zapi_ipv4_route(u_char, struct zclient *, struct prefix_ipv4 *,
struct zapi_ipv4 *) __attribute__((deprecated));