Skip to content

Commit

Permalink
Merge pull request #418 from mtomaschewski/kmroz-status-3
Browse files Browse the repository at this point in the history
ifstatus: initial status reporting fixes
  • Loading branch information
wipawel committed Sep 15, 2014
2 parents d2a4e0c + 7499247 commit 651871a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
16 changes: 8 additions & 8 deletions client/ifreload.c
Expand Up @@ -346,11 +346,11 @@ ni_do_ifreload_direct(int argc, char **argv)
status = ni_ifstatus_display_result(fsm, &ifnames, &up_marked,
opt_transient);

/* Do not report any transient errors to systemd (e.g. dhcp
* or whatever not ready in time) -- returning an error may
* cause to stop the network completely.
/*
* Do not report any errors to systemd -- returning an error
* here, will cause sytemd to stop the network completely.
*/
if (!opt_systemd)
if (opt_systemd)
status = NI_LSB_RC_SUCCESS;
}
}
Expand Down Expand Up @@ -666,11 +666,11 @@ ni_do_ifreload_nanny(int argc, char **argv)
status = ni_ifstatus_display_result(fsm, &ifnames, &up_marked,
opt_transient);

/* Do not report any transient errors to systemd (e.g. dhcp
* or whatever not ready in time) -- returning an error may
* cause to stop the network completely.
/*
* Do not report any errors to systemd -- returning an error
* here, will cause sytemd to stop the network completely.
*/
if (!opt_systemd)
if (opt_systemd)
status = NI_LSB_RC_SUCCESS;
}
else {
Expand Down
16 changes: 15 additions & 1 deletion client/ifstatus.c
Expand Up @@ -118,7 +118,7 @@ __find_peer_lease(ni_netdev_t *dev, sa_family_t family, unsigned int type)
static inline ni_bool_t
__is_peer_lease_up(ni_netdev_t *dev, ni_addrconf_lease_t *lease)
{
if (ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_OPTIONAL)) {
if (ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_GROUP)) {
const ni_addrconf_lease_t *other;

other = __find_peer_lease(dev, lease->family, lease->type);
Expand Down Expand Up @@ -157,6 +157,17 @@ __ifstatus_of_device_leases(ni_netdev_t *dev, unsigned int *st)
}
}

#if 0
/*
* duplicate addresses are not always a failure:
* dhcpv6 gets an address from dhcp-server. when the kernel
* finds out it is a duplicate and reports it, dhcpv6 will
* automatically try to decline it and get another address.
* wickedd will revert the lease state from applying back
* to requesting state and the lease gets not granted then.
* similar with tentative.
* => the lease state reflects the current status to use.
*/
static void
__ifstatus_of_device_addrs(ni_netdev_t *dev, unsigned int *st)
{
Expand All @@ -178,6 +189,7 @@ __ifstatus_of_device_addrs(ni_netdev_t *dev, unsigned int *st)
}
}
}
#endif

static unsigned int
__ifstatus_of_device(ni_netdev_t *dev)
Expand All @@ -195,9 +207,11 @@ __ifstatus_of_device(ni_netdev_t *dev)
return NI_WICKED_ST_IN_PROGRESS;

__ifstatus_of_device_leases(dev, &st);
#if 0
if (st != NI_WICKED_ST_NOT_RUNNING)
__ifstatus_of_device_addrs(dev, &st);

#endif
return st;
}

Expand Down
16 changes: 8 additions & 8 deletions client/ifup.c
Expand Up @@ -626,11 +626,11 @@ ni_do_ifup_nanny(int argc, char **argv)
status = ni_ifstatus_display_result(fsm, &ifnames, &ifmarked,
opt_transient);

/* Do not report any transient errors to systemd (e.g. dhcp
* or whatever not ready in time) -- returning an error may
* cause to stop the network completely.
/*
* Do not report any errors to systemd -- returning an error
* here, will cause sytemd to stop the network completely.
*/
if (!opt_systemd)
if (opt_systemd)
status = NI_LSB_RC_SUCCESS;

cleanup:
Expand Down Expand Up @@ -900,11 +900,11 @@ ni_do_ifup_direct(int argc, char **argv)
status = ni_ifstatus_display_result(fsm, &ifnames, &ifmarked,
opt_transient);

/* Do not report any transient errors to systemd (e.g. dhcp
* or whatever not ready in time) -- returning an error may
* cause to stop the network completely.
/*
* Do not report any errors to systemd -- returning an error
* here, will cause sytemd to stop the network completely.
*/
if (!opt_systemd)
if (opt_systemd)
status = NI_LSB_RC_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions client/suse/compat-suse.c
Expand Up @@ -3336,7 +3336,7 @@ __ni_suse_addrconf_dhcp4(const ni_sysconfig_t *sc, ni_compat_netdev_t *compat, n
__ni_suse_addrconf_dhcp4_options(sc, compat);

compat->dhcp4.enabled = TRUE;
ni_addrconf_flag_bit_set(&compat->dhcp4.flags, NI_ADDRCONF_FLAGS_OPTIONAL, !required);
ni_addrconf_flag_bit_set(&compat->dhcp4.flags, NI_ADDRCONF_FLAGS_GROUP, !required);
return TRUE;
}

Expand All @@ -3363,7 +3363,7 @@ __ni_suse_addrconf_dhcp6(const ni_sysconfig_t *sc, ni_compat_netdev_t *compat, n
__ni_suse_addrconf_dhcp6_options(sc, compat);

compat->dhcp6.enabled = TRUE;
ni_addrconf_flag_bit_set(&compat->dhcp6.flags, NI_ADDRCONF_FLAGS_OPTIONAL, !required);
ni_addrconf_flag_bit_set(&compat->dhcp6.flags, NI_ADDRCONF_FLAGS_GROUP, !required);
return TRUE;
}

Expand Down
5 changes: 4 additions & 1 deletion include/wicked/addrconf.h
Expand Up @@ -64,7 +64,10 @@ enum {
* Lease handling flag bits
*/
enum {
NI_ADDRCONF_FLAGS_OPTIONAL,
NI_ADDRCONF_FLAGS_GROUP, /* lease type group acting as one */
NI_ADDRCONF_FLAGS_PRIMARY, /* primary lease trigerring fallback */
NI_ADDRCONF_FLAGS_FALLBACK, /* fallback of a primary lease */
NI_ADDRCONF_FLAGS_OPTIONAL, /* optional lease allowed to fail */
};

/*
Expand Down
4 changes: 2 additions & 2 deletions src/fsm.c
Expand Up @@ -3483,7 +3483,7 @@ ni_ifworker_print_device_leases(ni_ifworker_t *w)
"%s: worker device leases:", w->name);
for (lease = w->device->leases; lease; lease = lease->next) {
ni_bool_t optional = ni_addrconf_flag_bit_is_set(lease->flags,
NI_ADDRCONF_FLAGS_OPTIONAL);
NI_ADDRCONF_FLAGS_GROUP);
ni_debug_verbose(NI_LOG_DEBUG1, NI_TRACE_EVENTS,
" %s:%s in state %s, uuid %s%s",
ni_addrfamily_type_to_name(lease->family),
Expand Down Expand Up @@ -4259,7 +4259,7 @@ address_acquired_callback_handler(ni_ifworker_t *w, const ni_objectmodel_callbac
continue;

/* a not ready, released or failed non-optional lease -> fail */
if (!ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_OPTIONAL))
if (!ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_GROUP))
return FALSE;

/* optional type-goup peer lease -> check peer lease */
Expand Down
3 changes: 3 additions & 0 deletions src/names.c
Expand Up @@ -188,6 +188,9 @@ ni_addrconf_state_to_name(unsigned int type)
* Map addrconf flag bits to strings and vice versa
*/
static const ni_intmap_t __addrconf_flag_bits[] = {
{ "group", NI_ADDRCONF_FLAGS_GROUP },
{ "primary", NI_ADDRCONF_FLAGS_PRIMARY },
{ "fallback", NI_ADDRCONF_FLAGS_FALLBACK },
{ "optional", NI_ADDRCONF_FLAGS_OPTIONAL },
{ NULL, -1U },
};
Expand Down

0 comments on commit 651871a

Please sign in to comment.