summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/networkd-link.c80
-rw-r--r--src/network/networkd-network-gperf.gperf8
-rw-r--r--src/network/networkd-network.c58
-rw-r--r--src/network/networkd.h5
4 files changed, 27 insertions, 124 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 5eeeb3d29e..3b8b7ed80e 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1770,7 +1770,7 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata
}
static int link_enter_join_netdev(Link *link) {
- NetDev *vlan, *macvlan, *vxlan;
+ NetDev *netdev;
Iterator i;
int r;
@@ -1784,10 +1784,7 @@ static int link_enter_join_netdev(Link *link) {
if (!link->network->bridge &&
!link->network->bond &&
- !link->network->tunnel &&
- hashmap_isempty(link->network->vlans) &&
- hashmap_isempty(link->network->macvlans) &&
- hashmap_isempty(link->network->vxlans))
+ hashmap_isempty(link->network->stacked_netdevs))
return link_joined(link);
if (link->network->bond) {
@@ -1836,82 +1833,19 @@ static int link_enter_join_netdev(Link *link) {
link->enslaving ++;
}
- if (link->network->tunnel) {
+ HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
- link->ifname, link->network->tunnel->ifname,
- NETDEVIF(link->network->tunnel),
- NULL);
+ link->ifname, netdev->ifname, NETDEVIF(netdev), NULL);
- r = netdev_join(link->network->tunnel, link, &netdev_join_handler);
+ r = netdev_join(netdev, link, &netdev_join_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
- link->ifname, link->network->tunnel->ifname, strerror(-r),
- NETDEVIF(link->network->tunnel),
- NULL);
- link_enter_failed(link);
- return r;
- }
-
- link->enslaving ++;
- }
-
- HASHMAP_FOREACH(vlan, link->network->vlans, i) {
- log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%-*s: enslaving by '%s'",
- IFNAMSIZ,
- link->ifname, vlan->ifname, NETDEVIF(vlan), NULL);
-
- r = netdev_join(vlan, link, &netdev_join_handler);
- if (r < 0) {
- log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not join netdev '%s': %s",
- IFNAMSIZ,
- link->ifname, vlan->ifname, strerror(-r),
- NETDEVIF(vlan), NULL);
- link_enter_failed(link);
- return r;
- }
-
- link->enslaving ++;
- }
-
- HASHMAP_FOREACH(macvlan, link->network->macvlans, i) {
- log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%-*s: enslaving by '%s'",
- IFNAMSIZ,
- link->ifname, macvlan->ifname, NETDEVIF(macvlan), NULL);
-
- r = netdev_join(macvlan, link, &netdev_join_handler);
- if (r < 0) {
- log_struct_link(LOG_WARNING, link,
- "MESSAGE=%-*s: could not join netdev '%s': %s",
- IFNAMSIZ,
- link->ifname, macvlan->ifname, strerror(-r),
- NETDEVIF(macvlan), NULL);
- link_enter_failed(link);
- return r;
- }
-
- link->enslaving ++;
- }
-
- HASHMAP_FOREACH(vxlan, link->network->vxlans, i) {
- log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%*s: enslaving by '%s'",
- IFNAMSIZ,
- link->ifname, vxlan->ifname, NETDEVIF(vxlan), NULL);
-
- r = netdev_join(vxlan, link, &netdev_join_handler);
- if (r < 0) {
- log_struct_link(LOG_WARNING, link,
- "MESSAGE=%*s: could not join netdev '%s': %s",
- IFNAMSIZ,
- link->ifname, vxlan->ifname, strerror(-r),
- NETDEVIF(vxlan), NULL);
+ link->ifname, netdev->ifname, strerror(-r),
+ NETDEVIF(netdev), NULL);
link_enter_failed(link);
return r;
}
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 852142f4de..3a58a4043b 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -27,9 +27,10 @@ Match.Architecture, config_parse_net_condition, CONDITION_ARCHI
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, offsetof(Network, vlans)
-Network.MACVLAN, config_parse_netdev, 0, offsetof(Network, macvlans)
-Network.VXLAN, config_parse_netdev, 0, offsetof(Network, vxlans)
+Network.VLAN, config_parse_netdev, 0, 0
+Network.MACVLAN, 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.IPv4LL, config_parse_bool, 0, offsetof(Network, ipv4ll)
@@ -38,7 +39,6 @@ Network.Address, config_parse_address, 0,
Network.Gateway, config_parse_gateway, 0, 0
Network.DNS, config_parse_strv, 0, offsetof(Network, dns)
Network.NTP, config_parse_strv, 0, offsetof(Network, ntp)
-Network.Tunnel, config_parse_tunnel, 0, offsetof(Network, tunnel)
Address.Address, config_parse_address, 0, 0
Address.Peer, config_parse_address, 0, 0
Address.Broadcast, config_parse_broadcast, 0, 0
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 84b6973f55..7e753e15af 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -62,16 +62,8 @@ static int network_load_one(Manager *manager, const char *filename) {
LIST_HEAD_INIT(network->static_addresses);
LIST_HEAD_INIT(network->static_routes);
- network->vlans = hashmap_new(string_hash_func, string_compare_func);
- if (!network->vlans)
- return log_oom();
-
- network->macvlans = hashmap_new(string_hash_func, string_compare_func);
- if (!network->macvlans)
- return log_oom();
-
- network->vxlans = hashmap_new(string_hash_func, string_compare_func);
- if (!network->vxlans)
+ network->stacked_netdevs = hashmap_new(string_hash_func, string_compare_func);
+ if (!network->stacked_netdevs)
return log_oom();
network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
@@ -178,19 +170,9 @@ void network_free(Network *network) {
netdev_unref(network->bond);
- netdev_unref(network->tunnel);
-
- HASHMAP_FOREACH(netdev, network->vlans, i)
- netdev_unref(netdev);
- hashmap_free(network->vlans);
-
- HASHMAP_FOREACH(netdev, network->macvlans, i)
- netdev_unref(netdev);
- hashmap_free(network->macvlans);
-
- HASHMAP_FOREACH(netdev, network->vxlans, i)
+ HASHMAP_FOREACH(netdev, network->stacked_netdevs, i)
netdev_unref(netdev);
- hashmap_free(network->vxlans);
+ hashmap_free(network->stacked_netdevs);
while ((route = network->static_routes))
route_free(route);
@@ -338,30 +320,12 @@ int config_parse_netdev(const char *unit,
break;
case NETDEV_KIND_VLAN:
- r = hashmap_put(network->vlans, netdev->ifname, netdev);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Can not add VLAN '%s' to network: %s",
- rvalue, strerror(-r));
- return 0;
- }
-
- break;
case NETDEV_KIND_MACVLAN:
- r = hashmap_put(network->macvlans, netdev->ifname, netdev);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Can not add MACVLAN '%s' to network: %s",
- rvalue, strerror(-r));
- return 0;
- }
-
- break;
case NETDEV_KIND_VXLAN:
- r = hashmap_put(network->vxlans, netdev->ifname, netdev);
+ r = hashmap_put(network->stacked_netdevs, netdev->ifname, netdev);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Can not add VXLAN '%s' to network: %s",
+ "Can not add VLAN '%s' to network: %s",
rvalue, strerror(-r));
return 0;
}
@@ -411,7 +375,15 @@ int config_parse_tunnel(const char *unit,
return 0;
}
- network->tunnel = netdev;
+ r = hashmap_put(network->stacked_netdevs, netdev->ifname, netdev);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Can not add VLAN '%s' to network: %s",
+ rvalue, strerror(-r));
+ return 0;
+ }
+
+ netdev_ref(netdev);
return 0;
}
diff --git a/src/network/networkd.h b/src/network/networkd.h
index fe63cfbd4e..bf73fe2bd5 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -81,10 +81,7 @@ struct Network {
char *description;
NetDev *bridge;
NetDev *bond;
- NetDev *tunnel;
- Hashmap *vlans;
- Hashmap *macvlans;
- Hashmap *vxlans;
+ Hashmap *stacked_netdevs;
DHCPSupport dhcp;
bool dhcp_dns;
bool dhcp_ntp;