diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-07-26 06:48:19 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-07-26 06:48:19 +0000 |
commit | f5c27da642c15694ba473ca727c63db899793cee (patch) | |
tree | acaeca318a843d79c2ee413ea845aac8dc853a81 | |
parent | 1ed0a5ba2613f9179c77b0afc0a7badbf5c7e2bc (diff) |
No need to provide a dummy nexthop anymore, instead set the nhflags to
NEXTHOP_VALID or 0 depending on the nexthop state for the testvector.
-rw-r--r-- | regress/usr.sbin/bgpd/unittests/rde_decide_test.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/regress/usr.sbin/bgpd/unittests/rde_decide_test.c b/regress/usr.sbin/bgpd/unittests/rde_decide_test.c index 90865199414..6d643dd0684 100644 --- a/regress/usr.sbin/bgpd/unittests/rde_decide_test.c +++ b/regress/usr.sbin/bgpd/unittests/rde_decide_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide_test.c,v 1.11 2022/07/19 16:27:59 claudio Exp $ */ +/* $OpenBSD: rde_decide_test.c,v 1.12 2022/07/26 06:48:18 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> @@ -34,13 +34,6 @@ struct rib dummy_rib = { struct rib_entry dummy_re; -struct nexthop nh_reach = { - .state = NEXTHOP_REACH -}; -struct nexthop nh_unreach = { - .state = NEXTHOP_UNREACH -}; - struct rde_peer peer1 = { .conf.ebgp = 1, .remote_bgpid = 1, @@ -110,47 +103,47 @@ struct test { struct prefix p; } test_pfx[] = { { .what = "test prefix", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* pathes with errors are not eligible */ { .what = "prefix with error", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[1], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[1], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* only loop free pathes are eligible */ { .what = "prefix with loop", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[2], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[2], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 1. check if prefix is eligible a.k.a reachable */ { .what = "prefix with unreachable nexthop", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nexthop = &nh_unreach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nhflags = 0, .lastchange = T1, } }, /* 2. local preference of prefix, bigger is better */ { .what = "local preference check", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[3], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[3], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 3. aspath count, the shorter the better */ { .what = "aspath count check", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[4], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[4], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 4. origin, the lower the better */ { .what = "origin EGP", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[5], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[5], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, { .what = "origin INCOMPLETE", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[6], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[6], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 5. MED decision */ { .what = "MED", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[7], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[7], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 6. EBGP is cooler than IBGP */ { .what = "EBGP vs IBGP", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1_i, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1_i, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 7. weight */ { .what = "local weight", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[8], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[8], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 8. nexthop cost not implemented */ /* 9. route age */ { .what = "route age", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T2, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T2, } }, /* 10. BGP Id or ORIGINATOR_ID if present */ { .what = "BGP ID", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer2, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer2, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, /* 11. CLUSTER_LIST length, TODO */ /* 12. lowest peer address wins */ { .what = "remote peer address", - .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1_a4, .nexthop = &nh_reach, .lastchange = T1, } }, + .p = { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1_a4, .nhflags = NEXTHOP_VALID, .lastchange = T1, } }, }; struct rde_aspath med_asp[] = { @@ -170,27 +163,27 @@ struct rde_aspath med_asp[] = { * For med_pfx3 and med_pfx4 the strict case differs in the bgp-id. */ struct prefix med_pfx1 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[0], .peer = &peer2, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[0], .peer = &peer2, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; struct prefix med_pfx2 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[1], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[1], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; struct prefix med_pfx3 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[2], .peer = &peer3, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[2], .peer = &peer3, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; struct prefix med_pfx4 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[3], .peer = &peer1_a4, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[3], .peer = &peer1_a4, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; /* the next two prefixes have a longer aspath than med_pfx1 & 2 */ struct prefix med_pfx5 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[5], .peer = &peer3, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[5], .peer = &peer3, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; struct prefix med_pfx6 = - { .entry.list.re = &dummy_re, .aspath = &med_asp[4], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &med_asp[4], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; /* * Define two prefixes where pfx1 > pfx2 if 'rde route-age evaluate' * but pfx1 < pfx2 if 'rde route-age ignore' */ struct prefix age_pfx1 = - { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer2, .nexthop = &nh_reach, .lastchange = T1, }; + { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer2, .nhflags = NEXTHOP_VALID, .lastchange = T1, }; struct prefix age_pfx2 = - { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nexthop = &nh_reach, .lastchange = T2, }; + { .entry.list.re = &dummy_re, .aspath = &asp[0], .peer = &peer1, .nhflags = NEXTHOP_VALID, .lastchange = T2, }; int prefix_cmp(struct prefix *, struct prefix *, int *); |