From: Daniel Borkmann <daniel@iogearbox.net>
To: Saeed Mahameed <saeedm@mellanox.com>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
Or Gerlitz <ogerlitz@mellanox.com>,
Maor Gottlieb <maorg@mellanox.com>,
Huy Nguyen <huyn@mellanox.com>, Tal Alon <talal@mellanox.com>,
Patrick McHardy <kaber@trash.net>,
Eric Dumazet <edumazet@google.com>,
ast@fb.com
Subject: Re: [PATCH net-next 13/18] net: Add offload kernel net stack packet type
Date: Fri, 17 Jun 2016 17:15:10 +0200 [thread overview]
Message-ID: <576413FE.3010703@iogearbox.net> (raw)
In-Reply-To: <1466174639-14576-14-git-send-email-saeedm@mellanox.com>
On 06/17/2016 04:43 PM, Saeed Mahameed wrote:
> From: Maor Gottlieb <maorg@mellanox.com>
>
> Add new packet type to skip kernel specific protocol handlers.
>
> This is needed so device drivers can pass packets up to user space
> (af_packet/tcpdump, etc..) without the need for them to go through
> the whole kernel data path.
>
> Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
> CC: David S. Miller <davem@davemloft.net>
> CC: Patrick McHardy <kaber@trash.net>
> CC: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> ---
> include/linux/skbuff.h | 6 +++---
> include/uapi/linux/if_packet.h | 1 +
> net/core/dev.c | 4 ++++
> 3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index dc0fca7..359724e 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -694,14 +694,14 @@ struct sk_buff {
>
> /* if you move pkt_type around you also must adapt those constants */
> #ifdef __BIG_ENDIAN_BITFIELD
> -#define PKT_TYPE_MAX (7 << 5)
> +#define PKT_TYPE_MAX (8 << 5)
> #else
> -#define PKT_TYPE_MAX 7
> +#define PKT_TYPE_MAX 8
> #endif
Aehm ... did you actually test this with BPF ?!
PKT_TYPE_MAX is a mask (naming could be better no doubt), see also function
convert_skb_access():
[...]
case SKF_AD_PKTTYPE:
*insn++ = BPF_LDX_MEM(BPF_B, dst_reg, src_reg, PKT_TYPE_OFFSET());
*insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg, PKT_TYPE_MAX);
#ifdef __BIG_ENDIAN_BITFIELD
*insn++ = BPF_ALU32_IMM(BPF_RSH, dst_reg, 5);
#endif
break;
[...]
Also, dunno if it's worth burning a skb bit for one driver.
> #define PKT_TYPE_OFFSET() offsetof(struct sk_buff, __pkt_type_offset)
>
> __u8 __pkt_type_offset[0];
> - __u8 pkt_type:3;
> + __u8 pkt_type:4;
> __u8 pfmemalloc:1;
> __u8 ignore_df:1;
> __u8 nfctinfo:3;
> diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h
> index 9e7edfd..93a9f13 100644
> --- a/include/uapi/linux/if_packet.h
> +++ b/include/uapi/linux/if_packet.h
> @@ -29,6 +29,7 @@ struct sockaddr_ll {
> #define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
> #define PACKET_USER 6 /* To user space */
> #define PACKET_KERNEL 7 /* To kernel space */
> +#define PACKET_OFFLOAD_KERNEL 8 /* Offload NET stack */
> /* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */
> #define PACKET_FASTROUTE 6 /* Fastrouted frame */
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d40593b..f300f1a 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4113,6 +4113,9 @@ another_round:
> pt_prev = ptype;
> }
>
> + if (unlikely(skb->pkt_type == PACKET_OFFLOAD_KERNEL))
> + goto done;
> +
> skip_taps:
> #ifdef CONFIG_NET_INGRESS
> if (static_key_false(&ingress_needed)) {
> @@ -4190,6 +4193,7 @@ ncls:
> &skb->dev->ptype_specific);
> }
>
> +done:
> if (pt_prev) {
> if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
> goto drop;
>
next prev parent reply other threads:[~2016-06-17 15:15 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 14:43 [PATCH net-next 00/18] mlx5 RoCE/RDMA packet sniffer Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 01/18] net/mlx5: Refactor mlx5_add_flow_rule Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 02/18] net/mlx5: Introduce mlx5_flow_steering structure Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 03/18] net/mlx5: Properly remove all steering objects Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 04/18] net/mlx5: Add hold/put rules refcount API Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 05/18] net/mlx5: Add support to add/del flow rule notifiers Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 06/18] net/mlx5: Introduce table of function pointer steering commands Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 07/18] net/mlx5: Introduce nop " Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 08/18] if_ether.h: Add RoCE Ethertype Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 09/18] IB/mlx5: Create RoCE root namespace Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 10/18] net/mlx5: Introduce get flow rule match API Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 11/18] net/mlx5: Add sniffer namespaces Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 12/18] IB/mlx5: Add kernel offload flow-tag Saeed Mahameed
2016-06-17 16:00 ` Alexei Starovoitov
2016-06-17 16:50 ` John Fastabend
2016-06-17 22:31 ` Saeed Mahameed
2016-06-17 23:34 ` Eric Dumazet
2016-06-19 14:27 ` Saeed Mahameed
2016-06-21 2:18 ` Alexei Starovoitov
2016-06-21 13:04 ` Saeed Mahameed
2016-06-21 15:18 ` Eric Dumazet
2016-06-21 15:41 ` Or Gerlitz
2016-06-17 14:43 ` [PATCH net-next 13/18] net: Add offload kernel net stack packet type Saeed Mahameed
2016-06-17 15:12 ` Eric Dumazet
2016-06-17 15:15 ` Daniel Borkmann [this message]
2016-06-17 22:54 ` Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 14/18] net/mlx5e: Set sniffer skbs packet type to offload kernel Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 15/18] net/mlx5: Introduce sniffer steering hardware capabilities Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 16/18] net/mlx5e: Sniffer support for kernel offload (RoCE) traffic Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 17/18] net/mlx5e: Lock device state in set features Saeed Mahameed
2016-06-17 14:43 ` [PATCH net-next 18/18] net/mlx5e: Add netdev hw feature flag offload-sniffer Saeed Mahameed
2016-06-21 13:10 ` [PATCH net-next 00/18] mlx5 RoCE/RDMA packet sniffer Saeed Mahameed
2016-06-22 18:52 ` David Miller
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=576413FE.3010703@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@fb.com \
--cc=davem@davemloft.net \
--cc=dledford@redhat.com \
--cc=edumazet@google.com \
--cc=huyn@mellanox.com \
--cc=kaber@trash.net \
--cc=maorg@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=talal@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).