mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 18:10:23 +00:00
bgpd: Use treat-as-withdraw for tunnel encapsulation attribute
Before this path we used session reset method, which is discouraged by rfc7606.
Handle this as rfc requires.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit bcb6b58d95
)
This commit is contained in:
parent
3c9e3f9640
commit
8a4a88c46d
@ -1416,6 +1416,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
|
|||||||
case BGP_ATTR_LARGE_COMMUNITIES:
|
case BGP_ATTR_LARGE_COMMUNITIES:
|
||||||
case BGP_ATTR_ORIGINATOR_ID:
|
case BGP_ATTR_ORIGINATOR_ID:
|
||||||
case BGP_ATTR_CLUSTER_LIST:
|
case BGP_ATTR_CLUSTER_LIST:
|
||||||
|
case BGP_ATTR_ENCAP:
|
||||||
case BGP_ATTR_OTC:
|
case BGP_ATTR_OTC:
|
||||||
return BGP_ATTR_PARSE_WITHDRAW;
|
return BGP_ATTR_PARSE_WITHDRAW;
|
||||||
case BGP_ATTR_MP_REACH_NLRI:
|
case BGP_ATTR_MP_REACH_NLRI:
|
||||||
@ -2644,26 +2645,21 @@ ipv6_ext_community_ignore:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse Tunnel Encap attribute in an UPDATE */
|
/* Parse Tunnel Encap attribute in an UPDATE */
|
||||||
static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
|
static int bgp_attr_encap(struct bgp_attr_parser_args *args)
|
||||||
bgp_size_t length, /* IN: attr's length field */
|
|
||||||
struct attr *attr, /* IN: caller already allocated */
|
|
||||||
uint8_t flag, /* IN: attr's flags field */
|
|
||||||
uint8_t *startp)
|
|
||||||
{
|
{
|
||||||
bgp_size_t total;
|
|
||||||
uint16_t tunneltype = 0;
|
uint16_t tunneltype = 0;
|
||||||
|
struct peer *const peer = args->peer;
|
||||||
total = length + (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
|
struct attr *const attr = args->attr;
|
||||||
|
bgp_size_t length = args->length;
|
||||||
|
uint8_t type = args->type;
|
||||||
|
uint8_t flag = args->flags;
|
||||||
|
|
||||||
if (!CHECK_FLAG(flag, BGP_ATTR_FLAG_TRANS)
|
if (!CHECK_FLAG(flag, BGP_ATTR_FLAG_TRANS)
|
||||||
|| !CHECK_FLAG(flag, BGP_ATTR_FLAG_OPTIONAL)) {
|
|| !CHECK_FLAG(flag, BGP_ATTR_FLAG_OPTIONAL)) {
|
||||||
zlog_info(
|
zlog_err("Tunnel Encap attribute flag isn't optional and transitive %d",
|
||||||
"Tunnel Encap attribute flag isn't optional and transitive %d",
|
flag);
|
||||||
flag);
|
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
|
args->total);
|
||||||
BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
|
|
||||||
startp, total);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BGP_ATTR_ENCAP == type) {
|
if (BGP_ATTR_ENCAP == type) {
|
||||||
@ -2671,12 +2667,11 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
|
|||||||
uint16_t tlv_length;
|
uint16_t tlv_length;
|
||||||
|
|
||||||
if (length < 4) {
|
if (length < 4) {
|
||||||
zlog_info(
|
zlog_err(
|
||||||
"Tunnel Encap attribute not long enough to contain outer T,L");
|
"Tunnel Encap attribute not long enough to contain outer T,L");
|
||||||
bgp_notify_send_with_data(
|
return bgp_attr_malformed(args,
|
||||||
peer, BGP_NOTIFY_UPDATE_ERR,
|
BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, startp, total);
|
args->total);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
tunneltype = stream_getw(BGP_INPUT(peer));
|
tunneltype = stream_getw(BGP_INPUT(peer));
|
||||||
tlv_length = stream_getw(BGP_INPUT(peer));
|
tlv_length = stream_getw(BGP_INPUT(peer));
|
||||||
@ -2706,13 +2701,11 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sublength > length) {
|
if (sublength > length) {
|
||||||
zlog_info(
|
zlog_err("Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d",
|
||||||
"Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d",
|
sublength, length);
|
||||||
sublength, length);
|
return bgp_attr_malformed(args,
|
||||||
bgp_notify_send_with_data(
|
BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
peer, BGP_NOTIFY_UPDATE_ERR,
|
args->total);
|
||||||
BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, startp, total);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alloc and copy sub-tlv */
|
/* alloc and copy sub-tlv */
|
||||||
@ -2760,13 +2753,10 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
|
|||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
/* spurious leftover data */
|
/* spurious leftover data */
|
||||||
zlog_info(
|
zlog_err("Tunnel Encap attribute length is bad: %d leftover octets",
|
||||||
"Tunnel Encap attribute length is bad: %d leftover octets",
|
length);
|
||||||
length);
|
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
|
args->total);
|
||||||
BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
|
||||||
startp, total);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -3690,8 +3680,7 @@ enum bgp_attr_parse_ret bgp_attr_parse(struct peer *peer, struct attr *attr,
|
|||||||
case BGP_ATTR_VNC:
|
case BGP_ATTR_VNC:
|
||||||
#endif
|
#endif
|
||||||
case BGP_ATTR_ENCAP:
|
case BGP_ATTR_ENCAP:
|
||||||
ret = bgp_attr_encap(type, peer, length, attr, flag,
|
ret = bgp_attr_encap(&attr_args);
|
||||||
startp);
|
|
||||||
break;
|
break;
|
||||||
case BGP_ATTR_PREFIX_SID:
|
case BGP_ATTR_PREFIX_SID:
|
||||||
ret = bgp_attr_prefix_sid(&attr_args);
|
ret = bgp_attr_prefix_sid(&attr_args);
|
||||||
|
Loading…
Reference in New Issue
Block a user