return BGP_ATTR_PARSE_PROCEED;
/* Core attributes, particularly ones which may influence route
- * selection, should always cause session resets
+ * selection, should be treat-as-withdraw.
*/
case BGP_ATTR_ORIGIN:
case BGP_ATTR_AS_PATH:
case BGP_ATTR_MULTI_EXIT_DISC:
case BGP_ATTR_LOCAL_PREF:
case BGP_ATTR_COMMUNITIES:
+ case BGP_ATTR_EXT_COMMUNITIES:
+ case BGP_ATTR_LARGE_COMMUNITIES:
case BGP_ATTR_ORIGINATOR_ID:
case BGP_ATTR_CLUSTER_LIST:
+ return BGP_ATTR_PARSE_WITHDRAW;
case BGP_ATTR_MP_REACH_NLRI:
case BGP_ATTR_MP_UNREACH_NLRI:
- case BGP_ATTR_EXT_COMMUNITIES:
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, subcode,
notify_datap, length);
return BGP_ATTR_PARSE_ERROR;
&& aspath_confed_check(attr->aspath))) {
flog_err(EC_BGP_ATTR_MAL_AS_PATH, "Malformed AS path from %s",
peer->host);
- bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MAL_AS_PATH);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
/* First AS check for EBGP. */
flog_err(EC_BGP_ATTR_FIRST_AS,
"%s incorrect first AS (must be %u)",
peer->host, peer->as);
- bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MAL_AS_PATH);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
}
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Length check. */
- if (length != 4) {
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not equal to 4. If malformed, the
+ * UPDATE message SHALL be handled using the approach of "treat-as-
+ * withdraw".
+ */
+ if (peer->sort == BGP_PEER_IBGP && length != 4) {
flog_err(EC_BGP_ATTR_LEN,
"LOCAL_PREF attribute length isn't 4 [%u]", length);
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
int wantedlen = 6;
/* peer with AS4 will send 4 Byte AS, peer without will send 2 Byte */
- if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV))
+ if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV)
+ && CHECK_FLAG(peer->cap, PEER_CAP_AS4_ADV))
wantedlen = 8;
if (length != wantedlen) {
/* XXX: fix community_parse to use stream API and remove this */
stream_forward_getp(peer->curr, length);
+ /* The Community attribute SHALL be considered malformed if its
+ * length is not a non-zero multiple of 4.
+ */
if (!attr->community)
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
args->total);
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Length check. */
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not equal to 4. If malformed, the
+ * UPDATE message SHALL be handled using the approach of "treat-as-
+ * withdraw".
+ */
if (length != 4) {
flog_err(EC_BGP_ATTR_LEN, "Bad originator ID length %d",
length);
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Check length. */
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not a non-zero multiple of 4. If
+ * malformed, the UPDATE message SHALL be handled using the approach
+ * of "treat-as-withdraw".
+ */
if (length % 4) {
flog_err(EC_BGP_ATTR_LEN, "Bad cluster list length %d", length);
/* XXX: fix ecommunity_parse to use stream API */
stream_forward_getp(peer->curr, length);
+ /* The Extended Community attribute SHALL be considered malformed if
+ * its length is not a non-zero multiple of 8.
+ */
if (!attr->ecommunity)
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
args->total);
&& !CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
type = BGP_ATTR_LOCAL_PREF;
+ /* If any of the well-known mandatory attributes are not present
+ * in an UPDATE message, then "treat-as-withdraw" MUST be used.
+ */
if (type) {
flog_warn(EC_BGP_MISSING_ATTRIBUTE,
"%s Missing well-known attribute %s.", peer->host,
lookup_msg(attr_str, type, NULL));
- bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MISS_ATTR, &type,
- 1);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
return BGP_ATTR_PARSE_PROCEED;
}