lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5a5b84a017bcdce540c7624a3c087c6971f82a34.camel@redhat.com>
Date:   Thu, 29 Sep 2022 15:12:23 +0200
From:   Paolo Abeni <pabeni@...hat.com>
To:     Liu Jian <liujian56@...wei.com>, davem@...emloft.net,
        yoshfuji@...ux-ipv6.org, dsahern@...nel.org, edumazet@...gle.com,
        kuba@...nel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: Add helper function to parse
 netlink msg of ip_tunnel_encap

On Wed, 2022-09-28 at 11:39 +0800, Liu Jian wrote:
> Add ip_tunnel_netlink_encap_parms to parse netlink msg of ip_tunnel_encap.
> Reduces duplicate code, no actual functional changes.
> 
> Signed-off-by: Liu Jian <liujian56@...wei.com>
> ---
> v1->v2: Move the implementation of the helper function to ip_tunnel_core.c
>  include/net/ip_tunnels.h  |  3 +++
>  net/ipv4/ip_tunnel_core.c | 35 +++++++++++++++++++++++++++++++++++
>  net/ipv4/ipip.c           | 38 ++------------------------------------
>  net/ipv6/ip6_tunnel.c     | 37 ++-----------------------------------
>  net/ipv6/sit.c            | 38 ++------------------------------------
>  5 files changed, 44 insertions(+), 107 deletions(-)
> 
> diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
> index ced80e2f8b58..51da2957cf48 100644
> --- a/include/net/ip_tunnels.h
> +++ b/include/net/ip_tunnels.h
> @@ -302,6 +302,9 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
>  		      struct ip_tunnel_parm *p, __u32 fwmark);
>  void ip_tunnel_setup(struct net_device *dev, unsigned int net_id);
>  
> +bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],
> +				   struct ip_tunnel_encap *encap);
> +
>  extern const struct header_ops ip_tunnel_header_ops;
>  __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
>  
> diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
> index cc1caab4a654..526e6a52a973 100644
> --- a/net/ipv4/ip_tunnel_core.c
> +++ b/net/ipv4/ip_tunnel_core.c
> @@ -1079,3 +1079,38 @@ EXPORT_SYMBOL(ip_tunnel_parse_protocol);
>  
>  const struct header_ops ip_tunnel_header_ops = { .parse_protocol = ip_tunnel_parse_protocol };
>  EXPORT_SYMBOL(ip_tunnel_header_ops);
> +
> +/* This function returns true when ENCAP attributes are present in the nl msg */
> +bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],
> +				   struct ip_tunnel_encap *encap)
> +{
> +	bool ret = false;
> +
> +	memset(encap, 0, sizeof(*encap));
> +
> +	if (!data)
> +		return ret;
> +
> +	if (data[IFLA_IPTUN_ENCAP_TYPE]) {
> +		ret = true;
> +		encap->type = nla_get_u16(data[IFLA_IPTUN_ENCAP_TYPE]);
> +	}
> +
> +	if (data[IFLA_IPTUN_ENCAP_FLAGS]) {
> +		ret = true;
> +		encap->flags = nla_get_u16(data[IFLA_IPTUN_ENCAP_FLAGS]);
> +	}
> +
> +	if (data[IFLA_IPTUN_ENCAP_SPORT]) {
> +		ret = true;
> +		encap->sport = nla_get_be16(data[IFLA_IPTUN_ENCAP_SPORT]);
> +	}
> +
> +	if (data[IFLA_IPTUN_ENCAP_DPORT]) {
> +		ret = true;
> +		encap->dport = nla_get_be16(data[IFLA_IPTUN_ENCAP_DPORT]);
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(ip_tunnel_netlink_encap_parms);

I think EXPORT_SYMBOL_GPL() fits better here.

Cheers,

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ