From: Denis Ovsienko Date: Sat, 12 Feb 2022 17:46:03 +0000 (+0000) Subject: BGP: Refine the previous commit. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/25e38f8a2a9f61cf752c0a4a8e1814cb065f6f23 BGP: Refine the previous commit. Fix references in some comments, reduce scope of a couple variables, lose an excess ND_TCHECK_LEN() before nd_printjn() and update the change log. --- diff --git a/CHANGES b/CHANGES index dec9d64f..7f0646d3 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Monthday, Month DD, YYYY by gharris and denis VQP: Do not print unknown error codes twice. ZMTP: Replace custom code with bittok2str(). BFD: Add support for S-BFD and spell LAG in uppercase. + BGP: Update cease notification decoding to RFC 9003. User interface: Add --print-sampling to print every Nth packet instead of all. Source code: diff --git a/print-bgp.c b/print-bgp.c index f5c3dfad..ba927e4b 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -273,9 +273,8 @@ static const struct tok bgp_notify_major_values[] = { { 0, NULL} }; -/* draft-ietf-idr-cease-subcode-02 */ +/* RFC 4486 */ #define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1 -/* draft-ietf-idr-shutdown-07 */ #define BGP_NOTIFY_MINOR_CEASE_SHUT 2 #define BGP_NOTIFY_MINOR_CEASE_RESET 4 static const struct tok bgp_notify_minor_cease_values[] = { @@ -2939,8 +2938,6 @@ bgp_notification_print(netdissect_options *ndo, const struct bgp_notification *bgp_notification_header; const u_char *tptr; uint8_t bgpn_major, bgpn_minor; - uint8_t shutdown_comm_length; - uint8_t remainder_offset; ND_TCHECK_LEN(dat, BGP_NOTIFICATION_SIZE); if (length= BGP_NOTIFICATION_SIZE + 7) { @@ -3006,15 +3003,15 @@ bgp_notification_print(netdissect_options *ndo, GET_BE_U_4(tptr + 3)); } /* - * draft-ietf-idr-shutdown describes a method to send a communication + * RFC 9003 describes a method to send a communication * intended for human consumption regarding the Administrative Shutdown */ if ((bgpn_minor == BGP_NOTIFY_MINOR_CEASE_SHUT || bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) && length >= BGP_NOTIFICATION_SIZE + 1) { tptr = dat + BGP_NOTIFICATION_SIZE; - shutdown_comm_length = GET_U_1(tptr); - remainder_offset = 0; + uint8_t shutdown_comm_length = GET_U_1(tptr); + uint8_t remainder_offset = 0; /* garbage, hexdump it all */ if (shutdown_comm_length > length - (BGP_NOTIFICATION_SIZE + 1)) { ND_PRINT(", invalid Shutdown Communication length"); @@ -3025,7 +3022,6 @@ bgp_notification_print(netdissect_options *ndo, } /* a proper shutdown communication */ else { - ND_TCHECK_LEN(tptr + 1, shutdown_comm_length); ND_PRINT(", Shutdown Communication (length: %u): \"", shutdown_comm_length); nd_printjn(ndo, tptr+1, shutdown_comm_length); ND_PRINT("\"");