1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <vmlinux.h> 4 #include <bpf/bpf_helpers.h> 5 #include "bpf_misc.h" 6 #include "bpf_kfuncs.h" 7 8 char _license[] SEC("license") = "GPL"; 9 10 /* 11 * The __szk size of a kfunc memory/size pair must be marked precise even when 12 * the nullable buffer is passed as NULL. 13 */ 14 SEC("?tc") 15 __success __log_level(2) 16 __msg("mark_precise: frame0: regs=r4 stack= before") dynptr_slice_null_buf_size_precise(struct __sk_buff * skb)17int dynptr_slice_null_buf_size_precise(struct __sk_buff *skb) 18 { 19 struct bpf_dynptr dptr; 20 char *p; 21 22 bpf_dynptr_from_skb(skb, 0, &dptr); 23 24 p = bpf_dynptr_slice(&dptr, 0, NULL, 8); 25 if (p) 26 return p[0]; 27 return 0; 28 } 29