From 17571c4ae7fa294e031b3e614a4fa62f834d0b3d Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 14 Nov 2022 15:56:40 +0100 Subject: bgpd: aspath list format binds on as-notation format Each BGP prefix may have an as-path list attached. A forged string is stored in the BGP attribute and shows the as-path list output. Before this commit, the as-path list output was expressed as a list of AS values in plain format. Now, if a given BGP instance uses a specific asnotation, then the output is changed: new output: router bgp 1.1 asnotation dot ! address-family ipv4 unicast network 10.200.0.0/24 route-map rmap network 10.201.0.0/24 route-map rmap redistribute connected route-map rmap exit-address-family exit ! route-map rmap permit 1 set as-path prepend 1.1 5433.55 264564564 exit ubuntu2004# do show bgp ipv4 BGP table version is 2, local router ID is 10.0.2.15, vrf id 0 Default local pref 100, local AS 1.1 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 4.4.4.4/32 0.0.0.0 0 32768 1.1 5433.55 4036.61268 ? *> 10.0.2.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 ? 10.200.0.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 i 10.201.0.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 i The changes include: - the aspath structure has a new field: asnotation type The ashash list will differentiate 2 aspaths using a different asnotation. - 3 new printf extensions display the as number in the wished format: pASP, pASD, pASE for plain, dot, or dot+ format (extended). Signed-off-by: Philippe Guibert --- tests/bgpd/test_aspath.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/bgpd') diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c index 0f6d5b023d..8c173ea669 100644 --- a/tests/bgpd/test_aspath.c +++ b/tests/bgpd/test_aspath.c @@ -880,7 +880,7 @@ static struct aspath *make_aspath(const uint8_t *data, size_t len, int use32bit) s = stream_new(len); stream_put(s, data, len); } - as = aspath_parse(s, len, use32bit); + as = aspath_parse(s, len, use32bit, ASNOTATION_PLAIN); if (s) stream_free(s); @@ -925,7 +925,7 @@ static int validate(struct aspath *as, const struct test_spec *sp) as4 = make_aspath(STREAM_DATA(s), bytes4, 1); asn_relax_as_zero(true); - asstr = aspath_str2aspath(sp->shouldbe); + asstr = aspath_str2aspath(sp->shouldbe, ASNOTATION_PLAIN); asn_relax_as_zero(false); asconfeddel = aspath_delete_confed_seq(aspath_dup(asinout)); @@ -1103,7 +1103,7 @@ static void empty_prepend_test(struct test_segment *t) printf("empty prepend %s: %s\n", t->name, t->desc); asp1 = make_aspath(t->asdata, t->len, 0); - asp2 = aspath_empty(); + asp2 = aspath_empty(ASNOTATION_PLAIN); ascratch = aspath_dup(asp2); aspath_unintern(&asp2); -- cgit v1.2.3