summaryrefslogtreecommitdiff
path: root/bgpd/bgp_dump.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@nvidia.com>2021-04-27 16:20:27 -0400
committerQuentin Young <qlyoung@nvidia.com>2021-05-06 11:54:02 -0400
commit556beacf106ac75043f63d4e10d5d3046f1d2163 (patch)
tree58fad225b1074538fa806e992e81e6e00ea49c55 /bgpd/bgp_dump.c
parent38861dab3c6825c65fefc351a1cc3b8b398cbc87 (diff)
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 'bgpd/bgp_dump.c')
-rw-r--r--bgpd/bgp_dump.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 944a5848ec..299ee305be 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -389,7 +389,8 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
bgp_dump_routes_attr(obuf, path->attr, p);
cur_endp = stream_get_endp(obuf);
- if (cur_endp > BGP_MAX_PACKET_SIZE + BGP_DUMP_MSG_HEADER
+ if (cur_endp > BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE
+ + BGP_DUMP_MSG_HEADER
+ BGP_DUMP_HEADER_SIZE) {
stream_set_endp(obuf, endp);
break;
@@ -868,8 +869,8 @@ void bgp_dump_init(void)
memset(&bgp_dump_routes, 0, sizeof(struct bgp_dump));
bgp_dump_obuf =
- stream_new((BGP_MAX_PACKET_SIZE << 1) + BGP_DUMP_MSG_HEADER
- + BGP_DUMP_HEADER_SIZE);
+ stream_new((BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE * 2)
+ + BGP_DUMP_MSG_HEADER + BGP_DUMP_HEADER_SIZE);
install_node(&bgp_dump_node);