* [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class
@ 2020-04-03 23:05 Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield Petr Machata
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Petr Machata @ 2020-04-03 23:05 UTC (permalink / raw)
To: netdev; +Cc: Petr Machata, Stephen Hemminger, David Ahern
The pedit action supports tos (and its synonyms, such as dsfield) for IPv4,
but not the corresponding IPv6 field, traffic_class. Patch #1 of this
series adds this IPv6 support. Patch #2 then adds two related examples to
man page, and patch #3 removes from the man page a claim that the extended
notation is only available for IPv4.
v2:
- Patch #1:
- Only accept 'traffic_class'.
- Move the if-branch that matches it to the end of the list.
- man: Drop the untrue statement that the traffic_class field needs
to be sandwiched between two 4-bit zeroes.
Petr Machata (3):
tc: p_ip6: Support pedit of IPv6 dsfield
man: tc-pedit: Add examples for dsfield and retain
man: tc-pedit: Drop the claim that pedit ex is only for IPv4
man/man8/tc-pedit.8 | 31 +++++++++++++++++++++++++++----
tc/p_ip6.c | 15 +++++++++++++++
2 files changed, 42 insertions(+), 4 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield
2020-04-03 23:05 [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class Petr Machata
@ 2020-04-03 23:05 ` Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 2/3] man: tc-pedit: Add examples for dsfield and retain Petr Machata
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2020-04-03 23:05 UTC (permalink / raw)
To: netdev; +Cc: Petr Machata, Stephen Hemminger, David Ahern
Support keywords dsfield, traffic_class and tos in the IPv6 context.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
Notes:
v2:
- Only accept 'traffic_class'.
- Move the if-branch that matches it to the end of the list.
- man: Drop the untrue statement that the traffic_class field needs
to be sandwiched between two 4-bit zeroes.
man/man8/tc-pedit.8 | 6 ++++--
tc/p_ip6.c | 15 +++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8
index bbd725c4..3f6baa3d 100644
--- a/man/man8/tc-pedit.8
+++ b/man/man8/tc-pedit.8
@@ -60,8 +60,8 @@ pedit - generic packet editor action
.ti -8
.IR IP6HDR_FIELD " := { "
-.BR src " | " dst " | " flow_lbl " | " payload_len " | " nexthdr " |"
-.BR hoplimit " }"
+.BR src " | " dst " | " traffic_class " | " flow_lbl " | " payload_len " | "
+.BR nexthdr " | " hoplimit " }"
.ti -8
.IR TCPHDR_FIELD " := { "
@@ -229,6 +229,8 @@ are:
.TQ
.B dst
.TQ
+.B traffic_class
+.TQ
.B flow_lbl
.TQ
.B payload_len
diff --git a/tc/p_ip6.c b/tc/p_ip6.c
index 7cc7997b..71660c61 100644
--- a/tc/p_ip6.c
+++ b/tc/p_ip6.c
@@ -74,6 +74,21 @@ parse_ip6(int *argc_p, char ***argv_p,
res = parse_cmd(&argc, &argv, 1, TU32, RU8, sel, tkey);
goto done;
}
+ if (strcmp(*argv, "traffic_class") == 0) {
+ NEXT_ARG();
+ tkey->off = 1;
+ res = parse_cmd(&argc, &argv, 1, TU32, RU8, sel, tkey);
+
+ /* Shift the field by 4 bits on success. */
+ if (!res) {
+ int nkeys = sel->sel.nkeys;
+ struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1];
+
+ key->mask = htonl(ntohl(key->mask) << 4 | 0xf);
+ key->val = htonl(ntohl(key->val) << 4);
+ }
+ goto done;
+ }
return -1;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2-next v2 2/3] man: tc-pedit: Add examples for dsfield and retain
2020-04-03 23:05 [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield Petr Machata
@ 2020-04-03 23:05 ` Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 3/3] man: tc-pedit: Drop the claim that pedit ex is only for IPv4 Petr Machata
2020-04-09 14:41 ` [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class David Ahern
3 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2020-04-03 23:05 UTC (permalink / raw)
To: netdev; +Cc: Petr Machata, Stephen Hemminger, David Ahern
Describe a way to update just the DSCP and just the ECN part of the
dsfield. That is useful on its own, but also it shows how retain works.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
man/man8/tc-pedit.8 | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8
index 3f6baa3d..d2b37ef0 100644
--- a/man/man8/tc-pedit.8
+++ b/man/man8/tc-pedit.8
@@ -369,6 +369,28 @@ tc filter add dev eth0 parent ffff: u32 \\
action pedit ex munge tcp dport set 22
.EE
.RE
+
+To rewrite just part of a field, use the
+.B retain
+directive. E.g. to overwrite the DSCP part of a dsfield with $DSCP, without
+touching ECN:
+
+.RS
+.EX
+tc filter add dev eth0 ingress flower ... \\
+ action pedit ex munge ip dsfield set $((DSCP << 2)) retain 0xfc
+.EE
+.RE
+
+And vice versa, to set ECN to e.g. 1 without impacting DSCP:
+
+.RS
+.EX
+tc filter add dev eth0 ingress flower ... \\
+ action pedit ex munge ip dsfield set 1 retain 0x3
+.EE
+.RE
+
.SH SEE ALSO
.BR tc (8),
.BR tc-htb (8),
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2-next v2 3/3] man: tc-pedit: Drop the claim that pedit ex is only for IPv4
2020-04-03 23:05 [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 2/3] man: tc-pedit: Add examples for dsfield and retain Petr Machata
@ 2020-04-03 23:05 ` Petr Machata
2020-04-09 14:41 ` [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class David Ahern
3 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2020-04-03 23:05 UTC (permalink / raw)
To: netdev; +Cc: Petr Machata, Stephen Hemminger, David Ahern, Ido Schimmel
This sentence predates addition of extended pedit for IPv6 packets.
Reported-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
man/man8/tc-pedit.8 | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8
index d2b37ef0..376ad4a8 100644
--- a/man/man8/tc-pedit.8
+++ b/man/man8/tc-pedit.8
@@ -90,8 +90,7 @@ action can be used to change arbitrary packet data. The location of data to
change can either be specified by giving an offset and size as in
.IR RAW_OP ,
or for header values by naming the header and field to edit the size is then
-chosen automatically based on the header field size. Currently this is supported
-only for IPv4 headers.
+chosen automatically based on the header field size.
.SH OPTIONS
.TP
.B ex
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class
2020-04-03 23:05 [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class Petr Machata
` (2 preceding siblings ...)
2020-04-03 23:05 ` [PATCH iproute2-next v2 3/3] man: tc-pedit: Drop the claim that pedit ex is only for IPv4 Petr Machata
@ 2020-04-09 14:41 ` David Ahern
3 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2020-04-09 14:41 UTC (permalink / raw)
To: Petr Machata, netdev; +Cc: Stephen Hemminger
On 4/3/20 5:05 PM, Petr Machata wrote:
> The pedit action supports tos (and its synonyms, such as dsfield) for IPv4,
> but not the corresponding IPv6 field, traffic_class. Patch #1 of this
> series adds this IPv6 support. Patch #2 then adds two related examples to
> man page, and patch #3 removes from the man page a claim that the extended
> notation is only available for IPv4.
>
applied to iproute2-next. Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-09 14:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-03 23:05 [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 1/3] tc: p_ip6: Support pedit of IPv6 dsfield Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 2/3] man: tc-pedit: Add examples for dsfield and retain Petr Machata
2020-04-03 23:05 ` [PATCH iproute2-next v2 3/3] man: tc-pedit: Drop the claim that pedit ex is only for IPv4 Petr Machata
2020-04-09 14:41 ` [PATCH iproute2-next v2 0/3] Support pedit of ip6 traffic_class 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).