diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2013-01-22 23:39:17 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2013-02-01 17:55:04 +0100 |
commit | 1cb9cf062ec3ed7a3f13fb5465eb5fb917ce3329 (patch) | |
tree | 4ca551c562d14cdd116155dba6aed6d9087c7f7d /tests | |
parent | bgpd: relax ORF capability length handling (diff) | |
download | frr-1cb9cf062ec3ed7a3f13fb5465eb5fb917ce3329.tar.xz frr-1cb9cf062ec3ed7a3f13fb5465eb5fb917ce3329.zip |
tests: update & extend AS_PATH tests
NB: these tests test for current implementation state, not for RFC
conformance. In particular, behaviour with confederations in AS4_PATH
as well as reconcilation of short AS_PATH + AS4_PATH is currently NOT
conforming to RFC 4893/6793.
* tests/aspath_test.c: add capability to put both AS4_PATH & AS_PATH,
add test for AS4_PATH w/o AS_PATH, update confederation test
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/aspath_test.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/tests/aspath_test.c b/tests/aspath_test.c index 9170455fb..7fdb5e221 100644 --- a/tests/aspath_test.c +++ b/tests/aspath_test.c @@ -443,6 +443,7 @@ static struct aspath_tests { const int cap; /* capabilities to set for peer */ const char attrheader [1024]; size_t len; + const struct test_segment *old_segment; } aspath_tests [] = { /* 0 */ @@ -590,10 +591,10 @@ static struct aspath_tests { }, /* 11 */ { - "4b AS_PATH: confed", + "4b AS4_PATH w/o AS_PATH", &test_segments[6], - "8466 3 52737 4096", - AS4_DATA, -1, + NULL, + AS4_DATA, 0, PEER_CAP_AS4_ADV, { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL, BGP_ATTR_AS4_PATH, @@ -601,6 +602,20 @@ static struct aspath_tests { }, 3, }, + /* 12 */ + { + "4b AS4_PATH: confed", + &test_segments[6], + "8466 3 52737 4096 (123 456 789)", + AS4_DATA, 0, + PEER_CAP_AS4_ADV, + { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL, + BGP_ATTR_AS4_PATH, + 14, + }, + 3, + &test_segments[0], + }, { NULL, NULL, NULL, 0, 0, 0, { 0 }, 0 }, }; @@ -1212,6 +1227,14 @@ handle_attr_test (struct aspath_tests *t) stream_write (peer.ibuf, t->attrheader, t->len); datalen = aspath_put (peer.ibuf, asp, t->as4 == AS4_DATA); + if (t->old_segment) + { + char dummyaspath[] = { BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, + t->old_segment->len }; + stream_write (peer.ibuf, dummyaspath, sizeof (dummyaspath)); + stream_write (peer.ibuf, t->old_segment->asdata, t->old_segment->len); + datalen += sizeof (dummyaspath) + t->old_segment->len; + } ret = bgp_attr_parse (&peer, &attr, t->len + datalen, NULL, NULL); @@ -1224,12 +1247,12 @@ handle_attr_test (struct aspath_tests *t) if (ret != 0) goto out; - if (attr.aspath == NULL) + if (t->shouldbe && attr.aspath == NULL) { - printf ("aspath is NULL!\n"); + printf ("aspath is NULL, but should be: %s\n", t->shouldbe); failed++; } - if (attr.aspath && strcmp (attr.aspath->str, t->shouldbe)) + if (t->shouldbe && attr.aspath && strcmp (attr.aspath->str, t->shouldbe)) { printf ("attr str and 'shouldbe' mismatched!\n" "attr str: %s\n" @@ -1237,6 +1260,11 @@ handle_attr_test (struct aspath_tests *t) attr.aspath->str, t->shouldbe); failed++; } + if (!t->shouldbe && attr.aspath) + { + printf ("aspath should be NULL, but is: %s\n", attr.aspath->str); + failed++; + } out: if (attr.aspath) |