Do not open sockets for stub interfaces.

This commit is contained in:
Ondrej Zajicek 2011-07-06 03:10:02 +02:00
parent f796945f04
commit 7d4e923603

View file

@ -70,7 +70,7 @@ find_nbma_node_in(list *nnl, ip_addr ip)
} }
static int static int
ospf_sk_open(struct ospf_iface *ifa, int multicast) ospf_sk_open(struct ospf_iface *ifa)
{ {
sock *sk = sk_new(ifa->pool); sock *sk = sk_new(ifa->pool);
sk->type = SK_IP; sk->type = SK_IP;
@ -118,7 +118,7 @@ ospf_sk_open(struct ospf_iface *ifa, int multicast)
*/ */
sk->saddr = ifa->addr->ip; sk->saddr = ifa->addr->ip;
if (multicast) if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_PTP))
{ {
if (sk_setup_multicast(sk) < 0) if (sk_setup_multicast(sk) < 0)
goto err; goto err;
@ -145,6 +145,7 @@ ospf_sk_join_dr(struct ospf_iface *ifa)
sk_join_group(ifa->sk, AllDRouters); sk_join_group(ifa->sk, AllDRouters);
ifa->sk_dr = 1; ifa->sk_dr = 1;
} }
static inline void static inline void
ospf_sk_leave_dr(struct ospf_iface *ifa) ospf_sk_leave_dr(struct ospf_iface *ifa)
{ {
@ -262,7 +263,7 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
OSPF_TRACE(D_EVENTS, "Changing state of iface %s from %s to %s", OSPF_TRACE(D_EVENTS, "Changing state of iface %s from %s to %s",
ifa->iface->name, ospf_is[oldstate], ospf_is[state]); ifa->iface->name, ospf_is[oldstate], ospf_is[state]);
if (ifa->type == OSPF_IT_BCAST) if ((ifa->type == OSPF_IT_BCAST) && ifa->sk)
{ {
if ((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR)) if ((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR))
ospf_sk_join_dr(ifa); ospf_sk_join_dr(ifa);
@ -354,7 +355,7 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
break; break;
case ISM_LOOP: case ISM_LOOP:
if (ifa->sk && ifa->check_link) if ((ifa->state > OSPF_IS_LOOP) && ifa->check_link)
ospf_iface_chstate(ifa, OSPF_IS_LOOP); ospf_iface_chstate(ifa, OSPF_IS_LOOP);
break; break;
@ -415,8 +416,8 @@ ospf_iface_add(struct object_lock *lock)
struct proto_ospf *po = ifa->oa->po; struct proto_ospf *po = ifa->oa->po;
struct proto *p = &po->proto; struct proto *p = &po->proto;
int mc = (ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_PTP); /* Open socket if interface is not stub */
if (! ospf_sk_open(ifa, mc)) if (! ifa->stub && ! ospf_sk_open(ifa))
{ {
log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->iface->name); log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->iface->name);
ifa->ioprob = OSPF_I_SK; ifa->ioprob = OSPF_I_SK;