mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	bpf: expose bpf_strtol and bpf_strtoul to all program types
bpf_strncmp is already exposed everywhere. The motivation is to keep those helpers in kernel/bpf/helpers.c. Otherwise it's tempting to move them under kernel/bpf/cgroup.c because they are currently only used by sysctl prog types. Suggested-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/20220823222555.523590-4-sdf@google.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
		
							parent
							
								
									bed89185af
								
							
						
					
					
						commit
						8a67f2de9b
					
				
					 2 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
					@ -2132,10 +2132,6 @@ sysctl_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 | 
				
			||||||
		return func_proto;
 | 
							return func_proto;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (func_id) {
 | 
						switch (func_id) {
 | 
				
			||||||
	case BPF_FUNC_strtol:
 | 
					 | 
				
			||||||
		return &bpf_strtol_proto;
 | 
					 | 
				
			||||||
	case BPF_FUNC_strtoul:
 | 
					 | 
				
			||||||
		return &bpf_strtoul_proto;
 | 
					 | 
				
			||||||
	case BPF_FUNC_sysctl_get_name:
 | 
						case BPF_FUNC_sysctl_get_name:
 | 
				
			||||||
		return &bpf_sysctl_get_name_proto;
 | 
							return &bpf_sysctl_get_name_proto;
 | 
				
			||||||
	case BPF_FUNC_sysctl_get_current_value:
 | 
						case BPF_FUNC_sysctl_get_current_value:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -427,6 +427,7 @@ const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = {
 | 
				
			||||||
	.ret_type	= RET_INTEGER,
 | 
						.ret_type	= RET_INTEGER,
 | 
				
			||||||
	.arg1_type	= ARG_ANYTHING,
 | 
						.arg1_type	= ARG_ANYTHING,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					#endif /* CONFIG_CGROUPS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BPF_STRTOX_BASE_MASK 0x1F
 | 
					#define BPF_STRTOX_BASE_MASK 0x1F
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -555,7 +556,6 @@ const struct bpf_func_proto bpf_strtoul_proto = {
 | 
				
			||||||
	.arg3_type	= ARG_ANYTHING,
 | 
						.arg3_type	= ARG_ANYTHING,
 | 
				
			||||||
	.arg4_type	= ARG_PTR_TO_LONG,
 | 
						.arg4_type	= ARG_PTR_TO_LONG,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2)
 | 
					BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1619,6 +1619,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
 | 
				
			||||||
		return &bpf_loop_proto;
 | 
							return &bpf_loop_proto;
 | 
				
			||||||
	case BPF_FUNC_strncmp:
 | 
						case BPF_FUNC_strncmp:
 | 
				
			||||||
		return &bpf_strncmp_proto;
 | 
							return &bpf_strncmp_proto;
 | 
				
			||||||
 | 
						case BPF_FUNC_strtol:
 | 
				
			||||||
 | 
							return &bpf_strtol_proto;
 | 
				
			||||||
 | 
						case BPF_FUNC_strtoul:
 | 
				
			||||||
 | 
							return &bpf_strtoul_proto;
 | 
				
			||||||
	case BPF_FUNC_dynptr_from_mem:
 | 
						case BPF_FUNC_dynptr_from_mem:
 | 
				
			||||||
		return &bpf_dynptr_from_mem_proto;
 | 
							return &bpf_dynptr_from_mem_proto;
 | 
				
			||||||
	case BPF_FUNC_dynptr_read:
 | 
						case BPF_FUNC_dynptr_read:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue