linux/net/sched
Kevin 'ldir' Darbyshire-Bryant 24ec483cec net: sched: Introduce act_ctinfo action
ctinfo is a new tc filter action module.  It is designed to restore
information contained in firewall conntrack marks to other packet fields
and is typically used on packet ingress paths.  At present it has two
independent sub-functions or operating modes, DSCP restoration mode &
skb mark restoration mode.

The DSCP restore mode:

This mode copies DSCP values that have been placed in the firewall
conntrack mark back into the IPv4/v6 diffserv fields of relevant
packets.

The DSCP restoration is intended for use and has been found useful for
restoring ingress classifications based on egress classifications across
links that bleach or otherwise change DSCP, typically home ISP Internet
links.  Restoring DSCP on ingress on the WAN link allows qdiscs such as
but by no means limited to CAKE to shape inbound packets according to
policies that are easier to set & mark on egress.

Ingress classification is traditionally a challenging task since
iptables rules haven't yet run and tc filter/eBPF programs are pre-NAT
lookups, hence are unable to see internal IPv4 addresses as used on the
typical home masquerading gateway.  Thus marking the connection in some
manner on egress for later restoration of classification on ingress is
easier to implement.

Parameters related to DSCP restore mode:

dscpmask - a 32 bit mask of 6 contiguous bits and indicate bits of the
conntrack mark field contain the DSCP value to be restored.

statemask - a 32 bit mask of (usually) 1 bit length, outside the area
specified by dscpmask.  This represents a conditional operation flag
whereby the DSCP is only restored if the flag is set.  This is useful to
implement a 'one shot' iptables based classification where the
'complicated' iptables rules are only run once to classify the
connection on initial (egress) packet and subsequent packets are all
marked/restored with the same DSCP.  A mask of zero disables the
conditional behaviour ie. the conntrack mark DSCP bits are always
restored to the ip diffserv field (assuming the conntrack entry is found
& the skb is an ipv4/ipv6 type)

e.g. dscpmask 0xfc000000 statemask 0x01000000

|----0xFC----conntrack mark----000000---|
| Bits 31-26 | bit 25 | bit24 |~~~ Bit 0|
| DSCP       | unused | flag  |unused   |
|-----------------------0x01---000000---|
      |                   |
      |                   |
      ---|             Conditional flag
         v             only restore if set
|-ip diffserv-|
| 6 bits      |
|-------------|

The skb mark restore mode (cpmark):

This mode copies the firewall conntrack mark to the skb's mark field.
It is completely the functional equivalent of the existing act_connmark
action with the additional feature of being able to apply a mask to the
restored value.

Parameters related to skb mark restore mode:

mask - a 32 bit mask applied to the firewall conntrack mark to mask out
bits unwanted for restoration.  This can be useful where the conntrack
mark is being used for different purposes by different applications.  If
not specified and by default the whole mark field is copied (i.e.
default mask of 0xffffffff)

e.g. mask 0x00ffffff to mask out the top 8 bits being used by the
aforementioned DSCP restore mode.

|----0x00----conntrack mark----ffffff---|
| Bits 31-24 |                          |
| DSCP & flag|      some value here     |
|---------------------------------------|
			|
			|
			v
|------------skb mark-------------------|
|            |                          |
|  zeroed    |                          |
|---------------------------------------|

Overall parameters:

zone - conntrack zone

control - action related control (reclassify | pipe | drop | continue |
ok | goto chain <CHAIN_INDEX>)

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-05-29 21:43:54 -07:00
..
act_api.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_bpf.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_connmark.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_csum.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_ctinfo.c net: sched: Introduce act_ctinfo action 2019-05-29 21:43:54 -07:00
act_gact.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_ife.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_ipt.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_meta_mark.c net: remove duplicate includes 2017-12-13 13:18:46 -05:00
act_meta_skbprio.c net sched actions: change IFE modules alias names 2017-10-12 22:13:20 -07:00
act_meta_skbtcindex.c net: remove duplicate includes 2017-12-13 13:18:46 -05:00
act_mirred.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_nat.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_pedit.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_police.c net/sched: allow stats updates from offloaded police actions 2019-05-05 21:49:24 -07:00
act_sample.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_simple.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_skbedit.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_skbmod.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_tunnel_key.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
act_vlan.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_api.c net/sched: add police action to the hardware intermediate representation 2019-05-05 21:49:24 -07:00
cls_basic.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_bpf.c net/sched: remove block pointer from common offload structure 2019-05-07 12:23:40 -07:00
cls_cgroup.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-05-07 17:22:09 -07:00
cls_flow.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_flower.c net/sched: remove block pointer from common offload structure 2019-05-07 12:23:40 -07:00
cls_fw.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_matchall.c net/sched: avoid double free on matchall reoffload 2019-05-08 16:34:58 -07:00
cls_route.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_rsvp6.c
cls_rsvp.c
cls_rsvp.h netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
cls_tcindex.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
cls_u32.c net/sched: remove block pointer from common offload structure 2019-05-07 12:23:40 -07:00
em_canid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 11 2019-05-21 11:28:45 +02:00
em_cmp.c
em_ipset.c netfilter: x_tables: move hook state into xt_action_param structure 2016-11-03 10:56:21 +01:00
em_ipt.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
em_meta.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
em_nbyte.c net: sched: em_nbyte: don't add the data offset twice 2018-01-24 14:52:40 -05:00
em_text.c
em_u32.c
ematch.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
Kconfig net: sched: Introduce act_ctinfo action 2019-05-29 21:43:54 -07:00
Makefile net: sched: Introduce act_ctinfo action 2019-05-29 21:43:54 -07:00
sch_api.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_atm.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sch_blackhole.c net_sched: blackhole: tell upper qdisc about dropped packets 2018-06-17 08:42:33 +09:00
sch_cake.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_cbq.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_cbs.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_choke.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_codel.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_drr.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_dsmark.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sch_etf.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_fifo.c net: sched: rename qdisc_destroy() to qdisc_put() 2018-09-25 20:17:35 -07:00
sch_fq_codel.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_fq.c net_sched: sch_fq: handle non connected flows 2019-05-07 12:09:25 -07:00
sch_generic.c net: add a generic tracepoint for TX queue timeout 2019-05-04 00:41:41 -04:00
sch_gred.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_hfsc.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_hhf.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sch_htb.c sch_htb: redefine htb qdisc overlimits 2019-05-05 21:55:20 -07:00
sch_ingress.c netlink: make nla_nest_start() add NLA_F_NESTED flag 2019-04-27 17:03:44 -04:00
sch_mq.c net: sched: introduce and use qstats read helpers 2019-04-01 14:50:13 -07:00
sch_mqprio.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_multiq.c net: sched: introduce and use qdisc tree flush/purge helpers 2019-04-01 14:50:13 -07:00
sch_netem.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_pie.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_plug.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_prio.c net: sched: introduce and use qdisc tree flush/purge helpers 2019-04-01 14:50:13 -07:00
sch_qfq.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_red.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_sfb.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_sfq.c net: sch: api: add extack support in tcf_block_get 2017-12-21 12:32:51 -05:00
sch_skbprio.c net/sched: add skbprio scheduler 2018-07-24 14:44:00 -07:00
sch_taprio.c taprio: add null check on sched_nest to avoid potential null pointer dereference 2019-05-07 12:15:33 -07:00
sch_tbf.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
sch_teql.c net: sched: sch: add extack for init callback 2017-12-21 12:32:50 -05:00