cleanup in lsupd.c, indenting, "struct proto" removed...
This commit is contained in:
parent
9b7de4c4d1
commit
6f3203fabf
8 changed files with 308 additions and 277 deletions
|
@ -102,7 +102,7 @@ iface_chstate(struct ospf_iface *ifa, u8 state)
|
||||||
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
||||||
if(state>=OSPF_IS_WAITING)
|
if(state>=OSPF_IS_WAITING)
|
||||||
{
|
{
|
||||||
net_flush_lsa(ifa->nlsa,po,ifa->oa);
|
ospf_lsupd_flush_nlsa(ifa->nlsa,ifa->oa);
|
||||||
}
|
}
|
||||||
if(can_flush_lsa(ifa->oa)) flush_lsa(ifa->nlsa,ifa->oa);
|
if(can_flush_lsa(ifa->oa)) flush_lsa(ifa->nlsa,ifa->oa);
|
||||||
ifa->nlsa=NULL;
|
ifa->nlsa=NULL;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
* (c) 1999--2004 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ ospf_age(struct ospf_area *oa)
|
||||||
en->inst_t=now;
|
en->inst_t=now;
|
||||||
en->ini_age=0;
|
en->ini_age=0;
|
||||||
lsasum_calculate(&en->lsa,en->lsa_body,po);
|
lsasum_calculate(&en->lsa,en->lsa_body,po);
|
||||||
flood_lsa(NULL,NULL,&en->lsa,po,NULL,oa,1);
|
ospf_lsupd_flood(NULL,NULL,&en->lsa,NULL,oa,1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((en->lsa.age=(en->ini_age+(now-en->inst_t)))>=LSA_MAXAGE)
|
if((en->lsa.age=(en->ini_age+(now-en->inst_t)))>=LSA_MAXAGE)
|
||||||
|
|
|
@ -116,6 +116,6 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ospf_lsupd_tx_list(n, &uplist);
|
ospf_lsupd_send_list(n, &uplist);
|
||||||
rfree(upslab);
|
rfree(upslab);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 2000-2004 Ondrej Filip <feela@network.cz>
|
* (c) 2000--2004 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#include "ospf.h"
|
#include "ospf.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flood_lsa - send received or generated lsa to the neighbors
|
* ospf_lsupd_flood - send received or generated lsa to the neighbors
|
||||||
* @n: neighbor than sent this lsa (or NULL if generated)
|
* @n: neighbor than sent this lsa (or NULL if generated)
|
||||||
* @hn: LSA header followed by lsa body in network endianity (may be NULL)
|
* @hn: LSA header followed by lsa body in network endianity (may be NULL)
|
||||||
* @hh: LSA header in host endianity (must be filled)
|
* @hh: LSA header in host endianity (must be filled)
|
||||||
|
@ -22,110 +22,127 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
||||||
struct ospf_lsa_header *hh, struct proto_ospf *po, struct ospf_iface *iff,
|
struct ospf_lsa_header *hh, struct ospf_iface *iff,
|
||||||
struct ospf_area *oa, int rtl)
|
struct ospf_area *oa, int rtl)
|
||||||
{
|
{
|
||||||
struct ospf_iface *ifa;
|
struct ospf_iface *ifa;
|
||||||
struct ospf_neighbor *nn;
|
struct ospf_neighbor *nn;
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
struct proto *p=&po->proto;
|
struct proto_ospf *po = oa->po;
|
||||||
|
struct proto *p = &po->proto;
|
||||||
int ret, retval = 0;
|
int ret, retval = 0;
|
||||||
|
|
||||||
/* pg 148 */
|
/* pg 148 */
|
||||||
WALK_LIST(NODE ifa,po->iface_list)
|
WALK_LIST(NODE ifa, po->iface_list)
|
||||||
{
|
{
|
||||||
if(ifa->stub) continue;
|
if (ifa->stub)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(hh->type==LSA_T_EXT)
|
if (hh->type == LSA_T_EXT)
|
||||||
{
|
{
|
||||||
if(ifa->type==OSPF_IT_VLINK) continue;
|
if (ifa->type == OSPF_IT_VLINK)
|
||||||
if(ifa->oa->stub) continue;
|
continue;
|
||||||
|
if (ifa->oa->stub)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(oa->areaid==BACKBONE)
|
if (oa->areaid == BACKBONE)
|
||||||
{
|
{
|
||||||
if((ifa->type!=OSPF_IT_VLINK)&&(ifa->oa!=oa)) continue;
|
if ((ifa->type != OSPF_IT_VLINK) && (ifa->oa != oa))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(ifa->oa!=oa) continue;
|
if (ifa->oa != oa)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret=0;
|
ret = 0;
|
||||||
WALK_LIST(NODE nn, ifa->neigh_list)
|
WALK_LIST(NODE nn, ifa->neigh_list)
|
||||||
{
|
{
|
||||||
if(nn->state<NEIGHBOR_EXCHANGE) continue;
|
if (nn->state < NEIGHBOR_EXCHANGE)
|
||||||
if(nn->state<NEIGHBOR_FULL)
|
continue;
|
||||||
|
if (nn->state < NEIGHBOR_FULL)
|
||||||
{
|
{
|
||||||
if((en=ospf_hash_find_header(nn->lsrqh,hh))!=NULL)
|
if ((en = ospf_hash_find_header(nn->lsrqh, hh)) != NULL)
|
||||||
{
|
{
|
||||||
switch(lsa_comp(hh,&en->lsa))
|
switch (lsa_comp(hh, &en->lsa))
|
||||||
{
|
{
|
||||||
case CMP_OLDER:
|
case CMP_OLDER:
|
||||||
continue;
|
continue;
|
||||||
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);
|
if (en->lsa_body != NULL)
|
||||||
en->lsa_body=NULL;
|
mb_free(en->lsa_body);
|
||||||
DBG("Removing from lsreq list for neigh %I\n", nn->rid);
|
en->lsa_body = NULL;
|
||||||
ospf_hash_delete(nn->lsrqh,en);
|
DBG("Removing from lsreq list for neigh %I\n", nn->rid);
|
||||||
if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE);
|
ospf_hash_delete(nn->lsrqh, en);
|
||||||
continue;
|
if (EMPTY_SLIST(nn->lsrql))
|
||||||
break;
|
ospf_neigh_sm(nn, INM_LOADDONE);
|
||||||
case CMP_NEWER:
|
continue;
|
||||||
s_rem_node(SNODE en);
|
break;
|
||||||
if(en->lsa_body!=NULL) mb_free(en->lsa_body);
|
case CMP_NEWER:
|
||||||
en->lsa_body=NULL;
|
s_rem_node(SNODE en);
|
||||||
DBG("Removing from lsreq list for neigh %I\n", nn->rid);
|
if (en->lsa_body != NULL)
|
||||||
ospf_hash_delete(nn->lsrqh,en);
|
mb_free(en->lsa_body);
|
||||||
if(EMPTY_SLIST(nn->lsrql)) ospf_neigh_sm(nn, INM_LOADDONE);
|
en->lsa_body = NULL;
|
||||||
break;
|
DBG("Removing from lsreq list for neigh %I\n", nn->rid);
|
||||||
default: bug("Bug in lsa_comp?");
|
ospf_hash_delete(nn->lsrqh, en);
|
||||||
|
if (EMPTY_SLIST(nn->lsrql))
|
||||||
|
ospf_neigh_sm(nn, INM_LOADDONE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bug("Bug in lsa_comp?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nn==n) continue;
|
if (nn == n)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(rtl)
|
if (rtl)
|
||||||
{
|
{
|
||||||
if((en=ospf_hash_find_header(nn->lsrth, hh))==NULL)
|
if ((en = ospf_hash_find_header(nn->lsrth, hh)) == NULL)
|
||||||
{
|
{
|
||||||
en=ospf_hash_get_header(nn->lsrth, hh);
|
en = ospf_hash_get_header(nn->lsrth, hh);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_rem_node(SNODE en);
|
s_rem_node(SNODE en);
|
||||||
}
|
}
|
||||||
s_add_tail(&nn->lsrtl, SNODE en);
|
s_add_tail(&nn->lsrtl, SNODE en);
|
||||||
memcpy(&en->lsa,hh,sizeof(struct ospf_lsa_header));
|
memcpy(&en->lsa, hh, sizeof(struct ospf_lsa_header));
|
||||||
DBG("Adding LSA lsrt RT: %I, Id: %I, Type: %u for n: %I\n",
|
DBG("Adding LSA lsrt RT: %I, Id: %I, Type: %u for n: %I\n",
|
||||||
en->lsa.rt,en->lsa.id, en->lsa.type, nn->ip);
|
en->lsa.rt, en->lsa.id, en->lsa.type, nn->ip);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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);
|
if (en->lsa_body != NULL)
|
||||||
en->lsa_body=NULL;
|
mb_free(en->lsa_body);
|
||||||
ospf_hash_delete(nn->lsrth, en);
|
en->lsa_body = NULL;
|
||||||
}
|
ospf_hash_delete(nn->lsrth, en);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret=1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret==0) continue; /* pg 150 (2) */
|
if (ret == 0)
|
||||||
|
continue; /* pg 150 (2) */
|
||||||
|
|
||||||
if(ifa==iff)
|
if (ifa == iff)
|
||||||
{
|
{
|
||||||
if((n->rid==iff->drid)||n->rid==iff->bdrid) continue; /* pg 150 (3) */
|
if ((n->rid == iff->drid) || n->rid == iff->bdrid)
|
||||||
if(iff->state==OSPF_IS_BACKUP) continue; /* pg 150 (4) */
|
continue; /* pg 150 (3) */
|
||||||
retval = 1; /* FIXME !!!!!!!!!!! */
|
if (iff->state == OSPF_IS_BACKUP)
|
||||||
|
continue; /* pg 150 (4) */
|
||||||
|
retval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -136,65 +153,70 @@ flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
||||||
struct ospf_packet *op;
|
struct ospf_packet *op;
|
||||||
struct ospf_lsa_header *lh;
|
struct ospf_lsa_header *lh;
|
||||||
|
|
||||||
if(ifa->type==OSPF_IT_NBMA) sk=ifa->ip_sk;
|
if (ifa->type == OSPF_IT_NBMA)
|
||||||
else sk=ifa->hello_sk; /* FIXME is this true for PTP? */
|
sk = ifa->ip_sk;
|
||||||
|
else
|
||||||
|
sk = ifa->hello_sk; /* FIXME is this true for PTP? */
|
||||||
|
|
||||||
pk=(struct ospf_lsupd_packet *)sk->tbuf;
|
pk = (struct ospf_lsupd_packet *) sk->tbuf;
|
||||||
op=(struct ospf_packet *)sk->tbuf;
|
op = (struct ospf_packet *) sk->tbuf;
|
||||||
|
|
||||||
fill_ospf_pkt_hdr(ifa, pk, LSUPD_P);
|
fill_ospf_pkt_hdr(ifa, pk, LSUPD_P);
|
||||||
pk->lsano=htonl(1);
|
pk->lsano = htonl(1);
|
||||||
|
|
||||||
lh = (struct ospf_lsa_header *)(pk+1);
|
lh = (struct ospf_lsa_header *) (pk + 1);
|
||||||
|
|
||||||
/* Copy LSA into the packet */
|
/* Copy LSA into the packet */
|
||||||
if(hn)
|
if (hn)
|
||||||
{
|
{
|
||||||
memcpy(lh, hn, ntohs(hn->length));
|
memcpy(lh, hn, ntohs(hn->length));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *help;
|
u8 *help;
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
|
|
||||||
htonlsah(hh,lh);
|
htonlsah(hh, lh);
|
||||||
help = (u8 *)(lh+1);
|
help = (u8 *) (lh + 1);
|
||||||
en = ospf_hash_find_header(oa->gr,hh);
|
en = ospf_hash_find_header(oa->gr, hh);
|
||||||
htonlsab(en->lsa_body,help,hh->type,hh->length
|
htonlsab(en->lsa_body, help, hh->type, hh->length
|
||||||
-sizeof(struct ospf_lsa_header));
|
- sizeof(struct ospf_lsa_header));
|
||||||
}
|
}
|
||||||
|
|
||||||
len = sizeof(struct ospf_lsupd_packet)+ntohs(lh->length);
|
len = sizeof(struct ospf_lsupd_packet) + ntohs(lh->length);
|
||||||
|
|
||||||
age = ntohs(lh->age);
|
age = ntohs(lh->age);
|
||||||
age += ifa->inftransdelay;
|
age += ifa->inftransdelay;
|
||||||
if( age > LSA_MAXAGE ) age = LSA_MAXAGE;
|
if (age > LSA_MAXAGE)
|
||||||
|
age = LSA_MAXAGE;
|
||||||
lh->age = htons(age);
|
lh->age = htons(age);
|
||||||
|
|
||||||
op->length=htons(len);
|
op->length = htons(len);
|
||||||
ospf_pkt_finalize(ifa, op);
|
ospf_pkt_finalize(ifa, op);
|
||||||
OSPF_TRACE(D_PACKETS, "LS upd flooded via %s", ifa->iface->name);
|
OSPF_TRACE(D_PACKETS, "LS upd flooded via %s", ifa->iface->name);
|
||||||
|
|
||||||
if(ifa->type==OSPF_IT_NBMA)
|
if (ifa->type == OSPF_IT_NBMA)
|
||||||
{
|
{
|
||||||
if((ifa->state==OSPF_IS_BACKUP)||(ifa->state==OSPF_IS_DR))
|
if ((ifa->state == OSPF_IS_BACKUP) || (ifa->state == OSPF_IS_DR))
|
||||||
sk_send_to_agt(sk ,len, ifa, NEIGHBOR_EXCHANGE);
|
sk_send_to_agt(sk, len, ifa, NEIGHBOR_EXCHANGE);
|
||||||
else sk_send_to_bdr(sk ,len, ifa);
|
else
|
||||||
|
sk_send_to_bdr(sk, len, ifa);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((ifa->state==OSPF_IS_BACKUP)||(ifa->state==OSPF_IS_DR)||
|
if ((ifa->state == OSPF_IS_BACKUP) || (ifa->state == OSPF_IS_DR) ||
|
||||||
(ifa->type==OSPF_IT_PTP))
|
(ifa->type == OSPF_IT_PTP))
|
||||||
sk_send_to(sk,len, AllSPFRouters, OSPF_PROTO);
|
sk_send_to(sk, len, AllSPFRouters, OSPF_PROTO);
|
||||||
else sk_send_to(sk,len, AllDRouters, OSPF_PROTO);
|
else
|
||||||
|
sk_send_to(sk, len, AllDRouters, OSPF_PROTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* I send all I received in LSREQ */
|
void /* I send all I received in LSREQ */
|
||||||
ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
|
ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
|
||||||
{
|
{
|
||||||
struct l_lsr_head *llsh;
|
struct l_lsr_head *llsh;
|
||||||
u16 len;
|
u16 len;
|
||||||
|
@ -202,95 +224,98 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
struct ospf_lsupd_packet *pk;
|
struct ospf_lsupd_packet *pk;
|
||||||
struct ospf_packet *op;
|
struct ospf_packet *op;
|
||||||
struct proto *p=&n->ifa->oa->po->proto;
|
struct proto *p = &n->ifa->oa->po->proto;
|
||||||
void *pktpos;
|
void *pktpos;
|
||||||
u8 ii;
|
u8 ii;
|
||||||
u8 *jj=n->ifa->ip_sk->tbuf;
|
u8 *jj = n->ifa->ip_sk->tbuf;
|
||||||
|
|
||||||
if(EMPTY_LIST(*l)) return;
|
if (EMPTY_LIST(*l))
|
||||||
|
return;
|
||||||
|
|
||||||
pk=(struct ospf_lsupd_packet *)n->ifa->ip_sk->tbuf;
|
pk = (struct ospf_lsupd_packet *) n->ifa->ip_sk->tbuf;
|
||||||
op=(struct ospf_packet *)n->ifa->ip_sk->tbuf;
|
op = (struct ospf_packet *) n->ifa->ip_sk->tbuf;
|
||||||
|
|
||||||
DBG("LSupd: 1st packet\n");
|
DBG("LSupd: 1st packet\n");
|
||||||
|
|
||||||
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
|
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
|
||||||
len=SIPH+sizeof(struct ospf_lsupd_packet);
|
len = SIPH + sizeof(struct ospf_lsupd_packet);
|
||||||
lsano=0;
|
lsano = 0;
|
||||||
pktpos=(pk+1);
|
pktpos = (pk + 1);
|
||||||
|
|
||||||
WALK_LIST(llsh, *l)
|
WALK_LIST(llsh, *l)
|
||||||
{
|
{
|
||||||
if((en=ospf_hash_find(n->ifa->oa->gr,llsh->lsh.id,llsh->lsh.rt,
|
if ((en = ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
|
||||||
llsh->lsh.type))==NULL) continue; /* Probably flushed LSA */
|
llsh->lsh.type)) == NULL)
|
||||||
|
continue; /* Probably flushed LSA */
|
||||||
|
|
||||||
DBG("Sending ID=%I, Type=%u, RT=%I Sn: 0x%x Age: %u\n",
|
DBG("Sending ID=%I, Type=%u, RT=%I Sn: 0x%x Age: %u\n",
|
||||||
llsh->lsh.id, llsh->lsh.type, llsh->lsh.rt, en->lsa.sn, en->lsa.age);
|
llsh->lsh.id, llsh->lsh.type, llsh->lsh.rt, en->lsa.sn, en->lsa.age);
|
||||||
if(((u32)(len+en->lsa.length))>n->ifa->iface->mtu)
|
if (((u32) (len + en->lsa.length)) > n->ifa->iface->mtu)
|
||||||
{
|
{
|
||||||
pk->lsano=htonl(lsano);
|
pk->lsano = htonl(lsano);
|
||||||
op->length=htons(len-SIPH);
|
op->length = htons(len - SIPH);
|
||||||
ospf_pkt_finalize(n->ifa, op);
|
ospf_pkt_finalize(n->ifa, op);
|
||||||
|
|
||||||
sk_send_to(n->ifa->ip_sk,len-SIPH, n->ip, OSPF_PROTO);
|
sk_send_to(n->ifa->ip_sk, len - SIPH, n->ip, OSPF_PROTO);
|
||||||
OSPF_TRACE(D_PACKETS, "LS upd sent to %I (%d LSAs)", n->ip, lsano);
|
OSPF_TRACE(D_PACKETS, "LS upd sent to %I (%d LSAs)", n->ip, lsano);
|
||||||
|
|
||||||
DBG("LSupd: next packet\n");
|
DBG("LSupd: next packet\n");
|
||||||
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
|
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD_P);
|
||||||
len=SIPH+sizeof(struct ospf_lsupd_packet);
|
len = SIPH + sizeof(struct ospf_lsupd_packet);
|
||||||
lsano=0;
|
lsano = 0;
|
||||||
pktpos=(pk+1);
|
pktpos = (pk + 1);
|
||||||
}
|
}
|
||||||
htonlsah(&(en->lsa), pktpos);
|
htonlsah(&(en->lsa), pktpos);
|
||||||
pktpos=pktpos+sizeof(struct ospf_lsa_header);
|
pktpos = pktpos + sizeof(struct ospf_lsa_header);
|
||||||
htonlsab(en->lsa_body, pktpos, en->lsa.type, en->lsa.length
|
htonlsab(en->lsa_body, pktpos, en->lsa.type, en->lsa.length
|
||||||
-sizeof(struct ospf_lsa_header));
|
- sizeof(struct ospf_lsa_header));
|
||||||
pktpos=pktpos+en->lsa.length-sizeof(struct ospf_lsa_header);
|
pktpos = pktpos + en->lsa.length - sizeof(struct ospf_lsa_header);
|
||||||
len+=en->lsa.length;
|
len += en->lsa.length;
|
||||||
lsano++;
|
lsano++;
|
||||||
}
|
}
|
||||||
if(lsano>0)
|
if (lsano > 0)
|
||||||
{
|
{
|
||||||
pk->lsano=htonl(lsano);
|
pk->lsano = htonl(lsano);
|
||||||
op->length=htons(len-SIPH);
|
op->length = htons(len - SIPH);
|
||||||
ospf_pkt_finalize(n->ifa, op);
|
ospf_pkt_finalize(n->ifa, op);
|
||||||
|
|
||||||
OSPF_TRACE(D_PACKETS, "LS upd sent to %I (%d LSAs)", n->ip, lsano);
|
OSPF_TRACE(D_PACKETS, "LS upd sent to %I (%d LSAs)", n->ip, lsano);
|
||||||
sk_send_to(n->ifa->ip_sk,len-SIPH, n->ip, OSPF_PROTO);
|
sk_send_to(n->ifa->ip_sk, len - SIPH, n->ip, OSPF_PROTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size)
|
struct ospf_iface *ifa, u16 size)
|
||||||
{
|
{
|
||||||
u32 area,nrid;
|
u32 area, nrid;
|
||||||
struct ospf_neighbor *n,*ntmp;
|
struct ospf_neighbor *n, *ntmp;
|
||||||
struct ospf_lsa_header *lsa;
|
struct ospf_lsa_header *lsa;
|
||||||
struct ospf_area *oa;
|
struct ospf_area *oa;
|
||||||
struct proto_ospf *po=ifa->proto;
|
struct proto_ospf *po = ifa->proto;
|
||||||
struct proto *p = (struct proto *)po;
|
struct proto *p = (struct proto *) po;
|
||||||
u16 length;
|
u16 length;
|
||||||
u8 i;
|
u8 i;
|
||||||
int sendreq = 1;
|
int sendreq = 1;
|
||||||
|
|
||||||
nrid=ntohl(ps->ospf_packet.routerid);
|
nrid = ntohl(ps->ospf_packet.routerid);
|
||||||
|
|
||||||
if((n=find_neigh(ifa, nrid))==NULL)
|
if ((n = find_neigh(ifa, nrid)) == NULL)
|
||||||
{
|
{
|
||||||
OSPF_TRACE(D_PACKETS, "Received lsupd from unknown neighbor! (%I)",
|
OSPF_TRACE(D_PACKETS, "Received lsupd from unknown neighbor! (%I)", nrid);
|
||||||
nrid);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(n->state<NEIGHBOR_EXCHANGE)
|
|
||||||
{
|
|
||||||
OSPF_TRACE(D_PACKETS, "Received lsupd in lesser state than EXCHANGE from (%I)",
|
|
||||||
n->ip);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(size<=(sizeof(struct ospf_lsupd_packet)+sizeof(struct ospf_lsa_header)))
|
if (n->state < NEIGHBOR_EXCHANGE)
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS,
|
||||||
|
"Received lsupd in lesser state than EXCHANGE from (%I)",
|
||||||
|
n->ip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size <=
|
||||||
|
(sizeof(struct ospf_lsupd_packet) + sizeof(struct ospf_lsa_header)))
|
||||||
{
|
{
|
||||||
log(L_WARN "Received lsupd from %I is too short!", n->ip);
|
log(L_WARN "Received lsupd from %I is too short!", n->ip);
|
||||||
return;
|
return;
|
||||||
|
@ -299,26 +324,28 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
OSPF_TRACE(D_PACKETS, "Received LS upd from %I", n->ip);
|
OSPF_TRACE(D_PACKETS, "Received LS upd from %I", n->ip);
|
||||||
ospf_neigh_sm(n, INM_HELLOREC); /* Questionable */
|
ospf_neigh_sm(n, INM_HELLOREC); /* Questionable */
|
||||||
|
|
||||||
lsa=(struct ospf_lsa_header *)(ps+1);
|
lsa = (struct ospf_lsa_header *) (ps + 1);
|
||||||
area=htonl(ps->ospf_packet.areaid);
|
area = htonl(ps->ospf_packet.areaid);
|
||||||
oa=ospf_find_area((struct proto_ospf *)p,area);
|
oa = ospf_find_area((struct proto_ospf *) p, area);
|
||||||
|
|
||||||
for(i=0; i<ntohl(ps->lsano); i++,
|
for (i = 0; i < ntohl(ps->lsano); i++,
|
||||||
lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length)))
|
lsa = (struct ospf_lsa_header *) (((u8 *) lsa) + ntohs(lsa->length)))
|
||||||
{
|
{
|
||||||
struct ospf_lsa_header lsatmp;
|
struct ospf_lsa_header lsatmp;
|
||||||
struct top_hash_entry *lsadb;
|
struct top_hash_entry *lsadb;
|
||||||
int diff=((u8 *)lsa)-((u8 *)ps);
|
int diff = ((u8 *) lsa) - ((u8 *) ps);
|
||||||
u16 chsum, lenn = ntohs(lsa->length);
|
u16 chsum, lenn = ntohs(lsa->length);
|
||||||
|
|
||||||
if(((diff+sizeof(struct ospf_lsa_header))>=size) || ((lenn+diff)>size))
|
if (((diff + sizeof(struct ospf_lsa_header)) >= size)
|
||||||
|
|| ((lenn + diff) > size))
|
||||||
{
|
{
|
||||||
log(L_WARN "Received lsupd from %I is too short!", n->ip);
|
log(L_WARN "Received lsupd from %I is too short!", n->ip);
|
||||||
ospf_neigh_sm(n, INM_BADLSREQ);
|
ospf_neigh_sm(n, INM_BADLSREQ);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((lenn<=sizeof(struct ospf_lsa_header))||(lenn!=(4*(lenn/4))))
|
if ((lenn <= sizeof(struct ospf_lsa_header))
|
||||||
|
|| (lenn != (4 * (lenn / 4))))
|
||||||
{
|
{
|
||||||
log(L_WARN "Received LSA from %I with bad length", n->ip);
|
log(L_WARN "Received LSA from %I with bad length", n->ip);
|
||||||
ospf_neigh_sm(n, INM_BADLSREQ);
|
ospf_neigh_sm(n, INM_BADLSREQ);
|
||||||
|
@ -326,53 +353,53 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg 143 (1) */
|
/* pg 143 (1) */
|
||||||
chsum=lsa->checksum;
|
chsum = lsa->checksum;
|
||||||
if(chsum!=lsasum_check(lsa,NULL,po))
|
if (chsum != lsasum_check(lsa, NULL, po))
|
||||||
{
|
{
|
||||||
log(L_WARN "Received bad lsa checksum from %I", n->ip);
|
log(L_WARN "Received bad lsa checksum from %I", n->ip);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg 143 (2) */
|
/* pg 143 (2) */
|
||||||
if((lsa->type<LSA_T_RT)||(lsa->type>LSA_T_EXT))
|
if ((lsa->type < LSA_T_RT) || (lsa->type > LSA_T_EXT))
|
||||||
{
|
{
|
||||||
log(L_WARN "Unknown LSA type from %I", n->ip);
|
log(L_WARN "Unknown LSA type from %I", n->ip);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg 143 (3) */
|
/* pg 143 (3) */
|
||||||
if((lsa->type==LSA_T_EXT)&&oa->stub)
|
if ((lsa->type == LSA_T_EXT) && oa->stub)
|
||||||
{
|
{
|
||||||
log(L_WARN "Received External LSA in stub area from %I", n->ip);
|
log(L_WARN "Received External LSA in stub area from %I", n->ip);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ntohlsah(lsa,&lsatmp);
|
ntohlsah(lsa, &lsatmp);
|
||||||
|
|
||||||
DBG("Update Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
|
DBG("Update Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
|
||||||
lsatmp.type, lsatmp.id, lsatmp.rt, lsatmp.sn, lsatmp.age,
|
lsatmp.type, lsatmp.id, lsatmp.rt, lsatmp.sn, lsatmp.age,
|
||||||
lsatmp.checksum);
|
lsatmp.checksum);
|
||||||
|
|
||||||
lsadb=ospf_hash_find_header(oa->gr, &lsatmp);
|
lsadb = ospf_hash_find_header(oa->gr, &lsatmp);
|
||||||
|
|
||||||
#ifdef LOCAL_DEBUG
|
#ifdef LOCAL_DEBUG
|
||||||
if(lsadb)
|
if (lsadb)
|
||||||
DBG("I have Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
|
DBG("I have Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
|
||||||
lsadb->lsa.type, lsadb->lsa.id, lsadb->lsa.rt, lsadb->lsa.sn,
|
lsadb->lsa.type, lsadb->lsa.id, lsadb->lsa.rt, lsadb->lsa.sn,
|
||||||
lsadb->lsa.age, lsadb->lsa.checksum);
|
lsadb->lsa.age, lsadb->lsa.checksum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* pg 143 (4) */
|
/* pg 143 (4) */
|
||||||
if((lsatmp.age==LSA_MAXAGE)&&(lsadb==NULL)&&can_flush_lsa(oa))
|
if ((lsatmp.age == LSA_MAXAGE) && (lsadb == NULL) && can_flush_lsa(oa))
|
||||||
{
|
{
|
||||||
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg 144 (5) */
|
/* pg 144 (5) */
|
||||||
if((lsadb==NULL)||(lsa_comp(&lsatmp,&lsadb->lsa)==CMP_NEWER))
|
if ((lsadb == NULL) || (lsa_comp(&lsatmp, &lsadb->lsa) == CMP_NEWER))
|
||||||
{
|
{
|
||||||
struct ospf_iface *ift=NULL;
|
struct ospf_iface *ift = NULL;
|
||||||
void *body;
|
void *body;
|
||||||
struct ospf_iface *nifa;
|
struct ospf_iface *nifa;
|
||||||
int self = (lsatmp.rt == p->cf->global->router_id);
|
int self = (lsatmp.rt == p->cf->global->router_id);
|
||||||
|
@ -380,93 +407,98 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
DBG("PG143(5): Received LSA is newer\n");
|
DBG("PG143(5): Received LSA is newer\n");
|
||||||
|
|
||||||
/* pg 145 (5f) - premature aging of self originated lsa */
|
/* pg 145 (5f) - premature aging of self originated lsa */
|
||||||
if((!self) && (lsatmp.type==LSA_T_NET))
|
if ((!self) && (lsatmp.type == LSA_T_NET))
|
||||||
{
|
{
|
||||||
WALK_LIST(nifa,po->iface_list)
|
WALK_LIST(nifa, po->iface_list)
|
||||||
{
|
{
|
||||||
if(ipa_compare(nifa->iface->addr->ip,ipa_from_u32(lsatmp.id))==0)
|
if (ipa_compare(nifa->iface->addr->ip, ipa_from_u32(lsatmp.id)) ==
|
||||||
{
|
0)
|
||||||
self = 1;
|
{
|
||||||
break;
|
self = 1;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self)
|
if (self)
|
||||||
{
|
{
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
|
|
||||||
if((lsatmp.age==LSA_MAXAGE)&&(lsatmp.sn==LSA_MAXSEQNO))
|
if ((lsatmp.age == LSA_MAXAGE) && (lsatmp.sn == LSA_MAXSEQNO))
|
||||||
{
|
{
|
||||||
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lsatmp.age=LSA_MAXAGE;
|
lsatmp.age = LSA_MAXAGE;
|
||||||
lsatmp.sn=LSA_MAXSEQNO;
|
lsatmp.sn = LSA_MAXSEQNO;
|
||||||
lsa->age=htons(LSA_MAXAGE);
|
lsa->age = htons(LSA_MAXAGE);
|
||||||
lsa->sn=htonl(LSA_MAXSEQNO);
|
lsa->sn = htonl(LSA_MAXSEQNO);
|
||||||
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa.");
|
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa.");
|
||||||
OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I",lsatmp.type,
|
OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I", lsatmp.type,
|
||||||
lsatmp.id, lsatmp.rt);
|
lsatmp.id, lsatmp.rt);
|
||||||
lsasum_check(lsa,(lsa+1),po); /* It also calculates chsum! */
|
lsasum_check(lsa, (lsa + 1), po); /* It also calculates chsum! */
|
||||||
lsatmp.checksum=ntohs(lsa->checksum);
|
lsatmp.checksum = ntohs(lsa->checksum);
|
||||||
flood_lsa(NULL,lsa,&lsatmp,po,NULL,oa,0);
|
ospf_lsupd_flood(NULL, lsa, &lsatmp, NULL, oa, 0);
|
||||||
if(en=ospf_hash_find_header(oa->gr,&lsatmp))
|
if (en = ospf_hash_find_header(oa->gr, &lsatmp))
|
||||||
{
|
{
|
||||||
flood_lsa(NULL,NULL,&en->lsa,po,NULL,oa,1);
|
ospf_lsupd_flood(NULL, NULL, &en->lsa, NULL, oa, 1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg 144 (5a) */
|
/* pg 144 (5a) */
|
||||||
if(lsadb && ((now-lsadb->inst_t)<=MINLSARRIVAL)) /* FIXME: test for flooding? */
|
if (lsadb && ((now - lsadb->inst_t) <= MINLSARRIVAL)) /* FIXME: test for flooding? */
|
||||||
{
|
{
|
||||||
DBG("I got it in less that MINLSARRIVAL\n");
|
DBG("I got it in less that MINLSARRIVAL\n");
|
||||||
sendreq = 0;
|
sendreq = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flood_lsa(n,lsa,&lsatmp,po,ifa,ifa->oa,1)==0)
|
if (ospf_lsupd_flood(n, lsa, &lsatmp, ifa, ifa->oa, 1) == 0)
|
||||||
{
|
{
|
||||||
DBG("Wasn't flooded back\n"); /* ps 144(5e), pg 153 */
|
DBG("Wasn't flooded back\n"); /* ps 144(5e), pg 153 */
|
||||||
if(ifa->state==OSPF_IS_BACKUP)
|
if (ifa->state == OSPF_IS_BACKUP)
|
||||||
{
|
{
|
||||||
if(ifa->drid==n->rid) ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
if (ifa->drid == n->rid)
|
||||||
|
ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
||||||
}
|
}
|
||||||
else ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
else
|
||||||
|
ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove old from all ret lists */
|
/* Remove old from all ret lists */
|
||||||
/* pg 144 (5c) */
|
/* pg 144 (5c) */
|
||||||
if(lsadb)
|
if (lsadb)
|
||||||
WALK_LIST(NODE ift,po->iface_list)
|
WALK_LIST(NODE ift, po->iface_list)
|
||||||
WALK_LIST(NODE ntmp,ift->neigh_list)
|
WALK_LIST(NODE ntmp, ift->neigh_list)
|
||||||
{
|
|
||||||
struct top_hash_entry *en;
|
|
||||||
if(ntmp->state>NEIGHBOR_EXSTART)
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if((lsatmp.age==LSA_MAXAGE)&&(lsatmp.sn==LSA_MAXSEQNO)
|
|
||||||
&&lsadb&&can_flush_lsa(oa))
|
|
||||||
{
|
{
|
||||||
flush_lsa(lsadb,oa);
|
struct top_hash_entry *en;
|
||||||
schedule_rtcalc(oa);
|
if (ntmp->state > NEIGHBOR_EXSTART)
|
||||||
continue;
|
if ((en = ospf_hash_find_header(ntmp->lsrth, &lsadb->lsa)) != NULL)
|
||||||
} /* FIXME lsack? */
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lsatmp.age == LSA_MAXAGE) && (lsatmp.sn == LSA_MAXSEQNO)
|
||||||
|
&& lsadb && can_flush_lsa(oa))
|
||||||
|
{
|
||||||
|
flush_lsa(lsadb, oa);
|
||||||
|
schedule_rtcalc(oa);
|
||||||
|
continue;
|
||||||
|
} /* FIXME lsack? */
|
||||||
|
|
||||||
/* pg 144 (5d) */
|
/* pg 144 (5d) */
|
||||||
body=mb_alloc(p->pool,lsatmp.length-sizeof(struct ospf_lsa_header));
|
body =
|
||||||
ntohlsab(lsa+1,body,lsatmp.type,
|
mb_alloc(p->pool, lsatmp.length - sizeof(struct ospf_lsa_header));
|
||||||
lsatmp.length-sizeof(struct ospf_lsa_header));
|
ntohlsab(lsa + 1, body, lsatmp.type,
|
||||||
lsadb=lsa_install_new(&lsatmp,body, oa);
|
lsatmp.length - sizeof(struct ospf_lsa_header));
|
||||||
|
lsadb = lsa_install_new(&lsatmp, body, oa);
|
||||||
DBG("New LSA installed in DB\n");
|
DBG("New LSA installed in DB\n");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -475,33 +507,35 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
/* FIXME pg145 (6) */
|
/* FIXME pg145 (6) */
|
||||||
|
|
||||||
/* pg145 (7) */
|
/* pg145 (7) */
|
||||||
if(lsa_comp(&lsatmp,&lsadb->lsa)==CMP_SAME)
|
if (lsa_comp(&lsatmp, &lsadb->lsa) == CMP_SAME)
|
||||||
{
|
{
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
DBG("PG145(7) Got the same LSA\n");
|
DBG("PG145(7) Got the same LSA\n");
|
||||||
if((en=ospf_hash_find_header(n->lsrth,&lsadb->lsa))!=NULL)
|
if ((en = ospf_hash_find_header(n->lsrth, &lsadb->lsa)) != NULL)
|
||||||
{
|
{
|
||||||
/* pg145 (7a) */
|
/* pg145 (7a) */
|
||||||
s_rem_node(SNODE en);
|
s_rem_node(SNODE en);
|
||||||
if(en->lsa_body!=NULL) mb_free(en->lsa_body);
|
if (en->lsa_body != NULL)
|
||||||
en->lsa_body=NULL;
|
mb_free(en->lsa_body);
|
||||||
ospf_hash_delete(n->lsrth, en);
|
en->lsa_body = NULL;
|
||||||
if(ifa->state==OSPF_IS_BACKUP)
|
ospf_hash_delete(n->lsrth, en);
|
||||||
{
|
if (ifa->state == OSPF_IS_BACKUP)
|
||||||
if(n->rid==ifa->drid) ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
{
|
||||||
}
|
if (n->rid == ifa->drid)
|
||||||
|
ospf_lsack_enqueue(n, lsa, ACKL_DELAY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* pg145 (7b) */
|
/* pg145 (7b) */
|
||||||
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
ospf_lsack_enqueue(n, lsa, ACKL_DIRECT);
|
||||||
}
|
}
|
||||||
sendreq = 0;
|
sendreq = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pg145 (8) */
|
/* pg145 (8) */
|
||||||
if((lsadb->lsa.age==LSA_MAXAGE)&&(lsadb->lsa.sn==LSA_MAXSEQNO))
|
if ((lsadb->lsa.age == LSA_MAXAGE) && (lsadb->lsa.sn == LSA_MAXSEQNO))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -510,36 +544,35 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
list l;
|
list l;
|
||||||
struct l_lsr_head ll;
|
struct l_lsr_head ll;
|
||||||
init_list(&l);
|
init_list(&l);
|
||||||
ll.lsh.id=lsadb->lsa.id;
|
ll.lsh.id = lsadb->lsa.id;
|
||||||
ll.lsh.rt=lsadb->lsa.rt;
|
ll.lsh.rt = lsadb->lsa.rt;
|
||||||
ll.lsh.type=lsadb->lsa.type;
|
ll.lsh.type = lsadb->lsa.type;
|
||||||
add_tail(&l, NODE &ll);
|
add_tail(&l, NODE & ll);
|
||||||
ospf_lsupd_tx_list(n, &l);
|
ospf_lsupd_send_list(n, &l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send direct LSAs */
|
/* Send direct LSAs */
|
||||||
ospf_lsack_send(n, ACKL_DIRECT);
|
ospf_lsack_send(n, ACKL_DIRECT);
|
||||||
|
|
||||||
if(sendreq && (n->state==NEIGHBOR_LOADING))
|
if (sendreq && (n->state == NEIGHBOR_LOADING))
|
||||||
{
|
{
|
||||||
ospf_lsreq_send(n); /* Ask for another part of neighbor's database */
|
ospf_lsreq_send(n); /* Ask for another part of neighbor's database */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
|
ospf_lsupd_flush_nlsa(struct top_hash_entry *en, struct ospf_area *oa)
|
||||||
struct ospf_area *oa)
|
|
||||||
{
|
{
|
||||||
struct ospf_lsa_header *lsa=&en->lsa;
|
struct ospf_lsa_header *lsa = &en->lsa;
|
||||||
struct proto *p=&po->proto;
|
struct proto_ospf *po = oa->po;
|
||||||
|
struct proto *p = &po->proto;
|
||||||
|
|
||||||
lsa->age=LSA_MAXAGE;
|
lsa->age = LSA_MAXAGE;
|
||||||
lsa->sn=LSA_MAXSEQNO;
|
lsa->sn = LSA_MAXSEQNO;
|
||||||
lsasum_calculate(lsa,en->lsa_body,po);
|
lsasum_calculate(lsa, en->lsa_body, po);
|
||||||
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa!");
|
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa!");
|
||||||
OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I", lsa->type,
|
OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I", lsa->type,
|
||||||
lsa->id, lsa->rt);
|
lsa->id, lsa->rt);
|
||||||
flood_lsa(NULL,NULL,lsa,po,NULL,oa,0);
|
ospf_lsupd_flood(NULL, NULL, lsa, NULL, oa, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 2000 Ondrej Filip <feela@network.cz>
|
* (c) 2000--2004 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*
|
*
|
||||||
|
@ -10,14 +10,12 @@
|
||||||
#ifndef _BIRD_OSPF_LSUPD_H_
|
#ifndef _BIRD_OSPF_LSUPD_H_
|
||||||
#define _BIRD_OSPF_LSUPD_H_
|
#define _BIRD_OSPF_LSUPD_H_
|
||||||
|
|
||||||
void ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l);
|
void ospf_lsupd_send_list(struct ospf_neighbor *n, list * l);
|
||||||
void ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
void ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size);
|
struct ospf_iface *ifa, u16 size);
|
||||||
int flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
int ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
|
||||||
struct ospf_lsa_header *hh, struct proto_ospf *po, struct ospf_iface *iff,
|
struct ospf_lsa_header *hh, struct ospf_iface *iff,
|
||||||
struct ospf_area *oa, int rtl);
|
struct ospf_area *oa, int rtl);
|
||||||
void net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
|
void ospf_lsupd_flush_nlsa(struct top_hash_entry *en, struct ospf_area *oa);
|
||||||
struct ospf_area *oa);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_LSUPD_H_ */
|
#endif /* _BIRD_OSPF_LSUPD_H_ */
|
||||||
|
|
|
@ -600,7 +600,7 @@ rxmt_timer_hook(timer *timer)
|
||||||
en->lsa.id, en->lsa.rt, en->lsa.type);
|
en->lsa.id, en->lsa.rt, en->lsa.type);
|
||||||
add_tail(&uplist, NODE llsh);
|
add_tail(&uplist, NODE llsh);
|
||||||
}
|
}
|
||||||
ospf_lsupd_tx_list(n, &uplist);
|
ospf_lsupd_send_list(n, &uplist);
|
||||||
rfree(upslab);
|
rfree(upslab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old, ea_list *attrs)
|
||||||
ext=en->lsa_body;
|
ext=en->lsa_body;
|
||||||
if(ipa_compare(ext->netmask, ipa_mkmask(n->n.pxlen))==0)
|
if(ipa_compare(ext->netmask, ipa_mkmask(n->n.pxlen))==0)
|
||||||
{
|
{
|
||||||
net_flush_lsa(en,po,oa);
|
ospf_lsupd_flush_nlsa(en,oa);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* BIRD -- OSPF Topological Database
|
* BIRD -- OSPF Topological Database
|
||||||
*
|
*
|
||||||
* (c) 1999 Martin Mares <mj@ucw.cz>
|
* (c) 1999 Martin Mares <mj@ucw.cz>
|
||||||
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2004 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -215,7 +215,7 @@ originate_rt_lsa(struct ospf_area *oa)
|
||||||
lsasum_calculate(&lsa,body,po);
|
lsasum_calculate(&lsa,body,po);
|
||||||
en=lsa_install_new(&lsa, body, oa);
|
en=lsa_install_new(&lsa, body, oa);
|
||||||
oa->rt=en;
|
oa->rt=en;
|
||||||
flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa,1);
|
ospf_lsupd_flood(NULL,NULL,&oa->rt->lsa,NULL,oa,1);
|
||||||
schedule_rtcalc(oa);
|
schedule_rtcalc(oa);
|
||||||
oa->origrt=0;
|
oa->origrt=0;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ originate_net_lsa(struct ospf_iface *ifa)
|
||||||
ifa->iface->name);
|
ifa->iface->name);
|
||||||
ifa->nlsa->lsa.sn+=1;
|
ifa->nlsa->lsa.sn+=1;
|
||||||
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
||||||
flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
|
ospf_lsupd_flood(NULL,NULL,&ifa->nlsa->lsa,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);
|
if(ifa->nlsa->lsa_body!=NULL) mb_free(ifa->nlsa->lsa_body);
|
||||||
ifa->nlsa->lsa_body=NULL;
|
ifa->nlsa->lsa_body=NULL;
|
||||||
|
@ -312,7 +312,7 @@ originate_net_lsa(struct ospf_iface *ifa)
|
||||||
body=originate_net_lsa_body(ifa, &lsa.length, po);
|
body=originate_net_lsa_body(ifa, &lsa.length, po);
|
||||||
lsasum_calculate(&lsa,body,po);
|
lsasum_calculate(&lsa,body,po);
|
||||||
ifa->nlsa=lsa_install_new(&lsa, body, ifa->oa);
|
ifa->nlsa=lsa_install_new(&lsa, body, ifa->oa);
|
||||||
flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,1);
|
ospf_lsupd_flood(NULL,NULL,&ifa->nlsa->lsa,NULL,ifa->oa,1);
|
||||||
ifa->orignet=0;
|
ifa->orignet=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs)
|
||||||
WALK_LIST(oa, po->area_list)
|
WALK_LIST(oa, po->area_list)
|
||||||
{
|
{
|
||||||
en=lsa_install_new(&lsa, body, oa);
|
en=lsa_install_new(&lsa, body, oa);
|
||||||
flood_lsa(NULL,NULL,&en->lsa,po,NULL,oa,1);
|
ospf_lsupd_flood(NULL,NULL,&en->lsa,NULL,oa,1);
|
||||||
body=originate_ext_lsa_body(n, e, po, attrs);
|
body=originate_ext_lsa_body(n, e, po, attrs);
|
||||||
}
|
}
|
||||||
mb_free(body);
|
mb_free(body);
|
||||||
|
|
Loading…
Reference in a new issue