summaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-06-06 02:46:00 +0200
committerOndrej Filip <feela@network.cz>2000-06-06 02:46:00 +0200
commitf8f1e1f110c3ff1aec03a9fa918257cf4d29e916 (patch)
tree31252271517e4c457a240b2ba56251574392c33c /proto
parent7d68e18b414bbdef9a5472006e8674a3d74e5a00 (diff)
downloadbird-f8f1e1f110c3ff1aec03a9fa918257cf4d29e916.tar
bird-f8f1e1f110c3ff1aec03a9fa918257cf4d29e916.zip
Interface locks added.
Diffstat (limited to 'proto')
-rw-r--r--proto/ospf/iface.c182
-rw-r--r--proto/ospf/iface.h1
-rw-r--r--proto/ospf/ospf.h2
3 files changed, 113 insertions, 72 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 6435d39..62beb3b 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -113,6 +113,7 @@ downint(struct ospf_iface *ifa)
tm_stop(ifa->hello_timer);
rfree(ifa->hello_timer);
}
+ rfree(ifa->lock);
mb_free(ifa);
}
@@ -285,13 +286,12 @@ find_iface(struct proto_ospf *p, struct iface *what)
void
ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
{
- struct ospf_iface *ifa;
- sock *mcsk;
+ struct proto_ospf *po=(struct proto_ospf *)p;
struct ospf_config *c=(struct ospf_config *)(p->cf);
struct ospf_area_config *ac;
struct ospf_iface_patt *ip=NULL;
- struct nbma_node *nbma,*nb;
- u8 i;
+ struct ospf_iface *ifa;
+ struct object_lock *lock;
DBG("%s: If notify called\n", p->name);
if (iface->flags & IF_IGNORE)
@@ -308,74 +308,14 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
if(ip)
{
- ifa=mb_allocz(p->pool, sizeof(struct ospf_iface));
- ifa->proto=(struct proto_ospf *)p;
- ifa->iface=iface;
-
- ifa->an=ac->areaid; /* FIXME This should respect config */
- ifa->cost=ip->cost;
- ifa->rxmtint=ip->rxmtint;
- ifa->inftransdelay=ip->inftransdelay;
- ifa->priority=ip->priority;
- ifa->helloint=ip->helloint;
- ifa->waitint=ip->waitint;
- ifa->deadc=ip->deadc;
- ifa->autype=0; /* FIXME add authentification */
- for(i=0;i<8;i++) ifa->aukey[i]=0;
- ifa->options=2; /* FIXME what options? */
-
- if(ip->type==OSPF_IT_UNDEF)
- ifa->type=ospf_iface_clasify(ifa->iface, (struct proto *)ifa->proto);
- else ifa->type=ip->type;
-
- if(ifa->type!=OSPF_IT_NBMA)
- {
- if((ifa->hello_sk=ospf_open_mc_socket(ifa))==NULL)
- {
- log("%s: Huh? could not open mc socket on interface %s?", p->name,
- iface->name);
- mb_free(ifa);
- log("%s: Ignoring this interface.", p->name);
- return;
- }
- ifa->dr_sk=NULL;
- }
-
- if((ifa->ip_sk=ospf_open_ip_socket(ifa))==NULL)
- {
- log("%s: Huh? could not open ip socket on interface %s?", p->name,
- iface->name);
- mb_free(ifa);
- log("%s: Ignoring this interface", p->name);
- return;
- }
-
- init_list(&ifa->neigh_list);
- init_list(&ifa->nbma_list);
- WALK_LIST(nb,ip->nbma_list)
- {
- nbma=mb_alloc(p->pool,sizeof(struct nbma_node));
- nbma->ip=nb->ip;
- add_tail(&ifa->nbma_list, NODE nbma);
- }
-
- /* Add hello timer */
- ifa->hello_timer=tm_new(p->pool);
- ifa->hello_timer->data=ifa;
- ifa->hello_timer->randomize=0;
- ifa->hello_timer->hook=hello_timer_hook;
- ifa->hello_timer->recurrent=ifa->helloint;
- DBG("%s: Installing hello timer. (%u)\n", p->name, ifa->helloint);
-
- ifa->wait_timer=tm_new(p->pool);
- ifa->wait_timer->data=ifa;
- ifa->wait_timer->randomize=0;
- ifa->wait_timer->hook=wait_timer_hook;
- ifa->wait_timer->recurrent=0;
- DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint);
- add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa);
- ifa->state=OSPF_IS_DOWN;
- ospf_int_sm(ifa, ISM_UP);
+ lock = olock_new( p->pool );
+ lock->addr = AllSPFRouters;
+ lock->type = OBJLOCK_UDP;
+ lock->port = OSPF_PROTO;
+ lock->iface = iface;
+ lock->data = p;
+ lock->hook = ospf_ifa_add;
+ olock_acquire(lock);
}
}
@@ -420,3 +360,101 @@ ospf_iface_info(struct ospf_iface *ifa)
cli_msg(-1015,"\tBackup designed router (IP): %I", ifa->bdrip);
}
}
+
+void
+ospf_ifa_add(struct object_lock *lock)
+{
+ struct proto_ospf *po=lock->data;
+ struct iface *iface=lock->iface;
+ struct proto *p=&po->proto;
+ struct nbma_node *nbma,*nb;
+ u8 i;
+ sock *mcsk;
+ struct ospf_iface *ifa;
+ struct ospf_config *c=(struct ospf_config *)(p->cf);
+ struct ospf_area_config *ac;
+ struct ospf_iface_patt *ip=NULL;
+
+ WALK_LIST(ac, c->area_list)
+ {
+ if(ip=(struct ospf_iface_patt *)
+ iface_patt_match(&ac->patt_list, iface)) break;
+ }
+
+ if(!ip)
+ {
+ bug("After lock I cannot find pattern.");
+ }
+
+ ifa=mb_allocz(p->pool, sizeof(struct ospf_iface));
+ ifa->proto=po;
+ ifa->iface=iface;
+
+ ifa->an=ac->areaid;
+ ifa->cost=ip->cost;
+ ifa->rxmtint=ip->rxmtint;
+ ifa->inftransdelay=ip->inftransdelay;
+ ifa->priority=ip->priority;
+ ifa->helloint=ip->helloint;
+ ifa->waitint=ip->waitint;
+ ifa->deadc=ip->deadc;
+ ifa->autype=0; /* FIXME add authentification */
+ for(i=0;i<8;i++) ifa->aukey[i]=0;
+ ifa->options=2; /* FIXME what options? */
+
+ if(ip->type==OSPF_IT_UNDEF)
+ ifa->type=ospf_iface_clasify(ifa->iface, (struct proto *)ifa->proto);
+ else ifa->type=ip->type;
+
+ if(ifa->type!=OSPF_IT_NBMA)
+ {
+ if((ifa->hello_sk=ospf_open_mc_socket(ifa))==NULL)
+ {
+ log("%s: Huh? could not open mc socket on interface %s?", p->name,
+ iface->name);
+ mb_free(ifa);
+ log("%s: Ignoring this interface.", p->name);
+ rfree(lock);
+ return;
+ }
+ ifa->dr_sk=NULL;
+ }
+
+ if((ifa->ip_sk=ospf_open_ip_socket(ifa))==NULL)
+ {
+ log("%s: Huh? could not open ip socket on interface %s?", p->name,
+ iface->name);
+ mb_free(ifa);
+ log("%s: Ignoring this interface", p->name);
+ rfree(lock);
+ return;
+ }
+ ifa->lock = lock;
+
+ init_list(&ifa->neigh_list);
+ init_list(&ifa->nbma_list);
+ WALK_LIST(nb,ip->nbma_list)
+ {
+ nbma=mb_alloc(p->pool,sizeof(struct nbma_node));
+ nbma->ip=nb->ip;
+ add_tail(&ifa->nbma_list, NODE nbma);
+ }
+
+ /* Add hello timer */
+ ifa->hello_timer=tm_new(p->pool);
+ ifa->hello_timer->data=ifa;
+ ifa->hello_timer->randomize=0;
+ ifa->hello_timer->hook=hello_timer_hook;
+ ifa->hello_timer->recurrent=ifa->helloint;
+ DBG("%s: Installing hello timer. (%u)\n", p->name, ifa->helloint);
+
+ ifa->wait_timer=tm_new(p->pool);
+ ifa->wait_timer->data=ifa;
+ ifa->wait_timer->randomize=0;
+ ifa->wait_timer->hook=wait_timer_hook;
+ ifa->wait_timer->recurrent=0;
+ DBG("%s: Installing wait timer. (%u)\n", p->name, ifa->waitint);
+ add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa);
+ ifa->state=OSPF_IS_DOWN;
+ ospf_int_sm(ifa, ISM_UP);
+}
diff --git a/proto/ospf/iface.h b/proto/ospf/iface.h
index b18f546..3070e19 100644
--- a/proto/ospf/iface.h
+++ b/proto/ospf/iface.h
@@ -22,5 +22,6 @@ void ospf_iface_default(struct ospf_iface *ifa);
struct ospf_iface *find_iface(struct proto_ospf *p, struct iface *what);
void ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface);
void ospf_iface_info(struct ospf_iface *ifa);
+void ospf_ifa_add(struct object_lock *lock);
#endif /* _BIRD_OSPF_IFACE_H_ */
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 6736fa0..65bb605 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -26,6 +26,7 @@
#include "nest/iface.h"
#include "nest/route.h"
#include "nest/cli.h"
+#include "nest/locks.h"
#include "conf/conf.h"
#include "lib/string.h"
@@ -70,6 +71,7 @@ struct ospf_iface {
struct proto_ospf *proto;
struct iface *iface; /* Nest's iface */
struct ospf_area *oa;
+ struct object_lock *lock;
u32 an; /* Area number */
sock *hello_sk; /* Hello socket */
sock *dr_sk; /* For states DR or BACKUP */