mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-09-07 09:45:10 +03:00
networkd: route - allow routes without a gateway
For IPv6, the kernel returns EINVAL if a route is added with the RTA_GATEWAY attribute set to in6addr_any (::). A route without a gateway is useful in some situations, such as layer 3 tunneling (sit, gre, etc.). This patch prevents the RTA_GATEWAY attribute from being added when route.in_addr is ip6addr_any (::).
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
bedd083aae
commit
59580681f5
@@ -118,13 +118,15 @@ int route_drop(Route *route, Link *link,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route->family == AF_INET)
|
if (!in_addr_is_null(route->family, &route->in_addr)) {
|
||||||
r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
if (route->family == AF_INET)
|
||||||
else if (route->family == AF_INET6)
|
r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
||||||
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
else if (route->family == AF_INET6)
|
||||||
if (r < 0) {
|
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
||||||
log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
|
if (r < 0) {
|
||||||
return r;
|
log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route->dst_prefixlen) {
|
if (route->dst_prefixlen) {
|
||||||
@@ -203,13 +205,15 @@ int route_configure(Route *route, Link *link,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route->family == AF_INET)
|
if (!in_addr_is_null(route->family, &route->in_addr)) {
|
||||||
r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
if (route->family == AF_INET)
|
||||||
else if (route->family == AF_INET6)
|
r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
||||||
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
else if (route->family == AF_INET6)
|
||||||
if (r < 0) {
|
r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
||||||
log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
|
if (r < 0) {
|
||||||
return r;
|
log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route->dst_prefixlen) {
|
if (route->dst_prefixlen) {
|
||||||
|
Reference in New Issue
Block a user