diff mbox series

[RFC,bpf-next,6/9] bpf: Remove ARG_PTR_TO_SOCKET_OR_NULL

Message ID 20211109021624.1140446-7-haoluo@google.com (mailing list archive)
State RFC
Delegated to: BPF
Headers show
Series bpf: Clean up _OR_NULL arg types | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail merge-conflict

Commit Message

Hao Luo Nov. 9, 2021, 2:16 a.m. UTC
Remove ARG_PTR_TO_SOCKET_OR_NULL and use flag to mark that the
argument may be null.

Signed-off-by: Hao Luo <haoluo@google.com>
---
 include/linux/bpf.h   | 1 -
 kernel/bpf/verifier.c | 2 --
 net/core/filter.c     | 5 ++++-
 3 files changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 27bf974ea6b5..94eb776c925a 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -330,7 +330,6 @@  struct bpf_arg_type {
 		ARG_PTR_TO_INT,		/* pointer to int */
 		ARG_PTR_TO_LONG,	/* pointer to long */
 		ARG_PTR_TO_SOCKET,	/* pointer to bpf_sock (fullsock) */
-		ARG_PTR_TO_SOCKET_OR_NULL,	/* pointer to bpf_sock (fullsock) or NULL */
 		ARG_PTR_TO_BTF_ID,	/* pointer to in-kernel struct */
 		ARG_PTR_TO_ALLOC_MEM,	/* pointer to dynamically allocated memory */
 		ARG_PTR_TO_ALLOC_MEM_OR_NULL,	/* pointer to dynamically allocated memory or NULL */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 07b93bfd3518..f89cf2a59c82 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -481,7 +481,6 @@  static bool arg_type_may_be_refcounted(struct bpf_arg_type arg)
 static bool arg_type_may_be_null(struct bpf_arg_type arg)
 {
 	return arg.flag & ARG_FLAG_MAYBE_NULL ||
-	       arg.type == ARG_PTR_TO_SOCKET_OR_NULL ||
 	       arg.type == ARG_PTR_TO_ALLOC_MEM_OR_NULL ||
 	       arg.type == ARG_PTR_TO_STACK_OR_NULL;
 }
@@ -5094,7 +5093,6 @@  static const struct bpf_reg_types *compatible_reg_types[__BPF_ARG_TYPE_MAX] = {
 	[ARG_PTR_TO_BTF_ID_SOCK_COMMON]	= &btf_id_sock_common_types,
 #endif
 	[ARG_PTR_TO_SOCKET]		= &fullsock_types,
-	[ARG_PTR_TO_SOCKET_OR_NULL]	= &fullsock_types,
 	[ARG_PTR_TO_BTF_ID]		= &btf_ptr_types,
 	[ARG_PTR_TO_SPIN_LOCK]		= &spin_lock_types,
 	[ARG_PTR_TO_MEM]		= &mem_types,
diff --git a/net/core/filter.c b/net/core/filter.c
index 2575460c054f..3ad3595a191e 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -10489,7 +10489,10 @@  static const struct bpf_func_proto bpf_sk_lookup_assign_proto = {
 	.gpl_only	= false,
 	.ret_type	= RET_INTEGER,
 	.arg1		= { .type = ARG_PTR_TO_CTX },
-	.arg2		= { .type = ARG_PTR_TO_SOCKET_OR_NULL },
+	.arg2		= {
+		.type = ARG_PTR_TO_SOCKET,
+		.flag = ARG_FLAG_MAYBE_NULL,
+	},
 	.arg3		= { .type = ARG_ANYTHING },
 };