Error out if the address family is already set to something incompatible with the
address being parsed.
if (!address)
return -ENOMEM;
+ address->family = AF_UNSPEC;
+
address->network = network;
LIST_PREPEND(static_addresses, network->static_addresses, address);
if (!address)
return -ENOMEM;
+ address->family = AF_UNSPEC;
+
*ret = address;
address = NULL;
"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 (!route)
return -ENOMEM;
+ route->family = AF_UNSPEC;
+
route->network = network;
LIST_PREPEND(static_routes, network->static_routes, route);
if (!route)
return -ENOMEM;
+ route->family = AF_UNSPEC;
+
*ret = route;
route = NULL;
return log_oom();
}
- r = net_parse_inaddr(address, &n->dst_family, &n->dst_addr);
+ r = net_parse_inaddr(address, &n->family, &n->dst_addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Destination is invalid, ignoring assignment: %s", address);
n->dst_prefixlen = (unsigned char) i;
} else {
- switch (n->dst_family) {
+ switch (n->family) {
case AF_INET:
n->dst_prefixlen = 32;
break;
uint64_t section;
unsigned char family;
- unsigned char dst_family;
unsigned char dst_prefixlen;
union {
/* IPv4 */
r = inet_pton(AF_INET, address, dst);
- if (r > 0)
- *family = AF_INET; /* successfully parsed IPv4 address */
- else if (r < 0)
+ if (r > 0) {
+ /* succsefully parsed IPv4 address */
+ if (*family == AF_UNSPEC)
+ *family = AF_INET;
+ else if (*family != AF_INET)
+ return -EINVAL;
+ } else if (r < 0)
return -errno;
else {
/* not an IPv4 address, so let's try IPv6 */
r = inet_pton(AF_INET6, address, dst);
- if (r > 0)
- *family = AF_INET6; /* successfully parsed IPv6 address */
- else if (r < 0)
+ if (r > 0) {
+ /* successfully parsed IPv6 address */
+ if (*family == AF_UNSPEC)
+ *family = AF_INET6;
+ else if (*family != AF_INET6)
+ return -EINVAL;
+ } else if (r < 0)
return -errno;
else
return -EINVAL;