-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for tc root chaining enhancements
Signed-off-by: Santhosh Fernandes <[email protected]>
- Loading branch information
Showing
5 changed files
with
197 additions
and
545 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
// Copyright Contributors to the L3AF Project. | ||
// SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | ||
|
||
#define KBUILD_MODNAME "foo" | ||
|
||
#include <uapi/linux/bpf.h> | ||
#include "bpf_helpers.h" | ||
#include "tc_root_common.h" | ||
|
||
struct bpf_elf_map SEC("maps") tc_egress_root_pass_array = { | ||
.type = BPF_MAP_TYPE_PROG_ARRAY, | ||
.size_key = sizeof(int), | ||
.size_value = sizeof(int), | ||
.pinning = PIN_GLOBAL_NS, | ||
.max_elem = ROOT_ARRAY_SIZE, | ||
}; | ||
struct { | ||
__uint(type, BPF_MAP_TYPE_PROG_ARRAY); | ||
__type(key, int); | ||
__type(value, int); | ||
__uint(max_entries, ROOT_ARRAY_SIZE); | ||
} tc_egress_root_array SEC(".maps"); | ||
|
||
struct bpf_elf_map SEC("maps") tc_egress_root_array = { | ||
.type = BPF_MAP_TYPE_PROG_ARRAY, | ||
.size_key = sizeof(int), | ||
.size_value = sizeof(int), | ||
.pinning = PIN_GLOBAL_NS, | ||
.max_elem = ROOT_ARRAY_SIZE, | ||
}; | ||
|
||
SEC("tc-egress-root") | ||
int tc_egress_root(struct __sk_buff *skb) { | ||
bpf_tail_call(skb, &tc_egress_root_pass_array, 0); | ||
return TC_ACT_OK; | ||
} | ||
|
||
SEC("tc-egress-pass-through") | ||
int tc_egress_pass_through(struct __sk_buff *skb) { | ||
bpf_tail_call(skb, &tc_egress_root_array, 0); | ||
return TC_ACT_OK; | ||
bpf_tail_call(skb, &tc_egress_root_array, 0); | ||
return TC_ACT_OK; | ||
} | ||
|
||
char _license[] SEC("license") = "Dual BSD/GPL"; |
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 |
---|---|---|
@@ -1,36 +1,30 @@ | ||
// Copyright Contributors to the L3AF Project. | ||
// SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | ||
|
||
#define KBUILD_MODNAME "foo" | ||
|
||
#include <uapi/linux/bpf.h> | ||
#include "bpf_helpers.h" | ||
#include "tc_root_common.h" | ||
|
||
struct bpf_elf_map SEC("maps") tc_ingress_root_pass_array = { | ||
.type = BPF_MAP_TYPE_PROG_ARRAY, | ||
.size_key = sizeof(int), | ||
.size_value = sizeof(int), | ||
.pinning = PIN_GLOBAL_NS, | ||
.max_elem = ROOT_ARRAY_SIZE, | ||
}; | ||
|
||
struct bpf_elf_map SEC("maps") tc_ingress_root_array = { | ||
.type = BPF_MAP_TYPE_PROG_ARRAY, | ||
.size_key = sizeof(int), | ||
.size_value = sizeof(int), | ||
.pinning = PIN_GLOBAL_NS, | ||
.max_elem = ROOT_ARRAY_SIZE, | ||
}; | ||
|
||
#define bpf_printk(fmt, ...) \ | ||
({ \ | ||
char ____fmt[] = fmt; \ | ||
bpf_trace_printk(____fmt, sizeof(____fmt), \ | ||
##__VA_ARGS__); \ | ||
}) | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_PROG_ARRAY); | ||
__type(key, int); | ||
__type(value, int); | ||
__uint(max_entries, ROOT_ARRAY_SIZE); | ||
} tc_ingress_root_array SEC(".maps"); | ||
|
||
SEC("tc-ingress-root") | ||
int tc_ingress_root(struct __sk_buff *skb) { | ||
bpf_tail_call(skb, &tc_ingress_root_pass_array, 0); | ||
return TC_ACT_OK; | ||
bpf_tail_call(skb, &tc_ingress_root_array, 0); | ||
return TC_ACT_OK; | ||
} | ||
|
||
SEC("tc-ingress-pass-through") | ||
int tc_ingress_pass_through(struct __sk_buff *skb) { | ||
bpf_tail_call(skb, &tc_ingress_root_array, 0); | ||
return TC_ACT_OK; | ||
} | ||
|
||
char _license[] SEC("license") = "Dual BSD/GPL"; |
Oops, something went wrong.