]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: check MULTI_EXIT_DISC attr flags (BZ#677)
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 20 Sep 2011 06:54:25 +0000 (10:54 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Sun, 25 Sep 2011 14:17:03 +0000 (18:17 +0400)
* bgp_attr.c
  * bgp_attr_med(): add checks for "optional", "transitive" and
    "partial" bits, log each error condition independently

bgpd/bgp_attr.c

index fe2d20e8b81b2fdccd5d29f819dec6b81353bae3..9b2c0162d10d99fc63ff87ecb4b239c9a7304958 100644 (file)
@@ -942,6 +942,38 @@ bgp_attr_med (struct peer *peer, bgp_size_t length,
 
   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,
+           "MULTI_EXIT_DISC attribute must 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,
+           "MULTI_EXIT_DISC attribute must not 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,
+           "MULTI_EXIT_DISC 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)
     {