diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-06-15 14:27:35 -0400 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-08-06 22:41:28 -0300 |
| commit | 0e64ed022892be68b9655a81c82094378c2eb10f (patch) | |
| tree | a2f408d3b9cccd6b407efdc239ec3060e692492d | |
| parent | e944996140173700f73281cf7efc444377eec331 (diff) | |
eigrpd: Convert eigrp_zebra.c to use appropriate vrf_id
Use the appropriate vrf_id in eigrp_zebra based off of the
struct eigrp *eigrp.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
| -rw-r--r-- | eigrpd/eigrp_topology.c | 14 | ||||
| -rw-r--r-- | eigrpd/eigrp_zebra.c | 32 | ||||
| -rw-r--r-- | eigrpd/eigrp_zebra.h | 7 |
3 files changed, 29 insertions, 24 deletions
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 4ca7cd19d1..394a14f8c4 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -154,6 +154,7 @@ void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node, struct eigrp_nexthop_entry *entry) { struct list *l = list_new(); + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); listnode_add(l, entry); @@ -161,7 +162,8 @@ void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node, listnode_add_sort(node->entries, entry); entry->prefix = node; - eigrp_zebra_route_add(node->destination, l, node->fdistance); + eigrp_zebra_route_add(eigrp, node->destination, + l, node->fdistance); } list_delete(&l); @@ -195,7 +197,7 @@ void eigrp_prefix_entry_delete(struct route_table *table, eigrp_nexthop_entry_delete(pe, ne); list_delete(&pe->entries); list_delete(&pe->rij); - eigrp_zebra_route_delete(pe->destination); + eigrp_zebra_route_delete(eigrp, pe->destination); prefix_free(pe->destination); rn->info = NULL; @@ -210,9 +212,11 @@ void eigrp_prefix_entry_delete(struct route_table *table, void eigrp_nexthop_entry_delete(struct eigrp_prefix_entry *node, struct eigrp_nexthop_entry *entry) { + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); + if (listnode_lookup(node->entries, entry) != NULL) { listnode_delete(node->entries, entry); - eigrp_zebra_route_delete(node->destination); + eigrp_zebra_route_delete(eigrp, node->destination); XFREE(MTYPE_EIGRP_NEXTHOP_ENTRY, entry); } } @@ -477,14 +481,14 @@ void eigrp_update_routing_table(struct eigrp_prefix_entry *prefix) successors = eigrp_topology_get_successor_max(prefix, eigrp->max_paths); if (successors) { - eigrp_zebra_route_add(prefix->destination, successors, + eigrp_zebra_route_add(eigrp, prefix->destination, successors, prefix->fdistance); for (ALL_LIST_ELEMENTS_RO(successors, node, entry)) entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; list_delete(&successors); } else { - eigrp_zebra_route_delete(prefix->destination); + eigrp_zebra_route_delete(eigrp, prefix->destination); for (ALL_LIST_ELEMENTS_RO(prefix->entries, node, entry)) entry->flags &= ~EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; } diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 1252593826..63cbe84ef2 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -59,7 +59,8 @@ static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS); static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS); static int eigrp_interface_state_up(ZAPI_CALLBACK_ARGS); static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS); -static struct interface *zebra_interface_if_lookup(struct stream *); +static struct interface *zebra_interface_if_lookup(struct stream *, + vrf_id_t vrf_id); static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS); @@ -257,7 +258,7 @@ static int eigrp_interface_state_up(ZAPI_CALLBACK_ARGS) { struct interface *ifp; - ifp = zebra_interface_if_lookup(zclient->ibuf); + ifp = zebra_interface_if_lookup(zclient->ibuf, vrf_id); if (ifp == NULL) return 0; @@ -328,7 +329,8 @@ static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS) return 0; } -static struct interface *zebra_interface_if_lookup(struct stream *s) +static struct interface *zebra_interface_if_lookup(struct stream *s, + vrf_id_t vrf_id) { char ifname_tmp[INTERFACE_NAMSIZ]; @@ -336,11 +338,11 @@ static struct interface *zebra_interface_if_lookup(struct stream *s) stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* And look it up. */ - return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); + return if_lookup_by_name(ifname_tmp, vrf_id); } -void eigrp_zebra_route_add(struct prefix *p, struct list *successors, - uint32_t distance) +void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p, + struct list *successors, uint32_t distance) { struct zapi_route api; struct zapi_nexthop *api_nh; @@ -352,7 +354,7 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors, return; memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = eigrp->vrf_id; api.type = ZEBRA_ROUTE_EIGRP; api.safi = SAFI_UNICAST; api.metric = distance; @@ -366,7 +368,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; + api_nh->vrf_id = eigrp->vrf_id; if (te->adv_router->src.s_addr) { api_nh->gate.ipv4 = te->adv_router->src; api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; @@ -388,7 +390,7 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors, zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); } -void eigrp_zebra_route_delete(struct prefix *p) +void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p) { struct zapi_route api; @@ -396,7 +398,7 @@ void eigrp_zebra_route_delete(struct prefix *p) return; memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = eigrp->vrf_id; api.type = ZEBRA_ROUTE_EIGRP; api.safi = SAFI_UNICAST; memcpy(&api.prefix, p, sizeof(*p)); @@ -411,20 +413,20 @@ void eigrp_zebra_route_delete(struct prefix *p) return; } -int eigrp_is_type_redistributed(int type) +static int eigrp_is_type_redistributed(int type, vrf_id_t vrf_id) { return ((DEFAULT_ROUTE_TYPE(type)) ? vrf_bitmap_check(zclient->default_information[AFI_IP], - VRF_DEFAULT) + vrf_id) : vrf_bitmap_check(zclient->redist[AFI_IP][type], - VRF_DEFAULT)); + vrf_id)); } int eigrp_redistribute_set(struct eigrp *eigrp, int type, struct eigrp_metrics metric) { - if (eigrp_is_type_redistributed(type)) { + if (eigrp_is_type_redistributed(type, eigrp->vrf_id)) { if (eigrp_metrics_is_same(metric, eigrp->dmetric[type])) { eigrp->dmetric[type] = metric; } @@ -453,7 +455,7 @@ int eigrp_redistribute_set(struct eigrp *eigrp, int type, int eigrp_redistribute_unset(struct eigrp *eigrp, int type) { - if (eigrp_is_type_redistributed(type)) { + if (eigrp_is_type_redistributed(type, eigrp->vrf_id)) { memset(&eigrp->dmetric[type], 0, sizeof(struct eigrp_metrics)); zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, eigrp->vrf_id); diff --git a/eigrpd/eigrp_zebra.h b/eigrpd/eigrp_zebra.h index 86b337cfe6..112f2584ce 100644 --- a/eigrpd/eigrp_zebra.h +++ b/eigrpd/eigrp_zebra.h @@ -33,11 +33,10 @@ extern void eigrp_zebra_init(void); -extern void eigrp_zebra_route_add(struct prefix *, struct list *, - uint32_t distance); -extern void eigrp_zebra_route_delete(struct prefix *); +extern void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p, + struct list *successors, uint32_t distance); +extern void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *); extern int eigrp_redistribute_set(struct eigrp *, int, struct eigrp_metrics); extern int eigrp_redistribute_unset(struct eigrp *, int); -extern int eigrp_is_type_redistributed(int); #endif /* _ZEBRA_EIGRP_ZEBRA_H_ */ |
