xref: /openbmc/linux/net/sched/act_skbedit.c (revision 4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2)
1ca9b0e27SAlexander Duyck /*
2ca9b0e27SAlexander Duyck  * Copyright (c) 2008, Intel Corporation.
3ca9b0e27SAlexander Duyck  *
4ca9b0e27SAlexander Duyck  * This program is free software; you can redistribute it and/or modify it
5ca9b0e27SAlexander Duyck  * under the terms and conditions of the GNU General Public License,
6ca9b0e27SAlexander Duyck  * version 2, as published by the Free Software Foundation.
7ca9b0e27SAlexander Duyck  *
8ca9b0e27SAlexander Duyck  * This program is distributed in the hope it will be useful, but WITHOUT
9ca9b0e27SAlexander Duyck  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10ca9b0e27SAlexander Duyck  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11ca9b0e27SAlexander Duyck  * more details.
12ca9b0e27SAlexander Duyck  *
13ca9b0e27SAlexander Duyck  * You should have received a copy of the GNU General Public License along with
14c057b190SJeff Kirsher  * this program; if not, see <http://www.gnu.org/licenses/>.
15ca9b0e27SAlexander Duyck  *
16ca9b0e27SAlexander Duyck  * Author: Alexander Duyck <alexander.h.duyck@intel.com>
17ca9b0e27SAlexander Duyck  */
18ca9b0e27SAlexander Duyck 
19ca9b0e27SAlexander Duyck #include <linux/module.h>
20ca9b0e27SAlexander Duyck #include <linux/init.h>
21ca9b0e27SAlexander Duyck #include <linux/kernel.h>
22ca9b0e27SAlexander Duyck #include <linux/skbuff.h>
23ca9b0e27SAlexander Duyck #include <linux/rtnetlink.h>
24ca9b0e27SAlexander Duyck #include <net/netlink.h>
25ca9b0e27SAlexander Duyck #include <net/pkt_sched.h>
26e7e3728bSQiaobin Fu #include <net/ip.h>
27e7e3728bSQiaobin Fu #include <net/ipv6.h>
28e7e3728bSQiaobin Fu #include <net/dsfield.h>
29ca9b0e27SAlexander Duyck 
30ca9b0e27SAlexander Duyck #include <linux/tc_act/tc_skbedit.h>
31ca9b0e27SAlexander Duyck #include <net/tc_act/tc_skbedit.h>
32ca9b0e27SAlexander Duyck 
33c7d03a00SAlexey Dobriyan static unsigned int skbedit_net_id;
34a85a970aSWANG Cong static struct tc_action_ops act_skbedit_ops;
35ddf97ccdSWANG Cong 
36dc7f9f6eSEric Dumazet static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a,
37ca9b0e27SAlexander Duyck 		       struct tcf_result *res)
38ca9b0e27SAlexander Duyck {
39a85a970aSWANG Cong 	struct tcf_skbedit *d = to_skbedit(a);
40ca9b0e27SAlexander Duyck 
41ca9b0e27SAlexander Duyck 	spin_lock(&d->tcf_lock);
429c4a4e48SJamal Hadi Salim 	tcf_lastuse_update(&d->tcf_tm);
43bfe0d029SEric Dumazet 	bstats_update(&d->tcf_bstats, skb);
44ca9b0e27SAlexander Duyck 
45ca9b0e27SAlexander Duyck 	if (d->flags & SKBEDIT_F_PRIORITY)
46ca9b0e27SAlexander Duyck 		skb->priority = d->priority;
47e7e3728bSQiaobin Fu 	if (d->flags & SKBEDIT_F_INHERITDSFIELD) {
48e7e3728bSQiaobin Fu 		int wlen = skb_network_offset(skb);
49e7e3728bSQiaobin Fu 
50e7e3728bSQiaobin Fu 		switch (tc_skb_protocol(skb)) {
51e7e3728bSQiaobin Fu 		case htons(ETH_P_IP):
52e7e3728bSQiaobin Fu 			wlen += sizeof(struct iphdr);
53e7e3728bSQiaobin Fu 			if (!pskb_may_pull(skb, wlen))
54e7e3728bSQiaobin Fu 				goto err;
55e7e3728bSQiaobin Fu 			skb->priority = ipv4_get_dsfield(ip_hdr(skb)) >> 2;
56e7e3728bSQiaobin Fu 			break;
57e7e3728bSQiaobin Fu 
58e7e3728bSQiaobin Fu 		case htons(ETH_P_IPV6):
59e7e3728bSQiaobin Fu 			wlen += sizeof(struct ipv6hdr);
60e7e3728bSQiaobin Fu 			if (!pskb_may_pull(skb, wlen))
61e7e3728bSQiaobin Fu 				goto err;
62e7e3728bSQiaobin Fu 			skb->priority = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2;
63e7e3728bSQiaobin Fu 			break;
64e7e3728bSQiaobin Fu 		}
65e7e3728bSQiaobin Fu 	}
66ca9b0e27SAlexander Duyck 	if (d->flags & SKBEDIT_F_QUEUE_MAPPING &&
67ca9b0e27SAlexander Duyck 	    skb->dev->real_num_tx_queues > d->queue_mapping)
68ca9b0e27SAlexander Duyck 		skb_set_queue_mapping(skb, d->queue_mapping);
694fe77d82SAntonio Quartulli 	if (d->flags & SKBEDIT_F_MARK) {
704fe77d82SAntonio Quartulli 		skb->mark &= ~d->mask;
714fe77d82SAntonio Quartulli 		skb->mark |= d->mark & d->mask;
724fe77d82SAntonio Quartulli 	}
73ff202ee1SJamal Hadi Salim 	if (d->flags & SKBEDIT_F_PTYPE)
74ff202ee1SJamal Hadi Salim 		skb->pkt_type = d->ptype;
75ca9b0e27SAlexander Duyck 
76ca9b0e27SAlexander Duyck 	spin_unlock(&d->tcf_lock);
77ca9b0e27SAlexander Duyck 	return d->tcf_action;
78e7e3728bSQiaobin Fu 
79e7e3728bSQiaobin Fu err:
80e7e3728bSQiaobin Fu 	d->tcf_qstats.drops++;
81e7e3728bSQiaobin Fu 	spin_unlock(&d->tcf_lock);
82e7e3728bSQiaobin Fu 	return TC_ACT_SHOT;
83ca9b0e27SAlexander Duyck }
84ca9b0e27SAlexander Duyck 
85ca9b0e27SAlexander Duyck static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = {
86ca9b0e27SAlexander Duyck 	[TCA_SKBEDIT_PARMS]		= { .len = sizeof(struct tc_skbedit) },
87ca9b0e27SAlexander Duyck 	[TCA_SKBEDIT_PRIORITY]		= { .len = sizeof(u32) },
88ca9b0e27SAlexander Duyck 	[TCA_SKBEDIT_QUEUE_MAPPING]	= { .len = sizeof(u16) },
891c55d62eSjamal 	[TCA_SKBEDIT_MARK]		= { .len = sizeof(u32) },
90ff202ee1SJamal Hadi Salim 	[TCA_SKBEDIT_PTYPE]		= { .len = sizeof(u16) },
914fe77d82SAntonio Quartulli 	[TCA_SKBEDIT_MASK]		= { .len = sizeof(u32) },
92e7e3728bSQiaobin Fu 	[TCA_SKBEDIT_FLAGS]		= { .len = sizeof(u64) },
93ca9b0e27SAlexander Duyck };
94ca9b0e27SAlexander Duyck 
95c1b52739SBenjamin LaHaise static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
96a85a970aSWANG Cong 			    struct nlattr *est, struct tc_action **a,
97789871bbSVlad Buslov 			    int ovr, int bind, bool rtnl_held,
98789871bbSVlad Buslov 			    struct netlink_ext_ack *extack)
99ca9b0e27SAlexander Duyck {
100ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, skbedit_net_id);
101ca9b0e27SAlexander Duyck 	struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
102ca9b0e27SAlexander Duyck 	struct tc_skbedit *parm;
103ca9b0e27SAlexander Duyck 	struct tcf_skbedit *d;
1044fe77d82SAntonio Quartulli 	u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL;
105ff202ee1SJamal Hadi Salim 	u16 *queue_mapping = NULL, *ptype = NULL;
106b2313077SWANG Cong 	bool exists = false;
107b2313077SWANG Cong 	int ret = 0, err;
108ca9b0e27SAlexander Duyck 
109ca9b0e27SAlexander Duyck 	if (nla == NULL)
110ca9b0e27SAlexander Duyck 		return -EINVAL;
111ca9b0e27SAlexander Duyck 
112fceb6435SJohannes Berg 	err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy, NULL);
113ca9b0e27SAlexander Duyck 	if (err < 0)
114ca9b0e27SAlexander Duyck 		return err;
115ca9b0e27SAlexander Duyck 
116ca9b0e27SAlexander Duyck 	if (tb[TCA_SKBEDIT_PARMS] == NULL)
117ca9b0e27SAlexander Duyck 		return -EINVAL;
118ca9b0e27SAlexander Duyck 
119ca9b0e27SAlexander Duyck 	if (tb[TCA_SKBEDIT_PRIORITY] != NULL) {
120ca9b0e27SAlexander Duyck 		flags |= SKBEDIT_F_PRIORITY;
121ca9b0e27SAlexander Duyck 		priority = nla_data(tb[TCA_SKBEDIT_PRIORITY]);
122ca9b0e27SAlexander Duyck 	}
123ca9b0e27SAlexander Duyck 
124ca9b0e27SAlexander Duyck 	if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) {
125ca9b0e27SAlexander Duyck 		flags |= SKBEDIT_F_QUEUE_MAPPING;
126ca9b0e27SAlexander Duyck 		queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]);
127ca9b0e27SAlexander Duyck 	}
1281c55d62eSjamal 
129ff202ee1SJamal Hadi Salim 	if (tb[TCA_SKBEDIT_PTYPE] != NULL) {
130ff202ee1SJamal Hadi Salim 		ptype = nla_data(tb[TCA_SKBEDIT_PTYPE]);
131ff202ee1SJamal Hadi Salim 		if (!skb_pkt_type_ok(*ptype))
132ff202ee1SJamal Hadi Salim 			return -EINVAL;
133ff202ee1SJamal Hadi Salim 		flags |= SKBEDIT_F_PTYPE;
134ff202ee1SJamal Hadi Salim 	}
135ff202ee1SJamal Hadi Salim 
1361c55d62eSjamal 	if (tb[TCA_SKBEDIT_MARK] != NULL) {
1371c55d62eSjamal 		flags |= SKBEDIT_F_MARK;
1381c55d62eSjamal 		mark = nla_data(tb[TCA_SKBEDIT_MARK]);
1391c55d62eSjamal 	}
1401c55d62eSjamal 
1414fe77d82SAntonio Quartulli 	if (tb[TCA_SKBEDIT_MASK] != NULL) {
1424fe77d82SAntonio Quartulli 		flags |= SKBEDIT_F_MASK;
1434fe77d82SAntonio Quartulli 		mask = nla_data(tb[TCA_SKBEDIT_MASK]);
1444fe77d82SAntonio Quartulli 	}
1454fe77d82SAntonio Quartulli 
146e7e3728bSQiaobin Fu 	if (tb[TCA_SKBEDIT_FLAGS] != NULL) {
147e7e3728bSQiaobin Fu 		u64 *pure_flags = nla_data(tb[TCA_SKBEDIT_FLAGS]);
148e7e3728bSQiaobin Fu 
149e7e3728bSQiaobin Fu 		if (*pure_flags & SKBEDIT_F_INHERITDSFIELD)
150e7e3728bSQiaobin Fu 			flags |= SKBEDIT_F_INHERITDSFIELD;
151e7e3728bSQiaobin Fu 	}
152e7e3728bSQiaobin Fu 
153ca9b0e27SAlexander Duyck 	parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
154ca9b0e27SAlexander Duyck 
15565a206c0SChris Mi 	exists = tcf_idr_check(tn, parm->index, a, bind);
1565e1567aeSJamal Hadi Salim 	if (exists && bind)
1575e1567aeSJamal Hadi Salim 		return 0;
1585e1567aeSJamal Hadi Salim 
1595e1567aeSJamal Hadi Salim 	if (!flags) {
160af5d0184SRoman Mashak 		if (exists)
16165a206c0SChris Mi 			tcf_idr_release(*a, bind);
1625e1567aeSJamal Hadi Salim 		return -EINVAL;
1635e1567aeSJamal Hadi Salim 	}
1645e1567aeSJamal Hadi Salim 
1655e1567aeSJamal Hadi Salim 	if (!exists) {
16665a206c0SChris Mi 		ret = tcf_idr_create(tn, parm->index, est, a,
167a85a970aSWANG Cong 				     &act_skbedit_ops, bind, false);
16886062033SWANG Cong 		if (ret)
16986062033SWANG Cong 			return ret;
170ca9b0e27SAlexander Duyck 
171a85a970aSWANG Cong 		d = to_skbedit(*a);
172ca9b0e27SAlexander Duyck 		ret = ACT_P_CREATED;
173ca9b0e27SAlexander Duyck 	} else {
174a85a970aSWANG Cong 		d = to_skbedit(*a);
175*4e8ddd7fSVlad Buslov 		if (!ovr) {
17665a206c0SChris Mi 			tcf_idr_release(*a, bind);
177ca9b0e27SAlexander Duyck 			return -EEXIST;
178ca9b0e27SAlexander Duyck 		}
179*4e8ddd7fSVlad Buslov 	}
180ca9b0e27SAlexander Duyck 
181ca9b0e27SAlexander Duyck 	spin_lock_bh(&d->tcf_lock);
182ca9b0e27SAlexander Duyck 
183ca9b0e27SAlexander Duyck 	d->flags = flags;
184ca9b0e27SAlexander Duyck 	if (flags & SKBEDIT_F_PRIORITY)
185ca9b0e27SAlexander Duyck 		d->priority = *priority;
186ca9b0e27SAlexander Duyck 	if (flags & SKBEDIT_F_QUEUE_MAPPING)
187ca9b0e27SAlexander Duyck 		d->queue_mapping = *queue_mapping;
1881c55d62eSjamal 	if (flags & SKBEDIT_F_MARK)
1891c55d62eSjamal 		d->mark = *mark;
190ff202ee1SJamal Hadi Salim 	if (flags & SKBEDIT_F_PTYPE)
191ff202ee1SJamal Hadi Salim 		d->ptype = *ptype;
1924fe77d82SAntonio Quartulli 	/* default behaviour is to use all the bits */
1934fe77d82SAntonio Quartulli 	d->mask = 0xffffffff;
1944fe77d82SAntonio Quartulli 	if (flags & SKBEDIT_F_MASK)
1954fe77d82SAntonio Quartulli 		d->mask = *mask;
1961c55d62eSjamal 
197ca9b0e27SAlexander Duyck 	d->tcf_action = parm->action;
198ca9b0e27SAlexander Duyck 
199ca9b0e27SAlexander Duyck 	spin_unlock_bh(&d->tcf_lock);
200ca9b0e27SAlexander Duyck 
201ca9b0e27SAlexander Duyck 	if (ret == ACT_P_CREATED)
20265a206c0SChris Mi 		tcf_idr_insert(tn, *a);
203ca9b0e27SAlexander Duyck 	return ret;
204ca9b0e27SAlexander Duyck }
205ca9b0e27SAlexander Duyck 
206cc7ec456SEric Dumazet static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
207ca9b0e27SAlexander Duyck 			    int bind, int ref)
208ca9b0e27SAlexander Duyck {
209ca9b0e27SAlexander Duyck 	unsigned char *b = skb_tail_pointer(skb);
210a85a970aSWANG Cong 	struct tcf_skbedit *d = to_skbedit(a);
2111c40be12SEric Dumazet 	struct tc_skbedit opt = {
2121c40be12SEric Dumazet 		.index   = d->tcf_index,
213036bb443SVlad Buslov 		.refcnt  = refcount_read(&d->tcf_refcnt) - ref,
214036bb443SVlad Buslov 		.bindcnt = atomic_read(&d->tcf_bindcnt) - bind,
2151c40be12SEric Dumazet 		.action  = d->tcf_action,
2161c40be12SEric Dumazet 	};
217ca9b0e27SAlexander Duyck 	struct tcf_t t;
218e7e3728bSQiaobin Fu 	u64 pure_flags = 0;
219ca9b0e27SAlexander Duyck 
2201b34ec43SDavid S. Miller 	if (nla_put(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt))
2211b34ec43SDavid S. Miller 		goto nla_put_failure;
2221b34ec43SDavid S. Miller 	if ((d->flags & SKBEDIT_F_PRIORITY) &&
22361cc535dSJamal Hadi Salim 	    nla_put_u32(skb, TCA_SKBEDIT_PRIORITY, d->priority))
2241b34ec43SDavid S. Miller 		goto nla_put_failure;
2251b34ec43SDavid S. Miller 	if ((d->flags & SKBEDIT_F_QUEUE_MAPPING) &&
22661cc535dSJamal Hadi Salim 	    nla_put_u16(skb, TCA_SKBEDIT_QUEUE_MAPPING, d->queue_mapping))
2271b34ec43SDavid S. Miller 		goto nla_put_failure;
2281b34ec43SDavid S. Miller 	if ((d->flags & SKBEDIT_F_MARK) &&
22961cc535dSJamal Hadi Salim 	    nla_put_u32(skb, TCA_SKBEDIT_MARK, d->mark))
2301b34ec43SDavid S. Miller 		goto nla_put_failure;
231ff202ee1SJamal Hadi Salim 	if ((d->flags & SKBEDIT_F_PTYPE) &&
23261cc535dSJamal Hadi Salim 	    nla_put_u16(skb, TCA_SKBEDIT_PTYPE, d->ptype))
233ff202ee1SJamal Hadi Salim 		goto nla_put_failure;
2344fe77d82SAntonio Quartulli 	if ((d->flags & SKBEDIT_F_MASK) &&
2354fe77d82SAntonio Quartulli 	    nla_put_u32(skb, TCA_SKBEDIT_MASK, d->mask))
2364fe77d82SAntonio Quartulli 		goto nla_put_failure;
237e7e3728bSQiaobin Fu 	if (d->flags & SKBEDIT_F_INHERITDSFIELD)
238e7e3728bSQiaobin Fu 		pure_flags |= SKBEDIT_F_INHERITDSFIELD;
239e7e3728bSQiaobin Fu 	if (pure_flags != 0 &&
240e7e3728bSQiaobin Fu 	    nla_put(skb, TCA_SKBEDIT_FLAGS, sizeof(pure_flags), &pure_flags))
241e7e3728bSQiaobin Fu 		goto nla_put_failure;
24248d8ee16SJamal Hadi Salim 
24348d8ee16SJamal Hadi Salim 	tcf_tm_dump(&t, &d->tcf_tm);
2449854518eSNicolas Dichtel 	if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD))
2451b34ec43SDavid S. Miller 		goto nla_put_failure;
246ca9b0e27SAlexander Duyck 	return skb->len;
247ca9b0e27SAlexander Duyck 
248ca9b0e27SAlexander Duyck nla_put_failure:
249ca9b0e27SAlexander Duyck 	nlmsg_trim(skb, b);
250ca9b0e27SAlexander Duyck 	return -1;
251ca9b0e27SAlexander Duyck }
252ca9b0e27SAlexander Duyck 
253ddf97ccdSWANG Cong static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb,
254ddf97ccdSWANG Cong 			      struct netlink_callback *cb, int type,
25541780105SAlexander Aring 			      const struct tc_action_ops *ops,
25641780105SAlexander Aring 			      struct netlink_ext_ack *extack)
257ddf97ccdSWANG Cong {
258ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, skbedit_net_id);
259ddf97ccdSWANG Cong 
260b3620145SAlexander Aring 	return tcf_generic_walker(tn, skb, cb, type, ops, extack);
261ddf97ccdSWANG Cong }
262ddf97ccdSWANG Cong 
263331a9295SAlexander Aring static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index,
264331a9295SAlexander Aring 			      struct netlink_ext_ack *extack)
265ddf97ccdSWANG Cong {
266ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, skbedit_net_id);
267ddf97ccdSWANG Cong 
26865a206c0SChris Mi 	return tcf_idr_search(tn, a, index);
269ddf97ccdSWANG Cong }
270ddf97ccdSWANG Cong 
271b409074eSVlad Buslov static int tcf_skbedit_delete(struct net *net, u32 index)
272b409074eSVlad Buslov {
273b409074eSVlad Buslov 	struct tc_action_net *tn = net_generic(net, skbedit_net_id);
274b409074eSVlad Buslov 
275b409074eSVlad Buslov 	return tcf_idr_delete_index(tn, index);
276b409074eSVlad Buslov }
277b409074eSVlad Buslov 
278ca9b0e27SAlexander Duyck static struct tc_action_ops act_skbedit_ops = {
279ca9b0e27SAlexander Duyck 	.kind		=	"skbedit",
280ca9b0e27SAlexander Duyck 	.type		=	TCA_ACT_SKBEDIT,
281ca9b0e27SAlexander Duyck 	.owner		=	THIS_MODULE,
282ca9b0e27SAlexander Duyck 	.act		=	tcf_skbedit,
283ca9b0e27SAlexander Duyck 	.dump		=	tcf_skbedit_dump,
284ca9b0e27SAlexander Duyck 	.init		=	tcf_skbedit_init,
285ddf97ccdSWANG Cong 	.walk		=	tcf_skbedit_walker,
286ddf97ccdSWANG Cong 	.lookup		=	tcf_skbedit_search,
287b409074eSVlad Buslov 	.delete		=	tcf_skbedit_delete,
288a85a970aSWANG Cong 	.size		=	sizeof(struct tcf_skbedit),
289ddf97ccdSWANG Cong };
290ddf97ccdSWANG Cong 
291ddf97ccdSWANG Cong static __net_init int skbedit_init_net(struct net *net)
292ddf97ccdSWANG Cong {
293ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, skbedit_net_id);
294ddf97ccdSWANG Cong 
295c7e460ceSCong Wang 	return tc_action_net_init(tn, &act_skbedit_ops);
296ddf97ccdSWANG Cong }
297ddf97ccdSWANG Cong 
298039af9c6SCong Wang static void __net_exit skbedit_exit_net(struct list_head *net_list)
299ddf97ccdSWANG Cong {
300039af9c6SCong Wang 	tc_action_net_exit(net_list, skbedit_net_id);
301ddf97ccdSWANG Cong }
302ddf97ccdSWANG Cong 
303ddf97ccdSWANG Cong static struct pernet_operations skbedit_net_ops = {
304ddf97ccdSWANG Cong 	.init = skbedit_init_net,
305039af9c6SCong Wang 	.exit_batch = skbedit_exit_net,
306ddf97ccdSWANG Cong 	.id   = &skbedit_net_id,
307ddf97ccdSWANG Cong 	.size = sizeof(struct tc_action_net),
308ca9b0e27SAlexander Duyck };
309ca9b0e27SAlexander Duyck 
310ca9b0e27SAlexander Duyck MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>");
311ca9b0e27SAlexander Duyck MODULE_DESCRIPTION("SKB Editing");
312ca9b0e27SAlexander Duyck MODULE_LICENSE("GPL");
313ca9b0e27SAlexander Duyck 
314ca9b0e27SAlexander Duyck static int __init skbedit_init_module(void)
315ca9b0e27SAlexander Duyck {
316ddf97ccdSWANG Cong 	return tcf_register_action(&act_skbedit_ops, &skbedit_net_ops);
317ca9b0e27SAlexander Duyck }
318ca9b0e27SAlexander Duyck 
319ca9b0e27SAlexander Duyck static void __exit skbedit_cleanup_module(void)
320ca9b0e27SAlexander Duyck {
321ddf97ccdSWANG Cong 	tcf_unregister_action(&act_skbedit_ops, &skbedit_net_ops);
322ca9b0e27SAlexander Duyck }
323ca9b0e27SAlexander Duyck 
324ca9b0e27SAlexander Duyck module_init(skbedit_init_module);
325ca9b0e27SAlexander Duyck module_exit(skbedit_cleanup_module);
326