netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wille Kuutti" <wille.kuutti@kuutti.com>
To: "'Alexei Starovoitov'" <ast@kernel.org>,
	"'Daniel Borkmann'" <daniel@iogearbox.net>,
	"'Andrii Nakryiko'" <andrii@kernel.org>,
	"'Martin KaFai Lau'" <kafai@fb.com>,
	"'Song Liu'" <songliubraving@fb.com>,
	"'Yonghong Song'" <yhs@fb.com>,
	"'John Fastabend'" <john.fastabend@gmail.com>,
	"'KP Singh'" <kpsingh@kernel.org>,
	"'David S. Miller'" <davem@davemloft.net>,
	"'Eric Dumazet'" <edumazet@google.com>,
	"'Jakub Kicinski'" <kuba@kernel.org>,
	"'Paolo Abeni'" <pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] net/core: Make bpf_skb_adjust_room BPF helper available for packets with non IPv4 or IPv6 payload
Date: Fri, 6 May 2022 01:06:20 +0300	[thread overview]
Message-ID: <00fd01d860cc$59d5fa60$0d81ef20$@kuutti.com> (raw)

Network traffic is not limited to only IPv4 and IPv6 protocols, but several
other L3 networking protocols are in common use in several
applications and deployment scenarios which also could utilize BPF. This
change enables the bpf_skb_adjust_room BPF helper to adjust the
room after the MAC header using BPF_ADJ_ROOM_MAC option for packets with any
L3 payload. For BPF_ADJ_ROOM_NET option only IPv4 and IPv6 are
still supported as each L3 protocol would need it's own logic to determine
the length of the L3 header to enable adjustment after the L3
headers.

Signed-off-by: Wille Kuutti <wille.kuutti@kuutti.com>
---
net/core/filter.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 64470a727ef7..c6790a763c9b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3362,7 +3362,7 @@ static u32 bpf_skb_net_base_len(const struct sk_buff
*skb)
        case htons(ETH_P_IPV6):
                return sizeof(struct ipv6hdr);
        default:
-               return ~0U;
+               return 0U;
        }
}

@@ -3582,7 +3582,8 @@ BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb,
s32, len_diff,
        if (unlikely(len_diff_abs > 0xfffU))
                return -EFAULT;
        if (unlikely(proto != htons(ETH_P_IP) &&
-                    proto != htons(ETH_P_IPV6)))
+                       proto != htons(ETH_P_IPV6) &&
+                       mode != BPF_ADJ_ROOM_MAC))
                return -ENOTSUPP;

        off = skb_mac_header_len(skb);
--
2.32.0



             reply	other threads:[~2022-05-05 22:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 22:06 Wille Kuutti [this message]
2022-05-09 20:24 ` [PATCH] net/core: Make bpf_skb_adjust_room BPF helper available for packets with non IPv4 or IPv6 payload Martin KaFai Lau

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='00fd01d860cc$59d5fa60$0d81ef20$@kuutti.com' \
    --to=wille.kuutti@kuutti.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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).