[systemd-commits] man/systemd-networkd.service.xml src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Sat Jan 4 15:26:41 PST 2014
man/systemd-networkd.service.xml | 4 ++--
src/network/networkd-network.c | 29 ++++++++++++++++++++++++++---
src/network/networkd-route.c | 4 ++--
src/network/networkd.h | 1 +
4 files changed, 31 insertions(+), 7 deletions(-)
New commits:
commit b3070dc0258831c7e2b13624f75fa3dbd80d9833
Author: Tom Gundersen <teg at jklm.no>
Date: Sat Jan 4 21:13:47 2014 +0100
networkd: refuse to use .network files with missing Address/Gateway key
These keys are mandatory in [Address]/[Route] sections. Otherwise, we
hit an assert:
ens3: setting addresses
Assertion 'address->family == 2 || address->family == 10' failed at /build/amd64-generic/tmp/portage/sys-apps/systemd-9999-r1/work/systemd-9999/src/network/networkd-address.c:137, function address_configure(). Aborting.
Reported-by: Alex Polvi <alex.polvi at coreos.com>
At the same time make sure Route's Destination and Gateway uses the same address family.
diff --git a/man/systemd-networkd.service.xml b/man/systemd-networkd.service.xml
index 57be335..de45d10 100644
--- a/man/systemd-networkd.service.xml
+++ b/man/systemd-networkd.service.xml
@@ -206,7 +206,7 @@
<varlistentry>
<term><varname>Address</varname></term>
<listitem>
- <para>As in the <literal>[Network]</literal> section.</para>
+ <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -223,7 +223,7 @@
<varlistentry>
<term><varname>Gateway</varname></term>
<listitem>
- <para>As in the <literal>[Network]</literal> section.</para>
+ <para>As in the <literal>[Network]</literal> section. This key is mandatory.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 3cbc9ab..0326fe6 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -29,6 +29,8 @@
static int network_load_one(Manager *manager, const char *filename) {
_cleanup_network_free_ Network *network = NULL;
_cleanup_fclose_ FILE *file = NULL;
+ Route *route;
+ Address *address;
int r;
assert(manager);
@@ -71,6 +73,29 @@ static int network_load_one(Manager *manager, const char *filename) {
}
LIST_PREPEND(networks, manager->networks, network);
+
+ LIST_FOREACH(static_routes, route, network->static_routes) {
+ if (!route->family) {
+ log_warning("Route section without Gateway field configured in %s. "
+ "Ignoring", filename);
+ return 0;
+ }
+
+ if (route->dst_family && route->family != route->dst_family) {
+ log_warning("Route section with conflicting Gateway and Destination address "
+ "family configured in %s. Ignoring", filename);
+ return 0;
+ }
+ }
+
+ LIST_FOREACH(static_addresses, address, network->static_addresses) {
+ if (!address->family) {
+ log_warning("Address section without Address field configured in %s. "
+ "Ignoring", filename);
+ return 0;
+ }
+ }
+
network = NULL;
return 0;
@@ -109,8 +134,6 @@ void network_free(Network *network) {
if (!network)
return;
- assert(network->manager);
-
free(network->filename);
free(network->match_mac);
@@ -130,7 +153,7 @@ void network_free(Network *network) {
hashmap_free(network->addresses_by_section);
hashmap_free(network->routes_by_section);
- if (network->manager->networks)
+ if (network->manager && network->manager->networks)
LIST_REMOVE(networks, network->manager->networks, network);
free(network);
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 488d3f5..83dad65 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -231,7 +231,7 @@ int config_parse_destination(const char *unit,
return log_oom();
}
- r = net_parse_inaddr(address, &n->family, &n->dst_addr);
+ r = net_parse_inaddr(address, &n->dst_family, &n->dst_addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Destination is invalid, ignoring assignment: %s", address);
@@ -252,7 +252,7 @@ int config_parse_destination(const char *unit,
n->dst_prefixlen = (unsigned char) i;
} else {
- switch (n->family) {
+ switch (n->dst_family) {
case AF_INET:
n->dst_prefixlen = 32;
break;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 3b29080..75309a9 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -119,6 +119,7 @@ struct Route {
uint64_t section;
unsigned char family;
+ unsigned char dst_family;
unsigned char dst_prefixlen;
union {
More information about the systemd-commits
mailing list