summaryrefslogtreecommitdiff
path: root/nest/iface.c
diff options
context:
space:
mode:
Diffstat (limited to 'nest/iface.c')
-rw-r--r--nest/iface.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/nest/iface.c b/nest/iface.c
index a23cdf4f..00af5052 100644
--- a/nest/iface.c
+++ b/nest/iface.c
@@ -46,7 +46,7 @@ list iface_list;
void
ifa_dump(struct ifa *a)
{
- debug("\t%I, net %I/%-2d bc %I -> %I%s%s%s\n", a->ip, a->prefix, a->pxlen, a->brd, a->opposite,
+ debug("\t%I, net %N bc %I -> %I%s%s%s\n", a->ip, &a->prefix, a->brd, a->opposite,
(a->flags & IF_UP) ? "" : " DOWN",
(a->flags & IA_PRIMARY) ? "" : " SEC",
(a->flags & IA_PEER) ? "PEER" : "");
@@ -138,13 +138,12 @@ if_copy(struct iface *to, struct iface *from)
static inline void
ifa_send_notify(struct proto *p, unsigned c, struct ifa *a)
{
- if (p->ifa_notify)
+ if (p->ifa_notify && (p->proto_state != PS_DOWN))
{
if (p->debug & D_IFACES)
- log(L_TRACE "%s < %s address %I/%d on interface %s %s",
+ log(L_TRACE "%s < %s address %N on interface %s %s",
p->name, (a->flags & IA_PRIMARY) ? "primary" : "secondary",
- a->prefix, a->pxlen, a->iface->name,
- (c & IF_CHANGE_UP) ? "added" : "removed");
+ &a->prefix, a->iface->name, (c & IF_CHANGE_UP) ? "added" : "removed");
p->ifa_notify(p, c, a);
}
}
@@ -156,7 +155,7 @@ ifa_notify_change_(unsigned c, struct ifa *a)
DBG("IFA change notification (%x) for %s:%I\n", c, a->iface->name, a->ip);
- WALK_LIST(p, active_proto_list)
+ WALK_LIST(p, proto_list)
ifa_send_notify(p, c, a);
}
@@ -175,7 +174,7 @@ ifa_notify_change(unsigned c, struct ifa *a)
static inline void
if_send_notify(struct proto *p, unsigned c, struct iface *i)
{
- if (p->if_notify)
+ if (p->if_notify && (p->proto_state != PS_DOWN))
{
if (p->debug & D_IFACES)
log(L_TRACE "%s < interface %s %s", p->name, i->name,
@@ -216,7 +215,7 @@ if_notify_change(unsigned c, struct iface *i)
ifa_notify_change_(IF_CHANGE_DOWN, a);
}
- WALK_LIST(p, active_proto_list)
+ WALK_LIST(p, proto_list)
if_send_notify(p, c, i);
if (c & IF_CHANGE_UP)
@@ -500,8 +499,7 @@ ifa_recalc_all_primary_addresses(void)
static inline int
ifa_same(struct ifa *a, struct ifa *b)
{
- return ipa_equal(a->ip, b->ip) && ipa_equal(a->prefix, b->prefix) &&
- a->pxlen == b->pxlen;
+ return ipa_equal(a->ip, b->ip) && net_equal(&a->prefix, &b->prefix);
}
@@ -534,10 +532,8 @@ ifa_update(struct ifa *a)
break;
}
-#ifndef IPV6
- if ((i->flags & IF_BROADCAST) && !ipa_nonzero(a->brd))
+ if ((a->prefix.type == NET_IP4) && (i->flags & IF_BROADCAST) && ipa_zero(a->brd))
log(L_ERR "Missing broadcast address for interface %s", i->name);
-#endif
b = mb_alloc(if_pool, sizeof(struct ifa));
memcpy(b, a, sizeof(struct ifa));
@@ -584,9 +580,8 @@ ifa_delete(struct ifa *a)
}
u32
-if_choose_router_id(struct iface_patt *mask UNUSED6, u32 old_id UNUSED6)
+if_choose_router_id(struct iface_patt *mask, u32 old_id)
{
-#ifndef IPV6
struct iface *i;
struct ifa *a, *b;
@@ -599,6 +594,9 @@ if_choose_router_id(struct iface_patt *mask UNUSED6, u32 old_id UNUSED6)
WALK_LIST(a, i->addrs)
{
+ if (a->prefix.type != NET_IP4)
+ continue;
+
if (a->flags & IA_SECONDARY)
continue;
@@ -623,10 +621,6 @@ if_choose_router_id(struct iface_patt *mask UNUSED6, u32 old_id UNUSED6)
log(L_INFO "Chosen router ID %R according to interface %s", id, b->iface->name);
return id;
-
-#else
- return 0;
-#endif
}
/**
@@ -669,17 +663,17 @@ iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a)
continue;
}
- if (p->pxlen == 0)
+ if (p->prefix.pxlen == 0)
return pos;
if (!a)
continue;
- if (ipa_in_net(a->ip, p->prefix, p->pxlen))
+ if (ipa_in_netX(a->ip, &p->prefix))
return pos;
if ((a->flags & IA_PEER) &&
- ipa_in_net(a->opposite, p->prefix, p->pxlen))
+ ipa_in_netX(a->opposite, &p->prefix))
return pos;
continue;
@@ -713,8 +707,7 @@ iface_plists_equal(struct iface_patt *pa, struct iface_patt *pb)
(!x->pattern && y->pattern) || /* This nasty lines where written by me... :-( Feela */
(!y->pattern && x->pattern) ||
((x->pattern != y->pattern) && strcmp(x->pattern, y->pattern)) ||
- !ipa_equal(x->prefix, y->prefix) ||
- (x->pxlen != y->pxlen))
+ !net_equal(&x->prefix, &y->prefix))
return 0;
x = (void *) x->n.next;
y = (void *) y->n.next;
@@ -747,14 +740,14 @@ iface_patts_equal(list *a, list *b, int (*comp)(struct iface_patt *, struct ifac
static void
if_show_addr(struct ifa *a)
{
- byte opp[STD_ADDRESS_P_LENGTH + 16];
+ byte opp[IPA_MAX_TEXT_LENGTH + 16];
if (ipa_nonzero(a->opposite))
bsprintf(opp, ", opposite %I", a->opposite);
else
opp[0] = 0;
cli_msg(-1003, "\t%I/%d (%s%s, scope %s)",
- a->ip, a->pxlen,
+ a->ip, a->prefix.pxlen,
(a->flags & IA_PRIMARY) ? "Primary" : (a->flags & IA_SECONDARY) ? "Secondary" : "Unselected",
opp, ip_scope_text(a->scope));
}
@@ -798,13 +791,13 @@ void
if_show_summary(void)
{
struct iface *i;
- byte addr[STD_ADDRESS_P_LENGTH + 16];
+ byte addr[IPA_MAX_TEXT_LENGTH + 16];
cli_msg(-2005, "interface state address");
WALK_LIST(i, iface_list)
{
if (i->addr)
- bsprintf(addr, "%I/%d", i->addr->ip, i->addr->pxlen);
+ bsprintf(addr, "%I/%d", i->addr->ip, i->addr->prefix.pxlen);
else
addr[0] = 0;
cli_msg(-1005, "%-9s %-5s %s", i->name, (i->flags & IF_UP) ? "up" : "DOWN", addr);