summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2011-10-12 13:54:21 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2011-10-12 13:59:09 +0400
commita5b228b3792937c93b589938a2545b9311b7938e (patch)
tree59c22c60531b0fe2a4ceeb0d8cc1070af1312a9d
parent21cc76941abc60b5b5ece0a71ace0b69d6f4572c (diff)
bgpd: fix regression in improved attr flag checks
Commit 2febf323411c1aed9d7694898f852ce2ef36a7e5 assumed every flag bit except optional/transitive/partial unset, which at times could not be true for "extended length" bit. * bgp_attr.c * bgp_attr_origin(): exclude BGP_ATTR_FLAG_EXTLEN from comparison * bgp_attr_nexthop(): idem * bgp_attr_med(): idem * bgp_attr_local_pref(): idem * bgp_attr_atomic(): idem
-rw-r--r--bgpd/bgp_attr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 5c3d153a..cda522a0 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -773,7 +773,7 @@ bgp_attr_origin (struct peer *peer, bgp_size_t length,
with the Attribute Type Code, then the Error Subcode is set to
Attribute Flags Error. The Data field contains the erroneous
attribute (type, length and value). */
- if (flag != BGP_ATTR_FLAG_TRANS)
+ if ((flag & ~BGP_ATTR_FLAG_EXTLEN) != BGP_ATTR_FLAG_TRANS)
{
if (CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
zlog (peer->log, LOG_ERR, "ORIGIN attribute must not be flagged as \"optional\" (%u)", flag);
@@ -980,7 +980,7 @@ bgp_attr_nexthop (struct peer *peer, bgp_size_t length,
total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
/* Flags check. */
- if (flag != BGP_ATTR_FLAG_TRANS)
+ if ((flag & ~BGP_ATTR_FLAG_EXTLEN) != BGP_ATTR_FLAG_TRANS)
{
if (CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
zlog (peer->log, LOG_ERR, "NEXT_HOP attribute must not be flagged as \"optional\" (%u)", flag);
@@ -1035,7 +1035,7 @@ bgp_attr_med (struct peer *peer, bgp_size_t length,
total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
/* Flag checks. */
- if (flag != BGP_ATTR_FLAG_OPTIONAL)
+ if ((flag & ~BGP_ATTR_FLAG_EXTLEN) != BGP_ATTR_FLAG_OPTIONAL)
{
if (! CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
zlog (peer->log, LOG_ERR, "MULTI_EXIT_DISC attribute must be flagged as \"optional\" (%u)", flag);
@@ -1074,7 +1074,7 @@ bgp_attr_local_pref (struct peer *peer, bgp_size_t length,
total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
/* Flag checks. */
- if (flag != BGP_ATTR_FLAG_TRANS)
+ if ((flag & ~BGP_ATTR_FLAG_EXTLEN) != BGP_ATTR_FLAG_TRANS)
{
if (CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
zlog (peer->log, LOG_ERR, "LOCAL_PREF attribute must not be flagged as \"optional\" (%u)", flag);
@@ -1122,7 +1122,7 @@ bgp_attr_atomic (struct peer *peer, bgp_size_t length,
total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
/* Flag checks. */
- if (flag != BGP_ATTR_FLAG_TRANS)
+ if ((flag & ~BGP_ATTR_FLAG_EXTLEN) != BGP_ATTR_FLAG_TRANS)
{
if (CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
zlog (peer->log, LOG_ERR, "ATOMIC_AGGREGATE attribute must not be flagged as \"optional\" (%u)", flag);