netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Saeed Mahameed <saeedm@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Dave Watson <davejwatson@fb.com>,
	Boris Pismenny <borisp@mellanox.com>,
	Ilya Lesokhin <ilyal@mellanox.com>
Subject: Re: [PATCH V2 net-next 07/14] net/tls: Support TLS device offload with IPv6
Date: Thu, 22 Mar 2018 12:36:59 +0300	[thread overview]
Message-ID: <d623296b-a49a-089f-a0f7-b4b59d68ac6f@cogentembedded.com> (raw)
In-Reply-To: <20180321210146.22537-8-saeedm@mellanox.com>

Hello!

On 3/22/2018 12:01 AM, Saeed Mahameed wrote:

> From: Ilya Lesokhin <ilyal@mellanox.com>
> 
> Previously get_netdev_for_sock worked only with IPv4.
> 
> Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
> Signed-off-by: Boris Pismenny <borisp@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

    Only stylistic comments...

> ---
>   net/tls/tls_device.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
> index e623280ea019..c35fc107d9c5 100644
> --- a/net/tls/tls_device.c
> +++ b/net/tls/tls_device.c
> @@ -34,6 +34,11 @@
>   #include <net/inet_common.h>
>   #include <linux/highmem.h>
>   #include <linux/netdevice.h>
> +#include <net/addrconf.h>
> +#include <net/flow.h>
> +#include <linux/ipv6.h>
> +#include <net/dst.h>
> +#include <linux/security.h>
>   
>   #include <net/tls.h>
>   #include <crypto/aead.h>
> @@ -99,13 +104,55 @@ static void tls_device_queue_ctx_destruction(struct tls_context *ctx)
>   	spin_unlock_irqrestore(&tls_device_lock, flags);
>   }
>   
> +static inline struct net_device *ipv6_get_netdev(struct sock *sk)
> +{
> +	struct net_device *dev = NULL;
> +#if IS_ENABLED(CONFIG_IPV6)
> +	struct inet_sock *inet = inet_sk(sk);
> +	struct ipv6_pinfo *np = inet6_sk(sk);
> +	struct flowi6 _fl6, *fl6 = &_fl6;
> +	struct dst_entry *dst;
> +
> +	memset(fl6, 0, sizeof(*fl6));
> +	fl6->flowi6_proto = sk->sk_protocol;
> +	fl6->daddr = sk->sk_v6_daddr;
> +	fl6->saddr = np->saddr;
> +	fl6->flowlabel = np->flow_label;
> +	IP6_ECN_flow_xmit(sk, fl6->flowlabel);
> +	fl6->flowi6_oif = sk->sk_bound_dev_if;
> +	fl6->flowi6_mark = sk->sk_mark;
> +	fl6->fl6_sport = inet->inet_sport;
> +	fl6->fl6_dport = inet->inet_dport;
> +	fl6->flowi6_uid = sk->sk_uid;
> +	security_sk_classify_flow(sk, flowi6_to_flowi(fl6));
> +
> +	if (ipv6_stub->ipv6_dst_lookup(sock_net(sk), sk, &dst, fl6) < 0)
> +		return NULL;
> +
> +	dev = dst->dev;
> +	dev_hold(dev);
> +	dst_release(dst);
> +
> +#endif

    I think the above empty line should be outside #if as you need an empty 
line between the declaration and other statements.

> +	return dev;
> +}
> +
>   /* We assume that the socket is already connected */
>   static struct net_device *get_netdev_for_sock(struct sock *sk)
>   {
>   	struct inet_sock *inet = inet_sk(sk);
>   	struct net_device *netdev = NULL;
>   
> -	netdev = dev_get_by_index(sock_net(sk), inet->cork.fl.flowi_oif);
> +	if (sk->sk_family == AF_INET)
> +		netdev = dev_get_by_index(sock_net(sk),
> +					  inet->cork.fl.flowi_oif);
> +	else if (sk->sk_family == AF_INET6) {

    Need {} in the 1st *if* branch since you have it in the 2nd.

> +		netdev = ipv6_get_netdev(sk);
> +		if (!netdev && !sk->sk_ipv6only &&
> +		    ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)
> +			netdev = dev_get_by_index(sock_net(sk),
> +						  inet->cork.fl.flowi_oif);
> +	}
>   
>   	return netdev;
>   }

MBR, Sergei

  reply	other threads:[~2018-03-22  9:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 21:01 [PATCH V2 net-next 00/14] TLS offload, netdev & MLX5 support Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 01/14] tcp: Add clean acked data hook Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 02/14] net: Rename and export copy_skb_header Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 03/14] net: Add Software fallback infrastructure for socket dependent offloads Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 04/14] net: Add TLS offload netdev ops Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 05/14] net: Add TLS TX offload features Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 06/14] net/tls: Add generic NIC offload infrastructure Saeed Mahameed
2018-03-21 21:10   ` Eric Dumazet
2018-03-22 12:45     ` Boris Pismenny
2018-03-21 22:27   ` Kirill Tkhai
2018-03-22 22:33     ` Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 07/14] net/tls: Support TLS device offload with IPv6 Saeed Mahameed
2018-03-22  9:36   ` Sergei Shtylyov [this message]
2018-03-22 22:18     ` Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 08/14] net/mlx5e: Move defines out of ipsec code Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 09/14] net/mlx5: Accel, Add TLS tx offload interface Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 10/14] net/mlx5e: TLS, Add Innova TLS TX support Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 11/14] net/mlx5e: TLS, Add Innova TLS TX offload data path Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 12/14] net/mlx5e: TLS, Add error statistics Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 13/14] MAINTAINERS: Update mlx5 innova driver maintainers Saeed Mahameed
2018-03-21 21:01 ` [PATCH V2 net-next 14/14] MAINTAINERS: Update TLS maintainers Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d623296b-a49a-089f-a0f7-b4b59d68ac6f@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=borisp@mellanox.com \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=ilyal@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).