diff mbox series

[net-next,3/4] bpf: Use the sockptr_t helpers

Message ID 631454442da243998455d325c224f2be@AcuMS.aculab.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series sockptr: Change sockptr_t to be a struct | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2666 this patch: 2666
netdev/cc_maintainers warning 8 maintainers not CCed: sdf@google.com haoluo@google.com bpf@vger.kernel.org jolsa@kernel.org kpsingh@kernel.org yonghong.song@linux.dev song@kernel.org john.fastabend@gmail.com
netdev/build_clang success Errors and warnings before: 1276 this patch: 1276
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2743 this patch: 2743
netdev/checkpatch warning CHECK: From:/Signed-off-by: email comments mismatch: 'From: David Laight <David.Laight@ACULAB.COM>' != 'Signed-off-by: David Laight <david.laight@aculab.com>'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

David Laight Dec. 25, 2023, 9:57 a.m. UTC
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 mbox series

Patch

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)