tc/pedit: p_ip: introduce editing ttl header
Enable user to edit IP header ttl field.
For example, to forward any TCP packet and decrease its TTL by one:
$ tc filter add dev enp0s9 protocol ip parent ffff: \
flower \
ip_proto tcp \
action pedit ex munge \
ip ttl add 0xff pipe \
action mirred egress \
redirect dev veth0
Signed-off-by: Amir Vadai <amir@vadai.me>
This commit is contained in:
parent
c05ddaf9e0
commit
8d193d9607
|
|
@ -28,6 +28,8 @@ pedit - generic packet editor action
|
||||||
.ti -8
|
.ti -8
|
||||||
.IR EXTENDED_LAYERED_OP " := { "
|
.IR EXTENDED_LAYERED_OP " := { "
|
||||||
.BI ip " IPHDR_FIELD"
|
.BI ip " IPHDR_FIELD"
|
||||||
|
|
|
||||||
|
.BI ip " EX_IPHDR_FIELD"
|
||||||
.RI } " CMD_SPEC"
|
.RI } " CMD_SPEC"
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
|
|
@ -39,6 +41,10 @@ pedit - generic packet editor action
|
||||||
.IR BEYOND_IPHDR_FIELD " := { "
|
.IR BEYOND_IPHDR_FIELD " := { "
|
||||||
.BR dport " | " sport " | " icmp_type " | " icmp_code " }"
|
.BR dport " | " sport " | " icmp_type " | " icmp_code " }"
|
||||||
|
|
||||||
|
.ti -8
|
||||||
|
.IR EX_IPHDR_FIELD " := { "
|
||||||
|
.BR ttl " }"
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
.IR CMD_SPEC " := {"
|
.IR CMD_SPEC " := {"
|
||||||
.BR clear " | " invert " | " set
|
.BR clear " | " invert " | " set
|
||||||
|
|
@ -161,6 +167,17 @@ If it is not or the latter is bigger than the minimum of 20 bytes, this will do
|
||||||
unexpected things. These fields are eight-bit values.
|
unexpected things. These fields are eight-bit values.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
.BI ip " EX_IPHDR_FIELD"
|
||||||
|
Supported only when
|
||||||
|
.I ex
|
||||||
|
is used. The supported keywords for
|
||||||
|
.I EX_IPHDR_FIELD
|
||||||
|
are:
|
||||||
|
.RS
|
||||||
|
.TP
|
||||||
|
.B ttl
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
.B clear
|
.B clear
|
||||||
Clear the addressed data (i.e., set it to zero).
|
Clear the addressed data (i.e., set it to zero).
|
||||||
.TP
|
.TP
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,12 @@ parse_ip(int *argc_p, char ***argv_p,
|
||||||
res = parse_cmd(&argc, &argv, 1, TU32, 0x0f, sel, tkey);
|
res = parse_cmd(&argc, &argv, 1, TU32, 0x0f, sel, tkey);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (strcmp(*argv, "ttl") == 0) {
|
||||||
|
NEXT_ARG();
|
||||||
|
tkey->off = 8;
|
||||||
|
res = parse_cmd(&argc, &argv, 1, TU32, RU8, sel, tkey);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if (strcmp(*argv, "protocol") == 0) {
|
if (strcmp(*argv, "protocol") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
tkey->off = 9;
|
tkey->off = 9;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue