OK job@ On Sat, May 11, 2019 at 14:37 Claudio Jeker <cje...@diehard.n-r-g.com> wrote:
> bgpd already got support for extended shutdown communication messages. > This adds the same support to tcpdump. > > OK? > -- > :wq Claudio > > Index: print-bgp.c > =================================================================== > RCS file: /cvs/src/usr.sbin/tcpdump/print-bgp.c,v > retrieving revision 1.27 > diff -u -p -r1.27 print-bgp.c > --- print-bgp.c 28 Dec 2018 11:54:10 -0000 1.27 > +++ print-bgp.c 25 Apr 2019 08:20:27 -0000 > @@ -241,7 +241,7 @@ static const char *bgpnotify_minor_fsm[] > /* RFC 8203 */ > #define BGP_NOTIFY_MINOR_CEASE_SHUT 2 > #define BGP_NOTIFY_MINOR_CEASE_RESET 4 > -#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN 128 > +#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN 255 > static const char *bgpnotify_minor_cease[] = { > NULL, "Maximum Number of Prefixes Reached", "Administrative > Shutdown", > "Peer De-configured", "Administrative Reset", "Connection > Rejected", > @@ -982,14 +982,14 @@ bgp_notification_print(const u_char *dat > u_int16_t af; > u_int8_t safi; > const u_char *p; > - uint8_t shutdown_comm_length; > + size_t shutdown_comm_length; > char shutstring[BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1]; > > TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); > memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); > > /* sanity checking */ > - if (length<BGP_NOTIFICATION_SIZE) > + if (length < BGP_NOTIFICATION_SIZE) > return; > > printf(": error %s,", bgp_notify_major(bgpn.bgpn_major)); > @@ -1027,22 +1027,23 @@ bgp_notification_print(const u_char *dat > (length >= BGP_NOTIFICATION_SIZE + 1)) { > p = dat + BGP_NOTIFICATION_SIZE; > TCHECK2(*p, 1); > - shutdown_comm_length = *(p); > + shutdown_comm_length = *p; > > /* sanity checking */ > if (shutdown_comm_length == 0) > return; > if (shutdown_comm_length > > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN) > - return; > - if (length < (shutdown_comm_length + 1 + > BGP_NOTIFICATION_SIZE)) > - return; > + goto trunc; > + if (length < (shutdown_comm_length + 1 + > + BGP_NOTIFICATION_SIZE)) > + goto trunc; > TCHECK2(*(p+1), shutdown_comm_length); > > /* a proper shutdown communication */ > - printf(", Shutdown Communication [len %u]: \"", > + printf(", Shutdown Communication [len %zu]: \"", > shutdown_comm_length); > - memset(shutstring, 0, > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1); > + memset(shutstring, 0, sizeof(shutstring)); > memcpy(shutstring, p+1, shutdown_comm_length); > safeputs(shutstring); > printf("\""); > >