Browse Source

bgpd: malformed attribute handling: don't pass on, and add missing notify

* bgpd/bgp_attr.c: (bgp_attr_malformed) A malformed attribute should
  never be passed on, even if we proceed with parsing the UPDATE.
  The default reset case should send the NOTIFY itself, so the given subcode
  is used.
Paul Jakma 7 years ago
parent
commit
409e437a7a
1 changed files with 9 additions and 2 deletions
  1. 9 2
      bgpd/bgp_attr.c

+ 9 - 2
bgpd/bgp_attr.c

@@ -897,7 +897,7 @@ bgp_attr_flush (struct attr *attr)
     }
 }
 
-/* Implement draft-scudder-idr-optional-transitive behaviour and
+/* Implement some draft-ietf-idr-error-handling behaviour and
  * avoid resetting sessions for malformed attributes which are
  * are partial/optional and hence where the error likely was not
  * introduced by the sending neighbour.
@@ -914,6 +914,11 @@ bgp_attr_malformed (struct bgp_attr_parser_args *args, u_char subcode,
    */
   u_char *notify_datap = (length > 0 ? args->startp : NULL);
   
+  /* The malformed attribute shouldn't be passed on, should
+   * we decide to proceed with parsing the UPDATE
+   */
+  UNSET_FLAG (args->attr->flag,  ATTR_FLAG_BIT (args->type));
+  
   /* Only relax error handling for eBGP peers */
   if (peer->sort != BGP_PEER_EBGP)
     {
@@ -970,7 +975,9 @@ bgp_attr_malformed (struct bgp_attr_parser_args *args, u_char subcode,
     return BGP_ATTR_PARSE_WITHDRAW;
   
   /* default to reset */
-  return BGP_ATTR_PARSE_ERROR_NOTIFYPLS;
+  bgp_notify_send_with_data (peer, BGP_NOTIFY_UPDATE_ERR, subcode,
+                             notify_datap, length);
+  return BGP_ATTR_PARSE_ERROR;
 }
 
 /* Find out what is wrong with the path attribute flag bits and log the error.