diff mbox series

[bpf-next] bpf, sockmap: Rename sock_map_get_from_fd to sock_map_prog_attach

Message ID 20230831014346.2931397-1-xukuohai@huaweicloud.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] bpf, sockmap: Rename sock_map_get_from_fd to sock_map_prog_attach | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-0 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for s390x with gcc
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next, async
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: 2824 this patch: 2824
netdev/cc_maintainers warning 14 maintainers not CCed: kuba@kernel.org daniel@iogearbox.net kpsingh@kernel.org martin.lau@linux.dev sdf@google.com song@kernel.org andrii@kernel.org yonghong.song@linux.dev jolsa@kernel.org davem@davemloft.net pabeni@redhat.com haoluo@google.com ast@kernel.org edumazet@google.com
netdev/build_clang success Errors and warnings before: 1522 this patch: 1522
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: 2852 this patch: 2852
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-28 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-10 fail Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on s390x with gcc

Commit Message

Xu Kuohai Aug. 31, 2023, 1:43 a.m. UTC
From: Xu Kuohai <xukuohai@huawei.com>

What function sock_map_get_from_fd does is to attach a bpf prog to
a sock map, so rename it to sock_map_prog_attach to make it more
readable.

Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
---
 include/linux/bpf.h  | 2 +-
 kernel/bpf/syscall.c | 2 +-
 net/core/sock_map.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

John Fastabend Aug. 31, 2023, 2:09 a.m. UTC | #1
Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
> 
> What function sock_map_get_from_fd does is to attach a bpf prog to
> a sock map, so rename it to sock_map_prog_attach to make it more
> readable.
> 
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
> ---

I don't really think the rename is needed. It will just make any
backports difficult.
Xu Kuohai Aug. 31, 2023, 2:21 a.m. UTC | #2
On 8/31/2023 10:09 AM, John Fastabend wrote:
> Xu Kuohai wrote:
>> From: Xu Kuohai <xukuohai@huawei.com>
>>
>> What function sock_map_get_from_fd does is to attach a bpf prog to
>> a sock map, so rename it to sock_map_prog_attach to make it more
>> readable.
>>
>> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
>> ---
> 
> I don't really think the rename is needed. It will just make any
> backports difficult.
> 

OK, please ignore this patch, this function has been around for a
long time, maybe everyone is used to the name and I don't insist
on renaming it.

> 
> .
kernel test robot Aug. 31, 2023, 11:10 a.m. UTC | #3
Hi Xu,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Xu-Kuohai/bpf-sockmap-Rename-sock_map_get_from_fd-to-sock_map_prog_attach/20230831-094551
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20230831014346.2931397-1-xukuohai%40huaweicloud.com
patch subject: [PATCH bpf-next] bpf, sockmap: Rename sock_map_get_from_fd to sock_map_prog_attach
config: parisc-randconfig-r012-20230831 (https://download.01.org/0day-ci/archive/20230831/202308311959.Snzn4Unt-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230831/202308311959.Snzn4Unt-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308311959.Snzn4Unt-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/bpf/syscall.c: In function 'bpf_prog_attach':
>> kernel/bpf/syscall.c:3825:23: error: implicit declaration of function 'sock_map_prog_attach'; did you mean 'sock_map_prog_detach'? [-Werror=implicit-function-declaration]
    3825 |                 ret = sock_map_prog_attach(attr, prog);
         |                       ^~~~~~~~~~~~~~~~~~~~
         |                       sock_map_prog_detach
   cc1: some warnings being treated as errors


vim +3825 kernel/bpf/syscall.c

  3782	
  3783	#define BPF_F_ATTACH_MASK_BASE	\
  3784		(BPF_F_ALLOW_OVERRIDE |	\
  3785		 BPF_F_ALLOW_MULTI |	\
  3786		 BPF_F_REPLACE)
  3787	
  3788	#define BPF_F_ATTACH_MASK_MPROG	\
  3789		(BPF_F_REPLACE |	\
  3790		 BPF_F_BEFORE |		\
  3791		 BPF_F_AFTER |		\
  3792		 BPF_F_ID |		\
  3793		 BPF_F_LINK)
  3794	
  3795	static int bpf_prog_attach(const union bpf_attr *attr)
  3796	{
  3797		enum bpf_prog_type ptype;
  3798		struct bpf_prog *prog;
  3799		u32 mask;
  3800		int ret;
  3801	
  3802		if (CHECK_ATTR(BPF_PROG_ATTACH))
  3803			return -EINVAL;
  3804	
  3805		ptype = attach_type_to_prog_type(attr->attach_type);
  3806		if (ptype == BPF_PROG_TYPE_UNSPEC)
  3807			return -EINVAL;
  3808		mask = bpf_mprog_supported(ptype) ?
  3809		       BPF_F_ATTACH_MASK_MPROG : BPF_F_ATTACH_MASK_BASE;
  3810		if (attr->attach_flags & ~mask)
  3811			return -EINVAL;
  3812	
  3813		prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype);
  3814		if (IS_ERR(prog))
  3815			return PTR_ERR(prog);
  3816	
  3817		if (bpf_prog_attach_check_attach_type(prog, attr->attach_type)) {
  3818			bpf_prog_put(prog);
  3819			return -EINVAL;
  3820		}
  3821	
  3822		switch (ptype) {
  3823		case BPF_PROG_TYPE_SK_SKB:
  3824		case BPF_PROG_TYPE_SK_MSG:
> 3825			ret = sock_map_prog_attach(attr, prog);
  3826			break;
  3827		case BPF_PROG_TYPE_LIRC_MODE2:
  3828			ret = lirc_prog_attach(attr, prog);
  3829			break;
  3830		case BPF_PROG_TYPE_FLOW_DISSECTOR:
  3831			ret = netns_bpf_prog_attach(attr, prog);
  3832			break;
  3833		case BPF_PROG_TYPE_CGROUP_DEVICE:
  3834		case BPF_PROG_TYPE_CGROUP_SKB:
  3835		case BPF_PROG_TYPE_CGROUP_SOCK:
  3836		case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
  3837		case BPF_PROG_TYPE_CGROUP_SOCKOPT:
  3838		case BPF_PROG_TYPE_CGROUP_SYSCTL:
  3839		case BPF_PROG_TYPE_SOCK_OPS:
  3840		case BPF_PROG_TYPE_LSM:
  3841			if (ptype == BPF_PROG_TYPE_LSM &&
  3842			    prog->expected_attach_type != BPF_LSM_CGROUP)
  3843				ret = -EINVAL;
  3844			else
  3845				ret = cgroup_bpf_prog_attach(attr, ptype, prog);
  3846			break;
  3847		case BPF_PROG_TYPE_SCHED_CLS:
  3848			ret = tcx_prog_attach(attr, prog);
  3849			break;
  3850		default:
  3851			ret = -EINVAL;
  3852		}
  3853	
  3854		if (ret)
  3855			bpf_prog_put(prog);
  3856		return ret;
  3857	}
  3858
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 12596af59c00..7a0c801f2795 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2799,7 +2799,7 @@  int bpf_prog_test_run_syscall(struct bpf_prog *prog,
 			      const union bpf_attr *kattr,
 			      union bpf_attr __user *uattr);
 
-int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog);
+int sock_map_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog);
 int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
 int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value, u64 flags);
 int sock_map_bpf_prog_query(const union bpf_attr *attr,
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ebeb0695305a..087a097d74d4 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3822,7 +3822,7 @@  static int bpf_prog_attach(const union bpf_attr *attr)
 	switch (ptype) {
 	case BPF_PROG_TYPE_SK_SKB:
 	case BPF_PROG_TYPE_SK_MSG:
-		ret = sock_map_get_from_fd(attr, prog);
+		ret = sock_map_prog_attach(attr, prog);
 		break;
 	case BPF_PROG_TYPE_LIRC_MODE2:
 		ret = lirc_prog_attach(attr, prog);
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 8f07fea39d9e..26706b667f44 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -57,7 +57,7 @@  static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
 	return &stab->map;
 }
 
-int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)
+int sock_map_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog)
 {
 	u32 ufd = attr->target_fd;
 	struct bpf_map *map;