diff options
author | Quentin Young <qlyoung@nvidia.com> | 2021-04-27 22:20:27 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@nvidia.com> | 2021-05-06 17:54:02 +0200 |
commit | 556beacf106ac75043f63d4e10d5d3046f1d2163 (patch) | |
tree | 58fad225b1074538fa806e992e81e6e00ea49c55 /tests/bgpd | |
parent | Merge pull request #8638 from ton31337/fix/bgp_doc (diff) | |
download | frr-556beacf106ac75043f63d4e10d5d3046f1d2163.tar.xz frr-556beacf106ac75043f63d4e10d5d3046f1d2163.zip |
bgpd: rework BGP_MAX_PACKET_SIZE & friends
BGP_MAX_PACKET_SIZE no longer represented the absolute maximum BGP
packet size as it did before, instead it was defined as 4096 bytes,
which is the maximum unless extended message capability is negotiated,
in which case the maximum goes to 65k.
That introduced at least one bug - last_reset_cause was undersized for
extended messages, and when sending an extended message > 4096 bytes
back to a peer as part of NOTIFY data would trigger a bounds check
assert.
This patch redefines the macro to restore its previous meaning,
introduces a new macro - BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE - to
represent the 4096 byte size, and renames the extended size to
BGP_EXTENDED_MESSAGE_MAX_PACKET_SIZE for consistency. Code locations
that definitely should use the small size have been updated, locations
that semantically always need whatever the max is, no matter what that
is, use BGP_MAX_PACKET_SIZE.
BGP_EXTENDED_MESSAGE_MAX_PACKET_SIZE should only be used as a constant
when storing what the negotiated max size is for use at runtime and to
define BGP_MAX_PACKET_SIZE. Unless there is a future standard that
introduces a third valid size it should not be used for any other
purpose.
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'tests/bgpd')
-rw-r--r-- | tests/bgpd/test_aspath.c | 6 | ||||
-rw-r--r-- | tests/bgpd/test_capability.c | 2 | ||||
-rw-r--r-- | tests/bgpd/test_mp_attr.c | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c index 1a9183c47..aaf3fd2aa 100644 --- a/tests/bgpd/test_aspath.c +++ b/tests/bgpd/test_aspath.c @@ -892,7 +892,7 @@ static int validate(struct aspath *as, const struct test_spec *sp) /* Excercise AS4 parsing a bit, with a dogfood test */ if (!s) - s = stream_new(BGP_MAX_EXTENDED_MESSAGE_PACKET_SIZE); + s = stream_new(BGP_MAX_PACKET_SIZE); bytes4 = aspath_put(s, as, 1); as4 = make_aspath(STREAM_DATA(s), bytes4, 1); @@ -1201,13 +1201,13 @@ static int handle_attr_test(struct aspath_tests *t) asp = make_aspath(t->segment->asdata, t->segment->len, 0); - peer.curr = stream_new(BGP_MAX_EXTENDED_MESSAGE_PACKET_SIZE); + peer.curr = stream_new(BGP_MAX_PACKET_SIZE); peer.obuf = stream_fifo_new(); peer.bgp = &bgp; peer.host = (char *)"none"; peer.fd = -1; peer.cap = t->cap; - peer.max_packet_size = BGP_MAX_PACKET_SIZE; + peer.max_packet_size = BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE; stream_write(peer.curr, t->attrheader, t->len); datalen = aspath_put(peer.curr, asp, t->as4 == AS4_DATA); diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c index 91c0cce80..153b83897 100644 --- a/tests/bgpd/test_capability.c +++ b/tests/bgpd/test_capability.c @@ -935,7 +935,7 @@ int main(void) peer->afc_adv[i][j] = 1; } - peer->curr = stream_new(BGP_MAX_EXTENDED_MESSAGE_PACKET_SIZE); + peer->curr = stream_new(BGP_MAX_PACKET_SIZE); i = 0; while (mp_segments[i].name) diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c index 8de0604c4..f51076091 100644 --- a/tests/bgpd/test_mp_attr.c +++ b/tests/bgpd/test_mp_attr.c @@ -1100,7 +1100,7 @@ int main(void) peer = peer_create_accept(bgp); peer->host = (char *)"foo"; peer->status = Established; - peer->curr = stream_new(BGP_MAX_EXTENDED_MESSAGE_PACKET_SIZE); + peer->curr = stream_new(BGP_MAX_PACKET_SIZE); ifp.ifindex = 0; peer->nexthop.ifp = &ifp; |