mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 08:38:42 +00:00
Patch from Andreas Steinmetz <ast@domdv.de>
This commit is contained in:
parent
8281ff201e
commit
035f6acbfe
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user