#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[] = {
iana_safi_t pkt_safi;
safi_t safi;
char soft_version[BGP_MAX_SOFT_VERSION + 1] = {};
+ const char *capability;
end = pnt + length;
/* 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;
/* 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;
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) {
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;
}
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;
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;
}
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;
}