diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkctl.c | 2 | ||||
-rw-r--r-- | src/network/networkd-dhcp4.c | 2 | ||||
-rw-r--r-- | src/network/networkd-ipv4ll.c | 4 | ||||
-rw-r--r-- | src/network/networkd-link.c | 38 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 4 | ||||
-rw-r--r-- | src/network/networkd-netdev-bond.c | 173 | ||||
-rw-r--r-- | src/network/networkd-netdev-ipvlan.c | 10 | ||||
-rw-r--r-- | src/network/networkd-netdev-macvlan.c | 10 | ||||
-rw-r--r-- | src/network/networkd-netdev-veth.c | 24 | ||||
-rw-r--r-- | src/network/networkd-netdev-vxlan.c | 112 | ||||
-rw-r--r-- | src/network/networkd-network.c | 16 | ||||
-rw-r--r-- | src/network/networkd.h | 1 |
12 files changed, 114 insertions, 282 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 3454394977..68925debe6 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -814,7 +814,7 @@ static char *lldp_system_caps(uint16_t cap) { } if (cap & LLDP_SYSTEM_CAPABILITIES_ROUTER) { - s = strjoin(t, lldp_system_capability_to_string(LLDP_SYSTEM_CAPABILITIES_ROUTER), " ", NULL); + s = strjoin(t, lldp_system_capability_to_string(LLDP_SYSTEM_CAPABILITIES_ROUTER), " ", NULL); if (!s) return NULL; diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 20aee53d6e..71cc722bcc 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -561,7 +561,7 @@ int dhcp4_configure(Link *link) { assert(link); assert(link->network); - assert(IN_SET(link->network->dhcp, ADDRESS_FAMILY_YES, ADDRESS_FAMILY_IPV4)); + assert(link->network->dhcp & ADDRESS_FAMILY_IPV4); r = sd_dhcp_client_new(&link->dhcp_client); if (r < 0) diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c index 8050801e19..14b8770429 100644 --- a/src/network/networkd-ipv4ll.c +++ b/src/network/networkd-ipv4ll.c @@ -34,7 +34,7 @@ static int ipv4ll_address_lost(Link *link) { assert(link); link->ipv4ll_route = false; - link->ipv4ll_address = false; + link->ipv4ll_address = false; r = sd_ipv4ll_get_address(link->ipv4ll, &addr); if (r < 0) @@ -209,7 +209,7 @@ int ipv4ll_configure(Link *link) { assert(link); assert(link->network); - assert(IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES)); + assert(link->network->link_local & ADDRESS_FAMILY_IPV4); r = sd_ipv4ll_new(&link->ipv4ll); if (r < 0) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index b30fd7ae89..7841f69dab 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -40,7 +40,7 @@ bool link_dhcp6_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->dhcp, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES); + return link->network->dhcp & ADDRESS_FAMILY_IPV6; } bool link_dhcp4_enabled(Link *link) { @@ -50,7 +50,7 @@ bool link_dhcp4_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->dhcp, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES); + return link->network->dhcp & ADDRESS_FAMILY_IPV4; } bool link_dhcp4_server_enabled(Link *link) { @@ -70,7 +70,7 @@ bool link_ipv4ll_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES); + return link->network->link_local & ADDRESS_FAMILY_IPV4; } bool link_ipv6ll_enabled(Link *link) { @@ -80,7 +80,7 @@ bool link_ipv6ll_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES); + return link->network->link_local & ADDRESS_FAMILY_IPV6; } bool link_lldp_enabled(Link *link) { @@ -103,7 +103,7 @@ static bool link_ipv4_forward_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->ip_forward, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES); + return link->network->ip_forward & ADDRESS_FAMILY_IPV4; } static bool link_ipv6_forward_enabled(Link *link) { @@ -113,7 +113,7 @@ static bool link_ipv6_forward_enabled(Link *link) { if (!link->network) return false; - return IN_SET(link->network->ip_forward, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES); + return link->network->ip_forward & ADDRESS_FAMILY_IPV6; } #define FLAG_STRING(string, flag, old, new) \ @@ -749,7 +749,6 @@ static int set_hostname_handler(sd_bus_message *m, void *userdata, sd_bus_error } int link_set_hostname(Link *link, const char *hostname) { - _cleanup_bus_message_unref_ sd_bus_message *m = NULL; int r = 0; assert(link); @@ -764,22 +763,19 @@ int link_set_hostname(Link *link, const char *hostname) { return 0; } - r = sd_bus_message_new_method_call( + r = sd_bus_call_method_async( link->manager->bus, - &m, + NULL, "org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1", - "SetHostname"); - if (r < 0) - return r; - - r = sd_bus_message_append(m, "sb", hostname, false); - if (r < 0) - return r; + "SetHostname", + set_hostname_handler, + link, + "sb", + hostname, + false); - r = sd_bus_call_async(link->manager->bus, NULL, m, set_hostname_handler, - link, 0); if (r < 0) return log_link_error_errno(link, r, "Could not set transient hostname: %m"); @@ -1481,9 +1477,6 @@ static int link_set_ipv4_forward(Link *link) { const char *p = NULL; int r; - if (link->network->ip_forward == ADDRESS_FAMILY_KERNEL) - 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) @@ -1500,9 +1493,6 @@ static int link_set_ipv6_forward(Link *link) { if (!socket_ipv6_is_supported()) return 0; - if (link->network->ip_forward == ADDRESS_FAMILY_KERNEL) - 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 2cc53df4b1..db737ad484 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -853,8 +853,6 @@ const char *address_family_boolean_to_string(AddressFamilyBoolean b) { return "ipv4"; if (b == ADDRESS_FAMILY_IPV6) return "ipv6"; - if (b == ADDRESS_FAMILY_KERNEL) - return "kernel"; return NULL; } @@ -874,8 +872,6 @@ AddressFamilyBoolean address_family_boolean_from_string(const char *s) { return ADDRESS_FAMILY_IPV4; if (streq(s, "ipv6")) return ADDRESS_FAMILY_IPV6; - if (streq(s, "kernel")) - return ADDRESS_FAMILY_KERNEL; return _ADDRESS_FAMILY_BOOLEAN_INVALID; } diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c index 70df08a5e1..9919955f51 100644 --- a/src/network/networkd-netdev-bond.c +++ b/src/network/networkd-netdev-bond.c @@ -191,215 +191,132 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m if (b->mode != _NETDEV_BOND_MODE_INVALID) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_MODE, bond_mode_to_kernel(b->mode)); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_MODE attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MODE attribute: %m"); } if (b->xmit_hash_policy != _NETDEV_BOND_XMIT_HASH_POLICY_INVALID) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY, bond_xmit_hash_policy_to_kernel(b->xmit_hash_policy)); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %m"); } if (b->lacp_rate != _NETDEV_BOND_LACP_RATE_INVALID && b->mode == NETDEV_BOND_MODE_802_3AD) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_LACP_RATE, b->lacp_rate ); if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_AD_LACP_RATE attribute: %s", - strerror(-r)); - return r; + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_LACP_RATE attribute: %m"); } } if (b->miimon != 0) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_MIIMON, b->miimon / USEC_PER_MSEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_BOND_MIIMON attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_BOND_MIIMON attribute: %m"); } if (b->downdelay != 0) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_DOWNDELAY, b->downdelay / USEC_PER_MSEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_DOWNDELAY attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_DOWNDELAY attribute: %m"); } if (b->updelay != 0) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_UPDELAY, b->updelay / USEC_PER_MSEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_UPDELAY attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_UPDELAY attribute: %m"); } if (b->arp_interval != 0) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_INTERVAL, b->arp_interval / USEC_PER_MSEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ARP_INTERVAL attribute: %s", - strerror(-r)); - return r; - } - } - - if ((b->lp_interval >= LEARNING_PACKETS_INTERVAL_MIN_SEC) && - (b->lp_interval <= LEARNING_PACKETS_INTERVAL_MAX_SEC)) { - r = sd_rtnl_message_append_u32(m, IFLA_BOND_LP_INTERVAL, b->lp_interval / USEC_PER_SEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_LP_INTERVAL attribute: %s", - strerror(-r)); - return r; + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_INTERVAL attribute: %m"); + + if ((b->lp_interval >= LEARNING_PACKETS_INTERVAL_MIN_SEC) && + (b->lp_interval <= LEARNING_PACKETS_INTERVAL_MAX_SEC)) { + r = sd_rtnl_message_append_u32(m, IFLA_BOND_LP_INTERVAL, b->lp_interval / USEC_PER_SEC); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_LP_INTERVAL attribute: %m"); } } if (b->ad_select != _NETDEV_BOND_AD_SELECT_INVALID && b->mode == BOND_MODE_8023AD) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_SELECT, b->ad_select); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_AD_SELECT attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_SELECT attribute: %m"); } if (b->fail_over_mac != _NETDEV_BOND_FAIL_OVER_MAC_INVALID && b->mode == NETDEV_BOND_MODE_ACTIVE_BACKUP) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_FAIL_OVER_MAC, b->fail_over_mac); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_FAIL_OVER_MAC attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_FAIL_OVER_MAC attribute: %m"); } if (b->arp_validate != _NETDEV_BOND_ARP_VALIDATE_INVALID) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_VALIDATE, b->arp_validate); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ARP_VALIDATE attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_VALIDATE attribute: %m"); } if (b->arp_all_targets != _NETDEV_BOND_ARP_ALL_TARGETS_INVALID) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_ALL_TARGETS, b->arp_all_targets); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ARP_VALIDATE attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_VALIDATE attribute: %m"); } if (b->primary_reselect != _NETDEV_BOND_PRIMARY_RESELECT_INVALID) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_ALL_TARGETS, b->primary_reselect); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m"); } if (b->resend_igmp <= RESEND_IGMP_MAX) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_RESEND_IGMP, b->resend_igmp); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_RESEND_IGMP attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + 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) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_PACKETS_PER_SLAVE, b->packets_per_slave); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %m"); } if (b->num_grat_arp <= GRATUITOUS_ARP_MAX) { r = sd_rtnl_message_append_u8(m, IFLA_BOND_NUM_PEER_NOTIF, b->num_grat_arp); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_NUM_PEER_NOTIF attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_NUM_PEER_NOTIF attribute: %m"); } if (b->min_links != 0) { r = sd_rtnl_message_append_u32(m, IFLA_BOND_MIN_LINKS, b->min_links); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_MIN_LINKS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MIN_LINKS attribute: %m"); } r = sd_rtnl_message_append_u8(m, IFLA_BOND_ALL_SLAVES_ACTIVE, b->all_slaves_active); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %m"); if (b->arp_interval > 0) { if (b->n_arp_ip_targets > 0) { r = sd_rtnl_message_open_container(m, IFLA_BOND_ARP_IP_TARGET); - if (r < 0) { - log_netdev_error(netdev, - "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %m"); LIST_FOREACH(arp_ip_target, target, b->arp_ip_targets) { r = sd_rtnl_message_append_u32(m, i++, target->ip.in.s_addr); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m"); } r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_netdev_error(netdev, - "Could not close contaniner IFLA_BOND_ARP_IP_TARGET : %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not close contaniner IFLA_BOND_ARP_IP_TARGET : %m"); } } diff --git a/src/network/networkd-netdev-ipvlan.c b/src/network/networkd-netdev-ipvlan.c index 5189000c1f..f1c8e0ccdb 100644 --- a/src/network/networkd-netdev-ipvlan.c +++ b/src/network/networkd-netdev-ipvlan.c @@ -42,13 +42,9 @@ static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl assert(netdev->ifname); if (m->mode != _NETDEV_IPVLAN_MODE_INVALID) { - r = sd_rtnl_message_append_u16(req, IFLA_IPVLAN_MODE, m->mode); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_IPVLAN_MODE attribute: %s", - strerror(-r)); - return r; - } + r = sd_rtnl_message_append_u16(req, IFLA_IPVLAN_MODE, m->mode); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPVLAN_MODE attribute: %m"); } return 0; diff --git a/src/network/networkd-netdev-macvlan.c b/src/network/networkd-netdev-macvlan.c index 5f41f1c865..a8bf6e6bb7 100644 --- a/src/network/networkd-netdev-macvlan.c +++ b/src/network/networkd-netdev-macvlan.c @@ -44,13 +44,9 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtn assert(netdev->ifname); if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) { - r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_MACVLAN_MODE attribute: %s", - strerror(-r)); - return r; - } + r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_MODE attribute: %m"); } return 0; diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c index 9e9e1225e7..7bb02d1ae1 100644 --- a/src/network/networkd-netdev-veth.c +++ b/src/network/networkd-netdev-veth.c @@ -35,12 +35,8 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m assert(m); r = sd_rtnl_message_open_container(m, VETH_INFO_PEER); - if (r < 0) { - log_netdev_error(netdev, - "Could not append VETH_INFO_PEER attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append VETH_INFO_PEER attribute: %m"); if (v->ifname_peer) { r = sd_rtnl_message_append_string(m, IFLA_IFNAME, v->ifname_peer); @@ -50,21 +46,13 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m if (v->mac_peer) { r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, v->mac_peer); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_ADDRESS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_ADDRESS attribute: %m"); } r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_INFO_DATA attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m"); return r; } diff --git a/src/network/networkd-netdev-vxlan.c b/src/network/networkd-netdev-vxlan.c index e2c2b108b9..01a1e5089c 100644 --- a/src/network/networkd-netdev-vxlan.c +++ b/src/network/networkd-netdev-vxlan.c @@ -39,123 +39,67 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_ if (v->id <= VXLAN_VID_MAX) { r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_ID, v->id); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_ID attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_ID attribute: %m"); } r = sd_rtnl_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_GROUP attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m"); r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_LINK attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LINK attribute: %m"); if(v->ttl) { r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_TTL attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_TTL attribute: %m"); } if(v->tos) { r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TOS, v->tos); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_TOS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_TOS attribute: %m"); } r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_LEARNING, v->learning); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_LEARNING attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LEARNING attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_RSC, v->route_short_circuit); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_RSC attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_RSC attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_PROXY, v->arp_proxy); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_PROXY attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_PROXY attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L2MISS, v->l2miss); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_L2MISS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_L2MISS attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L3MISS, v->l3miss); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_L3MISS attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_L3MISS attribute: %m"); if(v->fdb_ageing) { r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_AGEING, v->fdb_ageing / USEC_PER_SEC); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_AGEING attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_AGEING attribute: %m"); } r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_UDP_CSUM, v->udpcsum); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_UDP_CSUM attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_UDP_CSUM attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, v->udp6zerocsumtx); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_UDP_ZERO_CSUM6_TX attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_UDP_ZERO_CSUM6_TX attribute: %m"); r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, v->udp6zerocsumrx); - if (r < 0) { - log_netdev_error(netdev, - "Could not append IFLA_VXLAN_UDP_ZERO_CSUM6_RX attribute: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_UDP_ZERO_CSUM6_RX attribute: %m"); return r; } diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 5947084106..6f32e5f4a4 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -30,6 +30,7 @@ #include "networkd-netdev.h" #include "networkd-link.h" #include "network-internal.h" +#include "dns-domain.h" static int network_load_one(Manager *manager, const char *filename) { _cleanup_network_free_ Network *network = NULL; @@ -466,11 +467,16 @@ int config_parse_domains(const char *unit, STRV_FOREACH(domain, *domains) { if (is_localhost(*domain)) log_syntax(unit, LOG_ERR, filename, line, EINVAL, "'localhost' domain names may not be configured, ignoring assignment: %s", *domain); - else if (!hostname_is_valid(*domain)) { - if (!streq(*domain, "*")) - log_syntax(unit, LOG_ERR, filename, line, EINVAL, "domain name is not valid, ignoring assignment: %s", *domain); - } else - continue; + else { + r = dns_name_is_valid(*domain); + if (r <= 0 && !streq(*domain, "*")) { + if (r < 0) + log_error_errno(r, "Failed to validate domain name: %s: %m", *domain); + if (r == 0) + log_warning("Domain name is not valid, ignoring assignment: %s", *domain); + } else + continue; + } strv_remove(*domains, *domain); diff --git a/src/network/networkd.h b/src/network/networkd.h index 49afeffe81..4b13d4aed1 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -60,7 +60,6 @@ typedef enum AddressFamilyBoolean { ADDRESS_FAMILY_IPV4 = 1, ADDRESS_FAMILY_IPV6 = 2, ADDRESS_FAMILY_YES = 3, - ADDRESS_FAMILY_KERNEL = 4, _ADDRESS_FAMILY_BOOLEAN_MAX, _ADDRESS_FAMILY_BOOLEAN_INVALID = -1, } AddressFamilyBoolean; |