Skip to content

Commit

Permalink
addrconf: reworked flags adding group,primary,fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski authored and kmroz committed Sep 11, 2014
1 parent d2a4e0c commit baa6a79
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 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
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 baa6a79

Please sign in to comment.