909c68e1b51621fbb3192b0bf10f3b45e5352e16
[openwrt/openwrt.git] / target / linux / generic / backport-4.19 / 380-v5.3-net-sched-Introduce-act_ctinfo-action.patch
1 From c17877e414155b9b97d10416ff62b102d25019a1 Mon Sep 17 00:00:00 2001
2 From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
3 Date: Wed, 13 Mar 2019 20:54:49 +0000
4 Subject: [PATCH] net: sched: Introduce act_ctinfo action
5
6 ctinfo is a new tc filter action module. It is designed to restore DSCPs
7 stored in conntrack marks into the ipv4/v6 diffserv field.
8
9 The feature is intended for use and has been found useful for restoring
10 ingress classifications based on egress classifications across links
11 that bleach or otherwise change DSCP, typically home ISP Internet links.
12 Restoring DSCP on ingress on the WAN link allows qdiscs such as CAKE to
13 shape inbound packets according to policies that are easier to indicate
14 on egress.
15
16 Ingress classification is traditionally a challenging task since
17 iptables rules haven't yet run and tc filter/eBPF programs are pre-NAT
18 lookups, hence are unable to see internal IPv4 addresses as used on the
19 typical home masquerading gateway.
20
21 ctinfo understands the following parameters:
22
23 dscp dscpmask[/statemask]
24
25 dscpmask - a 32 bit mask of at least 6 contiguous bits and indicates
26 where ctinfo will find the DSCP bits stored in the conntrack mark.
27
28 statemask - a 32 bit mask of (usually) 1 bit length, outside the area
29 specified by dscpmask. This represents a conditional operation flag
30 whereby the DSCP is only restored if the flag is set. This is useful to
31 implement a 'one shot' iptables based classification where the
32 'complicated' iptables rules are only run once to classify the
33 connection on initial (egress) packet and subsequent packets are all
34 marked/restored with the same DSCP. A mask of zero disables the
35 conditional behaviour ie. the conntrack mark DSCP bits are always
36 restored to the ip diffserv field (assuming the conntrack entry is found
37 & the skb is an ipv4/ipv6 type)
38
39 optional parameters:
40
41 zone - conntrack zone
42
43 control - action related control (reclassify | pipe | drop | continue |
44 ok | goto chain <CHAIN_INDEX>)
45
46 e.g. dscp 0xfc000000/0x01000000
47
48 |----0xFC----conntrack mark----000000---|
49 | Bits 31-26 | bit 25 | bit24 |~~~ Bit 0|
50 | DSCP | unused | flag |unused |
51 |-----------------------0x01---000000---|
52 | |
53 | |
54 ---| Conditional flag
55 v only restore if set
56 |-ip diffserv-|
57 | 6 bits |
58 |-------------|
59
60 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
61 ---
62 include/net/tc_act/tc_ctinfo.h | 33 ++
63 include/uapi/linux/pkt_cls.h | 3 +-
64 include/uapi/linux/tc_act/tc_ctinfo.h | 29 ++
65 net/sched/Kconfig | 17 +
66 net/sched/Makefile | 1 +
67 net/sched/act_ctinfo.c | 395 ++++++++++++++++++++++
68 tools/testing/selftests/tc-testing/config | 1 +
69 7 files changed, 478 insertions(+), 1 deletion(-)
70 create mode 100644 include/net/tc_act/tc_ctinfo.h
71 create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h
72 create mode 100644 net/sched/act_ctinfo.c
73
74 --- /dev/null
75 +++ b/include/net/tc_act/tc_ctinfo.h
76 @@ -0,0 +1,33 @@
77 +/* SPDX-License-Identifier: GPL-2.0 */
78 +#ifndef __NET_TC_CTINFO_H
79 +#define __NET_TC_CTINFO_H
80 +
81 +#include <net/act_api.h>
82 +
83 +struct tcf_ctinfo_params {
84 + struct rcu_head rcu;
85 + struct net *net;
86 + u32 dscpmask;
87 + u32 dscpstatemask;
88 + u32 cpmarkmask;
89 + u16 zone;
90 + u8 mode;
91 + u8 dscpmaskshift;
92 +};
93 +
94 +struct tcf_ctinfo {
95 + struct tc_action common;
96 + struct tcf_ctinfo_params __rcu *params;
97 + u64 stats_dscp_set;
98 + u64 stats_dscp_error;
99 + u64 stats_cpmark_set;
100 +};
101 +
102 +enum {
103 + CTINFO_MODE_DSCP = BIT(0),
104 + CTINFO_MODE_CPMARK = BIT(1)
105 +};
106 +
107 +#define to_ctinfo(a) ((struct tcf_ctinfo *)a)
108 +
109 +#endif /* __NET_TC_CTINFO_H */
110 --- a/include/uapi/linux/pkt_cls.h
111 +++ b/include/uapi/linux/pkt_cls.h
112 @@ -68,7 +68,8 @@ enum {
113 TCA_ID_UNSPEC=0,
114 TCA_ID_POLICE=1,
115 /* other actions go here */
116 - __TCA_ID_MAX=255
117 + TCA_ID_CTINFO,
118 + __TCA_ID_MAX = 255
119 };
120
121 #define TCA_ID_MAX __TCA_ID_MAX
122 --- /dev/null
123 +++ b/include/uapi/linux/tc_act/tc_ctinfo.h
124 @@ -0,0 +1,29 @@
125 +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
126 +#ifndef __UAPI_TC_CTINFO_H
127 +#define __UAPI_TC_CTINFO_H
128 +
129 +#include <linux/types.h>
130 +#include <linux/pkt_cls.h>
131 +
132 +struct tc_ctinfo {
133 + tc_gen;
134 +};
135 +
136 +enum {
137 + TCA_CTINFO_UNSPEC,
138 + TCA_CTINFO_PAD,
139 + TCA_CTINFO_TM,
140 + TCA_CTINFO_ACT,
141 + TCA_CTINFO_ZONE,
142 + TCA_CTINFO_PARMS_DSCP_MASK,
143 + TCA_CTINFO_PARMS_DSCP_STATEMASK,
144 + TCA_CTINFO_PARMS_CPMARK_MASK,
145 + TCA_CTINFO_STATS_DSCP_SET,
146 + TCA_CTINFO_STATS_DSCP_ERROR,
147 + TCA_CTINFO_STATS_CPMARK_SET,
148 + __TCA_CTINFO_MAX
149 +};
150 +
151 +#define TCA_CTINFO_MAX (__TCA_CTINFO_MAX - 1)
152 +
153 +#endif
154 --- a/net/sched/Kconfig
155 +++ b/net/sched/Kconfig
156 @@ -866,6 +866,23 @@ config NET_ACT_CONNMARK
157 To compile this code as a module, choose M here: the
158 module will be called act_connmark.
159
160 +config NET_ACT_CTINFO
161 + tristate "Netfilter Connection Mark Actions"
162 + depends on NET_CLS_ACT && NETFILTER && IP_NF_IPTABLES
163 + depends on NF_CONNTRACK && NF_CONNTRACK_MARK
164 + help
165 + Say Y here to allow transfer of a connmark stored information.
166 + Current actions transfer connmark stored DSCP into
167 + ipv4/v6 diffserv and/or to transfer connmark to packet
168 + mark. Both are useful for restoring egress based marks
169 + back onto ingress connections for qdisc priority mapping
170 + purposes.
171 +
172 + If unsure, say N.
173 +
174 + To compile this code as a module, choose M here: the
175 + module will be called act_ctinfo.
176 +
177 config NET_ACT_SKBMOD
178 tristate "skb data modification action"
179 depends on NET_CLS_ACT
180 --- a/net/sched/Makefile
181 +++ b/net/sched/Makefile
182 @@ -21,6 +21,7 @@ obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o
183 obj-$(CONFIG_NET_ACT_VLAN) += act_vlan.o
184 obj-$(CONFIG_NET_ACT_BPF) += act_bpf.o
185 obj-$(CONFIG_NET_ACT_CONNMARK) += act_connmark.o
186 +obj-$(CONFIG_NET_ACT_CTINFO) += act_ctinfo.o
187 obj-$(CONFIG_NET_ACT_SKBMOD) += act_skbmod.o
188 obj-$(CONFIG_NET_ACT_IFE) += act_ife.o
189 obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o
190 --- /dev/null
191 +++ b/net/sched/act_ctinfo.c
192 @@ -0,0 +1,395 @@
193 +// SPDX-License-Identifier: GPL-2.0+
194 +/* net/sched/act_ctinfo.c netfilter ctinfo connmark actions
195 + *
196 + * Copyright (c) 2019 Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
197 + */
198 +
199 +#include <linux/module.h>
200 +#include <linux/init.h>
201 +#include <linux/kernel.h>
202 +#include <linux/skbuff.h>
203 +#include <linux/rtnetlink.h>
204 +#include <linux/pkt_cls.h>
205 +#include <linux/ip.h>
206 +#include <linux/ipv6.h>
207 +#include <net/netlink.h>
208 +#include <net/pkt_sched.h>
209 +#include <net/act_api.h>
210 +#include <net/pkt_cls.h>
211 +#include <uapi/linux/tc_act/tc_ctinfo.h>
212 +#include <net/tc_act/tc_ctinfo.h>
213 +
214 +#include <net/netfilter/nf_conntrack.h>
215 +#include <net/netfilter/nf_conntrack_core.h>
216 +#include <net/netfilter/nf_conntrack_ecache.h>
217 +#include <net/netfilter/nf_conntrack_zones.h>
218 +
219 +static struct tc_action_ops act_ctinfo_ops;
220 +static unsigned int ctinfo_net_id;
221 +
222 +static void tcf_ctinfo_dscp_set(struct nf_conn *ct, struct tcf_ctinfo *ca,
223 + struct tcf_ctinfo_params *cp,
224 + struct sk_buff *skb, int wlen, int proto)
225 +{
226 + u8 dscp, newdscp;
227 +
228 + newdscp = (((ct->mark & cp->dscpmask) >> cp->dscpmaskshift) << 2) &
229 + ~INET_ECN_MASK;
230 +
231 + switch (proto) {
232 + case NFPROTO_IPV4:
233 + dscp = ipv4_get_dsfield(ip_hdr(skb)) & ~INET_ECN_MASK;
234 + if (dscp != newdscp) {
235 + if (likely(!skb_try_make_writable(skb, wlen))) {
236 + ipv4_change_dsfield(ip_hdr(skb),
237 + INET_ECN_MASK,
238 + newdscp);
239 + ca->stats_dscp_set++;
240 + } else {
241 + ca->stats_dscp_error++;
242 + }
243 + }
244 + break;
245 + case NFPROTO_IPV6:
246 + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & ~INET_ECN_MASK;
247 + if (dscp != newdscp) {
248 + if (likely(!skb_try_make_writable(skb, wlen))) {
249 + ipv6_change_dsfield(ipv6_hdr(skb),
250 + INET_ECN_MASK,
251 + newdscp);
252 + ca->stats_dscp_set++;
253 + } else {
254 + ca->stats_dscp_error++;
255 + }
256 + }
257 + break;
258 + default:
259 + break;
260 + }
261 +}
262 +
263 +static void tcf_ctinfo_cpmark_set(struct nf_conn *ct, struct tcf_ctinfo *ca,
264 + struct tcf_ctinfo_params *cp,
265 + struct sk_buff *skb)
266 +{
267 + ca->stats_cpmark_set++;
268 + skb->mark = ct->mark & cp->cpmarkmask;
269 +}
270 +
271 +static int tcf_ctinfo_act(struct sk_buff *skb, const struct tc_action *a,
272 + struct tcf_result *res)
273 +{
274 + const struct nf_conntrack_tuple_hash *thash = NULL;
275 + struct tcf_ctinfo *ca = to_ctinfo(a);
276 + struct nf_conntrack_tuple tuple;
277 + struct nf_conntrack_zone zone;
278 + enum ip_conntrack_info ctinfo;
279 + struct tcf_ctinfo_params *cp;
280 + struct nf_conn *ct;
281 + int proto, wlen;
282 + int action;
283 +
284 + cp = rcu_dereference_bh(ca->params);
285 +
286 + tcf_lastuse_update(&ca->tcf_tm);
287 + bstats_update(&ca->tcf_bstats, skb);
288 + action = READ_ONCE(ca->tcf_action);
289 +
290 + wlen = skb_network_offset(skb);
291 + if (tc_skb_protocol(skb) == htons(ETH_P_IP)) {
292 + wlen += sizeof(struct iphdr);
293 + if (!pskb_may_pull(skb, wlen))
294 + goto out;
295 +
296 + proto = NFPROTO_IPV4;
297 + } else if (tc_skb_protocol(skb) == htons(ETH_P_IPV6)) {
298 + wlen += sizeof(struct ipv6hdr);
299 + if (!pskb_may_pull(skb, wlen))
300 + goto out;
301 +
302 + proto = NFPROTO_IPV6;
303 + } else {
304 + goto out;
305 + }
306 +
307 + ct = nf_ct_get(skb, &ctinfo);
308 + if (!ct) { /* look harder, usually ingress */
309 + if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb),
310 + proto, cp->net, &tuple))
311 + goto out;
312 + zone.id = cp->zone;
313 + zone.dir = NF_CT_DEFAULT_ZONE_DIR;
314 +
315 + thash = nf_conntrack_find_get(cp->net, &zone, &tuple);
316 + if (!thash)
317 + goto out;
318 +
319 + ct = nf_ct_tuplehash_to_ctrack(thash);
320 + }
321 +
322 + if (cp->mode & CTINFO_MODE_DSCP)
323 + if (!cp->dscpstatemask || (ct->mark & cp->dscpstatemask))
324 + tcf_ctinfo_dscp_set(ct, ca, cp, skb, wlen, proto);
325 +
326 + if (cp->mode & CTINFO_MODE_CPMARK)
327 + tcf_ctinfo_cpmark_set(ct, ca, cp, skb);
328 +
329 + if (thash)
330 + nf_ct_put(ct);
331 +out:
332 + return action;
333 +}
334 +
335 +static const struct nla_policy ctinfo_policy[TCA_CTINFO_MAX + 1] = {
336 + [TCA_CTINFO_ACT] = { .len = sizeof(struct
337 + tc_ctinfo) },
338 + [TCA_CTINFO_ZONE] = { .type = NLA_U16 },
339 + [TCA_CTINFO_PARMS_DSCP_MASK] = { .type = NLA_U32 },
340 + [TCA_CTINFO_PARMS_DSCP_STATEMASK] = { .type = NLA_U32 },
341 + [TCA_CTINFO_PARMS_CPMARK_MASK] = { .type = NLA_U32 },
342 +};
343 +
344 +static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
345 + struct nlattr *est, struct tc_action **a,
346 + int ovr, int bind, bool rtnl_held,
347 + struct netlink_ext_ack *extack)
348 +{
349 + struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
350 + struct nlattr *tb[TCA_CTINFO_MAX + 1];
351 + struct tcf_ctinfo_params *cp_new;
352 +/* struct tcf_chain *goto_ch = NULL; */
353 + u32 dscpmask = 0, dscpstatemask;
354 + struct tc_ctinfo *actparm;
355 + struct tcf_ctinfo *ci;
356 + u8 dscpmaskshift;
357 + int ret = 0, err;
358 +
359 + if (!nla)
360 + return -EINVAL;
361 +
362 + err = nla_parse_nested(tb, TCA_CTINFO_MAX, nla, ctinfo_policy, NULL);
363 + if (err < 0)
364 + return err;
365 +
366 + if (!tb[TCA_CTINFO_ACT])
367 + return -EINVAL;
368 + actparm = nla_data(tb[TCA_CTINFO_ACT]);
369 +
370 + /* do some basic validation here before dynamically allocating things */
371 + /* that we would otherwise have to clean up. */
372 + if (tb[TCA_CTINFO_PARMS_DSCP_MASK]) {
373 + dscpmask = nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_MASK]);
374 + /* need contiguous 6 bit mask */
375 + dscpmaskshift = dscpmask ? __ffs(dscpmask) : 0;
376 + if ((~0 & (dscpmask >> dscpmaskshift)) != 0x3f)
377 + return -EINVAL;
378 + dscpstatemask = tb[TCA_CTINFO_PARMS_DSCP_STATEMASK] ?
379 + nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_STATEMASK]) : 0;
380 + /* mask & statemask must not overlap */
381 + if (dscpmask & dscpstatemask)
382 + return -EINVAL;
383 + }
384 +
385 + /* done the validation:now to the actual action allocation */
386 + err = tcf_idr_check_alloc(tn, &actparm->index, a, bind);
387 + if (!err) {
388 + ret = tcf_idr_create(tn, actparm->index, est, a,
389 + &act_ctinfo_ops, bind, false);
390 + if (ret) {
391 + tcf_idr_cleanup(tn, actparm->index);
392 + return ret;
393 + }
394 + ret = ACT_P_CREATED;
395 + } else if (err > 0) {
396 + if (bind) /* don't override defaults */
397 + return 0;
398 + if (!ovr) {
399 + tcf_idr_release(*a, bind);
400 + return -EEXIST;
401 + }
402 + } else {
403 + return err;
404 + }
405 +
406 +/* err = tcf_action_check_ctrlact(actparm->action, tp, &goto_ch, extack);
407 + if (err < 0)
408 + goto release_idr;
409 + */
410 +
411 + ci = to_ctinfo(*a);
412 +
413 + cp_new = kzalloc(sizeof(*cp_new), GFP_KERNEL);
414 + if (unlikely(!cp_new)) {
415 + err = -ENOMEM;
416 + goto put_chain;
417 + }
418 +
419 + cp_new->net = net;
420 + cp_new->zone = tb[TCA_CTINFO_ZONE] ?
421 + nla_get_u16(tb[TCA_CTINFO_ZONE]) : 0;
422 + if (dscpmask) {
423 + cp_new->dscpmask = dscpmask;
424 + cp_new->dscpmaskshift = dscpmaskshift;
425 + cp_new->dscpstatemask = dscpstatemask;
426 + cp_new->mode |= CTINFO_MODE_DSCP;
427 + }
428 +
429 + if (tb[TCA_CTINFO_PARMS_CPMARK_MASK]) {
430 + cp_new->cpmarkmask =
431 + nla_get_u32(tb[TCA_CTINFO_PARMS_CPMARK_MASK]);
432 + cp_new->mode |= CTINFO_MODE_CPMARK;
433 + }
434 +
435 + spin_lock_bh(&ci->tcf_lock);
436 +/* goto_ch = tcf_action_set_ctrlact(*a, actparm->action, goto_ch); */
437 + ci->tcf_action = actparm->action;
438 + rcu_swap_protected(ci->params, cp_new,
439 + lockdep_is_held(&ci->tcf_lock));
440 + spin_unlock_bh(&ci->tcf_lock);
441 +
442 +/* if (goto_ch)
443 + tcf_chain_put_by_act(goto_ch); */
444 + if (cp_new)
445 + kfree_rcu(cp_new, rcu);
446 +
447 + if (ret == ACT_P_CREATED)
448 + tcf_idr_insert(tn, *a);
449 +
450 + return ret;
451 +
452 +put_chain:
453 +/* if (goto_ch)
454 + tcf_chain_put_by_act(goto_ch);
455 +release_idr: */
456 + tcf_idr_release(*a, bind);
457 + return err;
458 +}
459 +
460 +static int tcf_ctinfo_dump(struct sk_buff *skb, struct tc_action *a,
461 + int bind, int ref)
462 +{
463 + struct tcf_ctinfo *ci = to_ctinfo(a);
464 + struct tc_ctinfo opt = {
465 + .index = ci->tcf_index,
466 + .refcnt = refcount_read(&ci->tcf_refcnt) - ref,
467 + .bindcnt = atomic_read(&ci->tcf_bindcnt) - bind,
468 + };
469 + unsigned char *b = skb_tail_pointer(skb);
470 + struct tcf_ctinfo_params *cp;
471 + struct tcf_t t;
472 +
473 + spin_lock_bh(&ci->tcf_lock);
474 + cp = rcu_dereference_protected(ci->params,
475 + lockdep_is_held(&ci->tcf_lock));
476 +
477 + tcf_tm_dump(&t, &ci->tcf_tm);
478 + if (nla_put_64bit(skb, TCA_CTINFO_TM, sizeof(t), &t, TCA_CTINFO_PAD))
479 + goto nla_put_failure;
480 +
481 + opt.action = ci->tcf_action;
482 + if (nla_put(skb, TCA_CTINFO_ACT, sizeof(opt), &opt))
483 + goto nla_put_failure;
484 +
485 + if (nla_put_u16(skb, TCA_CTINFO_ZONE, cp->zone))
486 + goto nla_put_failure;
487 +
488 + if (cp->mode & CTINFO_MODE_DSCP) {
489 + if (nla_put_u32(skb, TCA_CTINFO_PARMS_DSCP_MASK,
490 + cp->dscpmask))
491 + goto nla_put_failure;
492 + if (nla_put_u32(skb, TCA_CTINFO_PARMS_DSCP_STATEMASK,
493 + cp->dscpstatemask))
494 + goto nla_put_failure;
495 + }
496 +
497 + if (cp->mode & CTINFO_MODE_CPMARK) {
498 + if (nla_put_u32(skb, TCA_CTINFO_PARMS_CPMARK_MASK,
499 + cp->cpmarkmask))
500 + goto nla_put_failure;
501 + }
502 +
503 + if (nla_put_u64_64bit(skb, TCA_CTINFO_STATS_DSCP_SET,
504 + ci->stats_dscp_set, TCA_CTINFO_PAD))
505 + goto nla_put_failure;
506 +
507 + if (nla_put_u64_64bit(skb, TCA_CTINFO_STATS_DSCP_ERROR,
508 + ci->stats_dscp_error, TCA_CTINFO_PAD))
509 + goto nla_put_failure;
510 +
511 + if (nla_put_u64_64bit(skb, TCA_CTINFO_STATS_CPMARK_SET,
512 + ci->stats_cpmark_set, TCA_CTINFO_PAD))
513 + goto nla_put_failure;
514 +
515 + spin_unlock_bh(&ci->tcf_lock);
516 + return skb->len;
517 +
518 +nla_put_failure:
519 + spin_unlock_bh(&ci->tcf_lock);
520 + nlmsg_trim(skb, b);
521 + return -1;
522 +}
523 +
524 +static int tcf_ctinfo_walker(struct net *net, struct sk_buff *skb,
525 + struct netlink_callback *cb, int type,
526 + const struct tc_action_ops *ops,
527 + struct netlink_ext_ack *extack)
528 +{
529 + struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
530 +
531 + return tcf_generic_walker(tn, skb, cb, type, ops, extack);
532 +}
533 +
534 +static int tcf_ctinfo_search(struct net *net, struct tc_action **a, u32 index,
535 + struct netlink_ext_ack *extack)
536 +{
537 + struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
538 +
539 + return tcf_idr_search(tn, a, index);
540 +}
541 +
542 +static struct tc_action_ops act_ctinfo_ops = {
543 + .kind = "ctinfo",
544 + .type = TCA_ID_CTINFO,
545 + .owner = THIS_MODULE,
546 + .act = tcf_ctinfo_act,
547 + .dump = tcf_ctinfo_dump,
548 + .init = tcf_ctinfo_init,
549 + .walk = tcf_ctinfo_walker,
550 + .lookup = tcf_ctinfo_search,
551 + .size = sizeof(struct tcf_ctinfo),
552 +};
553 +
554 +static __net_init int ctinfo_init_net(struct net *net)
555 +{
556 + struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
557 +
558 + return tc_action_net_init(net, tn, &act_ctinfo_ops);
559 +}
560 +
561 +static void __net_exit ctinfo_exit_net(struct list_head *net_list)
562 +{
563 + tc_action_net_exit(net_list, ctinfo_net_id);
564 +}
565 +
566 +static struct pernet_operations ctinfo_net_ops = {
567 + .init = ctinfo_init_net,
568 + .exit_batch = ctinfo_exit_net,
569 + .id = &ctinfo_net_id,
570 + .size = sizeof(struct tc_action_net),
571 +};
572 +
573 +static int __init ctinfo_init_module(void)
574 +{
575 + return tcf_register_action(&act_ctinfo_ops, &ctinfo_net_ops);
576 +}
577 +
578 +static void __exit ctinfo_cleanup_module(void)
579 +{
580 + tcf_unregister_action(&act_ctinfo_ops, &ctinfo_net_ops);
581 +}
582 +
583 +module_init(ctinfo_init_module);
584 +module_exit(ctinfo_cleanup_module);
585 +MODULE_AUTHOR("Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>");
586 +MODULE_DESCRIPTION("Connection tracking mark actions");
587 +MODULE_LICENSE("GPL");
588 --- a/tools/testing/selftests/tc-testing/config
589 +++ b/tools/testing/selftests/tc-testing/config
590 @@ -37,6 +37,7 @@ CONFIG_NET_ACT_SKBEDIT=m
591 CONFIG_NET_ACT_CSUM=m
592 CONFIG_NET_ACT_VLAN=m
593 CONFIG_NET_ACT_BPF=m
594 +CONFIG_NET_ACT_CONNDSCP=m
595 CONFIG_NET_ACT_CONNMARK=m
596 CONFIG_NET_ACT_SKBMOD=m
597 CONFIG_NET_ACT_IFE=m