summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2011-09-20 14:43:50 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2011-09-25 18:17:24 +0400
commitca22cc4cc397dac8f3bf57eca516360085d44214 (patch)
treea3b604beff5f6bedfc128e49c8f48f6d713aeb11
parent7d25f1883f9a391ad16ec57c06ae71df616b00d8 (diff)
bgpd: check ATOMIC_AGGREGATE attr flags (BZ#678)
* bgp_attr.c * bgp_attr_atomic(): accept extra argument, add checks for "optional", "transitive" and "partial" bits, log each error condition independently * bgp_attr_parse(): provide extra argument
-rw-r--r--bgpd/bgp_attr.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 9b2c0162..989c22b1 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1047,8 +1047,44 @@ bgp_attr_local_pref (struct peer *peer, bgp_size_t length,
/* Atomic aggregate. */
static int
bgp_attr_atomic (struct peer *peer, bgp_size_t length,
- struct attr *attr, u_char flag)
+ struct attr *attr, u_char flag, u_char *startp)
{
+ bgp_size_t total;
+
+ total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
+ /* Flag checks. */
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
+ {
+ zlog (peer->log, LOG_ERR,
+ "ATOMIC_AGGREGATE attribute must not be flagged as \"optional\" (%u)", flag);
+ bgp_notify_send_with_data (peer,
+ BGP_NOTIFY_UPDATE_ERR,
+ BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
+ startp, total);
+ return -1;
+ }
+ if (! CHECK_FLAG (flag, BGP_ATTR_FLAG_TRANS))
+ {
+ zlog (peer->log, LOG_ERR,
+ "ATOMIC_AGGREGATE attribute must be flagged as \"transitive\" (%u)", flag);
+ bgp_notify_send_with_data (peer,
+ BGP_NOTIFY_UPDATE_ERR,
+ BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
+ startp, total);
+ return -1;
+ }
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_PARTIAL))
+ {
+ zlog (peer->log, LOG_ERR,
+ "ATOMIC_AGGREGATE attribute must not be flagged as \"partial\" (%u)", flag);
+ bgp_notify_send_with_data (peer,
+ BGP_NOTIFY_UPDATE_ERR,
+ BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
+ startp, total);
+ return -1;
+ }
+
+ /* Length check. */
if (length != 0)
{
zlog (peer->log, LOG_ERR, "Bad atomic aggregate length %d", length);
@@ -1704,7 +1740,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
ret = bgp_attr_local_pref (peer, length, attr, flag, startp);
break;
case BGP_ATTR_ATOMIC_AGGREGATE:
- ret = bgp_attr_atomic (peer, length, attr, flag);
+ ret = bgp_attr_atomic (peer, length, attr, flag, startp);
break;
case BGP_ATTR_AGGREGATOR:
ret = bgp_attr_aggregator (peer, length, attr, flag);