1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Isovalent, Inc.
4 #include <bpf/bpf_helpers.h>
7 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
8 __uint(max_entries
, 2);
11 } sock_map
SEC(".maps");
14 __uint(type
, BPF_MAP_TYPE_SOCKHASH
);
15 __uint(max_entries
, 2);
18 } sock_hash
SEC(".maps");
21 __uint(type
, BPF_MAP_TYPE_SK_STORAGE
);
22 __uint(map_flags
, BPF_F_NO_PREALLOC
);
25 } socket_storage
SEC(".maps");
28 int prog_msg_verdict(struct sk_msg_md
*msg
)
30 struct task_struct
*task
= (struct task_struct
*)bpf_get_current_task();
31 int verdict
= SK_PASS
;
35 pid
= bpf_get_current_pid_tgid() >> 32;
36 sk_stg
= bpf_sk_storage_get(&socket_storage
, msg
->sk
, 0, BPF_SK_STORAGE_GET_F_CREATE
);
40 bpf_probe_read_kernel(&tpid
, sizeof(tpid
), &task
->tgid
);
43 bpf_sk_storage_delete(&socket_storage
, (void *)msg
->sk
);
47 char _license
[] SEC("license") = "GPL";