Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / bpf / test_obj_id.c
blob880d2963b4725192b6243200a9d81e0fe56329ab
1 /* Copyright (c) 2017 Facebook
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
6 */
7 #include <stddef.h>
8 #include <linux/bpf.h>
9 #include <linux/pkt_cls.h>
10 #include "bpf_helpers.h"
12 /* It is a dumb bpf program such that it must have no
13 * issue to be loaded since testing the verifier is
14 * not the focus here.
17 int _version SEC("version") = 1;
19 struct bpf_map_def SEC("maps") test_map_id = {
20 .type = BPF_MAP_TYPE_ARRAY,
21 .key_size = sizeof(__u32),
22 .value_size = sizeof(__u64),
23 .max_entries = 1,
26 SEC("test_obj_id_dummy")
27 int test_obj_id(struct __sk_buff *skb)
29 __u32 key = 0;
30 __u64 *value;
32 value = bpf_map_lookup_elem(&test_map_id, &key);
34 return TC_ACT_OK;