-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xdp-forward: Add the capability to load xdp_fwd_flowtable sample from…
… userspace Introduce the capability to load xdp-fw-flowtable sample to offload in xdp the processing of sw netfilter flowtable. Signed-off-by: Lorenzo Bianconi <[email protected]>
- Loading branch information
1 parent
9db1ee6
commit 7881bee
Showing
5 changed files
with
164 additions
and
18 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
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,37 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Original xdp_fwd sample Copyright (c) 2017-18 David Ahern <[email protected]> | ||
*/ | ||
|
||
#include <bpf/vmlinux.h> | ||
#include <linux/bpf.h> | ||
#include <linux/netfilter.h> | ||
#include <bpf/bpf_core_read.h> | ||
|
||
#define AF_INET 2 | ||
|
||
struct bpf_flowtable_opts { | ||
__s32 error; | ||
}; | ||
|
||
struct flow_offload_tuple_rhash * | ||
bpf_xdp_flow_lookup(struct xdp_md *, struct bpf_fib_lookup *, | ||
struct bpf_flowtable_opts *, __u32) __ksym; | ||
|
||
SEC("xdp") | ||
int xdp_fwd_flowtable_sample(struct xdp_md *ctx) | ||
{ | ||
struct flow_offload_tuple_rhash *tuplehash; | ||
struct bpf_flowtable_opts opts = {}; | ||
struct bpf_fib_lookup tuple = { | ||
.family = AF_INET, | ||
.ifindex = ctx->ingress_ifindex, | ||
}; | ||
|
||
tuplehash = bpf_xdp_flow_lookup(ctx, &tuple, &opts, sizeof(opts)); | ||
if (!tuplehash) | ||
return XDP_DROP; | ||
|
||
return XDP_PASS; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |