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]
Date:   Fri, 28 May 2021 19:43:41 +0200
From:   Lorenzo Bianconi <lorenzo@...nel.org>
To:     bpf@...r.kernel.org
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        daniel@...earbox.net, ast@...nel.org, echaudro@...hat.com,
        dsahern@...il.com, magnus.karlsson@...el.com, toke@...hat.com,
        brouer@...hat.com, bjorn@...nel.org, maciej.fijalkowski@...el.com,
        john.fastabend@...il.com
Subject: [RFC bpf-next 1/4] net: xdp: introduce flags field in xdp_buff and xdp_frame

Introduce flag field in xdp_buff and xdp_frame data structure in order
to report xdp_buffer metadata. For the moment just hw checksum hints
are defined but flags field will be reused for xdp multi-buffer
For the moment just CHECKSUM_UNNECESSARY is supported.
CHECKSUM_COMPLETE will need to set csum value in metada space.

Co-developed-by: David Ahern <dsahern@...nel.org>
Signed-off-by: David Ahern <dsahern@...nel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@...nel.org>
---
 include/net/xdp.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/include/net/xdp.h b/include/net/xdp.h
index 5533f0ab2afc..e81ac505752b 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -66,6 +66,13 @@ struct xdp_txq_info {
 	struct net_device *dev;
 };
 
+/* xdp metadata bitmask */
+#define XDP_CSUM_MASK		GENMASK(1, 0)
+enum xdp_flags {
+	XDP_CSUM_UNNECESSARY	= BIT(0),
+	XDP_CSUM_COMPLETE	= BIT(1),
+};
+
 struct xdp_buff {
 	void *data;
 	void *data_end;
@@ -74,6 +81,7 @@ struct xdp_buff {
 	struct xdp_rxq_info *rxq;
 	struct xdp_txq_info *txq;
 	u32 frame_sz; /* frame size to deduce data_hard_end/reserved tailroom*/
+	u16 flags; /* xdp_flags */
 };
 
 static __always_inline void
@@ -81,6 +89,7 @@ xdp_init_buff(struct xdp_buff *xdp, u32 frame_sz, struct xdp_rxq_info *rxq)
 {
 	xdp->frame_sz = frame_sz;
 	xdp->rxq = rxq;
+	xdp->flags = 0;
 }
 
 static __always_inline void
@@ -95,6 +104,18 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 	xdp->data_meta = meta_valid ? data : data + 1;
 }
 
+static __always_inline void
+xdp_buff_get_csum(struct xdp_buff *xdp, struct sk_buff *skb)
+{
+	switch (xdp->flags & XDP_CSUM_MASK) {
+	case XDP_CSUM_UNNECESSARY:
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		break;
+	default:
+		break;
+	}
+}
+
 /* Reserve memory area at end-of data area.
  *
  * This macro reserves tailroom in the XDP buffer by limiting the
@@ -122,8 +143,21 @@ struct xdp_frame {
 	 */
 	struct xdp_mem_info mem;
 	struct net_device *dev_rx; /* used by cpumap */
+	u16 flags; /* xdp_flags */
 };
 
+static __always_inline void
+xdp_frame_get_csum(struct xdp_frame *xdpf, struct sk_buff *skb)
+{
+	switch (xdpf->flags & XDP_CSUM_MASK) {
+	case XDP_CSUM_UNNECESSARY:
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		break;
+	default:
+		break;
+	}
+}
+
 #define XDP_BULK_QUEUE_SIZE	16
 struct xdp_frame_bulk {
 	int count;
@@ -180,6 +214,7 @@ void xdp_convert_frame_to_buff(struct xdp_frame *frame, struct xdp_buff *xdp)
 	xdp->data_end = frame->data + frame->len;
 	xdp->data_meta = frame->data - frame->metasize;
 	xdp->frame_sz = frame->frame_sz;
+	xdp->flags = frame->flags;
 }
 
 static inline
@@ -206,6 +241,7 @@ int xdp_update_frame_from_buff(struct xdp_buff *xdp,
 	xdp_frame->headroom = headroom - sizeof(*xdp_frame);
 	xdp_frame->metasize = metasize;
 	xdp_frame->frame_sz = xdp->frame_sz;
+	xdp_frame->flags = xdp->flags;
 
 	return 0;
 }
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ