summaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-03-29 19:18:06 +0200
committerOndrej Filip <feela@network.cz>2000-03-29 19:18:06 +0200
commit910e557b47f52bf38aa923a69249670d71befc02 (patch)
treeeb7bb463fb7ae1cc8651ef5e7224086ff8c866b9 /proto
parent315648af8ed75c91e0dd82748a933963b9e0c4ec (diff)
downloadbird-910e557b47f52bf38aa923a69249670d71befc02.tar
bird-910e557b47f52bf38aa923a69249670d71befc02.zip
Many changes in dbdes sending & receiving. EXDONE caused.
Diffstat (limited to 'proto')
-rw-r--r--proto/ospf/dbdes.c122
-rw-r--r--proto/ospf/hello.c6
-rw-r--r--proto/ospf/iface.c10
-rw-r--r--proto/ospf/neighbor.c6
-rw-r--r--proto/ospf/ospf.h4
5 files changed, 113 insertions, 35 deletions
diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c
index 1b82a4e..fb7ee93 100644
--- a/proto/ospf/dbdes.c
+++ b/proto/ospf/dbdes.c
@@ -59,7 +59,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
pkt->iface_mtu=htons(ifa->iface->mtu); /*FIXME NOT for VLINK! */
pkt->options= ifa->options;
pkt->imms=n->myimms;
- pkt->ddseq=n->dds;
+ pkt->ddseq=htonl(n->dds);
length=sizeof(struct ospf_dbdes_packet);
op->length=htons(length);
ospf_pkt_finalize(ifa, op);
@@ -69,8 +69,8 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
case NEIGHBOR_EXCHANGE:
n->myimms.bit.i=0;
- if(! (((n->myimms.bit.ms) && (n->dds==n->ddr+1)) ||
- ((!(n->myimms.bit.ms)) && (n->dds==n->ddr))))
+ if(((n->myimms.bit.ms) && (n->dds==n->ddr+1)) ||
+ ((!(n->myimms.bit.ms)) && (n->dds==n->ddr)))
{
snode *sn; /* Send next */
struct ospf_lsa_header *lsa;
@@ -81,12 +81,15 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
fill_ospf_pkt_hdr(ifa, pkt, DBDES);
pkt->iface_mtu=htons(ifa->iface->mtu);
pkt->options= ifa->options;
- pkt->ddseq=n->dds;
+ pkt->ddseq=htonl(n->dds);
j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet))/
sizeof(struct ospf_lsa_header); /* Number of lsaheaders */
lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet));
+ if(n->myimms.bit.m)
+ {
+
sn=s_get(&(n->dbsi));
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("M bit unset.\n");
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);
+ }
pkt->imms.byte=n->myimms.byte;
@@ -128,6 +131,9 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
ospf_pkt_finalize(ifa, op);
}
+ case NEIGHBOR_LOADING:
+ case NEIGHBOR_FULL:
+
aa=ifa->ip_sk->tbuf;
bb=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);
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 */
+ die("Bug in dbdes sending\n");
break;
}
}
@@ -164,13 +182,54 @@ rxmt_timer_hook(timer *timer)
struct proto *p;
struct ospf_neighbor *n;
- ifa=(struct ospf_iface *)timer->data;
+ n=(struct ospf_neighbor *)timer->data;
+ ifa=n->ifa;
p=(struct proto *)(ifa->proto);
debug("%s: RXMT timer fired on interface %s.\n",
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
+ */
+{
+ if(l1->sn<l2->sn) return 1;
+ if(l1->sn==l2->sn)
{
- ospf_dbdes_tx(n);
+ 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)))
{
/* I'm slave! */
- n->dds=ps->ddseq;
+ n->dds=ntohl(ps->ddseq);
+ n->ddr=ntohl(ps->ddseq);
n->options=ps->options;
n->myimms.bit.ms=0;
- n->ddr=ps->ddseq;
n->imms.byte=ps->imms.byte;
debug("%s: I'm slave to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE);
- tm_stop(n->ifa->rxmt_timer);
+ tm_stop(n->rxmt_timer);
+ ospf_dbdes_tx(n);
+ break;
}
else
{
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! */
n->options=ps->options;
- n->ddr=ps->ddseq;
+ n->ddr=ntohl(ps->ddseq)-1;
n->imms.byte=ps->imms.byte;
debug("%s: I'm master to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE);
@@ -240,15 +301,15 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
else
{
debug("%s: Nothing happend to %u (imms=%u)", p->name, nrid,
- ps->imms);
+ ps->imms.byte);
break;
}
}
- break; /* I should probably continue processing packet */
+ //break; /* I should probably continue processing packet */
case NEIGHBOR_EXCHANGE:
if((ps->imms.byte==n->imms.byte) && (ps->options=n->options) &&
- (ps->ddseq==n->dds))
+ (ntohl(ps->ddseq)==n->ddr))
{
/* Duplicate packet */
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;
}
- 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);
break;
}
@@ -282,25 +345,38 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
if(n->myimms.bit.ms)
{
- if(ps->ddseq!=n->dds)
+ if(ntohl(ps->ddseq)!=n->dds) /* MASTER */
{
DBG("SEQMIS-MASTER\n");
ospf_neigh_sm(n, INM_SEQMIS);
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
+ {
+ ospf_dbdes_tx(n);
+ }
+
}
else
{
- if(ps->ddseq!=(n->dds+1))
+ if(ps->ddseq!=(n->dds+1)) /* SLAVE */
{
DBG("SEQMIS-SLAVE\n");
ospf_neigh_sm(n, INM_SEQMIS);
break;
}
+ n->ddr=ps->ddseq;
+ ospf_dbdes_reqladd(ps,p,n);
+ ospf_dbdes_tx(n);
}
- /* FIXME: Packet accepted, go on */
-
break;
case NEIGHBOR_LOADING:
case NEIGHBOR_FULL:
diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c
index e3b8168..e025ae4 100644
--- a/proto/ospf/hello.c
+++ b/proto/ospf/hello.c
@@ -106,6 +106,12 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
n->ldbdes=mb_alloc(p->pool, ifa->iface->mtu);
neigh_chstate(n,NEIGHBOR_DOWN);
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);
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index e2aaa7a..2d53cf5 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -211,14 +211,6 @@ ospf_add_timers(struct ospf_iface *ifa, pool *pool)
ifa->hello_timer->recurrent=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->data=ifa;
ifa->wait_timer->randomize=0;
@@ -226,6 +218,8 @@ ospf_add_timers(struct ospf_iface *ifa, pool *pool)
ifa->wait_timer->recurrent=0;
if(ifa->waitint==0) ifa->waitint= WAIT_DMH*ifa->helloint;
DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint);
+
+ if(ifa->rxmtint==0) ifa->rxmtint=RXMTINT_D;
}
void
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index 3f9b0eb..d08e58c 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -163,7 +163,7 @@ tryadj(struct ospf_neighbor *n, struct proto *p)
n->myimms.bit.ms=1;
n->myimms.bit.m=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
@@ -210,10 +210,12 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
s_init_list(&(n->lsrql));
s_init_list(&(n->lsrtl));
s_init(&(n->dbsi), &(n->ifa->oa->lsal));
- ospf_dbdes_tx(n);
+ /*ospf_dbdes_tx(n);*/
}
break;
case INM_EXDONE:
+ neigh_chstate(n,NEIGHBOR_LOADING);
+ /* FIXME Go on */
break;
case INM_LOADDONE:
break;
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 6557355..06ca56d 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -94,7 +94,6 @@ struct ospf_iface {
#define OSPF_IS_DR 6 /* I'm DR */
timer *wait_timer; /* WAIT timer */
timer *hello_timer; /* HELLOINT timer */
- timer *rxmt_timer; /* RXMT timer */
/* Default values for interface parameters */
#define COST_D 10
#define RXMTINT_D 5
@@ -172,7 +171,7 @@ struct ospf_lsa_header {
#define LSA_T_SUM_RT 4
#define LSA_T_EXT 5
u32 rt; /* Advertising router */
- u32 sn; /* LS Sequence number */
+ s32 sn; /* LS Sequence number */
#define LSA_INITSEQNO 0x80000001
#define LSA_MAXSEQNO 0x7fffffff
u16 checksum;
@@ -264,6 +263,7 @@ struct ospf_neighbor
slist lsrtl; /* Link state retransmission list */
siterator lsrti;
void *ldbdes; /* Last database description packet */
+ timer *rxmt_timer; /* RXMT timer */
};
/* Definitions for interface state machine */