summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-03 10:52:42 +0200
committerTom Gundersen <teg@jklm.no>2014-07-03 11:00:36 +0200
commit4826dd6850478ddec604787756db26c1ab2c106f (patch)
treebc0f27a1465cc81ff6774277236d4dfe4570a84c /src/network/networkd-netdev.c
parent30ae9dfda3788cdfaf1b84d124dbc7feb638c77b (diff)
networkd: tunnels - make tunnel address parsing generic
It had a bug in the typing, fix that and also make it save the address family so we can print proper error messages.
Diffstat (limited to 'src/network/networkd-netdev.c')
-rw-r--r--src/network/networkd-netdev.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index cc85e5348b..a810be04b9 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -254,8 +254,8 @@ int config_parse_tunnel_address(const char *unit,
const char *rvalue,
void *data,
void *userdata) {
- NetDev *n = data;
- unsigned char family = AF_INET;
+ NetDev *n = userdata;
+ union in_addr_union *addr = data;
int r;
assert(filename);
@@ -263,13 +263,14 @@ int config_parse_tunnel_address(const char *unit,
assert(rvalue);
assert(data);
- r = net_parse_inaddr(rvalue, &family, n);
+ r = net_parse_inaddr(rvalue, &n->family, addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Tunnel address is invalid, ignoring assignment: %s", rvalue);
return 0;
}
- return 0;
+
+ return 0;
}
static int netdev_create(NetDev *netdev) {
@@ -607,9 +608,41 @@ static int netdev_load_one(Manager *manager, const char *filename) {
return r;
}
- if (netdev->kind == _NETDEV_KIND_INVALID) {
+ switch (netdev->kind) {
+ case _NETDEV_KIND_INVALID:
log_warning("NetDev without Kind configured in %s. Ignoring", filename);
return 0;
+ case NETDEV_KIND_VLAN:
+ if (netdev->vlanid > VLANID_MAX) {
+ log_warning("VLAN without valid Id configured in %s. Ignoring", filename);
+ return 0;
+ }
+ break;
+ case NETDEV_KIND_VXLAN:
+ if (netdev->vxlanid > VXLAN_VID_MAX) {
+ log_warning("VXLAN without valid Id configured in %s. Ignoring", filename);
+ return 0;
+ }
+ break;
+ case NETDEV_KIND_IPIP:
+ case NETDEV_KIND_GRE:
+ case NETDEV_KIND_SIT:
+ case NETDEV_KIND_VTI:
+ if (netdev->local.in.s_addr == INADDR_ANY) {
+ log_warning("Tunnel without local address configured in %s. Ignoring", filename);
+ return 0;
+ }
+ if (netdev->remote.in.s_addr == INADDR_ANY) {
+ log_warning("Tunnel without remote address configured in %s. Ignoring", filename);
+ return 0;
+ }
+ if (netdev->family != AF_INET) {
+ log_warning("Tunnel with invalid address family configured in %s. Ignoring", filename);
+ return 0;
+ }
+ break;
+ default:
+ break;
}
if (!netdev->ifname) {
@@ -617,16 +650,6 @@ static int netdev_load_one(Manager *manager, const char *filename) {
return 0;
}
- if (netdev->kind == NETDEV_KIND_VLAN && netdev->vlanid > VLANID_MAX) {
- log_warning("VLAN without valid Id configured in %s. Ignoring", filename);
- return 0;
- }
-
- if (netdev->kind == NETDEV_KIND_VXLAN && netdev->vxlanid > VXLAN_VID_MAX) {
- log_warning("VXLAN without valid Id configured in %s. Ignoring", filename);
- return 0;
- }
-
if (netdev->kind != NETDEV_KIND_VLAN && netdev->vlanid <= VLANID_MAX) {
log_warning("VLAN Id configured for a %s in %s. Ignoring",
netdev_kind_to_string(netdev->kind), filename);