* [PATCH iproute2-next] f_flower: Add l2_miss support
@ 2023-06-07 15:35 Ido Schimmel
2023-06-07 16:51 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Ido Schimmel @ 2023-06-07 15:35 UTC (permalink / raw)
To: netdev; +Cc: dsahern, stephen, jiri, razor, petrm, Ido Schimmel
Add the ability to match on packets that encountered a layer 2 miss in
bridge driver's FDB / MDB. Example:
# tc filter add dev swp2 egress pref 1 proto all flower indev swp1 l2_miss 1 action drop
# tc filter add dev swp2 egress pref 1 proto all flower indev swp1 l2_miss 0 action drop
# tc filter show dev swp2 egress
filter protocol all pref 1 flower chain 0
filter protocol all pref 1 flower chain 0 handle 0x1
indev swp1
l2_miss 1
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 1 ref 1 bind 1
filter protocol all pref 1 flower chain 0 handle 0x2
indev swp1
l2_miss 0
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 2 ref 1 bind 1
# tc -j -p filter show dev swp2 egress
[ {
"protocol": "all",
"pref": 1,
"kind": "flower",
"chain": 0
},{
"protocol": "all",
"pref": 1,
"kind": "flower",
"chain": 0,
"options": {
"handle": 1,
"indev": "swp1",
"keys": {
"l2_miss": 1
},
"not_in_hw": true,
"actions": [ {
[...]
} ]
}
},{
"protocol": "all",
"pref": 1,
"kind": "flower",
"chain": 0,
"options": {
"handle": 2,
"indev": "swp1",
"keys": {
"l2_miss": 0
},
"not_in_hw": true,
"actions": [ {
[...]
} ]
}
} ]
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Initially I used true / false instead of 1 / 0. If this patch is
accepted, I will adjust the kernel selftest accordingly.
---
man/man8/tc-flower.8 | 10 +++++++++-
tc/f_flower.c | 18 ++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/man/man8/tc-flower.8 b/man/man8/tc-flower.8
index fc73da93c5c3..cd99745065cf 100644
--- a/man/man8/tc-flower.8
+++ b/man/man8/tc-flower.8
@@ -100,7 +100,9 @@ flower \- flow based traffic control filter
}
.IR OPTIONS " | "
.BR ip_flags
-.IR IP_FLAGS " }"
+.IR IP_FLAGS " | "
+.B l2_miss
+.IR L2_MISS " }"
.ti -8
.IR LSE_LIST " := [ " LSE_LIST " ] " LSE
@@ -493,6 +495,12 @@ respectively. firstfrag and nofirstfrag can be used to further distinguish
fragmented packet. firstfrag can be used to indicate the first fragmented
packet. nofirstfrag can be used to indicates subsequent fragmented packets
or non-fragmented packets.
+.TP
+.BI l2_miss " L2_MISS"
+Match on layer 2 miss in the bridge driver's FDB / MDB. \fIL2_MISS\fR may be 0
+or 1. When 1, match on packets that encountered a layer 2 miss. When 0, match
+on packets that were forwarded using an FDB / MDB entry. Note that broadcast
+packets do not encounter a miss since a lookup is not performed for them.
.SH NOTES
As stated above where applicable, matches of a certain layer implicitly depend
on the matches of the next lower layer. Precisely, layer one and two matches
diff --git a/tc/f_flower.c b/tc/f_flower.c
index c73c46dd234b..f1a351fbaa03 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -91,6 +91,7 @@ static void explain(void)
" erspan_opts MASKED-OPTIONS |\n"
" gtp_opts MASKED-OPTIONS |\n"
" ip_flags IP-FLAGS |\n"
+ " l2_miss L2_MISS |\n"
" enc_dst_port [ port_number ] |\n"
" ct_state MASKED_CT_STATE |\n"
" ct_label MASKED_CT_LABEL |\n"
@@ -1520,6 +1521,15 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
fprintf(stderr, "Illegal \"ip_flags\"\n");
return -1;
}
+ } else if (strcmp(*argv, "l2_miss") == 0) {
+ __u8 l2_miss;
+
+ NEXT_ARG();
+ if (get_u8(&l2_miss, *argv, 10)) {
+ fprintf(stderr, "Illegal \"l2_miss\"\n");
+ return -1;
+ }
+ addattr8(n, MAX_MSG, TCA_FLOWER_L2_MISS, l2_miss);
} else if (matches(*argv, "verbose") == 0) {
flags |= TCA_CLS_FLAGS_VERBOSE;
} else if (matches(*argv, "skip_hw") == 0) {
@@ -2983,6 +2993,14 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
tb[TCA_FLOWER_KEY_FLAGS],
tb[TCA_FLOWER_KEY_FLAGS_MASK]);
+ if (tb[TCA_FLOWER_L2_MISS]) {
+ struct rtattr *attr = tb[TCA_FLOWER_L2_MISS];
+
+ print_nl();
+ print_uint(PRINT_ANY, "l2_miss", " l2_miss %d",
+ rta_getattr_u8(attr));
+ }
+
flower_print_ct_state(tb[TCA_FLOWER_KEY_CT_STATE],
tb[TCA_FLOWER_KEY_CT_STATE_MASK]);
flower_print_ct_zone(tb[TCA_FLOWER_KEY_CT_ZONE],
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2-next] f_flower: Add l2_miss support
2023-06-07 15:35 [PATCH iproute2-next] f_flower: Add l2_miss support Ido Schimmel
@ 2023-06-07 16:51 ` Stephen Hemminger
2023-06-09 21:50 ` David Ahern
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2023-06-07 16:51 UTC (permalink / raw)
To: Ido Schimmel; +Cc: netdev, dsahern, jiri, razor, petrm
On Wed, 7 Jun 2023 18:35:50 +0300
Ido Schimmel <idosch@nvidia.com> wrote:
> + print_uint(PRINT_ANY, "l2_miss", " l2_miss %d",
> + rta_getattr_u8(attr));
Use %u for unsigned?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2-next] f_flower: Add l2_miss support
2023-06-07 16:51 ` Stephen Hemminger
@ 2023-06-09 21:50 ` David Ahern
0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2023-06-09 21:50 UTC (permalink / raw)
To: Stephen Hemminger, Ido Schimmel; +Cc: netdev, jiri, razor, petrm
On 6/7/23 10:51 AM, Stephen Hemminger wrote:
> On Wed, 7 Jun 2023 18:35:50 +0300
> Ido Schimmel <idosch@nvidia.com> wrote:
>
>> + print_uint(PRINT_ANY, "l2_miss", " l2_miss %d",
>> + rta_getattr_u8(attr));
>
> Use %u for unsigned?
fixed up and applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-09 21:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07 15:35 [PATCH iproute2-next] f_flower: Add l2_miss support Ido Schimmel
2023-06-07 16:51 ` Stephen Hemminger
2023-06-09 21:50 ` David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).