Patch from Andreas Steinmetz <ast@domdv.de>

This commit is contained in:
Ondrej Filip 2004-06-01 13:12:10 +00:00
parent 8281ff201e
commit 035f6acbfe
11 changed files with 62 additions and 46 deletions

View file

@ -19,7 +19,7 @@ install_inactim(struct ospf_neighbor *n)
if(n->inactim==NULL) if(n->inactim==NULL)
{ {
n->inactim=tm_new(p->pool); n->inactim=tm_new(n->pool);
n->inactim->data=n; n->inactim->data=n;
n->inactim->randomize=0; n->inactim->randomize=0;
n->inactim->hook=neighbor_timer_hook; n->inactim->hook=neighbor_timer_hook;
@ -64,6 +64,7 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
ip_addr mask; ip_addr mask;
char *beg=": Bad OSPF hello packet from ", *rec=" received: "; char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
int eligible=0; int eligible=0;
pool *pool;
nrid=ntohl(((struct ospf_packet *)ps)->routerid); 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, OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s.", faddr,
ifa->iface->name); 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); add_tail(&ifa->neigh_list, NODE n);
n->rid=nrid; n->rid=nrid;
n->ip=faddr; n->ip=faddr;
@ -142,23 +145,23 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
n->options=ps->options; n->options=ps->options;
n->ifa=ifa; n->ifa=ifa;
n->adj=0; n->adj=0;
n->ldbdes=mb_alloc(p->pool, ifa->iface->mtu); n->ldbdes=mb_alloc(pool, ifa->iface->mtu);
n->state=NEIGHBOR_DOWN; n->state=NEIGHBOR_DOWN;
install_inactim(n); install_inactim(n);
n->rxmt_timer=tm_new(p->pool); n->rxmt_timer=tm_new(pool);
n->rxmt_timer->data=n; n->rxmt_timer->data=n;
n->rxmt_timer->randomize=0; n->rxmt_timer->randomize=0;
n->rxmt_timer->hook=rxmt_timer_hook; n->rxmt_timer->hook=rxmt_timer_hook;
n->rxmt_timer->recurrent=ifa->rxmtint; n->rxmt_timer->recurrent=ifa->rxmtint;
DBG("%s: Installing rxmt timer.\n", p->name); 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->data=n;
n->lsrr_timer->randomize=0; n->lsrr_timer->randomize=0;
n->lsrr_timer->hook=lsrr_timer_hook; n->lsrr_timer->hook=lsrr_timer_hook;
n->lsrr_timer->recurrent=ifa->rxmtint; n->lsrr_timer->recurrent=ifa->rxmtint;
DBG("%s: Installing lsrr timer.\n", p->name); DBG("%s: Installing lsrr timer.\n", p->name);
init_list(&n->ackl); 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->data=n;
n->ackd_timer->randomize=0; n->ackd_timer->randomize=0;
n->ackd_timer->hook=ackd_timer_hook; n->ackd_timer->hook=ackd_timer_hook;

View file

@ -70,6 +70,10 @@ iface_chstate(struct ospf_iface *ifa, u8 state)
{ {
if(ifa->dr_sk!=NULL) 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); rfree(ifa->dr_sk);
ifa->dr_sk=NULL; ifa->dr_sk=NULL;
} }
@ -103,14 +107,26 @@ downint(struct ospf_iface *ifa)
rem_node(NODE ifa); rem_node(NODE ifa);
if(ifa->hello_sk!=NULL) 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); rfree(ifa->hello_sk);
} }
if(ifa->dr_sk!=NULL) 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); rfree(ifa->dr_sk);
} }
if(ifa->ip_sk!=NULL) 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); rfree(ifa->ip_sk);
} }
if(ifa->wait_timer!=NULL) if(ifa->wait_timer!=NULL)

View file

@ -40,7 +40,7 @@ ospf_lsa_delay(struct ospf_neighbor *n,struct ospf_lsa_header *h,
{ {
struct lsah_n *no; 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)); memcpy(&no->lsa,h,sizeof(struct ospf_lsa_header));
add_tail(&n->ackl, NODE no); add_tail(&n->ackl, NODE no);
DBG("Adding delay ack for %I, ID: %I, RT: %I, Type: %u\n",n->rid, 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", DBG("Deleting LS Id: %I RT: %I Type: %u from LS Retl for neighbor %I\n",
lsa.id,lsa.rt,lsa.type,n->rid); lsa.id,lsa.rt,lsa.type,n->rid);
s_rem_node(SNODE en); 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); ospf_hash_delete(n->lsrth,en);
} }
} }

View 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", 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); en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.age);
s_rem_node(SNODE en); 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); ospf_hash_delete(oa->gr,en);
} }

View file

@ -82,7 +82,7 @@ lsrr_timer_hook(timer *timer)
struct l_lsr_head *llsh; struct l_lsr_head *llsh;
init_list(&uplist); 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) 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); length=ntohs(ps->ospf_packet.length);
lsh=(void *)(ps+1); lsh=(void *)(ps+1);
init_list(&uplist); 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))/ lsano=(length-sizeof(struct ospf_lsreq_packet))/
sizeof(struct ospf_lsreq_header); sizeof(struct ospf_lsreq_header);

View file

@ -55,6 +55,8 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
break; break;
case CMP_SAME: case CMP_SAME:
s_rem_node(SNODE en); 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); DBG("Removing from lsreq list for neigh %I\n", nn->rid);
ospf_hash_delete(nn->lsrqh,en); ospf_hash_delete(nn->lsrqh,en);
if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE); 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; break;
case CMP_NEWER: case CMP_NEWER:
s_rem_node(SNODE en); 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); DBG("Removing from lsreq list for neigh %I\n", nn->rid);
ospf_hash_delete(nn->lsrqh,en); ospf_hash_delete(nn->lsrqh,en);
if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE); 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) if((en=ospf_hash_find_header(nn->lsrth, hh))!=NULL)
{ {
s_rem_node(SNODE en); 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); 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) if((en=ospf_hash_find_header(ntmp->lsrth,&lsadb->lsa))!=NULL)
{ {
s_rem_node(SNODE en); 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); 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) if((en=ospf_hash_find_header(n->lsrth,&lsadb->lsa))!=NULL)
{ {
s_rem_node(SNODE en); 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); ospf_hash_delete(n->lsrth, en);
if(ifa->state==OSPF_IS_BACKUP) if(ifa->state==OSPF_IS_BACKUP)
{ {

View file

@ -261,10 +261,19 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
if(n->state==NEIGHBOR_EXSTART) if(n->state==NEIGHBOR_EXSTART)
{ {
neigh_chstate(n,NEIGHBOR_EXCHANGE); 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)); 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)); 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->dbsi), &(n->ifa->oa->lsal));
s_init(&(n->lsrqi), &(n->lsrql)); s_init(&(n->lsrqi), &(n->lsrql));
s_init(&(n->lsrti), &(n->lsrtl)); s_init(&(n->lsrti), &(n->lsrtl));
@ -490,37 +499,8 @@ ospf_neigh_remove(struct ospf_neighbor *n)
ifa=n->ifa; ifa=n->ifa;
p=(struct proto *)(ifa->proto); p=(struct proto *)(ifa->proto);
neigh_chstate(n, NEIGHBOR_DOWN); 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); rem_node(NODE n);
mb_free(n); rfree(n->pool);
OSPF_TRACE(D_EVENTS, "Deleting neigbor."); OSPF_TRACE(D_EVENTS, "Deleting neigbor.");
} }

View file

@ -100,7 +100,7 @@ ospf_start(struct proto *p)
oa->stub=ac->stub; oa->stub=ac->stub;
oa->tick=ac->tick; oa->tick=ac->tick;
oa->areaid=ac->areaid; oa->areaid=ac->areaid;
oa->gr=ospf_top_new(po); oa->gr=ospf_top_new(po->proto.pool, po);
s_init_list(&(oa->lsal)); s_init_list(&(oa->lsal));
oa->rt=NULL; oa->rt=NULL;
oa->po=po; oa->po=po;

View file

@ -324,6 +324,7 @@ struct ospf_lsack_packet {
struct ospf_neighbor struct ospf_neighbor
{ {
node n; node n;
pool *pool;
struct ospf_iface *ifa; struct ospf_iface *ifa;
u8 state; u8 state;
#define NEIGHBOR_DOWN 0 #define NEIGHBOR_DOWN 0

View file

@ -284,6 +284,8 @@ originate_net_lsa(struct ospf_iface *ifa)
ifa->nlsa->lsa.age=LSA_MAXAGE; ifa->nlsa->lsa.age=LSA_MAXAGE;
flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0); flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
s_rem_node(SNODE ifa->nlsa); 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); ospf_hash_delete(ifa->oa->gr, ifa->nlsa);
schedule_rtcalc(ifa->oa); schedule_rtcalc(ifa->oa);
ifa->nlsa=NULL; 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. * its used in @ospf_area structure.
*/ */
struct top_graph * struct top_graph *
ospf_top_new(struct proto_ospf *p) ospf_top_new(pool *pool, struct proto_ospf *p)
{ {
struct top_graph *f; struct top_graph *f;
f = mb_allocz(p->proto.pool, sizeof(struct top_graph)); f = mb_allocz(pool, sizeof(struct top_graph));
f->pool = p->proto.pool; f->pool = pool;
f->hash_slab = sl_new(f->pool, sizeof(struct top_hash_entry)); f->hash_slab = sl_new(f->pool, sizeof(struct top_hash_entry));
f->hash_order = HASH_DEF_ORDER; f->hash_order = HASH_DEF_ORDER;
ospf_top_ht_alloc(f); ospf_top_ht_alloc(f);

View file

@ -42,7 +42,7 @@ struct top_graph {
unsigned int hash_entries_min, hash_entries_max; 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_free(struct top_graph *);
void ospf_top_dump(struct top_graph *, struct proto *); 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); struct top_hash_entry *ospf_hash_find_header(struct top_graph *f, struct ospf_lsa_header *h);