Re: [PATCH v1 bpf-next 1/8] selftests/bpf: Introduce sock_addr_testmod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/29/24 12:18 PM, Jordan Rife wrote:
+static int do_sock_op(int op, struct sockaddr *addr, int addrlen)

This function can be made as a new kfunc in bpf_testmod.c. The sock_create_kern() could be moved to here also. Take a look at the register_btf_kfunc_id_set() usage in bpf_testmod.c and how those registered kfunc(s) can be called by the bpf prog in progs/*.

If the do_kernel_{bind,connect,sendmsg} and the sock_create_kern need a sleepable context, it will need to mark the kfunc KF_SLEEPABLE. The kfunc can be registered to the BPF_PROG_TYPE_SYSCALL sleepable prog type. There are some examples in progs/kfunc_call_test.c and how the "syscall" bpf prog can be run by bpf_prog_test_run_opts().

The result (e.g. ensuring the addr and addrlen have not been changed) can be checked in the bpf prog itself. Then the new sock_addr_testmod is not needed.

+{
+	switch (op) {
+	case BIND:
+		return do_kernel_bind(addr, addrlen);
+	case CONNECT:
+		return do_kernel_connect(addr, addrlen);
+	case SENDMSG:
+		return do_kernel_sendmsg(addr, addrlen);
+	default:
+		return -EINVAL;
+	}
+}
+





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux