Browse Source

bgpd: make bgp_nlri_parse_encap conform with other nlri_parse funcs

* bgp_encap.{c,h} (bgp_nlri_parse_encap) afi is already in the NLRI argument.
  update or withdraw is signalled by attr being non-NULL or NULL.

* bgp_packet.c: (update_receive) fixup to match, and also make the attr
  argument conform with NLRI_ATTR_ARG for correct error handling on
  optional, transitive, partial, attributes.
Paul Jakma 3 years ago
parent
commit
c49a2747f6
3 changed files with 8 additions and 14 deletions
  1. 3 4
      bgpd/bgp_encap.c
  2. 1 6
      bgpd/bgp_encap.h
  3. 4 4
      bgpd/bgp_packet.c

+ 3 - 4
bgpd/bgp_encap.c

@@ -126,14 +126,13 @@ ecom2prd(struct ecommunity *ecom, struct prefix_rd *prd)
 
 int
 bgp_nlri_parse_encap(
-    afi_t		afi,
     struct peer		*peer,
     struct attr		*attr, 		/* Need even for withdraw */
-    struct bgp_nlri	*packet,
-    int			withdraw)	/* 0=update, !0 = withdraw */
+    struct bgp_nlri	*packet)
 {
   u_char *pnt;
   u_char *lim;
+  afi_t afi = packet->afi;
   struct prefix p;
   int psize = 0;
   int prefixlen;
@@ -227,7 +226,7 @@ bgp_nlri_parse_encap(
 	    inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
 	    p.prefixlen);
 
-      if (!withdraw) {
+      if (attr) {
 	bgp_update (peer, &p, attr, afi, SAFI_ENCAP,
 		    ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
       } else {

+ 1 - 6
bgpd/bgp_encap.h

@@ -23,12 +23,7 @@
 #define _QUAGGA_BGP_ENCAP_H
 
 extern void bgp_encap_init (void);
-extern int bgp_nlri_parse_encap (
-    afi_t,
-    struct peer *,
-    struct attr *,
-    struct bgp_nlri *,
-    int withdraw);
+extern int bgp_nlri_parse_encap (struct peer *, struct attr *, struct bgp_nlri *);
 
 #include "bgp_encap_types.h"
 #endif /* _QUAGGA_BGP_ENCAP_H */

+ 4 - 4
bgpd/bgp_packet.c

@@ -1943,12 +1943,12 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
       if (mp_update.length
 	  && mp_update.afi == AFI_IP
 	  && mp_update.safi == SAFI_ENCAP)
-	bgp_nlri_parse_encap (mp_update.afi, peer, &attr, &mp_update, 0);
+	bgp_nlri_parse_encap (peer, NLRI_ATTR_ARG, &mp_update);
 
       if (mp_withdraw.length
 	  && mp_withdraw.afi == AFI_IP
 	  && mp_withdraw.safi == SAFI_ENCAP)
-	bgp_nlri_parse_encap (mp_withdraw.afi, peer, &attr, &mp_withdraw, 1);
+	bgp_nlri_parse_encap (peer, NULL, &mp_withdraw);
 
       if (! withdraw_len
 	  && mp_withdraw.afi == AFI_IP
@@ -1967,12 +1967,12 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
       if (mp_update.length 
 	  && mp_update.afi == AFI_IP6 
 	  && mp_update.safi == SAFI_ENCAP)
-	bgp_nlri_parse_encap (mp_update.afi, peer, &attr, &mp_update, 0);
+	bgp_nlri_parse_encap (peer, NLRI_ATTR_ARG, &mp_update);
 
       if (mp_withdraw.length 
 	  && mp_withdraw.afi == AFI_IP6
 	  && mp_withdraw.safi == SAFI_ENCAP)
-	bgp_nlri_parse_encap (mp_withdraw.afi, peer, &attr, &mp_withdraw, 1);
+	bgp_nlri_parse_encap (peer, NULL, &mp_withdraw);
 
       if (! withdraw_len
 	  && mp_withdraw.afi == AFI_IP6