summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-08-29 13:31:22 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2023-08-29 22:15:55 +0300
commit83ed05c7d3da27cdf4d67a72ea33dd9a1b51da91 (patch)
tree626399ffea251263fdd35e5cd7a11ed118db90b8
parentdccd9ab84858b593eeceaf5208a3f24fc283c90d (diff)
bgpd: Use zlog_err and not zlog_info when we have an error for dynamic capability
Also change the outputs a bit to be consistent and more detailed. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
-rw-r--r--bgpd/bgp_open.c33
-rw-r--r--bgpd/bgp_open.h1
-rw-r--r--bgpd/bgp_packet.c60
3 files changed, 47 insertions, 47 deletions
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 9cb88a2d6d..c7c91da74d 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -27,22 +27,23 @@
#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_memory.h"
-static const struct message capcode_str[] = {
- {CAPABILITY_CODE_MP, "MultiProtocol Extensions"},
- {CAPABILITY_CODE_REFRESH, "Route Refresh"},
- {CAPABILITY_CODE_ORF, "Cooperative Route Filtering"},
- {CAPABILITY_CODE_RESTART, "Graceful Restart"},
- {CAPABILITY_CODE_AS4, "4-octet AS number"},
- {CAPABILITY_CODE_ADDPATH, "AddPath"},
- {CAPABILITY_CODE_DYNAMIC, "Dynamic"},
- {CAPABILITY_CODE_ENHE, "Extended Next Hop Encoding"},
- {CAPABILITY_CODE_FQDN, "FQDN"},
- {CAPABILITY_CODE_ENHANCED_RR, "Enhanced Route Refresh"},
- {CAPABILITY_CODE_EXT_MESSAGE, "BGP Extended Message"},
- {CAPABILITY_CODE_LLGR, "Long-lived BGP Graceful Restart"},
- {CAPABILITY_CODE_ROLE, "Role"},
- {CAPABILITY_CODE_SOFT_VERSION, "Software Version"},
- {0}};
+const struct message capcode_str[] = {
+ { CAPABILITY_CODE_MP, "MultiProtocol Extensions" },
+ { CAPABILITY_CODE_REFRESH, "Route Refresh" },
+ { CAPABILITY_CODE_ORF, "Cooperative Route Filtering" },
+ { CAPABILITY_CODE_RESTART, "Graceful Restart" },
+ { CAPABILITY_CODE_AS4, "4-octet AS number" },
+ { CAPABILITY_CODE_ADDPATH, "AddPath" },
+ { CAPABILITY_CODE_DYNAMIC, "Dynamic" },
+ { CAPABILITY_CODE_ENHE, "Extended Next Hop Encoding" },
+ { CAPABILITY_CODE_FQDN, "FQDN" },
+ { CAPABILITY_CODE_ENHANCED_RR, "Enhanced Route Refresh" },
+ { CAPABILITY_CODE_EXT_MESSAGE, "BGP Extended Message" },
+ { CAPABILITY_CODE_LLGR, "Long-lived BGP Graceful Restart" },
+ { CAPABILITY_CODE_ROLE, "Role" },
+ { CAPABILITY_CODE_SOFT_VERSION, "Software Version" },
+ { 0 }
+};
/* Minimum sizes for length field of each cap (so not inc. the header) */
static const size_t cap_minsizes[] = {
diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h
index b18dbaa04f..20f5fdb22b 100644
--- a/bgpd/bgp_open.h
+++ b/bgpd/bgp_open.h
@@ -94,5 +94,6 @@ extern uint16_t bgp_open_capability(struct stream *s, struct peer *peer,
extern void bgp_capability_vty_out(struct vty *vty, struct peer *peer,
bool use_json, json_object *json_neigh);
extern as_t peek_for_as4_capability(struct peer *peer, uint16_t length);
+extern const struct message capcode_str[];
#endif /* _QUAGGA_BGP_OPEN_H */
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 01d73e9b07..8876c1df1b 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -2772,6 +2772,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
iana_safi_t pkt_safi;
safi_t safi;
char soft_version[BGP_MAX_SOFT_VERSION + 1] = {};
+ const char *capability;
end = pnt + length;
@@ -2779,7 +2780,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
/* We need at least action, capability code and capability
* length. */
if (pnt + 3 > end) {
- zlog_info("%s Capability length error", peer->host);
+ zlog_err("%pBP: Capability length error", peer);
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
@@ -2790,21 +2791,20 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
/* Action value check. */
if (action != CAPABILITY_ACTION_SET
&& action != CAPABILITY_ACTION_UNSET) {
- zlog_info("%s Capability Action Value error %d",
- peer->host, action);
+ zlog_err("%pBP: Capability Action Value error %d", peer,
+ action);
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
if (bgp_debug_neighbor_events(peer))
- zlog_debug(
- "%s CAPABILITY has action: %d, code: %u, length %u",
- peer->host, action, hdr->code, hdr->length);
+ zlog_debug("%pBP: CAPABILITY has action: %d, code: %u, length %u",
+ peer, action, hdr->code, hdr->length);
/* Capability length check. */
if ((pnt + hdr->length + 3) > end) {
- zlog_info("%s Capability length error", peer->host);
+ zlog_err("%pBP: Capability length error", peer);
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
@@ -2814,6 +2814,8 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
if (CHECK_FLAG(peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
continue;
+ capability = lookup_msg(capcode_str, hdr->code, "Unknown");
+
switch (hdr->code) {
case CAPABILITY_CODE_SOFT_VERSION:
if (action == CAPABILITY_ACTION_SET) {
@@ -2835,10 +2837,10 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
break;
case CAPABILITY_CODE_MP:
if (hdr->length < sizeof(struct capability_mp_data)) {
- zlog_info("%pBP Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d",
- peer,
- sizeof(struct capability_mp_data),
- hdr->length);
+ zlog_err("%pBP: Capability (%s) structure is not properly filled out, expected at least %zu bytes but header length specified is %d",
+ peer, capability,
+ sizeof(struct capability_mp_data),
+ hdr->length);
return BGP_Stop;
}
@@ -2850,24 +2852,22 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi,
&safi)) {
if (bgp_debug_neighbor_events(peer))
- zlog_debug(
- "%s Dynamic Capability MP_EXT afi/safi invalid (%s/%s)",
- peer->host,
- iana_afi2str(pkt_afi),
- iana_safi2str(pkt_safi));
+ zlog_debug("%pBP: Dynamic Capability %s afi/safi invalid (%s/%s)",
+ peer, capability,
+ iana_afi2str(pkt_afi),
+ iana_safi2str(pkt_safi));
continue;
}
/* Address family check. */
if (bgp_debug_neighbor_events(peer))
- zlog_debug(
- "%s CAPABILITY has %s MP_EXT CAP for afi/safi: %s/%s",
- peer->host,
- action == CAPABILITY_ACTION_SET
- ? "Advertising"
- : "Removing",
- iana_afi2str(pkt_afi),
- iana_safi2str(pkt_safi));
+ zlog_debug("%pBP: CAPABILITY has %s %s CAP for afi/safi: %s/%s",
+ peer,
+ action == CAPABILITY_ACTION_SET
+ ? "Advertising"
+ : "Removing",
+ capability, iana_afi2str(pkt_afi),
+ iana_safi2str(pkt_safi));
if (action == CAPABILITY_ACTION_SET) {
peer->afc_recv[afi][safi] = 1;
@@ -2900,9 +2900,8 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
break;
case CAPABILITY_CODE_ROLE:
if (hdr->length != CAPABILITY_CODE_ROLE_LEN) {
- flog_warn(EC_BGP_CAPABILITY_INVALID_LENGTH,
- "Role: Received invalid length %d",
- hdr->length);
+ zlog_err("%pBP: Capability (%s) length error",
+ peer, capability);
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
@@ -2920,10 +2919,9 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
}
break;
default:
- flog_warn(
- EC_BGP_UNRECOGNIZED_CAPABILITY,
- "%s unrecognized capability code: %d - ignored",
- peer->host, hdr->code);
+ flog_warn(EC_BGP_UNRECOGNIZED_CAPABILITY,
+ "%pBP: unrecognized capability code: %d - ignored",
+ peer, hdr->code);
break;
}