]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
If no NLRI's are present in an UPDATE message, parse the attributes, but
authorMartin Mares <mj@ucw.cz>
Fri, 21 Apr 2000 12:25:35 +0000 (12:25 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 21 Apr 2000 12:25:35 +0000 (12:25 +0000)
don't check presence of mandatory attributes. [draft-09]

proto/bgp/attrs.c
proto/bgp/bgp.h
proto/bgp/packets.c

index fa2649c5dee17d4c66fdffd824c2b6f487b19855..f7d7b788028a63a56880f0b7e2e3e34e2ba98136 100644 (file)
@@ -676,7 +676,7 @@ bgp_path_loopy(struct bgp_proto *p, eattr *a)
 }
 
 struct rta *
-bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct linpool *pool)
+bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct linpool *pool, int mandatory)
 {
   struct bgp_proto *bgp = conn->bgp;
   rta *a = lp_alloc(pool, sizeof(struct rta));
@@ -800,13 +800,16 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
     }
 
   /* Check if all mandatory attributes are present */
-  for(i=0; i < sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
+  if (mandatory)
     {
-      code = bgp_mandatory_attrs[i];
-      if (!(seen[code/8] & (1 << (code%8))))
+      for(i=0; i < sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
        {
-         bgp_error(conn, 3, 3, code, 1);
-         return NULL;
+         code = bgp_mandatory_attrs[i];
+         if (!(seen[code/8] & (1 << (code%8))))
+           {
+             bgp_error(conn, 3, 3, code, 1);
+             return NULL;
+           }
        }
     }
 
@@ -831,7 +834,7 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
   neigh = neigh_find(&bgp->p, &nexthop, 0) ? : bgp->neigh;
   a->gw = neigh->addr;
   a->iface = neigh->iface;
-  return rta_lookup(a);
+  return a;
 
 malformed:
   bgp_error(conn, 3, 1, len, 0);
index f579ce66fc5866262efa880d4d8cc65d8b69d922..b8e1abcf4a0104fd7ba3b37584205f7df42842ef 100644 (file)
@@ -94,7 +94,7 @@ void bgp_close_conn(struct bgp_conn *c);
 
 /* attrs.c */
 
-struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool);
+struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool, int mandatory);
 int bgp_get_attr(struct eattr *e, byte *buf);
 int bgp_rte_better(struct rte *, struct rte *);
 void bgp_rt_notify(struct proto *, struct network *, struct rte *, struct rte *, struct ea_list *);
index bec2e5014ff2ba764718968eec71485e2df6c8c6..ccaa91c1fadc88964a8a05d5faba591692235391 100644 (file)
@@ -305,6 +305,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
   int withdrawn_len, attr_len, nlri_len, pxlen;
   net *n;
   rte e;
+  rta *a0;
   rta *a = NULL;
 
   DBG("BGP: UPDATE\n");
@@ -341,11 +342,10 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
        rte_update(bgp->p.table, n, &bgp->p, NULL);
     }
 
-  if (nlri_len)
+  a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, nlri_len);
+  if (a0 && nlri_len)
     {
-      a = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool);
-      if (!a)
-       return;
+      a = rta_lookup(a0);
       while (nlri_len)
        {
          rte *e;
@@ -357,9 +357,9 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len)
          e->pflags = 0;
          rte_update(bgp->p.table, n, &bgp->p, e);
        }
-      lp_flush(bgp_linpool);
       rta_free(a);
     }
+  lp_flush(bgp_linpool);
   return;
 
 malformed: