Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
 1// SPDX-License-Identifier: GPL-2.0
 2/* Copyright (c) 2024 Meta Platforms, Inc */
 3#include <vmlinux.h>
 4#include <bpf/bpf_helpers.h>
 5#include "bpf_misc.h"
 6#include "bpf_kfuncs.h"
 7#include "../bpf_testmod/bpf_testmod_kfunc.h"
 8
 9SEC("tc")
10int kfunc_dynptr_nullable_test1(struct __sk_buff *skb)
11{
12	struct bpf_dynptr data;
13
14	bpf_dynptr_from_skb(skb, 0, &data);
15	bpf_kfunc_dynptr_test(&data, NULL);
16
17	return 0;
18}
19
20SEC("tc")
21int kfunc_dynptr_nullable_test2(struct __sk_buff *skb)
22{
23	struct bpf_dynptr data;
24
25	bpf_dynptr_from_skb(skb, 0, &data);
26	bpf_kfunc_dynptr_test(&data, &data);
27
28	return 0;
29}
30
31SEC("tc")
32__failure __msg("expected pointer to stack or const struct bpf_dynptr")
33int kfunc_dynptr_nullable_test3(struct __sk_buff *skb)
34{
35	struct bpf_dynptr data;
36
37	bpf_dynptr_from_skb(skb, 0, &data);
38	bpf_kfunc_dynptr_test(NULL, &data);
39
40	return 0;
41}
42
43char _license[] SEC("license") = "GPL";