Better adjacency building, some minor bugfixes.

This commit is contained in:
Ondrej Filip 2004-06-11 09:34:48 +00:00
parent 9a4b87905d
commit b1f7229ad7
2 changed files with 41 additions and 22 deletions

View file

@ -117,6 +117,7 @@ ospf_dbdes_send(struct ospf_neighbor *n)
case NEIGHBOR_LOADING: case NEIGHBOR_LOADING:
case NEIGHBOR_FULL: case NEIGHBOR_FULL:
pkt = n->ldbdes;
length = ntohs(((struct ospf_packet *) n->ldbdes)->length); length = ntohs(((struct ospf_packet *) n->ldbdes)->length);
if (!length) if (!length)
@ -130,8 +131,14 @@ ospf_dbdes_send(struct ospf_neighbor *n)
/* Copy last sent packet again */ /* Copy last sent packet again */
sk_send_to(ifa->ip_sk, length, n->ip, OSPF_PROTO); sk_send_to(ifa->ip_sk, length, n->ip, OSPF_PROTO);
if(n->myimms.bit.ms) tm_start(n->rxmt_timer, n->ifa->rxmtint); /* Restart timer */
OSPF_TRACE(D_PACKETS, "DB_DES (M) sent to %I via %s.", n->ip, OSPF_TRACE(D_PACKETS, "DB_DES (M) sent to %I via %s.", n->ip,
ifa->iface->name); ifa->iface->name);
DBG("DB_DES PS=%u, M=%u.", ntohl(pkt->ddseq), pkt->imms.bit.m);
if (!n->myimms.bit.ms) if (!n->myimms.bit.ms)
{ {
if ((n->myimms.bit.m == 0) && (n->imms.bit.m == 0) && if ((n->myimms.bit.m == 0) && (n->imms.bit.m == 0) &&
@ -190,6 +197,9 @@ ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
OSPF_TRACE(D_PACKETS, "Received dbdes from %I via %s.", n->ip, OSPF_TRACE(D_PACKETS, "Received dbdes from %I via %s.", n->ip,
ifa->iface->name); ifa->iface->name);
DBG("DB_DES PS=%u, M=%u SIZE=%u.", ntohl(ps->ddseq), ps->imms.bit.m, size);
ospf_neigh_sm(n, INM_HELLOREC); ospf_neigh_sm(n, INM_HELLOREC);
switch (n->state) switch (n->state)
@ -218,14 +228,13 @@ ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
ospf_dbdes_send(n); ospf_dbdes_send(n);
break; break;
} }
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 == ntohl(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 = ntohl(ps->ddseq) - 1; n->ddr = ntohl(ps->ddseq) - 1; /* It will be set corectly a few lines down */
n->imms.byte = ps->imms.byte; n->imms.byte = ps->imms.byte;
OSPF_TRACE(D_PACKETS, "I'm master to %I.", n->ip); OSPF_TRACE(D_PACKETS, "I'm master to %I.", n->ip);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
@ -236,9 +245,8 @@ ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
ps->imms.byte); ps->imms.byte);
break; break;
} }
} if(ps->imms.bit.i) log("FUCK");
if (ps->imms.bit.i)
break;
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) &&
(ntohl(ps->ddseq) == n->ddr)) (ntohl(ps->ddseq) == n->ddr))
@ -331,6 +339,7 @@ ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
{ {
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)", OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)",
n->ip); n->ip);
DBG("PS=%u, DDR=%u, DDS=%u", ntohl(ps->ddseq), n->ddr, n->dds);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
} }
break; break;

View file

@ -605,14 +605,24 @@ rxmt_timer_hook(timer * timer)
DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n", DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n",
p->name, ifa->iface->name, n->ip); p->name, ifa->iface->name, n->ip);
if (n->state < NEIGHBOR_LOADING)
if(n->state < NEIGHBOR_EXSTART) return;
if (n->state == NEIGHBOR_EXSTART)
{
ospf_dbdes_send(n);
return;
}
if ((n->state == NEIGHBOR_EXCHANGE) && n->myimms.bit.ms) /* I'm master */
ospf_dbdes_send(n); ospf_dbdes_send(n);
if (n->state < NEIGHBOR_FULL) if (n->state < NEIGHBOR_FULL)
ospf_lsreq_send(n); ospf_lsreq_send(n); /* EXCHANGE or LOADING */
else else
{ {
if (!EMPTY_SLIST(n->lsrtl)) if (!EMPTY_SLIST(n->lsrtl)) /* FULL */
{ {
list uplist; list uplist;
slab *upslab; slab *upslab;