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 <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-02-03 09:56:20 -05:00
parent 41e8603bfa
commit 0f9bc49647
7 changed files with 21 additions and 17 deletions

View File

@ -161,7 +161,7 @@ void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node,
listnode_add_sort(node->entries, entry); listnode_add_sort(node->entries, entry);
entry->prefix = node; entry->prefix = node;
eigrp_zebra_route_add(node->destination, l); eigrp_zebra_route_add(node->destination, l, node->fdistance);
} }
list_delete(&l); 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); successors = eigrp_topology_get_successor_max(prefix, eigrp->max_paths);
if (successors) { 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)) for (ALL_LIST_ELEMENTS_RO(successors, node, entry))
entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG;

View File

@ -353,7 +353,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)
return if_lookup_by_name(ifname_tmp, VRF_DEFAULT); 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_route api;
struct zapi_nexthop *api_nh; 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.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_EIGRP; api.type = ZEBRA_ROUTE_EIGRP;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.metric = distance;
memcpy(&api.prefix, p, sizeof(*p)); memcpy(&api.prefix, p, sizeof(*p));
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
/* Nexthop, ifindex, distance and metric information. */ /* Nexthop, ifindex, distance and metric information. */
for (ALL_LIST_ELEMENTS_RO(successors, node, te)) { for (ALL_LIST_ELEMENTS_RO(successors, node, te)) {

View File

@ -33,7 +33,8 @@
extern void eigrp_zebra_init(void); 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 void eigrp_zebra_route_delete(struct prefix *);
extern int eigrp_redistribute_set(struct eigrp *, int, struct eigrp_metrics); extern int eigrp_redistribute_set(struct eigrp *, int, struct eigrp_metrics);
extern int eigrp_redistribute_unset(struct eigrp *, int); extern int eigrp_redistribute_unset(struct eigrp *, int);

View File

@ -3,7 +3,7 @@
{ {
"prefix":"192.168.1.0/24", "prefix":"192.168.1.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,
@ -31,7 +31,7 @@
"prefix":"192.168.3.0/24", "prefix":"192.168.3.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":33280,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,
@ -47,7 +47,7 @@
{ {
"prefix":"193.1.1.0/26", "prefix":"193.1.1.0/26",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,
@ -75,7 +75,7 @@
"prefix":"193.1.2.0/24", "prefix":"193.1.2.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":30720,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,

View File

@ -4,7 +4,7 @@
"prefix":"192.168.1.0/24", "prefix":"192.168.1.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":30720,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,
@ -21,7 +21,7 @@
"prefix":"192.168.3.0/24", "prefix":"192.168.3.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":30720,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,
@ -37,7 +37,7 @@
{ {
"prefix":"193.1.1.0/26", "prefix":"193.1.1.0/26",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,
@ -64,7 +64,7 @@
{ {
"prefix":"193.1.2.0/24", "prefix":"193.1.2.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,

View File

@ -4,7 +4,7 @@
"prefix":"192.168.1.0/24", "prefix":"192.168.1.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":33280,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,
@ -38,7 +38,7 @@
{ {
"prefix":"192.168.3.0/24", "prefix":"192.168.3.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,
@ -66,7 +66,7 @@
"prefix":"193.1.1.0/26", "prefix":"193.1.1.0/26",
"protocol":"eigrp", "protocol":"eigrp",
"selected":true, "selected":true,
"metric":0, "metric":30720,
"nexthops":[ "nexthops":[
{ {
"fib":true, "fib":true,
@ -82,7 +82,7 @@
{ {
"prefix":"193.1.2.0/24", "prefix":"193.1.2.0/24",
"protocol":"eigrp", "protocol":"eigrp",
"metric":0, "metric":28160,
"nexthops":[ "nexthops":[
{ {
"directlyConnected":true, "directlyConnected":true,

View File

@ -153,7 +153,6 @@ def test_eigrp_routes():
assertmsg = '"show ip eigrp topo" mismatches on {}'.format(router.name) assertmsg = '"show ip eigrp topo" mismatches on {}'.format(router.name)
assert topotest.json_cmp(actual, expected) is None, assertmsg assert topotest.json_cmp(actual, expected) is None, assertmsg
def test_zebra_ipv4_routingTable(): def test_zebra_ipv4_routingTable():
"Test 'show ip route'" "Test 'show ip route'"