if (r == 0)
return 1; /* Polkit will call us back */
- r = link_reconfigure_full(l, LINK_RECONFIGURE_UNCONDITIONALLY | LINK_RECONFIGURE_CLEANLY, message, /* counter= */ NULL);
+ r = link_reconfigure_full(l, LINK_RECONFIGURE_UNCONDITIONALLY | LINK_RECONFIGURE_CLEANLY, message, /* varlink= */ NULL, /* counter= */ NULL);
if (r != 0)
return r; /* Will reply later when r > 0. */
#include "sd-ndisc.h"
#include "sd-netlink.h"
#include "sd-radv.h"
+#include "sd-varlink.h"
#include "alloc-util.h"
#include "arphrd-util.h"
Link *link;
LinkReconfigurationFlag flags;
sd_bus_message *message;
+ sd_varlink *varlink;
unsigned *counter;
} LinkReconfigurationData;
link_unref(data->link);
sd_bus_message_unref(data->message);
+ sd_varlink_unref(data->varlink);
return mfree(data);
}
int r;
assert(data);
+ assert(!data->message || !data->varlink); /* D-Bus and Varlink callers are mutually exclusive */
- if (data->message) {
- if (data->counter) {
- assert(*data->counter > 0);
- (*data->counter)--;
- }
+ if (data->counter) {
+ assert(*data->counter > 0);
+ (*data->counter)--;
+ }
- if (!data->counter || *data->counter <= 0) {
- /* Update the state files before replying the bus method. Otherwise,
- * systemd-networkd-wait-online following networkctl reload/reconfigure may read an
- * outdated state file and wrongly handle an interface is already in the configured
- * state. */
- (void) manager_clean_all(data->manager);
+ if (!data->counter || *data->counter == 0) {
+ /* Update the state files before replying. Otherwise, systemd-networkd-wait-online following
+ * networkctl reload/reconfigure may read an outdated state file and wrongly consider an
+ * interface already in the configured state. */
+ (void) manager_clean_all(data->manager);
+ if (data->message) {
r = sd_bus_reply_method_return(data->message, NULL);
if (r < 0)
log_warning_errno(r, "Failed to reply for DBus method, ignoring: %m");
}
+
+ if (data->varlink) {
+ r = sd_varlink_reply(data->varlink, NULL);
+ if (r < 0)
+ log_warning_errno(r, "Failed to reply to Varlink request, ignoring: %m");
+ }
}
link_reconfiguration_data_free(data);
return r;
}
-int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_message *message, unsigned *counter) {
+int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_message *message, sd_varlink *varlink, unsigned *counter) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(link_reconfiguration_data_freep) LinkReconfigurationData *data = NULL;
int r;
assert(link);
assert(link->manager);
assert(link->manager->rtnl);
+ assert(!message || !varlink); /* D-Bus and Varlink callers are mutually exclusive */
/* When the link is in the pending or initialized state, link_reconfigure_impl() will be called later
* by link_initialized() or link_initialized_and_synced(). To prevent the function from being called
.link = link_ref(link),
.flags = flags,
.message = sd_bus_message_ref(message), /* message may be NULL, but _ref() works fine. */
+ .varlink = sd_varlink_ref(varlink), /* varlink may be NULL, but _ref() works fine. */
.counter = counter,
};
int link_request_stacked_netdevs(Link *link, NetDevLocalAddressType type);
int link_reconfigure_impl(Link *link, LinkReconfigurationFlag flags);
-int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_message *message, unsigned *counter);
+int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_message *message, sd_varlink *varlink, unsigned *counter);
static inline int link_reconfigure(Link *link, LinkReconfigurationFlag flags) {
- return link_reconfigure_full(link, flags, NULL, NULL);
+ return link_reconfigure_full(link, flags, NULL, NULL, NULL);
}
int link_check_initialized(Link *link);
if (r == 0)
return 1; /* Polkit will call us back */
- r = manager_reload(manager, message);
+ r = manager_reload(manager, message, /* varlink= */ NULL);
if (r < 0)
return r;
static int signal_reload_callback(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
- (void) manager_reload(m, /* message= */ NULL);
+ (void) manager_reload(m, /* message= */ NULL, /* varlink= */ NULL);
return 0;
}
return 0;
}
-int manager_reload(Manager *m, sd_bus_message *message) {
+int manager_reload(Manager *m, sd_bus_message *message, sd_varlink *varlink) {
Link *link;
int r;
assert(m);
+ assert(!message || !varlink); /* D-Bus and Varlink callers are mutually exclusive */
log_debug("Reloading...");
(void) notify_reloading();
}
HASHMAP_FOREACH(link, m->links_by_index)
- (void) link_reconfigure_full(link, /* flags= */ 0, message,
- /* counter= */ message ? &m->reloading : NULL);
+ (void) link_reconfigure_full(
+ link,
+ /* flags= */ 0,
+ message,
+ varlink,
+ /* counter= */ (message || varlink) ? &m->reloading : NULL);
log_debug("Reloaded.");
r = 0;
int manager_set_hostname(Manager *m, const char *hostname);
int manager_set_timezone(Manager *m, const char *tz);
-int manager_reload(Manager *m, sd_bus_message *message);
+int manager_reload(Manager *m, sd_bus_message *message, sd_varlink *varlink);
static inline Hashmap** manager_get_sysctl_shadow(Manager *manager) {
#if ENABLE_SYSCTL_BPF