summaryrefslogtreecommitdiffstats
path: root/proto/ospf
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-09-04 21:42:17 +0200
committerOndrej Filip <feela@network.cz>2000-09-04 21:42:17 +0200
commitb02e40111ea8d97bf1c3bfa25970ee0d828cd7bc (patch)
tree4fafe22465b1e3b3208fe39461a2473b4daf60af /proto/ospf
parentfdb19982020abeddf2d9eb73efae92ae2cc58d93 (diff)
downloadbird-b02e40111ea8d97bf1c3bfa25970ee0d828cd7bc.tar
bird-b02e40111ea8d97bf1c3bfa25970ee0d828cd7bc.zip
I allocate struct ifa before unlocking. So route exported to OSPF are correct.
I work also with interfaces that have some problems with socket opening. I declare them as stub.
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/iface.c162
-rw-r--r--proto/ospf/ospf.c5
-rw-r--r--proto/ospf/ospf.h8
3 files changed, 86 insertions, 89 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index e82d8f3..0c39862 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -314,6 +314,10 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
struct ospf_iface_patt *ip=NULL;
struct ospf_iface *ifa;
struct object_lock *lock;
+ struct nbma_node *nbma,*nb;
+ u8 i;
+ sock *mcsk;
+
DBG("%s: If notify called\n", p->name);
if (iface->flags & IF_IGNORE)
@@ -330,12 +334,74 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
if(ip)
{
OSPF_TRACE(D_EVENTS, "Using interface %s.", iface->name);
+
+ 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->pollint=ip->pollint;
+ ifa->strictnbma=ip->strictnbma;
+ ifa->waitint=ip->waitint;
+ ifa->deadc=ip->deadc;
+ ifa->stub=ip->stub;
+ ifa->autype=ip->autype;
+ memcpy(ifa->aukey,ip->password,8);
+ 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;
+
+ 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;
+ nbma->eligible=nb->eligible;
+ 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);
+
+ if(ifa->type==OSPF_IT_NBMA)
+ {
+ ifa->poll_timer=tm_new(p->pool);
+ ifa->poll_timer->data=ifa;
+ ifa->poll_timer->randomize=0;
+ ifa->poll_timer->hook=poll_timer_hook;
+ ifa->poll_timer->recurrent=ifa->pollint;
+ DBG("%s: Installing poll timer. (%u)\n", p->name, ifa->pollint);
+ }
+ else ifa->poll_timer=NULL;
+
+ 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;
+
lock = olock_new( p->pool );
lock->addr = AllSPFRouters;
lock->type = OBJLOCK_IP;
lock->port = OSPF_PROTO;
lock->iface = iface;
- lock->data = p;
+ lock->data = ifa;
lock->hook = ospf_ifa_add;
olock_acquire(lock);
}
@@ -394,50 +460,12 @@ ospf_iface_info(struct ospf_iface *ifa)
void
ospf_ifa_add(struct object_lock *lock)
{
- struct proto_ospf *po=lock->data;
+ struct ospf_iface *ifa=lock->data;
+ struct proto_ospf *po=ifa->proto;
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->pollint=ip->pollint;
- ifa->strictnbma=ip->strictnbma;
- ifa->waitint=ip->waitint;
- ifa->deadc=ip->deadc;
- ifa->stub=ip->stub;
- ifa->autype=ip->autype;
- memcpy(ifa->aukey,ip->password,8);
- 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;
+ ifa->ioprob=OSPF_I_OK;
if(ifa->type!=OSPF_IT_NBMA)
{
@@ -445,10 +473,9 @@ ospf_ifa_add(struct object_lock *lock)
{
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;
+ log("%s: Declaring as stub.", p->name);
+ ifa->stub=1;
+ ifa->ioprob += OSPF_I_MC;
}
ifa->dr_sk=NULL;
}
@@ -457,49 +484,12 @@ ospf_ifa_add(struct object_lock *lock)
{
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;
+ log("%s: Declaring as stub.", p->name);
+ ifa->stub=1;
+ ifa->ioprob += OSPF_I_IP;
}
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;
- nbma->eligible=nb->eligible;
- 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);
-
- if(ifa->type==OSPF_IT_NBMA)
- {
- ifa->poll_timer=tm_new(p->pool);
- ifa->poll_timer->data=ifa;
- ifa->poll_timer->randomize=0;
- ifa->poll_timer->hook=poll_timer_hook;
- ifa->poll_timer->recurrent=ifa->pollint;
- DBG("%s: Installing poll timer. (%u)\n", p->name, ifa->pollint);
- }
- else ifa->poll_timer=NULL;
-
- 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/ospf.c b/proto/ospf/ospf.c
index 64bfcdc..83bcc56 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -578,7 +578,10 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
"Interface %s is now stub.",
ifa->iface->name);
}
- if((ip1->stub!=0)&&(ip2->stub==0))
+ if((ip1->stub!=0)&&(ip2->stub==0)&&
+ ((ifa->ioprob & OSPF_I_IP)==0)&&
+ (((ifa->ioprob & OSPF_I_MC)==0)||
+ (ifa->type==OSPF_IT_NBMA)))
{
ifa->stub=ip2->stub;
OSPF_TRACE(D_EVENTS,
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index d5ff8e9..3eb4659 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -102,13 +102,17 @@ struct ospf_iface {
ip_addr bdrip; /* Backup DR */
u32 bdrid;
u8 type; /* OSPF view of type */
- u8 strictnbma; /* Can I talk with unknown neighbors? */
- u8 stub; /* Inactive interface */
#define OSPF_IT_BCAST 0
#define OSPF_IT_NBMA 1
#define OSPF_IT_PTP 2
#define OSPF_IT_VLINK 3
#define OSPF_IT_UNDEF 4
+ u8 strictnbma; /* Can I talk with unknown neighbors? */
+ u8 stub; /* Inactive interface */
+ u8 ioprob;
+#define OSPF_I_OK 0 /* Everything OK */
+#define OSPF_I_MC 1 /* I didn't open MC socket */
+#define OSPF_I_IP 2 /* I didn't open IP socet */
u8 state; /* Interface state machine */
#define OSPF_IS_DOWN 0 /* Not working */
#define OSPF_IS_LOOP 1 /* Should never happen */