]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Patch from Andreas Steinmetz <ast@domdv.de>
authorOndrej Filip <feela@network.cz>
Tue, 1 Jun 2004 13:12:10 +0000 (13:12 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 1 Jun 2004 13:12:10 +0000 (13:12 +0000)
proto/ospf/hello.c
proto/ospf/iface.c
proto/ospf/lsack.c
proto/ospf/lsalib.c
proto/ospf/lsreq.c
proto/ospf/lsupd.c
proto/ospf/neighbor.c
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/topology.c
proto/ospf/topology.h

index b87b5ca66ab2e72fea043e020b850ba89d201580..e6dc7ab177fa14832330da2dc735c6faf69143fb 100644 (file)
@@ -19,7 +19,7 @@ install_inactim(struct ospf_neighbor *n)
 
   if(n->inactim==NULL)
   {
-    n->inactim=tm_new(p->pool);
+    n->inactim=tm_new(n->pool);
     n->inactim->data=n;
     n->inactim->randomize=0;
     n->inactim->hook=neighbor_timer_hook;
@@ -64,6 +64,7 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
   ip_addr mask;
   char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
   int eligible=0;
+  pool *pool;
 
   nrid=ntohl(((struct ospf_packet *)ps)->routerid);
 
@@ -130,7 +131,9 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
     }
     OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s.", faddr,
       ifa->iface->name);
-    n=mb_allocz(p->pool, sizeof(struct ospf_neighbor));
+    pool=rp_new(p->pool, "OSPF Neighbor");
+    n=mb_allocz(pool, sizeof(struct ospf_neighbor));
+    n->pool=pool;
     add_tail(&ifa->neigh_list, NODE n);
     n->rid=nrid;
     n->ip=faddr;
@@ -142,23 +145,23 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
     n->options=ps->options;
     n->ifa=ifa;
     n->adj=0;
-    n->ldbdes=mb_alloc(p->pool, ifa->iface->mtu);
+    n->ldbdes=mb_alloc(pool, ifa->iface->mtu);
     n->state=NEIGHBOR_DOWN;
     install_inactim(n);
-    n->rxmt_timer=tm_new(p->pool);
+    n->rxmt_timer=tm_new(pool);
     n->rxmt_timer->data=n;
     n->rxmt_timer->randomize=0;
     n->rxmt_timer->hook=rxmt_timer_hook;
     n->rxmt_timer->recurrent=ifa->rxmtint;
     DBG("%s: Installing rxmt timer.\n", p->name);
-    n->lsrr_timer=tm_new(p->pool);
+    n->lsrr_timer=tm_new(pool);
     n->lsrr_timer->data=n;
     n->lsrr_timer->randomize=0;
     n->lsrr_timer->hook=lsrr_timer_hook;
     n->lsrr_timer->recurrent=ifa->rxmtint;
     DBG("%s: Installing lsrr timer.\n", p->name);
     init_list(&n->ackl);
-    n->ackd_timer=tm_new(p->pool);
+    n->ackd_timer=tm_new(pool);
     n->ackd_timer->data=n;
     n->ackd_timer->randomize=0;
     n->ackd_timer->hook=ackd_timer_hook;
index 83f6ac309d09ef3320973d8d32cb7106a402f003..f2b0d31011ab8d35bf40cebc6d31821034457c05 100644 (file)
@@ -70,6 +70,10 @@ iface_chstate(struct ospf_iface *ifa, u8 state)
       {
         if(ifa->dr_sk!=NULL)
        {
+          if (ifa->dr_sk->rbuf)
+            mb_free(ifa->dr_sk->rbuf);
+          if (ifa->dr_sk->tbuf)
+            mb_free(ifa->dr_sk->tbuf);
          rfree(ifa->dr_sk);
          ifa->dr_sk=NULL;
        }
@@ -103,14 +107,26 @@ downint(struct ospf_iface *ifa)
   rem_node(NODE ifa);
   if(ifa->hello_sk!=NULL)
   {
+    if (ifa->hello_sk->rbuf)
+      mb_free(ifa->hello_sk->rbuf);
+    if (ifa->hello_sk->tbuf)
+      mb_free(ifa->hello_sk->tbuf);
     rfree(ifa->hello_sk);
   }
   if(ifa->dr_sk!=NULL)
   {
+    if (ifa->dr_sk->rbuf)
+      mb_free(ifa->dr_sk->rbuf);
+    if (ifa->dr_sk->tbuf)
+      mb_free(ifa->dr_sk->tbuf);
     rfree(ifa->dr_sk);
   }
   if(ifa->ip_sk!=NULL)
   {
+    if (ifa->ip_sk->rbuf)
+      mb_free(ifa->ip_sk->rbuf);
+    if (ifa->ip_sk->tbuf)
+      mb_free(ifa->ip_sk->tbuf);
     rfree(ifa->ip_sk);
   }
   if(ifa->wait_timer!=NULL)
index 51183ddcf973970cc0a16db61e99f457e709caf6..4b5f3b918fae744db8f11f272ddcd8f48ae45ca5 100644 (file)
@@ -40,7 +40,7 @@ ospf_lsa_delay(struct ospf_neighbor *n,struct ospf_lsa_header *h,
 {
   struct lsah_n *no;
 
-  no=mb_alloc(p->pool,sizeof(struct lsah_n));
+  no=mb_alloc(n->pool,sizeof(struct lsah_n));
   memcpy(&no->lsa,h,sizeof(struct ospf_lsa_header));
   add_tail(&n->ackl, NODE no);
   DBG("Adding delay ack for %I, ID: %I, RT: %I, Type: %u\n",n->rid,
@@ -213,6 +213,8 @@ ospf_lsack_rx(struct ospf_lsack_packet *ps, struct proto *p,
     DBG("Deleting LS Id: %I RT: %I Type: %u from LS Retl for neighbor %I\n",
       lsa.id,lsa.rt,lsa.type,n->rid);
     s_rem_node(SNODE en);
+    if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+    en->lsa_body=NULL;
     ospf_hash_delete(n->lsrth,en);
   }  
 }
index c12c5bdee158523400cf593bb45c414775eb00c3..1e97709655be35a4748a25a2be0b754c85cbce7d 100644 (file)
@@ -15,6 +15,8 @@ flush_lsa(struct top_hash_entry *en, struct ospf_area *oa)
   OSPF_TRACE(D_EVENTS, "Going to remove node Type: %u, Id: %I, Rt: %I, Age: %u",
     en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.age);
   s_rem_node(SNODE en);
+  if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+  en->lsa_body=NULL;
   ospf_hash_delete(oa->gr,en);
 }
 
index 4951c844f9204efbd100cc996d05dcb9c92da750..5d387eee5434dc520cecf7cbaa751617b611a6ed 100644 (file)
@@ -82,7 +82,7 @@ lsrr_timer_hook(timer *timer)
       struct l_lsr_head *llsh;
 
       init_list(&uplist);
-      upslab=sl_new(p->pool,sizeof(struct l_lsr_head));
+      upslab=sl_new(n->pool,sizeof(struct l_lsr_head));
 
       WALK_SLIST(SNODE en,n->lsrtl)
       {
@@ -132,7 +132,7 @@ ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
   length=ntohs(ps->ospf_packet.length);
   lsh=(void *)(ps+1);
   init_list(&uplist);
-  upslab=sl_new(p->pool,sizeof(struct l_lsr_head));
+  upslab=sl_new(n->pool,sizeof(struct l_lsr_head));
 
   lsano=(length-sizeof(struct ospf_lsreq_packet))/
     sizeof(struct ospf_lsreq_header);
index d1c2078825f58f59cd5f781de3ef1b95ffe66560..a8896d649cdc97dec1d541f4f64fe14c4e64ca2e 100644 (file)
@@ -55,6 +55,8 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
              break;
            case CMP_SAME:
               s_rem_node(SNODE en);
+              if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+              en->lsa_body=NULL;
              DBG("Removing from lsreq list for neigh %I\n", nn->rid);
              ospf_hash_delete(nn->lsrqh,en);
              if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE);
@@ -62,6 +64,8 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
              break;
            case CMP_NEWER:
               s_rem_node(SNODE en);
+              if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+              en->lsa_body=NULL;
              DBG("Removing from lsreq list for neigh %I\n", nn->rid);
              ospf_hash_delete(nn->lsrqh,en);
              if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE);
@@ -91,6 +95,8 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
         if((en=ospf_hash_find_header(nn->lsrth, hh))!=NULL)
         {
           s_rem_node(SNODE en);
+          if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+          en->lsa_body=NULL;
           ospf_hash_delete(nn->lsrth, en);
         }
       }
@@ -416,6 +422,8 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
               if((en=ospf_hash_find_header(ntmp->lsrth,&lsadb->lsa))!=NULL)
               {
                 s_rem_node(SNODE en);
+                if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+                en->lsa_body=NULL;
                 ospf_hash_delete(ntmp->lsrth,en);
               }
           }
@@ -448,6 +456,8 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
       if((en=ospf_hash_find_header(n->lsrth,&lsadb->lsa))!=NULL)
       {
         s_rem_node(SNODE en);
+        if(en->lsa_body!=NULL) mb_free(en->lsa_body);
+        en->lsa_body=NULL;
         ospf_hash_delete(n->lsrth, en);
         if(ifa->state==OSPF_IS_BACKUP)
         {
index 785e3bcaa39243493ee467680ed5ca2f9fc9165c..f2bb636ac66dd8b134fc7bc4751fb5e4f302c003 100644 (file)
@@ -261,10 +261,19 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
       if(n->state==NEIGHBOR_EXSTART)
       {
         neigh_chstate(n,NEIGHBOR_EXCHANGE);
+        while(!EMPTY_LIST(n->ackl))
+        {
+          struct lsah_n *no;
+          no=(struct lsah_n *)HEAD(n->ackl);
+          rem_node(NODE no);
+          mb_free(no);
+        }
         s_init_list(&(n->lsrql));
-       n->lsrqh=ospf_top_new(n->ifa->proto);
+       if(n->lsrqh) ospf_top_free(n->lsrqh);
+       n->lsrqh=ospf_top_new(n->pool, n->ifa->proto);
         s_init_list(&(n->lsrtl));
-       n->lsrth=ospf_top_new(n->ifa->proto);
+       if(n->lsrth) ospf_top_free(n->lsrth);
+       n->lsrth=ospf_top_new(n->pool, n->ifa->proto);
        s_init(&(n->dbsi), &(n->ifa->oa->lsal));
        s_init(&(n->lsrqi), &(n->lsrql));
        s_init(&(n->lsrti), &(n->lsrtl));
@@ -490,37 +499,8 @@ ospf_neigh_remove(struct ospf_neighbor *n)
   ifa=n->ifa;
   p=(struct proto *)(ifa->proto);
   neigh_chstate(n, NEIGHBOR_DOWN);
-  tm_stop(n->inactim);
-  rfree(n->inactim);
-  if(n->rxmt_timer!=NULL)
-  {
-    tm_stop(n->rxmt_timer);
-    rfree(n->rxmt_timer);
-  }
-  if(n->lsrr_timer!=NULL)
-  {
-    tm_stop(n->lsrr_timer);
-    rfree(n->lsrr_timer);
-  }
-  if(n->ackd_timer!=NULL)
-  {
-    tm_stop(n->ackd_timer);
-    rfree(n->ackd_timer);
-  }
-  if(n->ldbdes!=NULL)
-  {
-    mb_free(n->ldbdes);
-  }
-  if(n->lsrqh!=NULL)
-  {
-    ospf_top_free(n->lsrqh);
-  }
-  if(n->lsrth!=NULL)
-  {
-    ospf_top_free(n->lsrth);
-  }
   rem_node(NODE n);
-  mb_free(n);
+  rfree(n->pool);
   OSPF_TRACE(D_EVENTS, "Deleting neigbor.");
 }
 
index 9626ab8b101d478095b6ad4a399a434b31e2f645..dbe3b18dc50de0fc64f5cb3dc15f4f0810543ebf 100644 (file)
@@ -100,7 +100,7 @@ ospf_start(struct proto *p)
     oa->stub=ac->stub;
     oa->tick=ac->tick;
     oa->areaid=ac->areaid;
-    oa->gr=ospf_top_new(po);
+    oa->gr=ospf_top_new(po->proto.pool, po);
     s_init_list(&(oa->lsal));
     oa->rt=NULL;
     oa->po=po;
index a0dc878d9405ccdc41a701761a34a2bddaca409d..93731482ee6e34afd9d0227c678311db44e406bd 100644 (file)
@@ -324,6 +324,7 @@ struct ospf_lsack_packet {
 struct ospf_neighbor
 {
   node n;
+  pool *pool;
   struct ospf_iface *ifa;
   u8 state;
 #define NEIGHBOR_DOWN 0
index cf4a6e08640eb77568b9bdeb1ebd84ec8c9e6188..29629e205781342d71d10d016769407e0ee08492 100644 (file)
@@ -284,6 +284,8 @@ originate_net_lsa(struct ospf_iface *ifa)
     ifa->nlsa->lsa.age=LSA_MAXAGE;
     flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
     s_rem_node(SNODE ifa->nlsa);
+    if(ifa->nlsa->lsa_body!=NULL) mb_free(ifa->nlsa->lsa_body);
+    ifa->nlsa->lsa_body=NULL;
     ospf_hash_delete(ifa->oa->gr, ifa->nlsa);
     schedule_rtcalc(ifa->oa);
     ifa->nlsa=NULL;
@@ -511,12 +513,12 @@ return (ospf_top_hash_u32(lsaid) + ospf_top_hash_u32((type==LSA_T_NET) ? lsaid :
  * its used in @ospf_area structure.
  */
 struct top_graph *
-ospf_top_new(struct proto_ospf *p)
+ospf_top_new(pool *pool, struct proto_ospf *p)
 {
   struct top_graph *f;
 
-  f = mb_allocz(p->proto.pool, sizeof(struct top_graph));
-  f->pool = p->proto.pool;
+  f = mb_allocz(pool, sizeof(struct top_graph));
+  f->pool = pool;
   f->hash_slab = sl_new(f->pool, sizeof(struct top_hash_entry));
   f->hash_order = HASH_DEF_ORDER;
   ospf_top_ht_alloc(f);
index d85173fa0039e2acde71cdfd6aa6562aef23ec2c..a355837158ff8f9955fdb70ef2eb1eebf4b1415e 100644 (file)
@@ -42,7 +42,7 @@ struct top_graph {
   unsigned int hash_entries_min, hash_entries_max;
 };
 
-struct top_graph *ospf_top_new(struct proto_ospf *);
+struct top_graph *ospf_top_new(pool *, struct proto_ospf *);
 void ospf_top_free(struct top_graph *);
 void ospf_top_dump(struct top_graph *, struct proto *);
 struct top_hash_entry *ospf_hash_find_header(struct top_graph *f, struct ospf_lsa_header *h);