diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/kmod-setup.c | 8 | ||||
-rw-r--r-- | src/core/loopback-setup.c | 2 | ||||
-rw-r--r-- | src/core/selinux-access.c | 28 | ||||
-rw-r--r-- | src/core/umount.c | 2 | ||||
-rw-r--r-- | src/journal/journald-syslog.c | 3 | ||||
-rw-r--r-- | src/libsystemd-network/test-pppoe.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/local-addresses.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-message.c | 48 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-util.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/sd-rtnl.c | 109 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/test-rtnl.c | 14 | ||||
-rw-r--r-- | src/network/networkctl.c | 6 | ||||
-rw-r--r-- | src/network/networkd-link.c | 6 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 4 | ||||
-rw-r--r-- | src/network/networkd-netdev-bond.c | 5 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 130 | ||||
-rw-r--r-- | src/network/networkd-network.c | 34 | ||||
-rw-r--r-- | src/network/networkd-wait-online-manager.c | 2 | ||||
-rw-r--r-- | src/network/networkd.h | 3 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 12 | ||||
-rw-r--r-- | src/resolve/resolved-manager.c | 2 | ||||
-rw-r--r-- | src/systemd/sd-rtnl.h | 5 | ||||
-rw-r--r-- | src/test/test-rtnl-manual.c | 2 |
23 files changed, 246 insertions, 189 deletions
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index d956f9b190..f5584b6b14 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -117,10 +117,12 @@ int kmod_setup(void) { log_info("Inserted module '%s'", kmod_module_get_name(mod)); else if (r == KMOD_PROBE_APPLY_BLACKLIST) log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); - else - log_full_errno((kmod_table[i].warn_if_unavailable || (r < 0 && r != -ENOENT)) ? LOG_WARNING : LOG_DEBUG, - r, + else { + bool print_warning = kmod_table[i].warn_if_unavailable || (r < 0 && r != -ENOSYS); + + log_full_errno(print_warning ? LOG_WARNING : LOG_DEBUG, r, "Failed to insert module '%s': %m", kmod_module_get_name(mod)); + } kmod_module_unref(mod); } diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index 63b15c1200..938f3ab068 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -70,7 +70,7 @@ int loopback_setup(void) { _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; int r; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return r; diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index decd42f95a..e9a9a020de 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -82,11 +82,19 @@ static int audit_callback( static int callback_type_to_priority(int type) { switch(type) { - case SELINUX_ERROR: return LOG_ERR; - case SELINUX_WARNING: return LOG_WARNING; - case SELINUX_INFO: return LOG_INFO; + + case SELINUX_ERROR: + return LOG_ERR; + + case SELINUX_WARNING: + return LOG_WARNING; + + case SELINUX_INFO: + return LOG_INFO; + case SELINUX_AVC: - default: return LOG_NOTICE; + default: + return LOG_NOTICE; } } @@ -281,11 +289,13 @@ finish: #endif } -int mac_selinux_unit_access_check_strv(char **units, - sd_bus_message *message, - Manager *m, - const char *permission, - sd_bus_error *error) { +int mac_selinux_unit_access_check_strv( + char **units, + sd_bus_message *message, + Manager *m, + const char *permission, + sd_bus_error *error) { + #ifdef HAVE_SELINUX char **i; Unit *u; diff --git a/src/core/umount.c b/src/core/umount.c index bee267a5ad..d59b5d0ffb 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -385,7 +385,7 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e * alias read-only we hence should be * relatively safe regarding keeping the fs we * can otherwise not see dirty. */ - mount(NULL, m->path, NULL, MS_REMOUNT|MS_RDONLY, NULL); + (void) mount(NULL, m->path, NULL, MS_REMOUNT|MS_RDONLY, NULL); } /* Skip / and /usr since we cannot unmount that diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 90b7530946..ffba451955 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -234,7 +234,8 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid) if (t) *identifier = t; - e += strspn(p + e, WHITESPACE); + if (strchr(WHITESPACE, p[e])) + e++; *buf = p + e; return e; } diff --git a/src/libsystemd-network/test-pppoe.c b/src/libsystemd-network/test-pppoe.c index 9c8d6f7779..cc51197295 100644 --- a/src/libsystemd-network/test-pppoe.c +++ b/src/libsystemd-network/test-pppoe.c @@ -94,7 +94,7 @@ static int test_pppoe_server(sd_event *e) { assert_se(r >= 0); - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(sd_rtnl_attach_event(rtnl, e, 0) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0); diff --git a/src/libsystemd/sd-rtnl/local-addresses.c b/src/libsystemd/sd-rtnl/local-addresses.c index 31bfa06066..f05cbf1f47 100644 --- a/src/libsystemd/sd-rtnl/local-addresses.c +++ b/src/libsystemd/sd-rtnl/local-addresses.c @@ -66,7 +66,7 @@ int local_addresses(sd_rtnl *context, int ifindex, int af, struct local_address if (context) rtnl = sd_rtnl_ref(context); else { - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return r; } @@ -177,7 +177,7 @@ int local_gateways(sd_rtnl *context, int ifindex, int af, struct local_address * if (context) rtnl = sd_rtnl_ref(context); else { - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return r; } diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c index 9dcf7df559..79e67f6953 100644 --- a/src/libsystemd/sd-rtnl/rtnl-message.c +++ b/src/libsystemd/sd-rtnl/rtnl-message.c @@ -24,6 +24,7 @@ #include <unistd.h> #include "util.h" +#include "socket-util.h" #include "formats-util.h" #include "refcnt.h" #include "missing.h" @@ -1415,17 +1416,18 @@ int socket_write_message(sd_rtnl *nl, sd_rtnl_message *m) { } static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool peek) { - uint8_t cred_buffer[CMSG_SPACE(sizeof(struct ucred)) + - CMSG_SPACE(sizeof(struct nl_pktinfo))]; + union sockaddr_union sender; + uint8_t cmsg_buffer[CMSG_SPACE(sizeof(struct nl_pktinfo))]; struct msghdr msg = { .msg_iov = iov, .msg_iovlen = 1, - .msg_control = cred_buffer, - .msg_controllen = sizeof(cred_buffer), + .msg_name = &sender, + .msg_namelen = sizeof(sender), + .msg_control = cmsg_buffer, + .msg_controllen = sizeof(cmsg_buffer), }; struct cmsghdr *cmsg; uint32_t group = 0; - bool auth = false; int r; assert(fd >= 0); @@ -1442,29 +1444,10 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool return (errno == EAGAIN || errno == EINTR) ? 0 : -errno; } - CMSG_FOREACH(cmsg, &msg) { - if (cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SCM_CREDENTIALS && - cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) { - struct ucred *ucred = (void *)CMSG_DATA(cmsg); - - /* from the kernel */ - if (ucred->pid == 0) - auth = true; - else - log_debug("rtnl: ignoring message from PID "PID_FMT, ucred->pid); - } else if (cmsg->cmsg_level == SOL_NETLINK && - cmsg->cmsg_type == NETLINK_PKTINFO && - cmsg->cmsg_len == CMSG_LEN(sizeof(struct nl_pktinfo))) { - struct nl_pktinfo *pktinfo = (void *)CMSG_DATA(cmsg); - - /* multi-cast group */ - group = pktinfo->group; - } - } - - if (!auth) { + if (sender.nl.nl_pid != 0) { /* not from the kernel, ignore */ + log_debug("rtnl: ignoring message from portid %"PRIu32, sender.nl.nl_pid); + if (peek) { /* drop the message */ r = recvmsg(fd, &msg, 0); @@ -1475,6 +1458,17 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool return 0; } + CMSG_FOREACH(cmsg, &msg) { + if (cmsg->cmsg_level == SOL_NETLINK && + cmsg->cmsg_type == NETLINK_PKTINFO && + cmsg->cmsg_len == CMSG_LEN(sizeof(struct nl_pktinfo))) { + struct nl_pktinfo *pktinfo = (void *)CMSG_DATA(cmsg); + + /* multi-cast group */ + group = pktinfo->group; + } + } + if (_group) *_group = group; diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c index 9ddf074c24..c2b1a5c65d 100644 --- a/src/libsystemd/sd-rtnl/rtnl-util.c +++ b/src/libsystemd/sd-rtnl/rtnl-util.c @@ -34,7 +34,7 @@ int rtnl_set_link_name(sd_rtnl **rtnl, int ifindex, const char *name) { assert(name); if (!*rtnl) { - r = sd_rtnl_open(rtnl, 0); + r = sd_rtnl_open(rtnl); if (r < 0) return r; } @@ -66,7 +66,7 @@ int rtnl_set_link_properties(sd_rtnl **rtnl, int ifindex, const char *alias, return 0; if (!*rtnl) { - r = sd_rtnl_open(rtnl, 0); + r = sd_rtnl_open(rtnl); if (r < 0) return r; } diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c index 40dea1252f..5bafc282c0 100644 --- a/src/libsystemd/sd-rtnl/sd-rtnl.c +++ b/src/libsystemd/sd-rtnl/sd-rtnl.c @@ -106,25 +106,7 @@ static bool rtnl_pid_changed(sd_rtnl *rtnl) { return rtnl->original_pid != getpid(); } -static int rtnl_compute_groups_ap(uint32_t *_groups, unsigned n_groups, va_list ap) { - uint32_t groups = 0; - unsigned i; - - for (i = 0; i < n_groups; i++) { - unsigned group; - - group = va_arg(ap, unsigned); - assert_return(group < 32, -EINVAL); - - groups |= group ? (1 << (group - 1)) : 0; - } - - *_groups = groups; - - return 0; -} - -static int rtnl_open_fd_ap(sd_rtnl **ret, int fd, unsigned n_groups, va_list ap) { +int sd_rtnl_open_fd(sd_rtnl **ret, int fd) { _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; socklen_t addrlen; int r, one = 1; @@ -136,18 +118,10 @@ static int rtnl_open_fd_ap(sd_rtnl **ret, int fd, unsigned n_groups, va_list ap) if (r < 0) return r; - r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); - if (r < 0) - return -errno; - r = setsockopt(fd, SOL_NETLINK, NETLINK_PKTINFO, &one, sizeof(one)); if (r < 0) return -errno; - r = rtnl_compute_groups_ap(&rtnl->sockaddr.nl.nl_groups, n_groups, ap); - if (r < 0) - return r; - addrlen = sizeof(rtnl->sockaddr); r = bind(fd, &rtnl->sockaddr.sa, addrlen); @@ -167,33 +141,33 @@ static int rtnl_open_fd_ap(sd_rtnl **ret, int fd, unsigned n_groups, va_list ap) return 0; } -int sd_rtnl_open_fd(sd_rtnl **ret, int fd, unsigned n_groups, ...) { - va_list ap; +int sd_rtnl_open(sd_rtnl **ret) { + _cleanup_close_ int fd = -1; int r; - va_start(ap, n_groups); - r = rtnl_open_fd_ap(ret, fd, n_groups, ap); - va_end(ap); - - return r; -} - -int sd_rtnl_open(sd_rtnl **ret, unsigned n_groups, ...) { - va_list ap; - int fd, r; - fd = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_ROUTE); if (fd < 0) return -errno; - va_start(ap, n_groups); - r = rtnl_open_fd_ap(ret, fd, n_groups, ap); - va_end(ap); - - if (r < 0) { - safe_close(fd); + r = sd_rtnl_open_fd(ret, fd); + if (r < 0) return r; - } + + fd = -1; + + return 0; +} + +static int rtnl_join_broadcast_group(sd_rtnl *rtnl, unsigned group) { + int r; + + assert(rtnl); + assert(rtnl->fd >= 0); + assert(group > 0); + + r = setsockopt(rtnl->fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group, sizeof(group)); + if (r < 0) + return -errno; return 0; } @@ -1005,14 +979,12 @@ int sd_rtnl_add_match(sd_rtnl *rtnl, uint16_t type, sd_rtnl_message_handler_t callback, void *userdata) { - struct match_callback *c; + _cleanup_free_ struct match_callback *c = NULL; + int r; assert_return(rtnl, -EINVAL); assert_return(callback, -EINVAL); assert_return(!rtnl_pid_changed(rtnl), -ECHILD); - assert_return(rtnl_message_type_is_link(type) || - rtnl_message_type_is_addr(type) || - rtnl_message_type_is_route(type), -EOPNOTSUPP); c = new0(struct match_callback, 1); if (!c) @@ -1022,8 +994,36 @@ int sd_rtnl_add_match(sd_rtnl *rtnl, c->type = type; c->userdata = userdata; + switch (type) { + case RTM_NEWLINK: + case RTM_SETLINK: + case RTM_GETLINK: + case RTM_DELLINK: + r = rtnl_join_broadcast_group(rtnl, RTNLGRP_LINK); + if (r < 0) + return r; + + break; + case RTM_NEWADDR: + case RTM_GETADDR: + case RTM_DELADDR: + r = rtnl_join_broadcast_group(rtnl, RTNLGRP_IPV4_IFADDR); + if (r < 0) + return r; + + r = rtnl_join_broadcast_group(rtnl, RTNLGRP_IPV6_IFADDR); + if (r < 0) + return r; + + break; + default: + return -EOPNOTSUPP; + } + LIST_PREPEND(match_callbacks, rtnl->match_callbacks, c); + c = NULL; + return 0; } @@ -1037,6 +1037,13 @@ int sd_rtnl_remove_match(sd_rtnl *rtnl, assert_return(callback, -EINVAL); assert_return(!rtnl_pid_changed(rtnl), -ECHILD); + /* we should unsubscribe from the broadcast groups at this point, but it is not so + trivial for a few reasons: the refcounting is a bit of a mess and not obvious + how it will look like after we add genetlink support, and it is also not possible + to query what broadcast groups were subscribed to when we inherit the socket to get + the initial refcount. The latter could indeed be done for the first 32 broadcast + groups (which incidentally is all we currently support in .socket units anyway), + but we better not rely on only ever using 32 groups. */ LIST_FOREACH(match_callbacks, c, rtnl->match_callbacks) if (c->callback == callback && c->type == type && c->userdata == userdata) { LIST_REMOVE(match_callbacks, rtnl->match_callbacks, c); diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c index 47cce64816..94b1cb7c72 100644 --- a/src/libsystemd/sd-rtnl/test-rtnl.c +++ b/src/libsystemd/sd-rtnl/test-rtnl.c @@ -184,8 +184,8 @@ static void test_route(void) { static void test_multiple(void) { sd_rtnl *rtnl1, *rtnl2; - assert_se(sd_rtnl_open(&rtnl1, 0) >= 0); - assert_se(sd_rtnl_open(&rtnl2, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl1) >= 0); + assert_se(sd_rtnl_open(&rtnl2) >= 0); rtnl1 = sd_rtnl_unref(rtnl1); rtnl2 = sd_rtnl_unref(rtnl2); @@ -216,7 +216,7 @@ static void test_event_loop(int ifindex) { ifname = strdup("lo2"); assert_se(ifname); - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); assert_se(sd_rtnl_call_async(rtnl, m, &link_handler, ifname, 0, NULL) >= 0); @@ -256,7 +256,7 @@ static void test_async(int ifindex) { ifname = strdup("lo"); assert_se(ifname); - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); @@ -273,7 +273,7 @@ static void test_pipe(int ifindex) { _cleanup_rtnl_message_unref_ sd_rtnl_message *m1 = NULL, *m2 = NULL; int counter = 0; - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0); @@ -330,7 +330,7 @@ static void test_container(void) { static void test_match(void) { _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0); assert_se(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0); @@ -395,7 +395,7 @@ int main(void) { test_container(); - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(rtnl); if_loopback = (int) if_nametoindex("lo"); diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 68925debe6..8e20f70aae 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -199,7 +199,7 @@ static int list_links(int argc, char *argv[], void *userdata) { pager_open_if_enabled(); - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -670,7 +670,7 @@ static int link_status(int argc, char *argv[], void *userdata) { char **name; int r; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -910,7 +910,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { pager_open_if_enabled(); - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 7841f69dab..b1947886b7 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1477,6 +1477,9 @@ static int link_set_ipv4_forward(Link *link) { const char *p = NULL; int r; + if (link->network->ip_forward == _ADDRESS_FAMILY_BOOLEAN_INVALID) + return 0; + p = strjoina("/proc/sys/net/ipv4/conf/", link->ifname, "/forwarding"); r = write_string_file_no_create(p, one_zero(link_ipv4_forward_enabled(link))); if (r < 0) @@ -1493,6 +1496,9 @@ static int link_set_ipv6_forward(Link *link) { if (!socket_ipv6_is_supported()) return 0; + if (link->network->ip_forward == _ADDRESS_FAMILY_BOOLEAN_INVALID) + return 0; + p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/forwarding"); r = write_string_file_no_create(p, one_zero(link_ipv6_forward_enabled(link))); if (r < 0) diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index db737ad484..9936a8e7cd 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -385,9 +385,9 @@ static int manager_connect_rtnl(Manager *m) { fd = systemd_netlink_fd(); if (fd < 0) - r = sd_rtnl_open(&m->rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR); + r = sd_rtnl_open(&m->rtnl); else - r = sd_rtnl_open_fd(&m->rtnl, fd, 0); + r = sd_rtnl_open_fd(&m->rtnl, fd); if (r < 0) return r; diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c index 9919955f51..d7f9bb4f8e 100644 --- a/src/network/networkd-netdev-bond.c +++ b/src/network/networkd-netdev-bond.c @@ -242,7 +242,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m } if (b->ad_select != _NETDEV_BOND_AD_SELECT_INVALID && - b->mode == BOND_MODE_8023AD) { + b->mode == NETDEV_BOND_MODE_802_3AD) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_SELECT, b->ad_select); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_SELECT attribute: %m"); @@ -279,7 +279,8 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_RESEND_IGMP attribute: %m"); } - if (b->packets_per_slave <= PACKETS_PER_SLAVE_MAX) { + if (b->packets_per_slave <= PACKETS_PER_SLAVE_MAX && + b->mode == NETDEV_BOND_MODE_BALANCE_RR) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_PACKETS_PER_SLAVE, b->packets_per_slave); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %m"); diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 8abf5bcf2e..b05bc949f2 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -15,69 +15,69 @@ struct ConfigPerfItem; %struct-type %includes %% -Match.MACAddress, config_parse_hwaddr, 0, offsetof(Network, match_mac) -Match.Path, config_parse_strv, 0, offsetof(Network, match_path) -Match.Driver, config_parse_strv, 0, offsetof(Network, match_driver) -Match.Type, config_parse_strv, 0, offsetof(Network, match_type) -Match.Name, config_parse_ifnames, 0, offsetof(Network, match_name) -Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(Network, match_host) -Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(Network, match_virt) -Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(Network, match_kernel) -Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(Network, match_arch) -Link.MACAddress, config_parse_hwaddr, 0, offsetof(Network, mac) -Link.MTUBytes, config_parse_iec_size, 0, offsetof(Network, mtu) -Network.Description, config_parse_string, 0, offsetof(Network, description) -Network.Bridge, config_parse_netdev, 0, offsetof(Network, bridge) -Network.Bond, config_parse_netdev, 0, offsetof(Network, bond) -Network.VLAN, config_parse_netdev, 0, 0 -Network.MACVLAN, config_parse_netdev, 0, 0 -Network.IPVLAN, config_parse_netdev, 0, 0 -Network.VXLAN, config_parse_netdev, 0, 0 -Network.Tunnel, config_parse_tunnel, 0, 0 -Network.DHCP, config_parse_dhcp, 0, offsetof(Network, dhcp) -Network.DHCPServer, config_parse_bool, 0, offsetof(Network, dhcp_server) -Network.LinkLocalAddressing, config_parse_address_family_boolean,0, offsetof(Network, link_local) -Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route) -Network.IPv6Token, config_parse_ipv6token, 0, offsetof(Network, ipv6_token) -Network.LLDP, config_parse_bool, 0, offsetof(Network, lldp) -Network.Address, config_parse_address, 0, 0 -Network.Gateway, config_parse_gateway, 0, 0 -Network.Domains, config_parse_domains, 0, offsetof(Network, domains) -Network.DNS, config_parse_strv, 0, offsetof(Network, dns) -Network.LLMNR, config_parse_llmnr, 0, offsetof(Network, llmnr) -Network.NTP, config_parse_strv, 0, offsetof(Network, ntp) -Network.IPForward, config_parse_address_family_boolean,0, offsetof(Network, ip_forward) -Network.IPMasquerade, config_parse_bool, 0, offsetof(Network, ip_masquerade) -Network.BindCarrier, config_parse_strv, 0, offsetof(Network, bind_carrier) -Address.Address, config_parse_address, 0, 0 -Address.Peer, config_parse_address, 0, 0 -Address.Broadcast, config_parse_broadcast, 0, 0 -Address.Label, config_parse_label, 0, 0 -Route.Gateway, config_parse_gateway, 0, 0 -Route.Destination, config_parse_destination, 0, 0 -Route.Source, config_parse_destination, 0, 0 -Route.Metric, config_parse_route_priority, 0, 0 -Route.Scope, config_parse_route_scope, 0, 0 -DHCP.ClientIdentifier, config_parse_dhcp_client_identifier,0, offsetof(Network, dhcp_client_identifier) -DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) -DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_ntp) -DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) -DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) -DHCP.UseDomains, config_parse_bool, 0, offsetof(Network, dhcp_domains) -DHCP.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_routes) -DHCP.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_sendhost) -DHCP.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast) -DHCP.CriticalConnection, config_parse_bool, 0, offsetof(Network, dhcp_critical) -DHCP.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier) -DHCP.RouteMetric, config_parse_unsigned, 0, offsetof(Network, dhcp_route_metric) -Bridge.Cost, config_parse_unsigned, 0, offsetof(Network, cost) -BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0 -BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0 +Match.MACAddress, config_parse_hwaddr, 0, offsetof(Network, match_mac) +Match.Path, config_parse_strv, 0, offsetof(Network, match_path) +Match.Driver, config_parse_strv, 0, offsetof(Network, match_driver) +Match.Type, config_parse_strv, 0, offsetof(Network, match_type) +Match.Name, config_parse_ifnames, 0, offsetof(Network, match_name) +Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(Network, match_host) +Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(Network, match_virt) +Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(Network, match_kernel) +Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(Network, match_arch) +Link.MACAddress, config_parse_hwaddr, 0, offsetof(Network, mac) +Link.MTUBytes, config_parse_iec_size, 0, offsetof(Network, mtu) +Network.Description, config_parse_string, 0, offsetof(Network, description) +Network.Bridge, config_parse_netdev, 0, offsetof(Network, bridge) +Network.Bond, config_parse_netdev, 0, offsetof(Network, bond) +Network.VLAN, config_parse_netdev, 0, 0 +Network.MACVLAN, config_parse_netdev, 0, 0 +Network.IPVLAN, config_parse_netdev, 0, 0 +Network.VXLAN, config_parse_netdev, 0, 0 +Network.Tunnel, config_parse_tunnel, 0, 0 +Network.DHCP, config_parse_dhcp, 0, offsetof(Network, dhcp) +Network.DHCPServer, config_parse_bool, 0, offsetof(Network, dhcp_server) +Network.LinkLocalAddressing, config_parse_address_family_boolean, 0, offsetof(Network, link_local) +Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route) +Network.IPv6Token, config_parse_ipv6token, 0, offsetof(Network, ipv6_token) +Network.LLDP, config_parse_bool, 0, offsetof(Network, lldp) +Network.Address, config_parse_address, 0, 0 +Network.Gateway, config_parse_gateway, 0, 0 +Network.Domains, config_parse_domains, 0, offsetof(Network, domains) +Network.DNS, config_parse_strv, 0, offsetof(Network, dns) +Network.LLMNR, config_parse_llmnr, 0, offsetof(Network, llmnr) +Network.NTP, config_parse_strv, 0, offsetof(Network, ntp) +Network.IPForward, config_parse_address_family_boolean_with_kernel,0, offsetof(Network, ip_forward) +Network.IPMasquerade, config_parse_bool, 0, offsetof(Network, ip_masquerade) +Network.BindCarrier, config_parse_strv, 0, offsetof(Network, bind_carrier) +Address.Address, config_parse_address, 0, 0 +Address.Peer, config_parse_address, 0, 0 +Address.Broadcast, config_parse_broadcast, 0, 0 +Address.Label, config_parse_label, 0, 0 +Route.Gateway, config_parse_gateway, 0, 0 +Route.Destination, config_parse_destination, 0, 0 +Route.Source, config_parse_destination, 0, 0 +Route.Metric, config_parse_route_priority, 0, 0 +Route.Scope, config_parse_route_scope, 0, 0 +DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier) +DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) +DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_ntp) +DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) +DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) +DHCP.UseDomains, config_parse_bool, 0, offsetof(Network, dhcp_domains) +DHCP.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_routes) +DHCP.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_sendhost) +DHCP.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast) +DHCP.CriticalConnection, config_parse_bool, 0, offsetof(Network, dhcp_critical) +DHCP.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier) +DHCP.RouteMetric, config_parse_unsigned, 0, offsetof(Network, dhcp_route_metric) +Bridge.Cost, config_parse_unsigned, 0, offsetof(Network, cost) +BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0 +BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0 /* backwards compatibility: do not add new entries to this section */ -Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local) -DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) -DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) -DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) -DHCP.UseDomainName, config_parse_bool, 0, offsetof(Network, dhcp_domains) -DHCPv4.UseDomainName, config_parse_bool, 0, offsetof(Network, dhcp_domains) -DHCPv4.CriticalConnection, config_parse_bool, 0, offsetof(Network, dhcp_critical) +Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local) +DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns) +DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu) +DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname) +DHCP.UseDomainName, config_parse_bool, 0, offsetof(Network, dhcp_domains) +DHCPv4.UseDomainName, config_parse_bool, 0, offsetof(Network, dhcp_domains) +DHCPv4.CriticalConnection, config_parse_bool, 0, offsetof(Network, dhcp_critical) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 6f32e5f4a4..ec95c8661e 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -717,3 +717,37 @@ int config_parse_ipv6token( return 0; } + +int config_parse_address_family_boolean_with_kernel( + const char* unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + AddressFamilyBoolean *fwd = data, s; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + s = address_family_boolean_from_string(rvalue); + if (s < 0) { + if (streq(rvalue, "kernel")) + s = _ADDRESS_FAMILY_BOOLEAN_INVALID; + else { + log_syntax(unit, LOG_ERR, filename, line, s, "Failed to parse IPForwarding option, ignoring: %s", rvalue); + return 0; + } + } + + *fwd = s; + + return 0; +} diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c index 1c997a50a4..39f3845633 100644 --- a/src/network/networkd-wait-online-manager.c +++ b/src/network/networkd-wait-online-manager.c @@ -177,7 +177,7 @@ static int manager_rtnl_listen(Manager *m) { assert(m); /* First, subscribe to interfaces coming and going */ - r = sd_rtnl_open(&m->rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR); + r = sd_rtnl_open(&m->rtnl); if (r < 0) return r; diff --git a/src/network/networkd.h b/src/network/networkd.h index 4b13d4aed1..2c191a780c 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -448,6 +448,9 @@ AddressFamilyBoolean address_family_boolean_from_string(const char *s) _const_; int config_parse_address_family_boolean(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); +/* IPForwarding parser */ +int config_parse_address_family_boolean_with_kernel(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + /* Operational State */ const char* link_operstate_to_string(LinkOperationalState s) _const_; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 251af4a67c..6a21ed5471 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2062,7 +2062,7 @@ static int watch_rtnl(sd_event *event, int recv_fd, union in_addr_union *exposed assert(cmsg->cmsg_len == CMSG_LEN(sizeof(int))); memcpy(&fd, CMSG_DATA(cmsg), sizeof(int)); - r = sd_rtnl_open_fd(&rtnl, fd, 1, RTNLGRP_IPV4_IFADDR); + r = sd_rtnl_open_fd(&rtnl, fd); if (r < 0) { safe_close(fd); return log_error_errno(r, "Failed to create rtnl object: %m"); @@ -2574,7 +2574,7 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) { if (r < 0) return log_error_errno(r, "Failed to generate predictable MAC address for host side: %m"); - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -2659,7 +2659,7 @@ static int setup_bridge(const char veth_name[], int *ifi) { *ifi = bridge; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -2720,7 +2720,7 @@ static int move_network_interfaces(pid_t pid) { if (strv_isempty(arg_network_interfaces)) return 0; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -2767,7 +2767,7 @@ static int setup_macvlan(pid_t pid) { if (strv_isempty(arg_network_macvlan)) return 0; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); @@ -2857,7 +2857,7 @@ static int setup_ipvlan(pid_t pid) { if (strv_isempty(arg_network_ipvlan)) return 0; - r = sd_rtnl_open(&rtnl, 0); + r = sd_rtnl_open(&rtnl); if (r < 0) return log_error_errno(r, "Failed to connect to netlink: %m"); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index f8d4db7aad..aa78885ac3 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -195,7 +195,7 @@ static int manager_rtnl_listen(Manager *m) { assert(m); /* First, subscribe to interfaces coming and going */ - r = sd_rtnl_open(&m->rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR); + r = sd_rtnl_open(&m->rtnl); if (r < 0) return r; diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h index be318e58a8..b05690cb1c 100644 --- a/src/systemd/sd-rtnl.h +++ b/src/systemd/sd-rtnl.h @@ -42,8 +42,8 @@ typedef int (*sd_rtnl_message_handler_t)(sd_rtnl *rtnl, sd_rtnl_message *m, void /* bus */ int sd_rtnl_new_from_netlink(sd_rtnl **nl, int fd); -int sd_rtnl_open(sd_rtnl **nl, unsigned n_groups, ...); -int sd_rtnl_open_fd(sd_rtnl **nl, int fd, unsigned n_groups, ...); +int sd_rtnl_open(sd_rtnl **nl); +int sd_rtnl_open_fd(sd_rtnl **nl, int fd); int sd_rtnl_inc_rcvbuf(const sd_rtnl *const rtnl, const int size); sd_rtnl *sd_rtnl_ref(sd_rtnl *nl); @@ -57,7 +57,6 @@ int sd_rtnl_call_async_cancel(sd_rtnl *nl, uint32_t serial); int sd_rtnl_call(sd_rtnl *nl, sd_rtnl_message *message, uint64_t timeout, sd_rtnl_message **reply); - int sd_rtnl_get_events(sd_rtnl *nl); int sd_rtnl_get_timeout(sd_rtnl *nl, uint64_t *timeout); int sd_rtnl_process(sd_rtnl *nl, sd_rtnl_message **ret); diff --git a/src/test/test-rtnl-manual.c b/src/test/test-rtnl-manual.c index c406454f77..9fc860d6a5 100644 --- a/src/test/test-rtnl-manual.c +++ b/src/test/test-rtnl-manual.c @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) { sd_rtnl *rtnl; int r; - assert_se(sd_rtnl_open(&rtnl, 0) >= 0); + assert_se(sd_rtnl_open(&rtnl) >= 0); assert_se(rtnl); r = test_tunnel_configure(rtnl); |