Re: [PATCH 1/4] rtnl: Add l_rtnl_route_set_gateway

Denis Kenzior <denkenz at gmail.com>
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
Hi Andrew,

On 1/3/22 08:18, Andrew Zaborowski wrote:
> Allow creating prefix routes for off-link prefixes, i.e. ones that
> should be routed through a gateway.
> ---
>   ell/ell.sym |  1 +
>   ell/rtnl.c  | 16 ++++++++++++++++
>   ell/rtnl.h  |  1 +
>   3 files changed, 18 insertions(+)
> 

<snip>

>   
> +LIB_EXPORT bool l_rtnl_route_set_gateway(struct l_rtnl_route *rt,
> +						const char *address)
> +{
> +	if (unlikely(!rt))
> +		return false;
> +
> +	switch (rt->family) {
> +	case AF_INET:
> +		return inet_pton(AF_INET, address, &rt->gw.in_addr) == 1;
> +	case AF_INET6:
> +		return inet_pton(AF_INET6, address, &rt->gw.in6_addr) == 1;
> +	default:
> +		return  false;
> +	}
> +}
> +

Since we already have l_rtnl_route_new_gateway, would this make more sense as a 
dedicated constructor? Something like l_rtnl_route_new_static?

>   LIB_EXPORT uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt)
>   {
>   	if (unlikely(!rt))

Regards,
-Denis
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.