summaryrefslogtreecommitdiffstats
path: root/proto/ospf
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/lsupd.c26
-rw-r--r--proto/ospf/neighbor.c10
-rw-r--r--proto/ospf/neighbor.h1
-rw-r--r--proto/ospf/ospf.c14
-rw-r--r--proto/ospf/ospf.h4
-rw-r--r--proto/ospf/topology.c24
6 files changed, 46 insertions, 33 deletions
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index 2fa0137..5c0d836 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -86,6 +86,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
u32 area,nrid,myrid;
struct ospf_neighbor *n;
struct ospf_lsa_header *lsa;
+ struct ospf_area *oa;
u16 length;
u8 i;
@@ -108,15 +109,28 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
lsa=(struct ospf_lsa_header *)(ps+1);
area=htonl(ps->ospf_packet.areaid);
- for(i=0;i<ntohl(ps->lsano);i++)
+ oa=ospf_find_area((struct proto_ospf *)p,area);
+ for(i=0;i<ntohl(ps->lsano);i++,
+ lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length)))
{
- if(lsa->checksum==lsasum_check(lsa,NULL,(struct proto_ospf *)p))
+ if(lsa->checksum!=lsasum_check(lsa,NULL,(struct proto_ospf *)p))
{
- DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
- ntohl(lsa->id), ntohl(lsa->rt));
- /* FIXME Go on */
+ log("Received bad lsa checksum from %u\n",n->rid);
+ continue;
+ }
+ if((lsa->type<LSA_T_RT)||(lsa->type>LSA_T_EXT))
+ {
+ log("Unknown LSA type from %u\n",n->rid);
+ continue;
}
- lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length));
+ if((lsa->type==LSA_T_EXT)&&oa->stub)
+ {
+ log("Received External LSA in stub area from %u\n",n->rid);
+ continue;
+ }
+ /* FIXME Go on */
+ DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
+ ntohl(lsa->id), ntohl(lsa->rt));
}
}
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index b072623..ae415e1 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -354,3 +354,13 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
return NULL;
}
+struct ospf_area *
+ospf_find_area(struct proto_ospf *po, u32 aid)
+{
+ struct ospf_area *oa;
+ WALK_LIST(NODE oa,po->area_list)
+ if(((struct ospf_area *)oa)->areaid==aid) return oa;
+ return NULL;
+}
+
+
diff --git a/proto/ospf/neighbor.h b/proto/ospf/neighbor.h
index 26992ca..64b163a 100644
--- a/proto/ospf/neighbor.h
+++ b/proto/ospf/neighbor.h
@@ -18,5 +18,6 @@ void tryadj(struct ospf_neighbor *n, struct proto *p);
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
void bdr_election(struct ospf_iface *ifa, struct proto *p);
struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
+struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index 670ca73..a806de6 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -16,15 +16,6 @@ ospf_start(struct proto *p)
p->if_notify=ospf_if_notify;
- /* Create graph of LSA's */
- po->areano=1; /* FIXME should respect config! */
- po->firstarea=(struct ospf_area *)cfg_alloc(sizeof(struct ospf_area));
- po->firstarea->gr=ospf_top_new(po);
- po->firstarea->next=NULL;
- po->firstarea->areaid=0;
-
- po->areano=0; /* Waiting for interfaces comming up */
- po->firstarea=NULL;
return PS_UP;
}
@@ -52,14 +43,12 @@ ospf_dump(struct proto *p)
}
}
- oa=po->firstarea;
- while(oa!=NULL)
+ WALK_LIST(NODE oa,po->area_list)
{
debug("\n%s: LSA graph dump for area \"%d\" start:\n", p->name,oa->areaid);
ospf_top_dump(oa->gr);
debug("%s: LSA graph dump for area \"%d\" finished\n\n", p->name,
oa->areaid);
- oa=oa->next;
}
}
@@ -74,6 +63,7 @@ ospf_init(struct proto_config *c)
p->neigh_notify = NULL;
p->if_notify = NULL;
init_list(&(po->iface_list));
+ init_list(&(po->area_list));
return p;
}
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index c2db08d..ee94f10 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -315,7 +315,7 @@ struct ospf_neighbor
#define INM_LLDOWN 12 /* Line down */
struct ospf_area {
- struct ospf_area *next;
+ node n;
u32 areaid;
struct top_graph *gr; /* LSA graph */
slist lsal; /* List of all LSA's */
@@ -326,8 +326,8 @@ struct ospf_area {
struct proto_ospf {
struct proto proto;
list iface_list; /* Interfaces we really use */
+ list area_list;
int areano; /* Number of area I belong to */
- struct ospf_area *firstarea;
};
static int ospf_start(struct proto *p);
diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c
index 66a1553..e4982c2 100644
--- a/proto/ospf/topology.c
+++ b/proto/ospf/topology.c
@@ -160,25 +160,22 @@ addifa_rtlsa(struct ospf_iface *ifa)
struct top_graph_rtlsa_link *li, *lih;
po=ifa->proto;
- oa=po->firstarea;
rtid=po->proto.cf->global->router_id;
+ DBG("%s: New OSPF area \"%d\" adding.\n", po->proto.name, ifa->an);
+ oa=NULL;
- while(oa!=NULL)
+
+ WALK_LIST(NODE oa,po->area_list)
{
if(oa->areaid==ifa->an) break;
- oa=oa->next;
}
- ifa->oa=oa;
-
- if(oa==NULL) /* New area */
+ if(EMPTY_LIST(po->area_list) || (oa->areaid!=ifa->an)) /* New area */
{
struct ospf_lsa_header *lsa;
- oa=po->firstarea;
- po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
- po->firstarea->next=oa;
- oa=po->firstarea;
+ oa=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
+ add_tail(&po->area_list,NODE oa);
oa->areaid=ifa->an;
oa->gr=ospf_top_new(po);
s_init_list(&(oa->lsal));
@@ -189,13 +186,14 @@ addifa_rtlsa(struct ospf_iface *ifa)
oa->rt->lsa_body=NULL;
lsa->age=0;
lsa->sn=LSA_INITSEQNO; /* FIXME Check it latter */
- ifa->oa=oa;
+ po->areano++;
DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an);
-
}
+
+ ifa->oa=oa;
+
oa->rt->lsa.length=make_rt_lsa(oa, po)+sizeof(struct ospf_lsa_header);
oa->rt->lsa.checksum=0;
- /*oa->rt->lsa.checksum=ipsum_calculate(&(oa->rt->lsa.options),sizeof(struct ospf_lsa_header)-2,oa->rt->lsa_body,oa->rt->lsa.length-sizeof(struct ospf_lsa_header),NULL);*/
lsasum_calculate(&(oa->rt->lsa),oa->rt->lsa_body,po);
/*FIXME lsa_flood(oa->rt) */
}