OpenCloudOS-Kernel/include/uapi/linux/tc_act
Peilin Ye 56af5e749f net/sched: act_skbmod: Add SKBMOD_F_ECN option support
Currently, when doing rate limiting using the tc-police(8) action, the
easiest way is to simply drop the packets which exceed or conform the
configured bandwidth limit.  Add a new option to tc-skbmod(8), so that
users may use the ECN [1] extension to explicitly inform the receiver
about the congestion instead of dropping packets "on the floor".

The 2 least significant bits of the Traffic Class field in IPv4 and IPv6
headers are used to represent different ECN states [2]:

	0b00: "Non ECN-Capable Transport", Non-ECT
	0b10: "ECN Capable Transport", ECT(0)
	0b01: "ECN Capable Transport", ECT(1)
	0b11: "Congestion Encountered", CE

As an example:

	$ tc filter add dev eth0 parent 1: protocol ip prio 10 \
		matchall action skbmod ecn

Doing the above marks all ECT(0) and ECT(1) packets as CE.  It does NOT
affect Non-ECT or non-IP packets.  In the tc-police scenario mentioned
above, users may pipe a tc-police action and a tc-skbmod "ecn" action
together to achieve ECN-based rate limiting.

For TCP connections, upon receiving a CE packet, the receiver will respond
with an ECE packet, asking the sender to reduce their congestion window.
However ECN also works with other L4 protocols e.g. DCCP and SCTP [2], and
our implementation does not touch or care about L4 headers.

The updated tc-skbmod SYNOPSIS looks like the following:

	tc ... action skbmod { set SETTABLE | swap SWAPPABLE | ecn } ...

Only one of "set", "swap" or "ecn" shall be used in a single tc-skbmod
command.  Trying to use more than one of them at a time is considered
undefined behavior; pipe multiple tc-skbmod commands together instead.
"set" and "swap" only affect Ethernet packets, while "ecn" only affects
IPv{4,6} packets.

It is also worth mentioning that, in theory, the same effect could be
achieved by piping a "police" action and a "bpf" action using the
bpf_skb_ecn_set_ce() helper, but this requires eBPF programming from the
user, thus impractical.

Depends on patch "net/sched: act_skbmod: Skip non-Ethernet packets".

[1] https://datatracker.ietf.org/doc/html/rfc3168
[2] https://en.wikipedia.org/wiki/Explicit_Congestion_Notification

Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-28 13:19:31 +01:00
..
tc_bpf.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_connmark.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_csum.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_ct.h net/sched: Introduce action ct 2019-07-09 12:11:59 -07:00
tc_ctinfo.h net: sched: act_ctinfo: tidy UAPI definition 2019-06-19 17:11:01 -04:00
tc_defact.h License cleanup: add SPDX license identifier to uapi header files with no license 2017-11-02 11:19:54 +01:00
tc_gact.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_gate.h net: qos: introduce a gate control flow action 2020-05-01 16:08:19 -07:00
tc_ife.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_ipt.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_mirred.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_mpls.h net/sched: act_mpls: Add action to push MPLS LSE before Ethernet header 2020-10-03 17:28:45 -07:00
tc_nat.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_pedit.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_sample.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_skbedit.h net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
tc_skbmod.h net/sched: act_skbmod: Add SKBMOD_F_ECN option support 2021-07-28 13:19:31 +01:00
tc_tunnel_key.h net: sched: add erspan option support to act_tunnel_key 2019-11-21 11:44:06 -08:00
tc_vlan.h net/sched: act_vlan: Add {POP,PUSH}_ETH actions 2020-10-03 17:28:45 -07:00