mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	samples: bpf: Convert xdp_redirect_cpu to XDP samples helper
Use the libbpf skeleton facility and other utilities provided by XDP
samples helper.
Similar to xdp_monitor, xdp_redirect_cpu was quite featureful except a
few minor omissions (e.g. redirect errno reporting). All of these have
been moved to XDP samples helper, hence drop the unneeded code and
convert to usage of helpers provided by it.
One of the important changes here is dropping of mprog-disable option,
as we make that the default. Also, we support built-in programs for some
common actions on the packet when it reaches kthread (pass, drop,
redirect to device). If the user still needs to install a custom
program, they can still supply a BPF object, however the program should
be suitably tagged with SEC("xdp_cpumap") annotation so that the
expected attach type is correct when updating our cpumap map element.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210821002010.845777-19-memxor@gmail.com
			
			
This commit is contained in:
		
							parent
							
								
									79ccf4529e
								
							
						
					
					
						commit
						e531a220cc
					
				
					 2 changed files with 357 additions and 781 deletions
				
			
		| 
						 | 
					@ -41,7 +41,6 @@ tprogs-y += test_map_in_map
 | 
				
			||||||
tprogs-y += per_socket_stats_example
 | 
					tprogs-y += per_socket_stats_example
 | 
				
			||||||
tprogs-y += xdp_redirect_map
 | 
					tprogs-y += xdp_redirect_map
 | 
				
			||||||
tprogs-y += xdp_redirect_map_multi
 | 
					tprogs-y += xdp_redirect_map_multi
 | 
				
			||||||
tprogs-y += xdp_redirect_cpu
 | 
					 | 
				
			||||||
tprogs-y += xdp_rxq_info
 | 
					tprogs-y += xdp_rxq_info
 | 
				
			||||||
tprogs-y += syscall_tp
 | 
					tprogs-y += syscall_tp
 | 
				
			||||||
tprogs-y += cpustat
 | 
					tprogs-y += cpustat
 | 
				
			||||||
| 
						 | 
					@ -55,6 +54,7 @@ tprogs-y += xdp_sample_pkts
 | 
				
			||||||
tprogs-y += ibumad
 | 
					tprogs-y += ibumad
 | 
				
			||||||
tprogs-y += hbm
 | 
					tprogs-y += hbm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					tprogs-y += xdp_redirect_cpu
 | 
				
			||||||
tprogs-y += xdp_redirect
 | 
					tprogs-y += xdp_redirect
 | 
				
			||||||
tprogs-y += xdp_monitor
 | 
					tprogs-y += xdp_monitor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,7 +102,6 @@ test_map_in_map-objs := test_map_in_map_user.o
 | 
				
			||||||
per_socket_stats_example-objs := cookie_uid_helper_example.o
 | 
					per_socket_stats_example-objs := cookie_uid_helper_example.o
 | 
				
			||||||
xdp_redirect_map-objs := xdp_redirect_map_user.o
 | 
					xdp_redirect_map-objs := xdp_redirect_map_user.o
 | 
				
			||||||
xdp_redirect_map_multi-objs := xdp_redirect_map_multi_user.o
 | 
					xdp_redirect_map_multi-objs := xdp_redirect_map_multi_user.o
 | 
				
			||||||
xdp_redirect_cpu-objs := xdp_redirect_cpu_user.o
 | 
					 | 
				
			||||||
xdp_rxq_info-objs := xdp_rxq_info_user.o
 | 
					xdp_rxq_info-objs := xdp_rxq_info_user.o
 | 
				
			||||||
syscall_tp-objs := syscall_tp_user.o
 | 
					syscall_tp-objs := syscall_tp_user.o
 | 
				
			||||||
cpustat-objs := cpustat_user.o
 | 
					cpustat-objs := cpustat_user.o
 | 
				
			||||||
| 
						 | 
					@ -116,6 +115,7 @@ xdp_sample_pkts-objs := xdp_sample_pkts_user.o
 | 
				
			||||||
ibumad-objs := ibumad_user.o
 | 
					ibumad-objs := ibumad_user.o
 | 
				
			||||||
hbm-objs := hbm.o $(CGROUP_HELPERS)
 | 
					hbm-objs := hbm.o $(CGROUP_HELPERS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xdp_redirect_cpu-objs := xdp_redirect_cpu_user.o $(XDP_SAMPLE)
 | 
				
			||||||
xdp_redirect-objs := xdp_redirect_user.o $(XDP_SAMPLE)
 | 
					xdp_redirect-objs := xdp_redirect_user.o $(XDP_SAMPLE)
 | 
				
			||||||
xdp_monitor-objs := xdp_monitor_user.o $(XDP_SAMPLE)
 | 
					xdp_monitor-objs := xdp_monitor_user.o $(XDP_SAMPLE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -311,6 +311,7 @@ verify_target_bpf: verify_cmds
 | 
				
			||||||
$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
 | 
					$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
 | 
				
			||||||
$(src)/*.c: verify_target_bpf $(LIBBPF)
 | 
					$(src)/*.c: verify_target_bpf $(LIBBPF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(obj)/xdp_redirect_cpu_user.o: $(obj)/xdp_redirect_cpu.skel.h
 | 
				
			||||||
$(obj)/xdp_redirect_user.o: $(obj)/xdp_redirect.skel.h
 | 
					$(obj)/xdp_redirect_user.o: $(obj)/xdp_redirect.skel.h
 | 
				
			||||||
$(obj)/xdp_monitor_user.o: $(obj)/xdp_monitor.skel.h
 | 
					$(obj)/xdp_monitor_user.o: $(obj)/xdp_monitor.skel.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
		Reference in a new issue