Skip to content

Commit f4d3368

Browse files
committed
xdp-bench: Add drop mode for egress action
Simple XDP_DROP program as egress action. Signed-off-by: Dragos Tatulea <[email protected]>
1 parent ba5c3bd commit f4d3368

File tree

7 files changed

+20
-0
lines changed

7 files changed

+20
-0
lines changed

xdp-bench/xdp-bench.8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ Set egress program to load:
523523
.RS
524524
.nf
525525
\fCforward - Update the packet data so its source MAC address matches the one of the destination interface.
526+
drop - Drop packet.
526527
\fP
527528
.fi
528529
.RE
@@ -593,6 +594,7 @@ Set egress program to load:
593594
.RS
594595
.nf
595596
\fCforward - Update the packet data so its source MAC address matches the one of the destination interface.
597+
drop - Drop packet.
596598
\fP
597599
.fi
598600
.RE

xdp-bench/xdp-bench.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct enum_val cpumap_program_modes[] = {
7070

7171
struct enum_val devmap_egress_actions[] = {
7272
{"forward", DEVMAP_EGRESS_FORWARD },
73+
{"drop", DEVMAP_EGRESS_DROP },
7374
{NULL, 0}
7475
};
7576

xdp-bench/xdp-bench.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct redirect_opts {
5151
enum devmap_egress_action {
5252
DEVMAP_EGRESS_NONE,
5353
DEVMAP_EGRESS_FORWARD,
54+
DEVMAP_EGRESS_DROP,
5455
};
5556

5657
struct devmap_opts {

xdp-bench/xdp_redirect_devmap.bpf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,10 @@ int xdp_redirect_devmap_egress(struct xdp_md *ctx)
8585
return XDP_PASS;
8686
}
8787

88+
SEC("xdp/devmap")
89+
int xdp_redirect_devmap_egress_drop(struct xdp_md *ctx)
90+
{
91+
return XDP_DROP;
92+
}
93+
8894
char _license[] SEC("license") = "GPL";

xdp-bench/xdp_redirect_devmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static struct bpf_program *egress_prog(struct xdp_redirect_devmap *skel,
3737
enum devmap_egress_action action)
3838
{
3939
switch (action) {
40+
case DEVMAP_EGRESS_DROP:
41+
return skel->progs.xdp_redirect_devmap_egress_drop;
4042
case DEVMAP_EGRESS_NONE:
4143
case DEVMAP_EGRESS_FORWARD:
4244
default:

xdp-bench/xdp_redirect_devmap_multi.bpf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,10 @@ int xdp_devmap_prog(struct xdp_md *ctx)
7474
return XDP_PASS;
7575
}
7676

77+
SEC("xdp/devmap")
78+
int xdp_redirect_devmap_egress_drop(struct xdp_md *ctx)
79+
{
80+
return XDP_DROP;
81+
}
82+
7783
char _license[] SEC("license") = "GPL";

xdp-bench/xdp_redirect_devmap_multi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ egress_prog_multi(struct xdp_redirect_devmap_multi *skel,
7272
enum devmap_egress_action action)
7373
{
7474
switch (action) {
75+
case DEVMAP_EGRESS_DROP:
76+
return skel->progs.xdp_redirect_devmap_egress_drop;
7577
case DEVMAP_EGRESS_NONE:
7678
case DEVMAP_EGRESS_FORWARD:
7779
default:

0 commit comments

Comments
 (0)