File Index
Files and directories
Sign in
FILE

cg_storage_multi_egress_only.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/bpf/progs/cg_storage_multi_egress_only.c C
 1// SPDX-License-Identifier: GPL-2.0-only
 2
 3/*
 4 * Copyright 2020 Google LLC.
 5 */
 6
 7#include <errno.h>
 8#include <linux/bpf.h>
 9#include <linux/ip.h>
10#include <linux/udp.h>
11#include <bpf/bpf_helpers.h>
12
13#include "progs/cg_storage_multi.h"
14
15struct {
16	__uint(type, BPF_MAP_TYPE_CGROUP_STORAGE);
17	__type(key, struct bpf_cgroup_storage_key);
18	__type(value, struct cgroup_value);
19} cgroup_storage SEC(".maps");
20
21__u32 invocations = 0;
22
23SEC("cgroup_skb/egress")
24int egress(struct __sk_buff *skb)
25{
26	struct cgroup_value *ptr_cg_storage =
27		bpf_get_local_storage(&cgroup_storage, 0);
28
29	__sync_fetch_and_add(&ptr_cg_storage->egress_pkts, 1);
30	__sync_fetch_and_add(&invocations, 1);
31
32	return 1;
33}
~/ Read-only file preview.