From baa6a792652019e6f94a8e0dcfcc1fe7e0539b70 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Thu, 11 Sep 2014 10:24:36 +0200 Subject: [PATCH 1/3] addrconf: reworked flags adding group,primary,fallback --- client/ifstatus.c | 2 +- client/suse/compat-suse.c | 4 ++-- include/wicked/addrconf.h | 5 ++++- src/fsm.c | 4 ++-- src/names.c | 3 +++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/client/ifstatus.c b/client/ifstatus.c index 9725eac49..f76858920 100644 --- a/client/ifstatus.c +++ b/client/ifstatus.c @@ -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); diff --git a/client/suse/compat-suse.c b/client/suse/compat-suse.c index 1d8ed5539..6cb001542 100644 --- a/client/suse/compat-suse.c +++ b/client/suse/compat-suse.c @@ -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; } @@ -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; } diff --git a/include/wicked/addrconf.h b/include/wicked/addrconf.h index 48a7ee8e9..73aeff46d 100644 --- a/include/wicked/addrconf.h +++ b/include/wicked/addrconf.h @@ -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 */ }; /* diff --git a/src/fsm.c b/src/fsm.c index 5af907700..5c1afd74e 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -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), @@ -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 */ diff --git a/src/names.c b/src/names.c index d3492f9dc..07fd3fbab 100644 --- a/src/names.c +++ b/src/names.c @@ -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 }, }; From af420978e1d11800cc37eb5c3b67352a4b3a4905 Mon Sep 17 00:00:00 2001 From: Karol Mroz Date: Thu, 11 Sep 2014 21:32:52 -0700 Subject: [PATCH 2/3] ifstatus: disable pulling device status from addrs The lease state provides a more accurate status -- dhcpv6 automatically declines duplicate IPs and requests new one. --- client/ifstatus.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/ifstatus.c b/client/ifstatus.c index f76858920..b9f734058 100644 --- a/client/ifstatus.c +++ b/client/ifstatus.c @@ -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) { @@ -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) @@ -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; } From 74992476b9e29528e0ac4dcd5bcc73370d9b0cf8 Mon Sep 17 00:00:00 2001 From: Karol Mroz Date: Thu, 11 Sep 2014 21:41:48 -0700 Subject: [PATCH 3/3] ifup: fix exit code override when systemd in picture --- client/ifreload.c | 16 ++++++++-------- client/ifup.c | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/client/ifreload.c b/client/ifreload.c index eac28f880..671731b3d 100644 --- a/client/ifreload.c +++ b/client/ifreload.c @@ -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; } } @@ -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 { diff --git a/client/ifup.c b/client/ifup.c index a78d4549e..bddda028f 100644 --- a/client/ifup.c +++ b/client/ifup.c @@ -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: @@ -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; }