-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to exercise the bpf_prog/map id generation, bpf_(prog|map)_get_next_id(), bpf_(prog|map)_get_fd_by_id() and bpf_get_obj_info_by_fd(). Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Alexei Starovoitov <ast@fb.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Martin KaFai Lau
authored and
David S. Miller
committed
Jun 6, 2017
1 parent
1e27097
commit 95b9afd
Showing
6 changed files
with
341 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Copyright (c) 2017 Facebook | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of version 2 of the GNU General Public | ||
* License as published by the Free Software Foundation. | ||
*/ | ||
#include <stddef.h> | ||
#include <linux/bpf.h> | ||
#include <linux/pkt_cls.h> | ||
#include "bpf_helpers.h" | ||
|
||
/* It is a dumb bpf program such that it must have no | ||
* issue to be loaded since testing the verifier is | ||
* not the focus here. | ||
*/ | ||
|
||
int _version SEC("version") = 1; | ||
|
||
struct bpf_map_def SEC("maps") test_map_id = { | ||
.type = BPF_MAP_TYPE_ARRAY, | ||
.key_size = sizeof(__u32), | ||
.value_size = sizeof(__u64), | ||
.max_entries = 1, | ||
}; | ||
|
||
SEC("test_prog_id") | ||
int test_prog_id(struct __sk_buff *skb) | ||
{ | ||
__u32 key = 0; | ||
__u64 *value; | ||
|
||
value = bpf_map_lookup_elem(&test_map_id, &key); | ||
|
||
return TC_ACT_OK; | ||
} |
Oops, something went wrong.