version 1.1, 2017/08/22 12:33:54
|
version 1.1.1.2, 2021/03/17 19:50:23
|
Line 116 if_what_changed(struct iface *i, struct iface *j)
|
Line 116 if_what_changed(struct iface *i, struct iface *j)
|
unsigned c; |
unsigned c; |
|
|
if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED)) |
if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED)) |
|| i->index != j->index) | || (i->index != j->index) || (i->master != j->master)) |
return IF_CHANGE_TOO_MUCH; |
return IF_CHANGE_TOO_MUCH; |
c = 0; |
c = 0; |
if ((i->flags ^ j->flags) & IF_UP) |
if ((i->flags ^ j->flags) & IF_UP) |
Line 133 if_copy(struct iface *to, struct iface *from)
|
Line 133 if_copy(struct iface *to, struct iface *from)
|
{ |
{ |
to->flags = from->flags | (to->flags & IF_TMP_DOWN); |
to->flags = from->flags | (to->flags & IF_TMP_DOWN); |
to->mtu = from->mtu; |
to->mtu = from->mtu; |
|
to->master_index = from->master_index; |
|
to->master = from->master; |
} |
} |
|
|
static inline void |
static inline void |
ifa_send_notify(struct proto *p, unsigned c, struct ifa *a) |
ifa_send_notify(struct proto *p, unsigned c, struct ifa *a) |
{ |
{ |
if (p->ifa_notify) | if (p->ifa_notify && (!p->vrf_set || p->vrf == a->iface->master)) |
{ |
{ |
if (p->debug & D_IFACES) |
if (p->debug & D_IFACES) |
log(L_TRACE "%s < %s address %I/%d on interface %s %s", | log(L_TRACE "%s <%s address %I/%d on interface %s %s", |
p->name, (a->flags & IA_PRIMARY) ? "primary" : "secondary", | p->name, (a->flags & IA_PRIMARY) ? " primary" : "", |
a->prefix, a->pxlen, a->iface->name, |
a->prefix, a->pxlen, a->iface->name, |
(c & IF_CHANGE_UP) ? "added" : "removed"); |
(c & IF_CHANGE_UP) ? "added" : "removed"); |
p->ifa_notify(p, c, a); |
p->ifa_notify(p, c, a); |
Line 175 ifa_notify_change(unsigned c, struct ifa *a)
|
Line 177 ifa_notify_change(unsigned c, struct ifa *a)
|
static inline void |
static inline void |
if_send_notify(struct proto *p, unsigned c, struct iface *i) |
if_send_notify(struct proto *p, unsigned c, struct iface *i) |
{ |
{ |
if (p->if_notify) | if (p->if_notify && (!p->vrf_set || p->vrf == i->master)) |
{ |
{ |
if (p->debug & D_IFACES) |
if (p->debug & D_IFACES) |
log(L_TRACE "%s < interface %s %s", p->name, i->name, |
log(L_TRACE "%s < interface %s %s", p->name, i->name, |
Line 238 if_recalc_flags(struct iface *i, unsigned flags)
|
Line 240 if_recalc_flags(struct iface *i, unsigned flags)
|
{ |
{ |
if ((flags & (IF_SHUTDOWN | IF_TMP_DOWN)) || |
if ((flags & (IF_SHUTDOWN | IF_TMP_DOWN)) || |
!(flags & IF_ADMIN_UP) || |
!(flags & IF_ADMIN_UP) || |
!i->addr) | !i->addr || |
| (i->master_index && !i->master)) |
flags &= ~IF_UP; |
flags &= ~IF_UP; |
else |
else |
flags |= IF_UP; |
flags |= IF_UP; |
Line 438 if_find_by_name(char *name)
|
Line 441 if_find_by_name(char *name)
|
struct iface *i; |
struct iface *i; |
|
|
WALK_LIST(i, iface_list) |
WALK_LIST(i, iface_list) |
if (!strcmp(i->name, name)) | if (!strcmp(i->name, name) && !(i->flags & IF_SHUTDOWN)) |
return i; |
return i; |
return NULL; |
return NULL; |
} |
} |
Line 448 if_get_by_name(char *name)
|
Line 451 if_get_by_name(char *name)
|
{ |
{ |
struct iface *i; |
struct iface *i; |
|
|
if (i = if_find_by_name(name)) | WALK_LIST(i, iface_list) |
return i; | if (!strcmp(i->name, name)) |
| return i; |
|
|
/* No active iface, create a dummy */ |
/* No active iface, create a dummy */ |
i = mb_allocz(if_pool, sizeof(struct iface)); |
i = mb_allocz(if_pool, sizeof(struct iface)); |
Line 466 struct ifa *kif_choose_primary(struct iface *i);
|
Line 470 struct ifa *kif_choose_primary(struct iface *i);
|
static int |
static int |
ifa_recalc_primary(struct iface *i) |
ifa_recalc_primary(struct iface *i) |
{ |
{ |
struct ifa *a = kif_choose_primary(i); | struct ifa *a; |
| int c = 0; |
|
|
|
#ifdef IPV6 |
|
struct ifa *ll = NULL; |
|
|
|
WALK_LIST(a, i->addrs) |
|
if (ipa_is_link_local(a->ip) && (!ll || (a == i->llv6))) |
|
ll = a; |
|
|
|
c = (ll != i->llv6); |
|
i->llv6 = ll; |
|
#endif |
|
|
|
a = kif_choose_primary(i); |
|
|
if (a == i->addr) |
if (a == i->addr) |
return 0; | return c; |
|
|
if (i->addr) |
if (i->addr) |
i->addr->flags &= ~IA_PRIMARY; |
i->addr->flags &= ~IA_PRIMARY; |
Line 573 ifa_delete(struct ifa *a)
|
Line 591 ifa_delete(struct ifa *a)
|
b->flags &= ~IF_UP; |
b->flags &= ~IF_UP; |
ifa_notify_change(IF_CHANGE_DOWN, b); |
ifa_notify_change(IF_CHANGE_DOWN, b); |
} |
} |
if (b->flags & IA_PRIMARY) | if ((b->flags & IA_PRIMARY) || (b == ifa_llv6(i))) |
{ |
{ |
if_change_flags(i, i->flags | IF_TMP_DOWN); |
if_change_flags(i, i->flags | IF_TMP_DOWN); |
ifa_recalc_primary(i); |
ifa_recalc_primary(i); |
Line 771 if_show(void)
|
Line 789 if_show(void)
|
if (i->flags & IF_SHUTDOWN) |
if (i->flags & IF_SHUTDOWN) |
continue; |
continue; |
|
|
cli_msg(-1001, "%s %s (index=%d)", i->name, (i->flags & IF_UP) ? "up" : "DOWN", i->index); | char mbuf[16 + sizeof(i->name)] = {}; |
| if (i->master) |
| bsprintf(mbuf, " master=%s", i->master->name); |
| else if (i->master_index) |
| bsprintf(mbuf, " master=#%u", i->master_index); |
| |
| cli_msg(-1001, "%s %s (index=%d%s)", i->name, (i->flags & IF_UP) ? "up" : "DOWN", i->index, mbuf); |
if (!(i->flags & IF_MULTIACCESS)) |
if (!(i->flags & IF_MULTIACCESS)) |
type = "PtP"; |
type = "PtP"; |
else |
else |
Line 803 if_show_summary(void)
|
Line 827 if_show_summary(void)
|
cli_msg(-2005, "interface state address"); |
cli_msg(-2005, "interface state address"); |
WALK_LIST(i, iface_list) |
WALK_LIST(i, iface_list) |
{ |
{ |
|
if (i->flags & IF_SHUTDOWN) |
|
continue; |
|
|
if (i->addr) |
if (i->addr) |
bsprintf(addr, "%I/%d", i->addr->ip, i->addr->pxlen); |
bsprintf(addr, "%I/%d", i->addr->ip, i->addr->pxlen); |
else |
else |