Support pedit of ip6 traffic_class
Subsystems (2)
v2 cover Support pedit of ip6 traffic_class
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(-)
Signature · 1 line
2.20.1
PATCH v2 1/3 tc: p_ip6: Support pedit of IPv6 dsfield
Support keywords dsfield, traffic_class and tos in the IPv6 context.
---
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(-)
man/man8/tc-pedit.8 +4 -2
@@ -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
tc/p_ip6.c +15 -0
@@ -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 ;
Signature · 1 line
2.20.1
PATCH v2 2/3 man: tc-pedit: Add examples for dsfield and retain
In reply to Petr MachataDescribe 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.
--- man/man8/tc-pedit.8 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
man/man8/tc-pedit.8 +22 -0
@@ -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),
Signature · 1 line
2.20.1
PATCH v2 3/3 man: tc-pedit: Drop the claim that pedit ex is only for IPv4
In reply to Petr MachataThis sentence predates addition of extended pedit for IPv6 packets.
--- man/man8/tc-pedit.8 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
man/man8/tc-pedit.8 +1 -2
@@ -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
Signature · 1 line
2.20.1
David Ahern
AppliedQuoted 6 lines · Petr Machata
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