Skip to content

Commit c3801dd

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 114ebf6 commit c3801dd

File tree

9 files changed

+25
-1
lines changed

9 files changed

+25
-1
lines changed

xdp-bench/README.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ Set egress program to load:
457457

458458
#+begin_src sh
459459
forward - Update the packet data so its source MAC address matches the one of the destination interface.
460+
drop - Drop packet.
460461
#+end_src
461462

462463
The default for this option is =forward=.
@@ -517,6 +518,7 @@ Set egress program to load:
517518

518519
#+begin_src sh
519520
forward - Update the packet data so its source MAC address matches the one of the destination interface.
521+
drop - Drop packet.
520522
#+end_src
521523

522524
The default for this option is =forward=.

xdp-bench/tests/test-xdp-bench.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ test_redirect_map_egress()
112112
if is_progmap_supported; then
113113
check_run $XDP_BENCH redirect-map btest0 btest1 -X -vv
114114
check_run $XDP_BENCH redirect-map btest0 btest1 -X -A forward -vv
115+
check_run $XDP_BENCH redirect-map btest0 btest1 -X -A drop -vv
115116
fi
116117
ip link del dev btest0
117118
}
@@ -140,6 +141,7 @@ test_redirect_multi_egress()
140141

141142
check_run $XDP_BENCH redirect-multi btest0 btest1 btest2 btest3 -X -vv
142143
check_run $XDP_BENCH redirect-multi btest0 btest1 btest2 btest3 -X -A forward -vv
144+
check_run $XDP_BENCH redirect-multi btest0 btest1 btest2 btest3 -X -A drop -vv
143145

144146
ip link del dev btest0
145147
ip link del dev btest2

xdp-bench/xdp-bench.8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "xdp-bench" "8" "NOVEMBER 19, 2024" "V1.5.8" "A simple XDP benchmarking tool"
1+
.TH "xdp-bench" "8" "DECEMBER 14, 2025" "V1.5.8" "A simple XDP benchmarking tool"
22
.SH "NAME"
33
XDP-bench \- a simple XDP benchmarking tool
44
.SH "SYNOPSIS"
@@ -522,6 +522,7 @@ Set egress program to load:
522522
.RS
523523
.nf
524524
\fCforward - Update the packet data so its source MAC address matches the one of the destination interface.
525+
drop - Drop packet.
525526
\fP
526527
.fi
527528
.RE
@@ -590,6 +591,7 @@ Set egress program to load:
590591
.RS
591592
.nf
592593
\fCforward - Update the packet data so its source MAC address matches the one of the destination interface.
594+
drop - Drop packet.
593595
\fP
594596
.fi
595597
.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)