Temporary OSPF commit - sockets.

This commit is contained in:
Ondrej Zajicek 2010-03-14 16:36:59 +01:00
parent 54305181f6
commit 0aad2b9292
12 changed files with 268 additions and 136 deletions

View file

@ -566,8 +566,8 @@ if_init(void)
* Interface Pattern Lists
*/
static int
iface_patt_match(struct iface_patt *ifp, struct iface *i)
int
iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a)
{
struct iface_patt_node *p;
@ -588,8 +588,9 @@ iface_patt_match(struct iface_patt *ifp, struct iface *i)
continue;
}
// FIXME there should be check for prefix in prefix. (?)
if (p->pxlen)
if (!i->addr || !ipa_in_net(i->addr->ip, p->prefix, p->pxlen))
if (!a || !ipa_in_net(a->ip, p->prefix, p->pxlen))
continue;
return pos;
@ -599,12 +600,12 @@ iface_patt_match(struct iface_patt *ifp, struct iface *i)
}
struct iface_patt *
iface_patt_find(list *l, struct iface *i)
iface_patt_find(list *l, struct iface *i, struct ifa *a)
{
struct iface_patt *p;
WALK_LIST(p, *l)
if (iface_patt_match(p, i))
if (iface_patt_match(p, i, a))
return p;
return NULL;

View file

@ -144,7 +144,8 @@ struct iface_patt {
/* Protocol-specific data follow after this structure */
};
struct iface_patt *iface_patt_find(list *, struct iface *);
int iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a);
struct iface_patt *iface_patt_find(list *l, struct iface *i, struct ifa *a);
int iface_patts_equal(list *, list *, int (*)(struct iface_patt *, struct iface_patt *));
#endif

View file

@ -30,7 +30,7 @@ dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad)
struct rt_dev_config *P = (void *) p->cf;
if (!EMPTY_LIST(P->iface_list) &&
!iface_patt_find(&P->iface_list, ad->iface))
!iface_patt_find(&P->iface_list, ad->iface, ad->iface->addr))
/* Empty list is automagically treated as "*" */
return;

View file

@ -254,8 +254,8 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
return; /* Don't send any packet on stub iface */
p = (struct proto *) (ifa->oa->po);
DBG("%s: Hello/Poll timer fired on interface %s.\n",
p->name, ifa->iface->name);
DBG("%s: Hello/Poll timer fired on interface %s with IP %I\n",
p->name, ifa->iface->name, ifa->addr->ip);
/* Now we should send a hello packet */
pkt = ospf_tx_buffer(ifa);

View file

@ -21,7 +21,6 @@ char *ospf_it[] = { "broadcast", "nbma", "point-to-point", "virtual link" };
static void
poll_timer_hook(timer * timer)
{
log("POLL!");
ospf_hello_send(timer, 1, NULL);
}
@ -59,7 +58,7 @@ rxbufsize(struct ospf_iface *ifa)
}
static int
ospf_sk_open(struct ospf_iface *ifa, int mc)
ospf_sk_open(struct ospf_iface *ifa)
{
sock *sk;
struct proto *p = &ifa->oa->po->proto;
@ -73,10 +72,8 @@ ospf_sk_open(struct ospf_iface *ifa, int mc)
* In Linux IPv4, binding a raw socket to an IP address of an iface causes
* that the socket does not receive multicast packets, as they have
* different (multicast) destination IP address.
*
* We want such filter in the vlink (non-mc) socket.
*/
sk->saddr = mc ? IPA_NONE : ifa->addr->ip;
sk->saddr = IPA_NONE;
#else /* OSPFv3 */
sk->saddr = ifa->addr->ip; /* link-local addr */
#endif
@ -100,7 +97,8 @@ ospf_sk_open(struct ospf_iface *ifa, int mc)
goto err;
#endif
if (mc && (sk_setup_multicast(sk) < 0))
sk->saddr = ifa->addr->ip;
if (sk_setup_multicast(sk) < 0)
goto err;
ifa->sk = sk;
@ -188,12 +186,6 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
OSPF_TRACE(D_EVENTS,
"Changing state of virtual link %R from \"%s\" into \"%s\".",
ifa->vid, ospf_is[oldstate], ospf_is[state]);
/*
if (state == OSPF_IS_PTP)
ospf_sk_open(ifa, 0);
if (state == OSPF_IS_DOWN)
ospf_sk_close(ifa);
*/
}
else
{
@ -240,7 +232,7 @@ ospf_iface_down(struct ospf_iface *ifa)
{
WALK_LIST(iff, po->iface_list)
{
if ((iff->type == OSPF_IT_VLINK) && (iff->iface == ifa->iface))
if ((iff->type == OSPF_IT_VLINK) && (iff->vifa == ifa))
ospf_iface_sm(iff, ISM_DOWN);
}
}
@ -253,7 +245,11 @@ ospf_iface_down(struct ospf_iface *ifa)
if (ifa->type == OSPF_IT_VLINK)
{
ifa->vifa = NULL;
ifa->iface = NULL;
ifa->addr = NULL;
ifa->sk = NULL;
ifa->vip = IPA_NONE;
return;
}
else
@ -351,9 +347,9 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
}
u8
ospf_iface_clasify(struct iface * ifa)
ospf_iface_clasify(struct iface *ifa, struct ifa *addr)
{
if (ifa->addr->flags & IA_UNNUMBERED)
if (addr->flags & IA_UNNUMBERED)
return OSPF_IT_PTP;
if ((ifa->flags & (IF_MULTIACCESS | IF_MULTICAST)) ==
@ -382,23 +378,19 @@ ospf_iface_add(struct object_lock *lock)
struct ospf_iface *ifa = lock->data;
struct proto_ospf *po = ifa->oa->po;
struct proto *p = &po->proto;
struct iface *iface = lock->iface;
ifa->lock = lock;
ifa->ioprob = OSPF_I_OK;
ospf_sk_open(ifa, 1);
if (ifa->type != OSPF_IT_NBMA)
ospf_sk_join_spf(ifa);
if (0)
if (ospf_sk_open(ifa))
{
log(L_ERR "%s: Huh? could not open ip socket on interface %s?", p->name,
iface->name);
log(L_ERR "%s: Declaring as stub.", p->name);
if (ifa->type != OSPF_IT_NBMA)
ospf_sk_join_spf(ifa);
}
else
{
log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->iface->name);
ifa->ioprob = OSPF_I_SK;
ifa->stub = 1;
ifa->ioprob += OSPF_I_IP;
}
ifa->state = OSPF_IS_DOWN;
@ -406,7 +398,7 @@ ospf_iface_add(struct object_lock *lock)
}
void
ospf_iface_new(struct proto_ospf *po, struct iface *iface,
ospf_iface_new(struct proto_ospf *po, struct iface *iface, struct ifa *addr,
struct ospf_area_config *ac, struct ospf_iface_patt *ip)
{
struct proto *p = &po->proto;
@ -420,6 +412,7 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
ifa = mb_allocz(p->pool, sizeof(struct ospf_iface));
ifa->iface = iface;
ifa->addr = addr;
ifa->cost = ip->cost;
ifa->rxmtint = ip->rxmtint;
@ -431,44 +424,47 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
ifa->waitint = ip->waitint;
ifa->dead = (ip->dead == 0) ? ip->deadc * ifa->helloint : ip->dead;
ifa->stub = ip->stub;
ifa->ioprob = OSPF_I_OK;
ifa->rxbuf = ip->rxbuf;
#ifdef OSPFv2
ifa->autype = ip->autype;
ifa->passwords = ip->passwords;
ifa->addr = iface->addr;
#endif
#ifdef OSPFv3
ifa->instance_id = ip->instance_id;
ifa->addr = NULL;
/* Find link-local address */
/*
addr = NULL;
if (ifa->type != OSPF_IT_VLINK)
{
struct ifa *a;
WALK_LIST(a, iface->addrs)
if (a->scope == SCOPE_LINK)
{
ifa->addr = a;
addr = a;
break;
}
if (! ifa->addr)
log(L_WARN "%s: Missing link local address on interface %s", p->name, iface->name);
if (!addr)
{
log(L_ERR "%s: Missing link-local address on interface %s, declaring as stub", p->name, iface->name);
ifa->ioprob = OSPF_I_LL;
ifa->stub = 1;
}
}
*/
#endif
ifa->rxbuf = ip->rxbuf;
if (ip->type == OSPF_IT_UNDEF)
ifa->type = ospf_iface_clasify(ifa->iface);
ifa->type = ospf_iface_clasify(iface, addr);
else
ifa->type = ip->type;
#ifdef OSPFv2
if ((ifa->type != OSPF_IT_PTP) && (ifa->type != OSPF_IT_VLINK) &&
(ifa->iface->addr->flags & IA_UNNUMBERED))
(addr->flags & IA_UNNUMBERED))
{
log(L_WARN "%s: Missing proper IP prefix on interface %s, forcing point-to-point mode",
p->name, iface->name);
@ -538,8 +534,19 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
return; /* Don't lock, don't add sockets */
}
/*
* In some cases we allow more ospf_ifaces on one physical iface.
* In OSPFv2, if they use different IP address prefix.
* In OSPFv3, if they use different instance_id.
* Therefore, we store such info to lock->addr field.
*/
lock = olock_new(p->pool);
lock->addr = AllSPFRouters;
#ifdef OSPFv2
lock->addr = ifa->addr->prefix;
#else /* OSPFv3 */
lock->addr = _MI(0,0,0,ifa->instance_id);
#endif
lock->type = OBJLOCK_IP;
lock->port = OSPF_PROTO;
lock->iface = iface;
@ -549,6 +556,150 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
olock_acquire(lock);
}
#ifdef OSPFv2
void
ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a)
{
struct proto_ospf *po = (struct proto_ospf *) p;
struct ospf_config *cf = (struct ospf_config *) (p->cf);
if (a->flags & IA_SECONDARY)
return;
if (a->scope <= SCOPE_LINK)
return;
/* In OSPFv2, we create OSPF iface for each address. */
if (flags & IF_CHANGE_UP)
{
int done = 0;
struct ospf_area_config *ac;
WALK_LIST(ac, cf->area_list)
{
struct ospf_iface_patt *ip = (struct ospf_iface_patt *)
iface_patt_find(&ac->patt_list, a->iface, a);
if (ip)
{
if (!done)
ospf_iface_new(po, a->iface, a, ac, ip);
done++;
}
}
if (done > 1)
log(L_WARN "%s: Interface %s (IP %I) matches for multiple areas", p->name, a->iface->name, a->ip);
}
if (flags & IF_CHANGE_DOWN)
{
struct ospf_iface *ifa, *ifx;
WALK_LIST_DELSAFE(ifa, ifx, po->iface_list)
{
if ((ifa->type != OSPF_IT_VLINK) && (ifa->addr == a))
ospf_iface_sm(ifa, ISM_DOWN);
/* See a note in ospf_iface_notify() */
}
}
}
#else /* OSPFv3 */
static inline int iflag_test(u32 *a, u8 i)
{
return a[i / 32] & (1u << (i % 32));
}
static inline void iflag_set(u32 *a, u8 i)
{
a[i / 32] |= (1u << (i % 32));
}
void
ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a)
{
struct proto_ospf *po = (struct proto_ospf *) p;
struct ospf_config *cf = (struct ospf_config *) (p->cf);
if (a->flags & IA_SECONDARY)
return;
if (a->scope < SCOPE_LINK)
return;
/* In OSPFv3, we create OSPF iface for link-local address,
other addresses are used for link-LSA. */
if (a->scope == SCOPE_LINK)
{
if (flags & IF_CHANGE_UP)
{
u32 found_all[8] = {};
struct ospf_area_config *ac;
WALK_LIST(ac, cf->area_list)
{
u32 found_new[8] = {};
struct iface_patt *p;
WALK_LIST(p, ac->patt_list)
{
if (iface_patt_match(p, i, a))
{
struct ospf_iface_patt *ip = (struct ospf_iface_patt *) p;
/* If true, we already assigned that IID and we skip
this to implement first-match behavior */
if (iflag_test(found_new, ip->instance_id))
continue;
/* If true, we already assigned that in a different area,
we log collision */
if (iflag_test(found_all, ip->instance_id))
{
log(L_WARN "%s: Interface %s (IID %d) matches for multiple areas",
p->name, a->iface->name, ip->instance_id);
continue;
}
iflag_set(found_all, ip->instance_id);
iflag_set(found_new, ip->instance_id);
ospf_iface_new(po, a->iface, a, ac, ip);
}
}
}
}
if (flags & IF_CHANGE_DOWN)
{
struct ospf_iface *ifa, *ifx;
WALK_LIST_DELSAFE(ifa, ifx, po->iface_list)
{
if ((ifa->type != OSPF_IT_VLINK) && (ifa->addr == a))
ospf_iface_sm(ifa, ISM_DOWN);
/* See a note in ospf_iface_notify() */
}
}
}
else
{
struct ospf_iface *ifa;
WALK_LIST(ifa, po->iface_list)
{
if (ifa->iface == a->iface)
{
schedule_rt_lsa(ifa->oa);
/* Event 5 from RFC5340 4.4.3. */
schedule_link_lsa(ifa);
return;
}
}
}
}
#endif
void
ospf_iface_change_mtu(struct proto_ospf *po, struct ospf_iface *ifa)
{
@ -580,38 +731,29 @@ void
ospf_iface_notify(struct proto *p, unsigned flags, struct iface *iface)
{
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 ospf_iface *ifa;
DBG("%s: If notify called\n", p->name);
if (iface->flags & IF_IGNORE)
return;
if (flags & IF_CHANGE_UP)
{
WALK_LIST(ac, c->area_list)
{
if (ip = (struct ospf_iface_patt *)
iface_patt_find(&ac->patt_list, iface))
break;
}
if (ip)
ospf_iface_new(po, iface, ac, ip);
}
if (flags & IF_CHANGE_DOWN)
{
if ((ifa = ospf_iface_find((struct proto_ospf *) p, iface)) != NULL)
ospf_iface_sm(ifa, ISM_DOWN);
struct ospf_iface *ifa, *ifx;
WALK_LIST_DELSAFE(ifa, ifx, po->iface_list)
if ((ifa->type != OSPF_IT_VLINK) && (ifa->iface == iface))
ospf_iface_sm(ifa, ISM_DOWN);
/* We use here that even shutting down iface also shuts down
the vlinks, but vlinks are not freed and stays in the
iface_list even when down */
}
if (flags & IF_CHANGE_MTU)
{
if ((ifa = ospf_iface_find((struct proto_ospf *) p, iface)) != NULL)
ospf_iface_change_mtu(po, ifa);
struct ospf_iface *ifa;
WALK_LIST(ifa, po->iface_list)
if ((ifa->type != OSPF_IT_VLINK) && (ifa->iface == iface))
ospf_iface_change_mtu(po, ifa);
}
}
@ -633,8 +775,14 @@ ospf_iface_info(struct ospf_iface *ifa)
}
else
{
cli_msg(-1015, "Interface \"%s\":",
(ifa->iface ? ifa->iface->name : "(none)"));
#ifdef OSPFv2
if (ifa->addr->flags & IA_UNNUMBERED)
cli_msg(-1015, "Interface %s (peer %I)", ifa->iface->name, ifa->addr->opposite);
else
cli_msg(-1015, "Interface %s (%I/%d)", ifa->iface->name, ifa->addr->prefix, ifa->addr->pxlen);
#else /* OSPFv3 */
cli_msg(-1015, "Interface %s (IID %d)", ifa->iface->name, ifa->instance_id);
#endif
cli_msg(-1015, "\tType: %s %s", ospf_it[ifa->type], strict);
cli_msg(-1015, "\tArea: %R (%u)", ifa->oa->areaid, ifa->oa->areaid);
}

View file

@ -14,9 +14,10 @@ void ospf_iface_chstate(struct ospf_iface *ifa, u8 state);
void ospf_iface_sm(struct ospf_iface *ifa, int event);
struct ospf_iface *ospf_iface_find(struct proto_ospf *p, struct iface *what);
void ospf_iface_notify(struct proto *p, unsigned flags, struct iface *iface);
void ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a);
void ospf_iface_info(struct ospf_iface *ifa);
void ospf_iface_shutdown(struct ospf_iface *ifa);
void ospf_iface_new(struct proto_ospf *po, struct iface *iface, struct ospf_area_config *ac, struct ospf_iface_patt *ip);
void ospf_iface_new(struct proto_ospf *po, struct iface *iface, struct ifa *addr, struct ospf_area_config *ac, struct ospf_iface_patt *ip);
void ospf_iface_change_mtu(struct proto_ospf *po, struct ospf_iface *ifa);
void ospf_set_rxbuf_size(struct ospf_iface *ifa, u32 rxbuf);

View file

@ -79,7 +79,6 @@
static int ospf_reload_routes(struct proto *p);
static void ospf_rt_notify(struct proto *p, struct rtable *table UNUSED, net * n, rte * new, rte * old UNUSED, ea_list * attrs);
static void ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a);
static int ospf_rte_better(struct rte *new, struct rte *old);
static int ospf_rte_same(struct rte *new, struct rte *old);
static void ospf_disp(timer *timer);
@ -196,7 +195,7 @@ ospf_start(struct proto *p)
oa->options = OPT_R | OPT_E | OPT_V6;
#endif
}
ospf_iface_new(po, NULL, ac, ipatt);
ospf_iface_new(po, NULL, NULL, ac, ipatt);
}
}
}
@ -503,27 +502,6 @@ ospf_rt_notify(struct proto *p, rtable *tbl UNUSED, net * n, rte * new, rte * ol
flush_ext_lsa(n, po);
}
static void
ospf_ifa_notify(struct proto *p, unsigned flags UNUSED, struct ifa *a)
{
struct proto_ospf *po = (struct proto_ospf *) p;
struct ospf_iface *ifa;
if ((a->flags & IA_SECONDARY) || (a->flags & IA_UNNUMBERED))
return;
WALK_LIST(ifa, po->iface_list)
{
if (ifa->iface == a->iface)
{
schedule_rt_lsa(ifa->oa);
/* Event 5 from RFC5340 4.4.3. */
schedule_link_lsa(ifa);
return;
}
}
}
static void
ospf_get_status(struct proto *p, byte * buf)
{
@ -714,12 +692,17 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
WALK_LIST(ifa, po->iface_list)
{
/* FIXME: better handling of vlinks */
if (ifa->iface == NULL)
continue;
/* FIXME: better matching of interface_id in OSPFv3 */
if (oldip = (struct ospf_iface_patt *)
iface_patt_find(&oldac->patt_list, ifa->iface))
iface_patt_find(&oldac->patt_list, ifa->iface, ifa->addr))
{
/* Now reconfigure interface */
if (!(newip = (struct ospf_iface_patt *)
iface_patt_find(&newac->patt_list, ifa->iface)))
iface_patt_find(&newac->patt_list, ifa->iface, ifa->addr)))
return 0;
/* HELLO TIMER */
@ -785,9 +768,7 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
ifa->stub = newip->stub;
OSPF_TRACE(D_EVENTS, "Interface %s is now stub.", ifa->iface->name);
}
if ((oldip->stub != 0) && (newip->stub == 0) &&
((ifa->ioprob & OSPF_I_IP) == 0) &&
(((ifa->ioprob & OSPF_I_MC) == 0) || (ifa->type == OSPF_IT_NBMA)))
if ((oldip->stub != 0) && (newip->stub == 0) && (ifa->ioprob == OSPF_I_OK))
{
ifa->stub = newip->stub;
OSPF_TRACE(D_EVENTS,

View file

@ -171,7 +171,8 @@ struct ospf_iface
u32 dead; /* after "deadint" missing hellos is router dead */
u32 vid; /* Id of peer of virtual link */
ip_addr vip; /* IP of peer of virtual link */
struct ospf_area *voa; /* Area wich the vlink goes through */
struct ospf_iface *vifa; /* OSPF iface which the vlink goes through */
struct ospf_area *voa; /* OSPF area which the vlink goes through */
u16 inftransdelay; /* The estimated number of seconds it takes to
transmit a Link State Update Packet over this
interface. LSAs contained in the update */
@ -203,9 +204,6 @@ struct ospf_iface
#define OSPF_IT_UNDEF 4
u8 strictnbma; /* Can I talk with unknown neighbors? */
u8 stub; /* Inactive interface */
#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 */
@ -239,6 +237,9 @@ struct ospf_iface
list nbma_list;
u8 priority; /* A router priority for DR election */
u8 ioprob;
#define OSPF_I_OK 0 /* Everything OK */
#define OSPF_I_SK 1 /* Socket open failed */
#define OSPF_I_LL 2 /* Missing link-local address (OSPFv3) */
u8 sk_spf; /* Socket is a member of SPFRouters group */
u8 sk_dr; /* Socket is a member of DRouters group */
u32 rxbuf;

View file

@ -424,12 +424,14 @@ ospf_rt_spfa(struct ospf_area *oa)
if ((tmp = ospf_hash_find_rt(po->gr, oa->areaid, iface->vid)) &&
(!ipa_equal(tmp->lb, IPA_NONE)))
{
if ((iface->state != OSPF_IS_PTP) || (iface->iface != tmp->nhi->iface) || (!ipa_equal(iface->vip, tmp->lb)))
if ((iface->state != OSPF_IS_PTP) || (iface->vifa != tmp->nhi) || (!ipa_equal(iface->vip, tmp->lb)))
{
OSPF_TRACE(D_EVENTS, "Vlink peer %R found", tmp->lsa.id);
ospf_iface_sm(iface, ISM_DOWN);
iface->vifa = tmp->nhi;
iface->iface = tmp->nhi->iface;
iface->addr = iface->iface->addr;
iface->addr = tmp->nhi->addr;
iface->sk = tmp->nhi->sk;
iface->vip = tmp->lb;
ospf_iface_sm(iface, ISM_UP);
}

View file

@ -272,24 +272,20 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length)
break;
}
/* Now we will originate stub areas for interfaces addresses */
struct ifa *a;
WALK_LIST(a, ifa->iface->addrs)
{
if (((a == ifa->addr) && net_lsa) ||
(a->flags & IA_SECONDARY) ||
(a->flags & IA_UNNUMBERED) ||
configured_stubnet(oa, a))
continue;
/* Now we will originate stub area if there is no primary */
if (net_lsa ||
(ifa->type == OSPF_IT_VLINK) ||
(ifa->addr->flags & IA_UNNUMBERED) ||
configured_stubnet(oa, ifa->addr))
continue;
ln = lsab_alloc(po, sizeof(struct ospf_lsa_rt_link));
ln->type = LSART_STUB;
ln->id = ipa_to_u32(a->prefix);
ln->data = ipa_to_u32(ipa_mkmask(a->pxlen));
ln->metric = ifa->cost;
ln->padding = 0;
i++;
}
ln = lsab_alloc(po, sizeof(struct ospf_lsa_rt_link));
ln->type = LSART_STUB;
ln->id = ipa_to_u32(ifa->addr->prefix);
ln->data = ipa_to_u32(ipa_mkmask(ifa->addr->pxlen));
ln->metric = ifa->cost;
ln->padding = 0;
i++;
}
struct ospf_stubnet_config *sn;
@ -898,6 +894,7 @@ originate_ext_lsa_body(net *n, rte *e, u16 *length, struct proto_ospf *po,
int gw = 0;
int size = sizeof(struct ospf_lsa_ext);
// FIXME check for gw should be per ifa, not per iface
if ((e->attrs->dest == RTD_ROUTER) &&
!ipa_equal(e->attrs->gw, IPA_NONE) &&
!ipa_has_link_scope(e->attrs->gw) &&

View file

@ -761,7 +761,7 @@ rip_real_if_add(struct object_lock *lock)
struct iface *iface = lock->iface;
struct proto *p = lock->data;
struct rip_interface *rif;
struct iface_patt *k = iface_patt_find(&P_CF->iface_list, iface);
struct iface_patt *k = iface_patt_find(&P_CF->iface_list, iface, iface->addr);
if (!k)
bug("This can not happen! It existed few seconds ago!" );
@ -790,7 +790,7 @@ rip_if_notify(struct proto *p, unsigned c, struct iface *iface)
}
}
if (c & IF_CHANGE_UP) {
struct iface_patt *k = iface_patt_find(&P_CF->iface_list, iface);
struct iface_patt *k = iface_patt_find(&P_CF->iface_list, iface, iface->addr);
struct object_lock *lock;
struct rip_patt *PATT = (struct rip_patt *) k;

View file

@ -62,18 +62,18 @@ get_inaddr(ip_addr *a, struct in_addr *ia)
#define MREQ_IFA struct in_addr
#define MREQ_GRP struct ip_mreq
static inline void fill_mreq_ifa(struct in_addr *m, struct iface *ifa, UNUSED ip_addr maddr)
static inline void fill_mreq_ifa(struct in_addr *m, struct iface *ifa UNUSED, ip_addr saddr, ip_addr maddr UNUSED)
{
set_inaddr(m, ifa->addr->ip);
set_inaddr(m, saddr);
}
static inline void fill_mreq_grp(struct ip_mreq *m, struct iface *ifa, ip_addr maddr)
static inline void fill_mreq_grp(struct ip_mreq *m, struct iface *ifa, ip_addr saddr, ip_addr maddr)
{
bzero(m, sizeof(*m));
#ifdef CONFIG_LINUX_MC_MREQ_BIND
m->imr_interface.s_addr = INADDR_ANY;
#else
set_inaddr(&m->imr_interface, ifa->addr->ip);
set_inaddr(&m->imr_interface, saddr);
#endif
set_inaddr(&m->imr_multiaddr, maddr);
}
@ -101,11 +101,11 @@ struct ip_mreqn
#define fill_mreq_ifa fill_mreq
#define fill_mreq_grp fill_mreq
static inline void fill_mreq(struct ip_mreqn *m, struct iface *ifa, ip_addr maddr)
static inline void fill_mreq(struct ip_mreqn *m, struct iface *ifa, ip_addr saddr, ip_addr maddr)
{
bzero(m, sizeof(*m));
m->imr_ifindex = ifa->index;
set_inaddr(&m->imr_address, ifa->addr->ip);
set_inaddr(&m->imr_address, saddr);
set_inaddr(&m->imr_multiaddr, maddr);
}
#endif
@ -123,7 +123,7 @@ sysio_setup_multicast(sock *s)
return "IP_MULTICAST_TTL";
/* This defines where should we send _outgoing_ multicasts */
fill_mreq_ifa(&m, s->iface, IPA_NONE);
fill_mreq_ifa(&m, s->iface, s->saddr, IPA_NONE);
if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &m, sizeof(m)) < 0)
return "IP_MULTICAST_IF";
@ -145,7 +145,7 @@ sysio_join_group(sock *s, ip_addr maddr)
MREQ_GRP m;
/* And this one sets interface for _receiving_ multicasts from */
fill_mreq_grp(&m, s->iface, maddr);
fill_mreq_grp(&m, s->iface, s->saddr, maddr);
if (setsockopt(s->fd, SOL_IP, IP_ADD_MEMBERSHIP, &m, sizeof(m)) < 0)
return "IP_ADD_MEMBERSHIP";
@ -158,7 +158,7 @@ sysio_leave_group(sock *s, ip_addr maddr)
MREQ_GRP m;
/* And this one sets interface for _receiving_ multicasts from */
fill_mreq_grp(&m, s->iface, maddr);
fill_mreq_grp(&m, s->iface, s->saddr, maddr);
if (setsockopt(s->fd, SOL_IP, IP_DROP_MEMBERSHIP, &m, sizeof(m)) < 0)
return "IP_DROP_MEMBERSHIP";