Skip to content

Commit

Permalink
Merge commit 'master' into sle15-sp1
Browse files Browse the repository at this point in the history
- addrconf: fix fallback-lease drop (bsc#1220996)
- Replace "nvme show-nbft" with "nvme nbft show" (bsc#1221358)
- hide secrets in debug log (bsc#1221194)
  • Loading branch information
cfconrad committed Apr 9, 2024
2 parents 8678e99 + 210e557 commit 1c557e4
Show file tree
Hide file tree
Showing 18 changed files with 308 additions and 75 deletions.
15 changes: 8 additions & 7 deletions client/ifreload.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <wicked/netinfo.h>
#include <wicked/logging.h>
#include <wicked/fsm.h>
#include <wicked/compiler.h>

#include "wicked-client.h"
#include "appconfig.h"
Expand All @@ -59,7 +60,7 @@ ifreload_mark_add(ni_ifworker_array_t *marked, ni_ifworker_t *w)

static inline void
ifreload_mark_down_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *lower,
void (*logit)(const char *, ...) __fmtattr)
void (*logit)(const char *, ...) ni__printf(1, 2))
{
ni_ifworker_t *w;
unsigned int i;
Expand Down Expand Up @@ -94,7 +95,7 @@ ifreload_mark_down_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked,

static ni_bool_t
ifreload_mark_down(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w,
void (*logit)(const char *, ...) __fmtattr,
void (*logit)(const char *, ...) ni__printf(1, 2),
unsigned int depth)
{
/* ifdown is disabled when persistent mode is on (todo: add --force?) */
Expand Down Expand Up @@ -176,7 +177,7 @@ ifreload_mark_down(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker

static void
ifreload_mark_up_slave_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *master,
void (*logit)(const char *, ...) __fmtattr)
void (*logit)(const char *, ...) ni__printf(1, 2))
{
ni_ifworker_t *w;
unsigned int i;
Expand Down Expand Up @@ -207,7 +208,7 @@ ifreload_mark_up_slave_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni

static void
ifreload_mark_up_master(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w,
void (*logit)(const char *, ...) __fmtattr)
void (*logit)(const char *, ...) ni__printf(1, 2))
{
if (!ni_ifcheck_worker_config_exists(w)) {
logit("skipping %s set-up: no configuration available", w->name);
Expand All @@ -228,7 +229,7 @@ ifreload_mark_up_master(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifw

static void
ifreload_mark_up_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *lower,
void (*logit)(const char *, ...) __fmtattr)
void (*logit)(const char *, ...) ni__printf(1, 2))
{
ni_ifworker_t *w;
unsigned int i;
Expand Down Expand Up @@ -268,7 +269,7 @@ ifreload_mark_up_lower_deps(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni

static ni_bool_t
ifreload_mark_up(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t *w,
void (*logit)(const char *, ...) __fmtattr)
void (*logit)(const char *, ...) ni__printf(1, 2))
{
if (!ni_ifcheck_worker_config_exists(w)) {
logit("skipping %s set-up: no configuration available", w->name);
Expand Down Expand Up @@ -299,7 +300,7 @@ ifreload_mark_up(const ni_fsm_t *fsm, ni_ifworker_array_t *marked, ni_ifworker_t
static void
ifreload_mark_workers(const ni_fsm_t *fsm, ni_ifworker_array_t *down_marked, ni_ifworker_array_t *up_marked, const char *ifname)
{
void (*logit)(const char *, ...) __fmtattr = ifname ? ni_note : ni_info;
void (*logit)(const char *, ...) ni__printf(1, 2) = ifname ? ni_note : ni_info;
ni_ifworker_t *w;
unsigned int i;

Expand Down
54 changes: 51 additions & 3 deletions client/ifstatus.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,44 @@ __ifstatus_of_device_lease(ni_netdev_t *dev, ni_addrconf_lease_t *lease, unsigne
}
}

static ni_addrconf_lease_t*
ifstatus_primary_lease(ni_netdev_t *dev,
ni_addrconf_lease_t *lease)
{
ni_addrconf_lease_t *l;

if (!ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_FALLBACK))
return NULL;

for (l = dev->leases; l; l = l->next) {
if (l->family != lease->family)
continue;

if (!ni_addrconf_flag_bit_is_set(l->flags, NI_ADDRCONF_FLAGS_PRIMARY))
continue;

if (ni_log_level_at(NI_LOG_DEBUG1)) {
ni_stringbuf_t buf = NI_STRINGBUF_INIT_DYNAMIC;

ni_addrconf_flags_format(&buf, l->flags, "|");
ni_debug_application("%s: primary lease %s:%s, state=%s, flags=%s",
dev->name,
ni_addrfamily_type_to_name(l->family),
ni_addrconf_type_to_name(l->type),
ni_addrconf_state_to_name(l->state),
buf.string);
ni_stringbuf_destroy(&buf);
}

return l;
}
return NULL;
}

static void
__ifstatus_of_device_leases(ni_netdev_t *dev, unsigned int *st)
{
ni_addrconf_lease_t *lease;
ni_addrconf_lease_t *lease, *primary;

if (!dev || !st)
return;
Expand All @@ -241,6 +275,16 @@ __ifstatus_of_device_leases(ni_netdev_t *dev, unsigned int *st)
NI_ADDRCONF_FLAGS_OPTIONAL))
continue;

/* Do not consider fallback lease status, if there is a
* corresponding primary+granted lease */
if ((primary = ifstatus_primary_lease(dev, lease))) {
unsigned int tmp = NI_WICKED_ST_OK;

__ifstatus_of_device_lease(dev, primary, &tmp);
if (tmp == NI_WICKED_ST_OK)
continue;
}

__ifstatus_of_device_lease(dev, lease, st);
}
}
Expand Down Expand Up @@ -617,10 +661,14 @@ __show_leases_by_family(const ni_netdev_t *dev, ni_bool_t verbose, sa_family_t f
ni_addrconf_type_to_name(lease->type),
ni_addrconf_state_to_name(lease->state));

if (verbose && lease->flags) {
if ((verbose && lease->flags) ||
ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_FALLBACK)) {
ni_stringbuf_t tmp = NI_STRINGBUF_INIT_DYNAMIC;
ni_stringbuf_puts(&buf, " [");
ni_addrconf_flags_format(&buf, lease->flags, ",");
ni_addrconf_flags_format(&tmp, lease->flags, ",");
ni_stringbuf_puts(&buf, tmp.string);
ni_stringbuf_puts(&buf, "]");
ni_stringbuf_destroy(&tmp);
}
}
if (buf.string)
Expand Down
4 changes: 2 additions & 2 deletions extensions/nbft
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ nvme_show_nbft() {
if test "X$OPT_ROOTDIR" != "X" -a -f "$OPT_ROOTDIR/nbft.json" ; then
cat "$OPT_ROOTDIR/nbft.json"
else
nvme show-nbft -H -o json
nvme nbft show -H -o json
fi
}

Expand All @@ -261,7 +261,7 @@ nbft_parse() {
local j=0 i

nbft_json=$(nvme_show_nbft 2>/dev/null) || {
warn "failed to read NBFT table, is \"nvme show-nbft\" supported?"
warn "failed to read NBFT table, is \"nvme nbft show\" supported?"
return $RC_ERROR
}
n_nbft=$(nbft_run_jq ". | length" "$nbft_json") || return 0
Expand Down
1 change: 1 addition & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ wicked_include_HEADERS = \
wicked/bridge.h \
wicked/client.h \
wicked/constants.h \
wicked/compiler.h \
wicked/dbus.h \
wicked/dbus-errors.h \
wicked/dbus-service.h \
Expand Down
42 changes: 42 additions & 0 deletions include/wicked/compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Compiler specific definitions
*
* Copyright (C) 2024 SUSE LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef NI_WICKED_COMPILER_H
#define NI_WICKED_COMPILER_H

#ifdef __GNUC__

# define ni__printf(a, b) __attribute__ ((format (printf, a, b)))
# define ni__noreturn __attribute__ ((noreturn))
# define ni__packed __attribute__ ((__packed__))
# define ni__unused __attribute__ ((unused))
# define ni__constructor __attribute__ ((constructor))

#else /* __GNUC__ */

# define ni__printf(a, b) /* */
# define ni__noreturn /* */
# define ni__packed /* */
# define ni__unused /* */
# define ni__constructor /* */

#endif

#endif /* NI_WICKED_COMPILER_H */
36 changes: 18 additions & 18 deletions include/wicked/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@
* Copyright (C) 2010-2012 Olaf Kirch <okir@suse.de>
*/

#ifndef __WICKED_LOGGING_H__
#define __WICKED_LOGGING_H__
#ifndef NI_WICKED_LOGGING_H
#define NI_WICKED_LOGGING_H

#include <wicked/types.h>
#include <wicked/compiler.h>

#ifdef __GNUC__
# define __fmtattr __attribute__ ((format (printf, 1, 2)))
# define __noreturn __attribute__ ((noreturn))
#else
# define __fmtattr /* */
# define __noreturn /* */
#endif

extern void ni_info(const char *, ...) __fmtattr;
extern void ni_note(const char *, ...) __fmtattr;
extern void ni_warn(const char *, ...) __fmtattr;
extern void ni_error(const char *, ...) __fmtattr;
extern void ni_error_extra(const char *, ...) __fmtattr;
extern void ni_trace(const char *, ...) __fmtattr;
extern void ni_fatal(const char *, ...) __fmtattr __noreturn;

extern void ni_info(const char *, ...) ni__printf(1, 2);
extern void ni_note(const char *, ...) ni__printf(1, 2);
extern void ni_warn(const char *, ...) ni__printf(1, 2);
extern void ni_error(const char *, ...) ni__printf(1, 2);
extern void ni_error_extra(const char *, ...) ni__printf(1, 2);
extern void ni_trace(const char *, ...) ni__printf(1, 2);
extern void ni_fatal(const char *, ...) ni__printf(1, 2) ni__noreturn;
extern void ni_debug_verbose_config_xml(const xml_node_t *,
unsigned int, unsigned int,
const char *, ...) ni__printf(4, 5);

extern int ni_enable_debug(const char *);
extern int ni_debug_set_default(const char *);
Expand Down Expand Up @@ -123,6 +120,9 @@ extern unsigned int ni_log_level;
} \
} while (0)

#define ni_debug_config_xml(xml_node, level, fmt, args...) \
ni_debug_verbose_config_xml(xml_node, level, NI_TRACE_WICKED_XML, fmt, ##args)

#define ni_debug_none(fmt, args...) do { } while (0)

#define ni_debug_verbose(level, facility, fmt, args...) \
Expand All @@ -149,4 +149,4 @@ extern unsigned int ni_log_level;
__warned = 1; \
} while (0)

#endif /* __WICKED_LOGGING_H__ */
#endif /* NI_WICKED_LOGGING_H */
18 changes: 8 additions & 10 deletions include/wicked/xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* This basically parses tags, attributes and CDATA, and that's
* just about it.
*
* Copyright (C) 2009-2012 Olaf Kirch <okir@suse.de>
* Copyright (C) 2009-2012 Olaf Kirch <okir@suse.de>
* Copyright (C) 2009-2024 SUSE LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -15,15 +16,11 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/> or write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __WICKED_XML_H__
#define __WICKED_XML_H__
#ifndef NI_WICKED_XML_H
#define NI_WICKED_XML_H

#include <stdio.h>
#include <wicked/util.h>
Expand Down Expand Up @@ -109,6 +106,7 @@ extern int xml_node_uuid(const xml_node_t *, unsigned int, const ni_uuid_t *, n
extern int xml_node_content_uuid(const xml_node_t *, unsigned int, const ni_uuid_t *, ni_uuid_t *);
extern int xml_node_print_fn(const xml_node_t *, void (*)(const char *, void *), void *);
extern int xml_node_print_debug(const xml_node_t *, unsigned int facility);
extern void xml_node_hide_cdata(xml_node_t *, const char * const [], const char *);
extern xml_node_t * xml_node_scan(FILE *fp, const char *location);
extern void xml_node_set_cdata(xml_node_t *, const char *);
extern void xml_node_set_int(xml_node_t *, int);
Expand Down Expand Up @@ -185,4 +183,4 @@ xml_document_is_empty(const xml_document_t *doc)
return (!doc || xml_node_is_empty(doc->root));
}

#endif /* __WICKED_XML_H__ */
#endif /* NI_WICKED_XML_H */
7 changes: 3 additions & 4 deletions nanny/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ ni_factory_device_apply_policy(ni_fsm_t *fsm, ni_ifworker_t *w, ni_managed_polic
w->name, type_name);
return -1;
}
ni_debug_nanny("%s: using device config", w->name);
xml_node_print_debug(config, 0);

ni_debug_config_xml(config, NI_LOG_DEBUG, "%s: using device config", w->name);

ni_ifworker_set_config(w, config, ni_fsm_policy_origin(policy));
xml_node_free(config);
Expand Down Expand Up @@ -269,8 +269,7 @@ ni_managed_device_apply_policy(ni_managed_device_t *mdev, ni_managed_policy_t *m
ni_error("%s: error when applying policy to %s document", w->name, type_name);
return -1;
}
ni_debug_nanny("%s: using device config", w->name);
xml_node_print_debug(config, 0);
ni_debug_config_xml(config, NI_LOG_DEBUG, "%s: using device config", w->name);

ni_managed_device_set_policy(mdev, mpolicy, config);
xml_node_free(config);
Expand Down
8 changes: 8 additions & 0 deletions src/dbus-objects/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,14 @@ ni_objectmodel_addrconf_fallback_release(ni_netdev_t *dev, unsigned int family)
ni_debug_objectmodel("%s: no %s/%s lease", dev->name,
ni_addrconf_type_to_name(forwarder->addrconf),
ni_addrfamily_type_to_name(forwarder->addrfamily));

if (ni_addrconf_flag_bit_is_set(lease->flags, NI_ADDRCONF_FLAGS_FALLBACK)) {
/* bsc#1220996 - on fallback lease, it just wasn't triggered,
* so we need to change state and inform nanny that it's done. */
lease->state = NI_ADDRCONF_STATE_REQUESTING;
ni_objectmodel_addrconf_send_event(dev,
NI_EVENT_ADDRESS_DEFERRED, &lease->uuid);
}
rv = TRUE;
break;
default:
Expand Down
9 changes: 1 addition & 8 deletions src/duid.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ struct ni_duid_map {
struct flock flock;
};

/*
* compiler (gcc) specific ...
*/
#define NI_PACKED __attribute__((__packed__))

/*
* DUID typed packed data union
*/
Expand All @@ -84,9 +79,7 @@ typedef union ni_duid_data {
ni_duid_llt_t llt;
ni_duid_ll_t ll;
ni_duid_en_t en;
} NI_PACKED ni_duid_data_t;

#undef NI_PACKED
} ni__packed ni_duid_data_t;


/*
Expand Down

0 comments on commit 1c557e4

Please sign in to comment.