[systemd-devel] [PATCH] networkd: route - allow routes without a gateway

Lennart Poettering lennart at poettering.net
Mon Nov 24 12:16:12 PST 2014


On Mon, 24.11.14 12:01, Gavin Li (gavinli at thegavinli.com) wrote:

> 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 (::).

Patch is line-broken. It's hard to review it and we cannot apply it
this way. Please resend non-line-broken version. If your mailer
doesn't allow that, just attach the git-format-patch formatted patch
to your email.

> ---
>  src/network/networkd-route.c | 32 ++++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
> index 10d8cd9..82c9e00 100644
> --- a/src/network/networkd-route.c
> +++ b/src/network/networkd-route.c
> @@ -118,13 +118,15 @@ int route_drop(Route *route, Link *link,
>                  return r;
>          }
> 
> -        if (route->family == AF_INET)
> -                r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY,
> &route->in_addr.in);
> -        else if (route->family == AF_INET6)
> -                r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY,
> &route->in_addr.in6);
> -        if (r < 0) {
> -                log_error("Could not append RTA_GATEWAY attribute:
> %s", strerror(-r));
> -                return r;
> +        if (!in_addr_is_null(route->family, &route->in_addr)) {
> +                if (route->family == AF_INET)
> +                        r = sd_rtnl_message_append_in_addr(req,
> RTA_GATEWAY, &route->in_addr.in);
> +                else if (route->family == AF_INET6)
> +                        r = sd_rtnl_message_append_in6_addr(req,
> RTA_GATEWAY, &route->in_addr.in6);
> +                if (r < 0) {
> +                        log_error("Could not append RTA_GATEWAY
> attribute: %s", strerror(-r));
> +                        return r;
> +                }
>          }
> 
>          if (route->dst_prefixlen) {
> @@ -203,13 +205,15 @@ int route_configure(Route *route, Link *link,
>                  return r;
>          }
> 
> -        if (route->family == AF_INET)
> -                r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY,
> &route->in_addr.in);
> -        else if (route->family == AF_INET6)
> -                r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY,
> &route->in_addr.in6);
> -        if (r < 0) {
> -                log_error("Could not append RTA_GATEWAY attribute:
> %s", strerror(-r));
> -                return r;
> +        if (!in_addr_is_null(route->family, &route->in_addr)) {
> +                if (route->family == AF_INET)
> +                        r = sd_rtnl_message_append_in_addr(req,
> RTA_GATEWAY, &route->in_addr.in);
> +                else if (route->family == AF_INET6)
> +                        r = sd_rtnl_message_append_in6_addr(req,
> RTA_GATEWAY, &route->in_addr.in6);
> +                if (r < 0) {
> +                        log_error("Could not append RTA_GATEWAY
> attribute: %s", strerror(-r));
> +                        return r;
> +                }
>          }
> 
>          if (route->dst_prefixlen) {
> -- 
> 2.1.3
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list