]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Convert bgp_open.c to use flog_warn
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 16 Aug 2018 13:29:23 +0000 (09:29 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 6 Sep 2018 20:50:58 +0000 (20:50 +0000)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_errors.c
bgpd/bgp_errors.h
bgpd/bgp_open.c

index 70cdf53bd42abfb9180c04badd3691c5da4385ce..6a0b0a9ee9926787a28ae4690484cf054db44f09 100644 (file)
@@ -157,6 +157,30 @@ static struct log_ref ferr_bgp_warn[] = {
                .description = "BGP has attempted to send data to zebra but has been unable to do so",
                .suggestion = "Gather log data, open an Issue and restart FRR"
        },
+       {
+               .code = BGP_WARN_CAPABILITY_INVALID_LENGTH,
+               .title = "BGP has received a capability with an invalid length",
+               .description = "BGP has received a capability from it's peer who's size is wrong",
+               .suggestion = "Gather log files from here and from peer and open an Issue",
+       },
+       {
+               .code = BGP_WARN_CAPABILITY_INVALID_DATA,
+               .title = "BGP has received capability data with invalid information",
+               .description = "BGP has noticed that during processing of capability information that data was wrong",
+               .suggestion = "Gather log files from here and from peer and open an Issue",
+       },
+       {
+               .code = BGP_WARN_CAPABILITY_VENDOR,
+               .title = "BGP has recieved capability data specific to a particular vendor",
+               .description = "BGP has received a capability that is vendor specific and as such we have no knowledge of how to use this capability in FRR",
+               .suggestion = "On peer turn off this feature"
+       },
+       {
+               .code = BGP_WARN_CAPABILITY_UNKNOWN,
+               .title = "BGP has received capability data for a unknown capability",
+               .description = "BGP has received a capability that it does not know how to decode.  This may be due to a new feature that has not been coded into FRR or it may be a bug in the remote peer",
+               .suggestion = "Gather log files from here and from peer and open an Issue",
+       },
        {
                .code = END_FERR,
        }
index 6accd442307736b9e31bbffcd1965654330eefc3..4de04f760e5d2deb096339df9fce14203de20126 100644 (file)
@@ -94,6 +94,10 @@ enum bgp_log_refs {
        BGP_WARN_EVPN_ESI,
        BGP_WARN_INVALID_LABEL_STACK,
        BGP_WARN_ZEBRA_SEND,
+       BGP_WARN_CAPABILITY_INVALID_LENGTH,
+       BGP_WARN_CAPABILITY_INVALID_DATA,
+       BGP_WARN_CAPABILITY_VENDOR,
+       BGP_WARN_CAPABILITY_UNKNOWN,
 };
 
 extern void bgp_error_init(void);
index 5bdee5f512fa572aef759088b9c88178e4660f48..2a32f02f42a31a3cab189afa67036326e2fffc92 100644 (file)
@@ -254,7 +254,8 @@ static int bgp_capability_mp(struct peer *peer, struct capability_header *hdr)
 
        /* Verify length is 4 */
        if (hdr->length != 4) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_LENGTH,
                        "MP Cap: Received invalid length %d, non-multiple of 4",
                        hdr->length);
                return -1;
@@ -449,7 +450,8 @@ static int bgp_capability_restart(struct peer *peer,
 
        /* Verify length is a multiple of 4 */
        if ((caphdr->length - 2) % 4) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_LENGTH,
                        "Restart Cap: Received invalid length %d, non-multiple of 4",
                        caphdr->length);
                return -1;
@@ -546,7 +548,8 @@ static int bgp_capability_addpath(struct peer *peer,
 
        /* Verify length is a multiple of 4 */
        if (hdr->length % 4) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_LENGTH,
                        "Add Path: Received invalid length %d, non-multiple of 4",
                        hdr->length);
                return -1;
@@ -604,7 +607,8 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr)
 
        /* Verify length is a multiple of 4 */
        if (hdr->length % 6) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_LENGTH,
                        "Extended NH: Received invalid length %d, non-multiple of 6",
                        hdr->length);
                return -1;
@@ -646,7 +650,8 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr)
                if (afi != AFI_IP || nh_afi != AFI_IP6
                    || !(safi == SAFI_UNICAST
                         || safi == SAFI_LABELED_UNICAST)) {
-                       zlog_warn(
+                       flog_warn(
+                               BGP_WARN_CAPABILITY_INVALID_DATA,
                                "%s Unexpected afi/safi/next-hop afi: %u/%u/%u "
                                "in Extended Next-hop capability, ignoring",
                                peer->host, pkt_afi, pkt_safi, pkt_nh_afi);
@@ -677,7 +682,8 @@ static int bgp_capability_hostname(struct peer *peer,
 
        len = stream_getc(s);
        if (stream_get_getp(s) + len > end) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_DATA,
                        "%s: Received malformed hostname capability from peer %s",
                        __FUNCTION__, peer->host);
                return -1;
@@ -707,7 +713,8 @@ static int bgp_capability_hostname(struct peer *peer,
        }
 
        if (stream_get_getp(s) + 1 > end) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_DATA,
                        "%s: Received invalid domain name len (hostname capability) from peer %s",
                        __FUNCTION__, peer->host);
                return -1;
@@ -715,7 +722,8 @@ static int bgp_capability_hostname(struct peer *peer,
 
        len = stream_getc(s);
        if (stream_get_getp(s) + len > end) {
-               zlog_warn(
+               flog_warn(
+                       BGP_WARN_CAPABILITY_INVALID_DATA,
                        "%s: Received runt domain name (hostname capability) from peer %s",
                        __FUNCTION__, peer->host);
                return -1;
@@ -952,10 +960,12 @@ static int bgp_capability_parse(struct peer *peer, size_t length,
                                   specific
                                   capabilities.  It seems reasonable for now...
                                   */
-                               zlog_warn("%s Vendor specific capability %d",
+                               flog_warn(BGP_WARN_CAPABILITY_VENDOR,
+                                         "%s Vendor specific capability %d",
                                          peer->host, caphdr.code);
                        } else {
-                               zlog_warn(
+                               flog_warn(
+                                       BGP_WARN_CAPABILITY_UNKNOWN,
                                        "%s unrecognized capability code: %d - ignored",
                                        peer->host, caphdr.code);
                                memcpy(*error, sp, caphdr.length + 2);
@@ -970,7 +980,8 @@ static int bgp_capability_parse(struct peer *peer, size_t length,
                }
                if (stream_get_getp(s) != (start + caphdr.length)) {
                        if (stream_get_getp(s) > (start + caphdr.length))
-                               zlog_warn(
+                               flog_warn(
+                                       BGP_WARN_CAPABILITY_INVALID_LENGTH,
                                        "%s Cap-parser for %s read past cap-length, %u!",
                                        peer->host,
                                        lookup_msg(capcode_str, caphdr.code,