summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2011-09-30 15:08:54 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2011-10-17 19:02:55 +0400
commitd595b566bca1de8b026c469a31ae50f2aee11781 (patch)
tree1572e36687c8666c8f0c8519addc94f9d2c886af
parent566b36ebf903fd873c974ba34c19097d8fb48ce4 (diff)
bgpd: check ORIGINATOR_ID attribute flags
* bgp_attr.c * bgp_attr_originator_id(): accept extra argument, add checks for "optional", "transitive" and "partial" bits, log each error condition independently * bgp_attr_parse(): provide extra arguments
-rw-r--r--bgpd/bgp_attr.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index cda522a0..a3db9f15 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1353,8 +1353,24 @@ bgp_attr_community (struct peer *peer, bgp_size_t length,
/* Originator ID attribute. */
static bgp_attr_parse_ret_t
bgp_attr_originator_id (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 (flag != BGP_ATTR_FLAG_OPTIONAL)
+ {
+ if (! CHECK_FLAG (flag, BGP_ATTR_FLAG_OPTIONAL))
+ zlog (peer->log, LOG_ERR, "ORIGINATOR_ID attribute must be flagged as \"optional\" (%u)", flag);
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_TRANS))
+ zlog (peer->log, LOG_ERR, "ORIGINATOR_ID attribute must not be flagged as \"transitive\" (%u)", flag);
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_PARTIAL))
+ zlog (peer->log, LOG_ERR, "ORIGINATOR_ID 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 != 4)
{
zlog (peer->log, LOG_ERR, "Bad originator ID length %d", length);
@@ -1807,7 +1823,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
ret = bgp_attr_community (peer, length, attr, flag, startp);
break;
case BGP_ATTR_ORIGINATOR_ID:
- ret = bgp_attr_originator_id (peer, length, attr, flag);
+ ret = bgp_attr_originator_id (peer, length, attr, flag, startp);
break;
case BGP_ATTR_CLUSTER_LIST:
ret = bgp_attr_cluster_list (peer, length, attr, flag);