summaryrefslogtreecommitdiff
path: root/bgpd/bgp_attr.c
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2011-09-30 15:12:17 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2011-10-17 19:03:31 +0400
commit0b83044b91d7ea50824cfd803d77213b9ff38ed9 (patch)
treea18f7841fa039c1236ef5ea4770c0f0a5b81d3b1 /bgpd/bgp_attr.c
parentd595b566bca1de8b026c469a31ae50f2aee11781 (diff)
bgpd: check CLUSTER_LIST attribute flags
* bgp_attr.c * bgp_attr_cluster_list(): accept extra argument, add checks for "optional", "transitive" and "partial" bits, log each error condition independently * bgp_attr_parse(): provide extra arguments
Diffstat (limited to 'bgpd/bgp_attr.c')
-rw-r--r--bgpd/bgp_attr.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index a3db9f15..6dd14893 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1391,8 +1391,23 @@ bgp_attr_originator_id (struct peer *peer, bgp_size_t length,
/* Cluster list attribute. */
static bgp_attr_parse_ret_t
bgp_attr_cluster_list (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, "CLUSTER_LIST attribute must be flagged as \"optional\" (%u)", flag);
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_TRANS))
+ zlog (peer->log, LOG_ERR, "CLUSTER_LIST attribute must not be flagged as \"transitive\" (%u)", flag);
+ if (CHECK_FLAG (flag, BGP_ATTR_FLAG_PARTIAL))
+ zlog (peer->log, LOG_ERR, "CLUSTER_LIST 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;
+ }
/* Check length. */
if (length % 4)
{
@@ -1826,7 +1841,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
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);
+ ret = bgp_attr_cluster_list (peer, length, attr, flag, startp);
break;
case BGP_ATTR_MP_REACH_NLRI:
ret = bgp_mp_reach_parse (peer, length, attr, mp_update);