Many changes in dbdes sending & receiving. EXDONE caused.

This commit is contained in:
Ondrej Filip 2000-03-29 17:18:06 +00:00
parent 315648af8e
commit 910e557b47
5 changed files with 113 additions and 35 deletions

View file

@ -59,7 +59,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
pkt->iface_mtu=htons(ifa->iface->mtu); /*FIXME NOT for VLINK! */ pkt->iface_mtu=htons(ifa->iface->mtu); /*FIXME NOT for VLINK! */
pkt->options= ifa->options; pkt->options= ifa->options;
pkt->imms=n->myimms; pkt->imms=n->myimms;
pkt->ddseq=n->dds; pkt->ddseq=htonl(n->dds);
length=sizeof(struct ospf_dbdes_packet); length=sizeof(struct ospf_dbdes_packet);
op->length=htons(length); op->length=htons(length);
ospf_pkt_finalize(ifa, op); ospf_pkt_finalize(ifa, op);
@ -69,8 +69,8 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
n->myimms.bit.i=0; n->myimms.bit.i=0;
if(! (((n->myimms.bit.ms) && (n->dds==n->ddr+1)) || if(((n->myimms.bit.ms) && (n->dds==n->ddr+1)) ||
((!(n->myimms.bit.ms)) && (n->dds==n->ddr)))) ((!(n->myimms.bit.ms)) && (n->dds==n->ddr)))
{ {
snode *sn; /* Send next */ snode *sn; /* Send next */
struct ospf_lsa_header *lsa; struct ospf_lsa_header *lsa;
@ -81,12 +81,15 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
fill_ospf_pkt_hdr(ifa, pkt, DBDES); fill_ospf_pkt_hdr(ifa, pkt, DBDES);
pkt->iface_mtu=htons(ifa->iface->mtu); pkt->iface_mtu=htons(ifa->iface->mtu);
pkt->options= ifa->options; pkt->options= ifa->options;
pkt->ddseq=n->dds; pkt->ddseq=htonl(n->dds);
j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet))/ j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet))/
sizeof(struct ospf_lsa_header); /* Number of lsaheaders */ sizeof(struct ospf_lsa_header); /* Number of lsaheaders */
lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet)); lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet));
if(n->myimms.bit.m)
{
sn=s_get(&(n->dbsi)); sn=s_get(&(n->dbsi));
DBG("Number of LSA: %d\n", j); DBG("Number of LSA: %d\n", j);
@ -114,10 +117,10 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
DBG("Number of LSA NOT sent: %d\n", i); DBG("Number of LSA NOT sent: %d\n", i);
DBG("M bit unset.\n"); DBG("M bit unset.\n");
n->myimms.bit.m=0; /* Unset more bit */ n->myimms.bit.m=0; /* Unset more bit */
DBG("Ini: %d, M: %d MS: %d.\n",n->imms.bit.i, n->imms.bit.m, n->imms.bit.ms);
} }
s_put(&(n->dbsi),sn); s_put(&(n->dbsi),sn);
}
pkt->imms.byte=n->myimms.byte; pkt->imms.byte=n->myimms.byte;
@ -128,6 +131,9 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
ospf_pkt_finalize(ifa, op); ospf_pkt_finalize(ifa, op);
} }
case NEIGHBOR_LOADING:
case NEIGHBOR_FULL:
aa=ifa->ip_sk->tbuf; aa=ifa->ip_sk->tbuf;
bb=n->ldbdes; bb=n->ldbdes;
op=n->ldbdes; op=n->ldbdes;
@ -150,9 +156,21 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO); sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO);
debug("%s: DB_DES sent for %u.\n", p->name, n->rid); debug("%s: DB_DES sent for %u.\n", p->name, n->rid);
if(n->myimms.bit.ms) tm_start(n->ifa->rxmt_timer,1); if(n->myimms.bit.ms) tm_start(n->rxmt_timer,ifa->rxmtint);
else
{
if((n->myimms.bit.m==0) && (n->imms.bit.m==0) &&
(n->state==NEIGHBOR_EXCHANGE))
{
ospf_neigh_sm(n, INM_EXDONE);
if(n->myimms.bit.ms) tm_stop(n->rxmt_timer);
else tm_start(n->rxmt_timer,ifa->rxmtint);
}
}
break;
default: /* Ignore it */ default: /* Ignore it */
die("Bug in dbdes sending\n");
break; break;
} }
} }
@ -164,13 +182,54 @@ rxmt_timer_hook(timer *timer)
struct proto *p; struct proto *p;
struct ospf_neighbor *n; struct ospf_neighbor *n;
ifa=(struct ospf_iface *)timer->data; n=(struct ospf_neighbor *)timer->data;
ifa=n->ifa;
p=(struct proto *)(ifa->proto); p=(struct proto *)(ifa->proto);
debug("%s: RXMT timer fired on interface %s.\n", debug("%s: RXMT timer fired on interface %s.\n",
p->name, ifa->iface->name); p->name, ifa->iface->name);
WALK_LIST (n, ifa->neigh_list) /* Try to send db_des */ if(n->state<NEIGHBOR_LOADING) ospf_dbdes_tx(n);
/* else FIXME I should dealloc ldbdes */
}
int
lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2)
/*
* 1 l1 is newer
* 0 identical
* -1 l2 is newer
*/
{ {
ospf_dbdes_tx(n); if(l1->sn<l2->sn) return 1;
if(l1->sn==l2->sn)
{
if(l1->checksum=!l2->checksum) return l1->checksum<l2->checksum ? -1 :1;
if(l1->age==MAXAGE) return 1;
if(l2->age==MAXAGE) return -1;
if(abs(l1->age-l2->age)>MAXAGEDIFF) return l1->age<l2->age ? 1 : -1;
}
return 0;
}
void
ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct proto *p,
struct ospf_neighbor *n)
{
struct ospf_lsa_header *plsa,lsa;
struct top_hash_entry *he,*sn;
struct top_graph *gr;
gr=n->ifa->oa->gr;
plsa=(void *)(ps+1);
ntohlsah(plsa, &lsa);
/* FIXME Test Checksum */
if(((he=ospf_hash_find(gr,lsa.id,lsa.rt,lsa.type))==NULL)||
(lsa_comp(&lsa, &(he->lsa))==1))
{
sn=sl_alloc(gr->hash_slab);
ntohlsah(plsa, &(sn->lsa));
s_add_tail(&(n->lsrql), SNODE sn);
} }
} }
@ -216,23 +275,25 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
(size == sizeof(struct ospf_dbdes_packet))) (size == sizeof(struct ospf_dbdes_packet)))
{ {
/* I'm slave! */ /* I'm slave! */
n->dds=ps->ddseq; n->dds=ntohl(ps->ddseq);
n->ddr=ntohl(ps->ddseq);
n->options=ps->options; n->options=ps->options;
n->myimms.bit.ms=0; n->myimms.bit.ms=0;
n->ddr=ps->ddseq;
n->imms.byte=ps->imms.byte; n->imms.byte=ps->imms.byte;
debug("%s: I'm slave to %u. \n", p->name, nrid); debug("%s: I'm slave to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
tm_stop(n->ifa->rxmt_timer); tm_stop(n->rxmt_timer);
ospf_dbdes_tx(n);
break;
} }
else else
{ {
if(((ps->imms.bit.i==0) && (ps->imms.bit.ms==0)) && if(((ps->imms.bit.i==0) && (ps->imms.bit.ms==0)) &&
(n->rid < myrid) && (n->dds == ps->ddseq)) (n->rid < myrid) && (n->dds == ntohl(ps->ddseq)))
{ {
/* I'm master! */ /* I'm master! */
n->options=ps->options; n->options=ps->options;
n->ddr=ps->ddseq; n->ddr=ntohl(ps->ddseq)-1;
n->imms.byte=ps->imms.byte; n->imms.byte=ps->imms.byte;
debug("%s: I'm master to %u. \n", p->name, nrid); debug("%s: I'm master to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
@ -240,15 +301,15 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
else else
{ {
debug("%s: Nothing happend to %u (imms=%u)", p->name, nrid, debug("%s: Nothing happend to %u (imms=%u)", p->name, nrid,
ps->imms); ps->imms.byte);
break; break;
} }
} }
break; /* I should probably continue processing packet */ //break; /* I should probably continue processing packet */
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
if((ps->imms.byte==n->imms.byte) && (ps->options=n->options) && if((ps->imms.byte==n->imms.byte) && (ps->options=n->options) &&
(ps->ddseq==n->dds)) (ntohl(ps->ddseq)==n->ddr))
{ {
/* Duplicate packet */ /* Duplicate packet */
debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid); debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid);
@ -259,9 +320,11 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
return; return;
} }
if(ps->imms.bit.ms!=n->myimms.bit.m) /* M/S bit differs */ n->ddr=ntohl(ps->ddseq);
if(ps->imms.bit.ms!=n->imms.bit.ms) /* M/S bit differs */
{ {
DBG("SEQMIS-IMMS\n"); DBG("SEQMIS-BIT-MS\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
@ -282,25 +345,38 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
if(n->myimms.bit.ms) if(n->myimms.bit.ms)
{ {
if(ps->ddseq!=n->dds) if(ntohl(ps->ddseq)!=n->dds) /* MASTER */
{ {
DBG("SEQMIS-MASTER\n"); DBG("SEQMIS-MASTER\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
n->dds++;
DBG("Incrementing dds\n");
ospf_dbdes_reqladd(ps,p,n);
if((n->myimms.bit.m==0) && (ps->imms.bit.m==0))
{
ospf_neigh_sm(n, INM_EXDONE);
} }
else else
{ {
if(ps->ddseq!=(n->dds+1)) ospf_dbdes_tx(n);
}
}
else
{
if(ps->ddseq!=(n->dds+1)) /* SLAVE */
{ {
DBG("SEQMIS-SLAVE\n"); DBG("SEQMIS-SLAVE\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
n->ddr=ps->ddseq;
ospf_dbdes_reqladd(ps,p,n);
ospf_dbdes_tx(n);
} }
/* FIXME: Packet accepted, go on */
break; break;
case NEIGHBOR_LOADING: case NEIGHBOR_LOADING:
case NEIGHBOR_FULL: case NEIGHBOR_FULL:

View file

@ -106,6 +106,12 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
n->ldbdes=mb_alloc(p->pool, ifa->iface->mtu); n->ldbdes=mb_alloc(p->pool, ifa->iface->mtu);
neigh_chstate(n,NEIGHBOR_DOWN); neigh_chstate(n,NEIGHBOR_DOWN);
install_inactim(n); install_inactim(n);
n->rxmt_timer=tm_new(p->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);
} }
ospf_neigh_sm(n, INM_HELLOREC); ospf_neigh_sm(n, INM_HELLOREC);

View file

@ -211,14 +211,6 @@ ospf_add_timers(struct ospf_iface *ifa, pool *pool)
ifa->hello_timer->recurrent=ifa->helloint; ifa->hello_timer->recurrent=ifa->helloint;
DBG("%s: Installing hello timer. (%u)\n", p->name, ifa->helloint); DBG("%s: Installing hello timer. (%u)\n", p->name, ifa->helloint);
ifa->rxmt_timer=tm_new(pool);
ifa->rxmt_timer->data=ifa;
ifa->rxmt_timer->randomize=0;
if(ifa->rxmtint==0) ifa->rxmtint=RXMTINT_D;
ifa->rxmt_timer->hook=rxmt_timer_hook;
ifa->rxmt_timer->recurrent=ifa->rxmtint;
DBG("%s: Installing rxmt timer. (%u)\n", p->name, ifa->rxmtint);
ifa->wait_timer=tm_new(pool); ifa->wait_timer=tm_new(pool);
ifa->wait_timer->data=ifa; ifa->wait_timer->data=ifa;
ifa->wait_timer->randomize=0; ifa->wait_timer->randomize=0;
@ -226,6 +218,8 @@ ospf_add_timers(struct ospf_iface *ifa, pool *pool)
ifa->wait_timer->recurrent=0; ifa->wait_timer->recurrent=0;
if(ifa->waitint==0) ifa->waitint= WAIT_DMH*ifa->helloint; if(ifa->waitint==0) ifa->waitint= WAIT_DMH*ifa->helloint;
DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint); DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint);
if(ifa->rxmtint==0) ifa->rxmtint=RXMTINT_D;
} }
void void

View file

@ -163,7 +163,7 @@ tryadj(struct ospf_neighbor *n, struct proto *p)
n->myimms.bit.ms=1; n->myimms.bit.ms=1;
n->myimms.bit.m=1; n->myimms.bit.m=1;
n->myimms.bit.i=1; n->myimms.bit.i=1;
tm_start(n->ifa->rxmt_timer,1); /* Or some other number ? */ tm_start(n->rxmt_timer,1); /* Or some other number ? */
} }
void void
@ -210,10 +210,12 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
s_init_list(&(n->lsrql)); s_init_list(&(n->lsrql));
s_init_list(&(n->lsrtl)); s_init_list(&(n->lsrtl));
s_init(&(n->dbsi), &(n->ifa->oa->lsal)); s_init(&(n->dbsi), &(n->ifa->oa->lsal));
ospf_dbdes_tx(n); /*ospf_dbdes_tx(n);*/
} }
break; break;
case INM_EXDONE: case INM_EXDONE:
neigh_chstate(n,NEIGHBOR_LOADING);
/* FIXME Go on */
break; break;
case INM_LOADDONE: case INM_LOADDONE:
break; break;

View file

@ -94,7 +94,6 @@ struct ospf_iface {
#define OSPF_IS_DR 6 /* I'm DR */ #define OSPF_IS_DR 6 /* I'm DR */
timer *wait_timer; /* WAIT timer */ timer *wait_timer; /* WAIT timer */
timer *hello_timer; /* HELLOINT timer */ timer *hello_timer; /* HELLOINT timer */
timer *rxmt_timer; /* RXMT timer */
/* Default values for interface parameters */ /* Default values for interface parameters */
#define COST_D 10 #define COST_D 10
#define RXMTINT_D 5 #define RXMTINT_D 5
@ -172,7 +171,7 @@ struct ospf_lsa_header {
#define LSA_T_SUM_RT 4 #define LSA_T_SUM_RT 4
#define LSA_T_EXT 5 #define LSA_T_EXT 5
u32 rt; /* Advertising router */ u32 rt; /* Advertising router */
u32 sn; /* LS Sequence number */ s32 sn; /* LS Sequence number */
#define LSA_INITSEQNO 0x80000001 #define LSA_INITSEQNO 0x80000001
#define LSA_MAXSEQNO 0x7fffffff #define LSA_MAXSEQNO 0x7fffffff
u16 checksum; u16 checksum;
@ -264,6 +263,7 @@ struct ospf_neighbor
slist lsrtl; /* Link state retransmission list */ slist lsrtl; /* Link state retransmission list */
siterator lsrti; siterator lsrti;
void *ldbdes; /* Last database description packet */ void *ldbdes; /* Last database description packet */
timer *rxmt_timer; /* RXMT timer */
}; };
/* Definitions for interface state machine */ /* Definitions for interface state machine */