From 0f9bc496479098d88750823e054ad6c372e7aa9f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 3 Feb 2019 09:56:20 -0500 Subject: [PATCH] eigrpd: Modify code to pass down metric to zebra Modify EIGRP code to pass its used metric down to zebra. Additionally update topotests to pass with these changes. Fixes: #3703 Signed-off-by: Donald Sharp --- eigrpd/eigrp_topology.c | 5 +++-- eigrpd/eigrp_zebra.c | 5 ++++- eigrpd/eigrp_zebra.h | 3 ++- tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref | 8 ++++---- tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref | 8 ++++---- tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref | 8 ++++---- tests/topotests/eigrp-topo1/test_eigrp_topo1.py | 1 - 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 2d0ebf1bc5..23f5a705eb 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -161,7 +161,7 @@ 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); + eigrp_zebra_route_add(node->destination, l, node->fdistance); } list_delete(&l); @@ -477,7 +477,8 @@ 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(prefix->destination, successors, + prefix->fdistance); for (ALL_LIST_ELEMENTS_RO(successors, node, entry)) entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index a810e01468..09d876afaa 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -353,7 +353,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s) return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); } -void eigrp_zebra_route_add(struct prefix *p, struct list *successors) +void eigrp_zebra_route_add(struct prefix *p, struct list *successors, + uint32_t distance) { struct zapi_route api; struct zapi_nexthop *api_nh; @@ -368,9 +369,11 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors) api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_EIGRP; api.safi = SAFI_UNICAST; + api.metric = distance; memcpy(&api.prefix, p, sizeof(*p)); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); + SET_FLAG(api.message, ZAPI_MESSAGE_METRIC); /* Nexthop, ifindex, distance and metric information. */ for (ALL_LIST_ELEMENTS_RO(successors, node, te)) { diff --git a/eigrpd/eigrp_zebra.h b/eigrpd/eigrp_zebra.h index 1c418dddef..86b337cfe6 100644 --- a/eigrpd/eigrp_zebra.h +++ b/eigrpd/eigrp_zebra.h @@ -33,7 +33,8 @@ extern void eigrp_zebra_init(void); -extern void eigrp_zebra_route_add(struct prefix *, struct list *); +extern void eigrp_zebra_route_add(struct prefix *, struct list *, + uint32_t distance); extern void eigrp_zebra_route_delete(struct prefix *); extern int eigrp_redistribute_set(struct eigrp *, int, struct eigrp_metrics); extern int eigrp_redistribute_unset(struct eigrp *, int); diff --git a/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref index 36dd5da597..26fa7ca415 100644 --- a/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref +++ b/tests/topotests/eigrp-topo1/r1/show_ip_route.json_ref @@ -3,7 +3,7 @@ { "prefix":"192.168.1.0/24", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, @@ -31,7 +31,7 @@ "prefix":"192.168.3.0/24", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":33280, "nexthops":[ { "fib":true, @@ -47,7 +47,7 @@ { "prefix":"193.1.1.0/26", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, @@ -75,7 +75,7 @@ "prefix":"193.1.2.0/24", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":30720, "nexthops":[ { "fib":true, diff --git a/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref index 44903ce3ff..71c931b17a 100644 --- a/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref +++ b/tests/topotests/eigrp-topo1/r2/show_ip_route.json_ref @@ -4,7 +4,7 @@ "prefix":"192.168.1.0/24", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":30720, "nexthops":[ { "fib":true, @@ -21,7 +21,7 @@ "prefix":"192.168.3.0/24", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":30720, "nexthops":[ { "fib":true, @@ -37,7 +37,7 @@ { "prefix":"193.1.1.0/26", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, @@ -64,7 +64,7 @@ { "prefix":"193.1.2.0/24", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, diff --git a/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref b/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref index d80e1d97e6..5e0b79d811 100644 --- a/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref +++ b/tests/topotests/eigrp-topo1/r3/show_ip_route.json_ref @@ -4,7 +4,7 @@ "prefix":"192.168.1.0/24", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":33280, "nexthops":[ { "fib":true, @@ -38,7 +38,7 @@ { "prefix":"192.168.3.0/24", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, @@ -66,7 +66,7 @@ "prefix":"193.1.1.0/26", "protocol":"eigrp", "selected":true, - "metric":0, + "metric":30720, "nexthops":[ { "fib":true, @@ -82,7 +82,7 @@ { "prefix":"193.1.2.0/24", "protocol":"eigrp", - "metric":0, + "metric":28160, "nexthops":[ { "directlyConnected":true, diff --git a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py index de8cb81f8f..8ea2f0b506 100755 --- a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py +++ b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py @@ -153,7 +153,6 @@ def test_eigrp_routes(): assertmsg = '"show ip eigrp topo" mismatches on {}'.format(router.name) assert topotest.json_cmp(actual, expected) is None, assertmsg - def test_zebra_ipv4_routingTable(): "Test 'show ip route'" -- 2.39.5