From: David Laight <David.Laight@ACULAB.COM>
To: "'netdev@vger.kernel.org'" <netdev@vger.kernel.org>,
"'David S . Miller'" <davem@davemloft.net>,
"'kuba@kernel.org'" <kuba@kernel.org>
Cc: "'eric.dumazet@gmail.com'" <eric.dumazet@gmail.com>,
"'martin.lau@linux.dev'" <martin.lau@linux.dev>,
'Alexei Starovoitov' <ast@kernel.org>,
'Stephen Hemminger' <stephen@networkplumber.org>,
"'Jens Axboe'" <axboe@kernel.dk>,
'Daniel Borkmann' <daniel@iogearbox.net>,
"'Andrii Nakryiko'" <andrii@kernel.org>
Subject: [PATCH net-next 3/4] bpf: Use the sockptr_t helpers
Date: Mon, 25 Dec 2023 09:57:07 +0000 [thread overview]
Message-ID: <631454442da243998455d325c224f2be@AcuMS.aculab.com> (raw)
In-Reply-To: <199c9af56a5741feaf4b1768bf7356be@AcuMS.aculab.com>
bpfptr_t is defined as sockptr_t but the bpfptr_is_kernel(),
bpfptr_is_null(), KERNEL_BPFPTR() and USER_BPFPTR() helpers are
copies of the sockptr ones.
Instead implement in terms of the sockptr helpers.
Signed-off-by: David Laight <david.laight@aculab.com>
---
include/linux/bpfptr.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/linux/bpfptr.h b/include/linux/bpfptr.h
index 79b2f78eec1a..862e87350477 100644
--- a/include/linux/bpfptr.h
+++ b/include/linux/bpfptr.h
@@ -10,17 +10,17 @@ typedef sockptr_t bpfptr_t;
static inline bool bpfptr_is_kernel(bpfptr_t bpfptr)
{
- return bpfptr.is_kernel;
+ return sockptr_is_kernel(bpfptr);
}
static inline bpfptr_t KERNEL_BPFPTR(void *p)
{
- return (bpfptr_t) { .kernel = p, .is_kernel = true };
+ return KERNEL_SOCKPTR(p);
}
static inline bpfptr_t USER_BPFPTR(void __user *p)
{
- return (bpfptr_t) { .user = p };
+ return USER_SOCKPTR(p);
}
static inline bpfptr_t make_bpfptr(u64 addr, bool is_kernel)
@@ -33,9 +33,7 @@ static inline bpfptr_t make_bpfptr(u64 addr, bool is_kernel)
static inline bool bpfptr_is_null(bpfptr_t bpfptr)
{
- if (bpfptr_is_kernel(bpfptr))
- return !bpfptr.kernel;
- return !bpfptr.user;
+ return sockptr_is_null(bpfptr);
}
static inline void bpfptr_add(bpfptr_t *bpfptr, size_t val)
--
2.17.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-12-25 9:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-25 9:46 [PATCH net-next 0/4] sockptr: Change sockptr_t to be a struct David Laight
2023-12-25 9:51 ` [PATCH net-next 1/4] net: Use sockptr_is_kernel() instead of testing is_kernel David Laight
2023-12-25 9:55 ` [PATCH net-next 2/4] bpf: Use bpfptr_is_kernel() instead of checking the is_kernel member David Laight
2023-12-25 9:57 ` David Laight [this message]
2023-12-25 9:58 ` [PATCH net-next 4/4] sockptr: Change sockptr_t to be a struct of a kernel and user pointer David Laight
2024-01-02 22:32 ` [PATCH net-next 0/4] sockptr: Change sockptr_t to be a struct Jakub Kicinski
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=631454442da243998455d325c224f2be@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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).