summaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2004-06-04 18:30:04 +0200
committerOndrej Filip <feela@network.cz>2004-06-04 18:30:04 +0200
commitc76ba51a5fc7d61e18213f99d9c09502af0bc192 (patch)
treee778fef3a0fe4a169ba35f162733904e40756498 /proto
parent28de5133ecdcb5b45dc251123047164fbb940e50 (diff)
downloadbird-c76ba51a5fc7d61e18213f99d9c09502af0bc192.tar
bird-c76ba51a5fc7d61e18213f99d9c09502af0bc192.zip
lsack.c cleaned. Better names for functions and
DIRECT acks can be sent in one packet now.
Diffstat (limited to 'proto')
-rw-r--r--proto/ospf/lsack.c59
-rw-r--r--proto/ospf/lsack.h11
-rw-r--r--proto/ospf/lsupd.c15
-rw-r--r--proto/ospf/neighbor.c9
-rw-r--r--proto/ospf/ospf.h4
-rw-r--r--proto/ospf/packet.c2
6 files changed, 44 insertions, 56 deletions
diff --git a/proto/ospf/lsack.c b/proto/ospf/lsack.c
index 47c7f6b..ba9717b 100644
--- a/proto/ospf/lsack.c
+++ b/proto/ospf/lsack.c
@@ -1,54 +1,35 @@
/*
* 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.
*/
#include "ospf.h"
-/* Note, that h is in network endianity! */
-void
-ospf_lsack_direct_tx(struct ospf_neighbor *n,struct ospf_lsa_header *h)
-{
- struct ospf_packet *op;
- struct ospf_lsack_packet *pk;
- sock *sk=n->ifa->ip_sk;
- struct proto *p=&n->ifa->proto->proto;
- u16 len;
-
- DBG("Sending direct ACK to %I for Type: %u, ID: %I, RT: %I\n",n->rid,
- h->type, ntohl(h->id), ntohl(h->rt));
-
- pk=(struct ospf_lsack_packet *)sk->tbuf;
- op=(struct ospf_packet *)sk->tbuf;
-
- fill_ospf_pkt_hdr(n->ifa, pk, LSACK_P);
-
- memcpy(pk+1,h,sizeof(struct ospf_lsa_header));
- len=sizeof(struct ospf_lsack_packet)+sizeof(struct ospf_lsa_header);
- op->length=htons(len);
- ospf_pkt_finalize(n->ifa, op);
- sk_send_to(sk,len, n->ip, OSPF_PROTO);
- OSPF_TRACE(D_PACKETS, "LS ack sent to %I", n->ip);
-}
+char *s_queue[]={ "direct", "delayed" };
+/*
+ * =====================================
+ * Note, that h is in network endianity!
+ * =====================================
+ */
void
-ospf_lsa_delay(struct ospf_neighbor *n,struct ospf_lsa_header *h,
- struct proto *p)
+ospf_lsack_enqueue(struct ospf_neighbor *n,struct ospf_lsa_header *h,
+ struct proto *p, int queue)
{
struct lsah_n *no;
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,
+ add_tail(&n->ackl[queue], NODE no);
+ DBG("Adding (%s) ack for %I, ID: %I, RT: %I, Type: %u\n", s_queue[queue], n->rid,
ntohl(h->id), ntohl(h->rt),h->type);
}
void
-ospf_lsack_delay_tx(struct ospf_neighbor *n)
+ospf_lsack_send(struct ospf_neighbor *n, int queue)
{
struct ospf_packet *op;
struct ospf_lsack_packet *pk;
@@ -59,7 +40,9 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
struct ospf_iface *ifa=n->ifa;
struct proto *p=&n->ifa->proto->proto;
- OSPF_TRACE(D_PACKETS, "LS ack sent to %I (delayed)",n->ip);
+ if(EMPTY_LIST(n->ackl[queue])) return;
+
+ OSPF_TRACE(D_PACKETS, "LS ack sent to %I (%s)", n->ip, s_queue[queue]);
if(ifa->type==OSPF_IT_BCAST)
{
@@ -76,9 +59,9 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
fill_ospf_pkt_hdr(n->ifa, pk, LSACK_P);
h=(struct ospf_lsa_header *)(pk+1);
- while(!EMPTY_LIST(n->ackl))
+ while(!EMPTY_LIST(n->ackl[queue]))
{
- no=(struct lsah_n *)HEAD(n->ackl);
+ no=(struct lsah_n *)HEAD(n->ackl[queue]);
memcpy(h+i,&no->lsa, sizeof(struct ospf_lsa_header));
i++;
DBG("Iter %u ID: %I, RT: %I, Type: %u\n",i, ntohl((h+i)->id),
@@ -88,7 +71,7 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
if((i*sizeof(struct ospf_lsa_header)+sizeof(struct ospf_lsack_packet)+SIPH)>
n->ifa->iface->mtu)
{
- if(!EMPTY_LIST(n->ackl))
+ if(!EMPTY_LIST(n->ackl[queue]))
{
len=sizeof(struct ospf_lsack_packet)+i*sizeof(struct ospf_lsa_header);
op->length=htons(len);
@@ -131,11 +114,11 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
{
if((ifa->state==OSPF_IS_DR)||(ifa->state==OSPF_IS_BACKUP))
{
- 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);
+ sk_send_to(sk, len, AllDRouters, OSPF_PROTO);
}
}
else
@@ -145,7 +128,7 @@ ospf_lsack_delay_tx(struct ospf_neighbor *n)
}
void
-ospf_lsack_rx(struct ospf_lsack_packet *ps, struct proto *p,
+ospf_lsack_receive(struct ospf_lsack_packet *ps, struct proto *p,
struct ospf_iface *ifa, u16 size)
{
u32 nrid, myrid;
diff --git a/proto/ospf/lsack.h b/proto/ospf/lsack.h
index 55198a4..484c434 100644
--- a/proto/ospf/lsack.h
+++ b/proto/ospf/lsack.h
@@ -1,7 +1,7 @@
/*
* 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.
*
@@ -14,10 +14,9 @@ struct lsah_n {
struct ospf_lsa_header lsa;
};
-void ospf_lsack_direct_tx(struct ospf_neighbor *n,struct ospf_lsa_header *h);
-void ospf_lsack_rx(struct ospf_lsack_packet *ps, struct proto *p,
+void ospf_lsack_receive(struct ospf_lsack_packet *ps, struct proto *p,
struct ospf_iface *ifa, u16 size);
-void ospf_lsack_delay_tx(struct ospf_neighbor *n);
-void ospf_lsa_delay(struct ospf_neighbor *n,struct ospf_lsa_header *h,
- struct proto *p);
+void ospf_lsack_send(struct ospf_neighbor *n, int queue);
+void ospf_lsack_enqueue(struct ospf_neighbor *n,struct ospf_lsa_header *h,
+ struct proto *p, int queue);
#endif /* _BIRD_OSPF_LSACK_H_ */
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index 39a089d..f56974c 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -366,7 +366,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
/* pg 143 (4) */
if((lsatmp.age==LSA_MAXAGE)&&(lsadb==NULL)&&can_flush_lsa(oa))
{
- ospf_lsack_direct_tx(n,lsa);
+ ospf_lsack_enqueue(n, lsa, p, ACKL_DIRECT);
continue;
}
@@ -399,7 +399,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
if((lsatmp.age==LSA_MAXAGE)&&(lsatmp.sn==LSA_MAXSEQNO))
{
- ospf_lsack_direct_tx(n,lsa);
+ ospf_lsack_enqueue(n, lsa, p, ACKL_DIRECT);
continue;
}
@@ -432,9 +432,9 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
DBG("Wasn't flooded back\n"); /* ps 144(5e), pg 153 */
if(ifa->state==OSPF_IS_BACKUP)
{
- if(ifa->drid==n->rid) ospf_lsa_delay(n, lsa, p);
+ if(ifa->drid==n->rid) ospf_lsack_enqueue(n, lsa, p, ACKL_DELAY);
}
- else ospf_lsa_delay(n, lsa, p);
+ else ospf_lsack_enqueue(n, lsa, p, ACKL_DELAY);
}
/* Remove old from all ret lists */
@@ -488,13 +488,13 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
ospf_hash_delete(n->lsrth, en);
if(ifa->state==OSPF_IS_BACKUP)
{
- if(n->rid==ifa->drid) ospf_lsa_delay(n, lsa, p);
+ if(n->rid==ifa->drid) ospf_lsack_enqueue(n, lsa, p, ACKL_DELAY);
}
}
else
{
/* pg145 (7b) */
- ospf_lsack_direct_tx(n,lsa);
+ ospf_lsack_enqueue(n, lsa, p, ACKL_DIRECT);
}
continue;
}
@@ -517,6 +517,9 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
}
}
+ /* Send direct LSAs */
+ ospf_lsack_send(n, ACKL_DIRECT);
+
if(n->state==NEIGHBOR_LOADING)
{
ospf_lsreq_tx(n); /* Send me another part of database */
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index e533eb6..eb777b7 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -67,7 +67,8 @@ ospf_neighbor_new(struct ospf_iface *ifa)
n->ackd_timer->randomize = 0;
n->ackd_timer->hook = ackd_timer_hook;
n->ackd_timer->recurrent = ifa->rxmtint/2;
- init_list(&n->ackl);
+ init_list(&n->ackl[ACKL_DIRECT]);
+ init_list(&n->ackl[ACKL_DELAY]);
tm_start(n->ackd_timer,n->ifa->rxmtint/2);
DBG("%s: Installing ackd timer.\n", p->name);
@@ -306,10 +307,10 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
{
neigh_chstate(n,NEIGHBOR_EXCHANGE);
s_init(&(n->dbsi), &(n->ifa->oa->lsal));
- while(!EMPTY_LIST(n->ackl))
+ while(!EMPTY_LIST(n->ackl[ACKL_DELAY]))
{
struct lsah_n *no;
- no=(struct lsah_n *)HEAD(n->ackl);
+ no=(struct lsah_n *)HEAD(n->ackl[ACKL_DELAY]);
rem_node(NODE no);
mb_free(no);
}
@@ -611,6 +612,6 @@ void
ackd_timer_hook(timer *t)
{
struct ospf_neighbor *n=t->data;
- if(!EMPTY_LIST(n->ackl)) ospf_lsack_delay_tx(n);
+ ospf_lsack_send(n, ACKL_DELAY);
}
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 5144150..56471b6 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -356,7 +356,9 @@ struct ospf_neighbor
struct top_graph *lsrth;
void *ldbdes; /* Last database description packet */
timer *rxmt_timer; /* RXMT timer */
- list ackl;
+ list ackl[2];
+#define ACKL_DIRECT 0
+#define ACKL_DELAY 1
timer *ackd_timer; /* Delayed ack timer */
};
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 8ee6cba..53daa8f 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -192,7 +192,7 @@ ospf_rx_hook (sock * sk, int size)
break;
case LSACK_P:
DBG ("%s: Link state ack received.\n", p->name);
- ospf_lsack_rx ((struct ospf_lsack_packet *) ps, p, ifa, size);
+ ospf_lsack_receive((struct ospf_lsack_packet *) ps, p, ifa, size);
break;
default:
log ("%s: Bad packet received: wrong type %u", p->name, ps->type);