xref: /openbmc/linux/net/sched/act_vlan.c (revision 8cb081746c031fb164089322e2336a0bf5b3070c)
1c7e2b968SJiri Pirko /*
2c7e2b968SJiri Pirko  * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
3c7e2b968SJiri Pirko  *
4c7e2b968SJiri Pirko  * This program is free software; you can redistribute it and/or modify
5c7e2b968SJiri Pirko  * it under the terms of the GNU General Public License as published by
6c7e2b968SJiri Pirko  * the Free Software Foundation; either version 2 of the License, or
7c7e2b968SJiri Pirko  * (at your option) any later version.
8c7e2b968SJiri Pirko  */
9c7e2b968SJiri Pirko 
10c7e2b968SJiri Pirko #include <linux/module.h>
11c7e2b968SJiri Pirko #include <linux/init.h>
12c7e2b968SJiri Pirko #include <linux/kernel.h>
13c7e2b968SJiri Pirko #include <linux/skbuff.h>
14c7e2b968SJiri Pirko #include <linux/rtnetlink.h>
15c7e2b968SJiri Pirko #include <linux/if_vlan.h>
16c7e2b968SJiri Pirko #include <net/netlink.h>
17c7e2b968SJiri Pirko #include <net/pkt_sched.h>
187e0c8892SDavide Caratti #include <net/pkt_cls.h>
19c7e2b968SJiri Pirko 
20c7e2b968SJiri Pirko #include <linux/tc_act/tc_vlan.h>
21c7e2b968SJiri Pirko #include <net/tc_act/tc_vlan.h>
22c7e2b968SJiri Pirko 
23c7d03a00SAlexey Dobriyan static unsigned int vlan_net_id;
24a85a970aSWANG Cong static struct tc_action_ops act_vlan_ops;
25ddf97ccdSWANG Cong 
268aa7f22eSJamal Hadi Salim static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
27c7e2b968SJiri Pirko 			struct tcf_result *res)
28c7e2b968SJiri Pirko {
29a85a970aSWANG Cong 	struct tcf_vlan *v = to_vlan(a);
304c5b9d96SManish Kurup 	struct tcf_vlan_params *p;
31c7e2b968SJiri Pirko 	int action;
32c7e2b968SJiri Pirko 	int err;
3345a497f2SShmulik Ladkani 	u16 tci;
34c7e2b968SJiri Pirko 
359c4a4e48SJamal Hadi Salim 	tcf_lastuse_update(&v->tcf_tm);
36e0496cbbSManish Kurup 	bstats_cpu_update(this_cpu_ptr(v->common.cpu_bstats), skb);
37e0496cbbSManish Kurup 
38f39acc84SShmulik Ladkani 	/* Ensure 'data' points at mac_header prior calling vlan manipulating
39f39acc84SShmulik Ladkani 	 * functions.
40f39acc84SShmulik Ladkani 	 */
41f39acc84SShmulik Ladkani 	if (skb_at_tc_ingress(skb))
42f39acc84SShmulik Ladkani 		skb_push_rcsum(skb, skb->mac_len);
43f39acc84SShmulik Ladkani 
444c5b9d96SManish Kurup 	action = READ_ONCE(v->tcf_action);
454c5b9d96SManish Kurup 
467fd4b288SPaolo Abeni 	p = rcu_dereference_bh(v->vlan_p);
474c5b9d96SManish Kurup 
484c5b9d96SManish Kurup 	switch (p->tcfv_action) {
49c7e2b968SJiri Pirko 	case TCA_VLAN_ACT_POP:
50c7e2b968SJiri Pirko 		err = skb_vlan_pop(skb);
51c7e2b968SJiri Pirko 		if (err)
52c7e2b968SJiri Pirko 			goto drop;
53c7e2b968SJiri Pirko 		break;
54c7e2b968SJiri Pirko 	case TCA_VLAN_ACT_PUSH:
554c5b9d96SManish Kurup 		err = skb_vlan_push(skb, p->tcfv_push_proto, p->tcfv_push_vid |
564c5b9d96SManish Kurup 				    (p->tcfv_push_prio << VLAN_PRIO_SHIFT));
57c7e2b968SJiri Pirko 		if (err)
58c7e2b968SJiri Pirko 			goto drop;
59c7e2b968SJiri Pirko 		break;
6045a497f2SShmulik Ladkani 	case TCA_VLAN_ACT_MODIFY:
6145a497f2SShmulik Ladkani 		/* No-op if no vlan tag (either hw-accel or in-payload) */
6245a497f2SShmulik Ladkani 		if (!skb_vlan_tagged(skb))
637fd4b288SPaolo Abeni 			goto out;
6445a497f2SShmulik Ladkani 		/* extract existing tag (and guarantee no hw-accel tag) */
6545a497f2SShmulik Ladkani 		if (skb_vlan_tag_present(skb)) {
6645a497f2SShmulik Ladkani 			tci = skb_vlan_tag_get(skb);
67b1817524SMichał Mirosław 			__vlan_hwaccel_clear_tag(skb);
6845a497f2SShmulik Ladkani 		} else {
6945a497f2SShmulik Ladkani 			/* in-payload vlan tag, pop it */
7045a497f2SShmulik Ladkani 			err = __skb_vlan_pop(skb, &tci);
7145a497f2SShmulik Ladkani 			if (err)
7245a497f2SShmulik Ladkani 				goto drop;
7345a497f2SShmulik Ladkani 		}
7445a497f2SShmulik Ladkani 		/* replace the vid */
754c5b9d96SManish Kurup 		tci = (tci & ~VLAN_VID_MASK) | p->tcfv_push_vid;
7645a497f2SShmulik Ladkani 		/* replace prio bits, if tcfv_push_prio specified */
774c5b9d96SManish Kurup 		if (p->tcfv_push_prio) {
7845a497f2SShmulik Ladkani 			tci &= ~VLAN_PRIO_MASK;
794c5b9d96SManish Kurup 			tci |= p->tcfv_push_prio << VLAN_PRIO_SHIFT;
8045a497f2SShmulik Ladkani 		}
8145a497f2SShmulik Ladkani 		/* put updated tci as hwaccel tag */
824c5b9d96SManish Kurup 		__vlan_hwaccel_put_tag(skb, p->tcfv_push_proto, tci);
8345a497f2SShmulik Ladkani 		break;
84c7e2b968SJiri Pirko 	default:
85c7e2b968SJiri Pirko 		BUG();
86c7e2b968SJiri Pirko 	}
87c7e2b968SJiri Pirko 
887fd4b288SPaolo Abeni out:
89f39acc84SShmulik Ladkani 	if (skb_at_tc_ingress(skb))
90f39acc84SShmulik Ladkani 		skb_pull_rcsum(skb, skb->mac_len);
91f39acc84SShmulik Ladkani 
92c7e2b968SJiri Pirko 	return action;
937fd4b288SPaolo Abeni 
947fd4b288SPaolo Abeni drop:
957fd4b288SPaolo Abeni 	qstats_drop_inc(this_cpu_ptr(v->common.cpu_qstats));
967fd4b288SPaolo Abeni 	return TC_ACT_SHOT;
97c7e2b968SJiri Pirko }
98c7e2b968SJiri Pirko 
99c7e2b968SJiri Pirko static const struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = {
100c7e2b968SJiri Pirko 	[TCA_VLAN_PARMS]		= { .len = sizeof(struct tc_vlan) },
101c7e2b968SJiri Pirko 	[TCA_VLAN_PUSH_VLAN_ID]		= { .type = NLA_U16 },
102c7e2b968SJiri Pirko 	[TCA_VLAN_PUSH_VLAN_PROTOCOL]	= { .type = NLA_U16 },
103956af371SHadar Hen Zion 	[TCA_VLAN_PUSH_VLAN_PRIORITY]	= { .type = NLA_U8 },
104c7e2b968SJiri Pirko };
105c7e2b968SJiri Pirko 
106c7e2b968SJiri Pirko static int tcf_vlan_init(struct net *net, struct nlattr *nla,
107a85a970aSWANG Cong 			 struct nlattr *est, struct tc_action **a,
108789871bbSVlad Buslov 			 int ovr, int bind, bool rtnl_held,
10985d0966fSDavide Caratti 			 struct tcf_proto *tp, struct netlink_ext_ack *extack)
110c7e2b968SJiri Pirko {
111ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, vlan_net_id);
112c7e2b968SJiri Pirko 	struct nlattr *tb[TCA_VLAN_MAX + 1];
1137e0c8892SDavide Caratti 	struct tcf_chain *goto_ch = NULL;
114764e9a24SVlad Buslov 	struct tcf_vlan_params *p;
115c7e2b968SJiri Pirko 	struct tc_vlan *parm;
116c7e2b968SJiri Pirko 	struct tcf_vlan *v;
117c7e2b968SJiri Pirko 	int action;
11894cb5492SDavide Caratti 	u16 push_vid = 0;
119c7e2b968SJiri Pirko 	__be16 push_proto = 0;
120956af371SHadar Hen Zion 	u8 push_prio = 0;
121b2313077SWANG Cong 	bool exists = false;
122b2313077SWANG Cong 	int ret = 0, err;
123c7e2b968SJiri Pirko 
124c7e2b968SJiri Pirko 	if (!nla)
125c7e2b968SJiri Pirko 		return -EINVAL;
126c7e2b968SJiri Pirko 
127*8cb08174SJohannes Berg 	err = nla_parse_nested_deprecated(tb, TCA_VLAN_MAX, nla, vlan_policy,
128*8cb08174SJohannes Berg 					  NULL);
129c7e2b968SJiri Pirko 	if (err < 0)
130c7e2b968SJiri Pirko 		return err;
131c7e2b968SJiri Pirko 
132c7e2b968SJiri Pirko 	if (!tb[TCA_VLAN_PARMS])
133c7e2b968SJiri Pirko 		return -EINVAL;
134c7e2b968SJiri Pirko 	parm = nla_data(tb[TCA_VLAN_PARMS]);
1350190c1d4SVlad Buslov 	err = tcf_idr_check_alloc(tn, &parm->index, a, bind);
1360190c1d4SVlad Buslov 	if (err < 0)
1370190c1d4SVlad Buslov 		return err;
1380190c1d4SVlad Buslov 	exists = err;
1395026c9b1SJamal Hadi Salim 	if (exists && bind)
1405026c9b1SJamal Hadi Salim 		return 0;
1415026c9b1SJamal Hadi Salim 
142c7e2b968SJiri Pirko 	switch (parm->v_action) {
143c7e2b968SJiri Pirko 	case TCA_VLAN_ACT_POP:
144c7e2b968SJiri Pirko 		break;
145c7e2b968SJiri Pirko 	case TCA_VLAN_ACT_PUSH:
14645a497f2SShmulik Ladkani 	case TCA_VLAN_ACT_MODIFY:
1475026c9b1SJamal Hadi Salim 		if (!tb[TCA_VLAN_PUSH_VLAN_ID]) {
1485026c9b1SJamal Hadi Salim 			if (exists)
14965a206c0SChris Mi 				tcf_idr_release(*a, bind);
1500190c1d4SVlad Buslov 			else
1510190c1d4SVlad Buslov 				tcf_idr_cleanup(tn, parm->index);
152c7e2b968SJiri Pirko 			return -EINVAL;
1535026c9b1SJamal Hadi Salim 		}
154c7e2b968SJiri Pirko 		push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
1555026c9b1SJamal Hadi Salim 		if (push_vid >= VLAN_VID_MASK) {
1565026c9b1SJamal Hadi Salim 			if (exists)
15765a206c0SChris Mi 				tcf_idr_release(*a, bind);
1580190c1d4SVlad Buslov 			else
1590190c1d4SVlad Buslov 				tcf_idr_cleanup(tn, parm->index);
160c7e2b968SJiri Pirko 			return -ERANGE;
1615026c9b1SJamal Hadi Salim 		}
162c7e2b968SJiri Pirko 
163c7e2b968SJiri Pirko 		if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) {
164c7e2b968SJiri Pirko 			push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
165c7e2b968SJiri Pirko 			switch (push_proto) {
166c7e2b968SJiri Pirko 			case htons(ETH_P_8021Q):
167c7e2b968SJiri Pirko 			case htons(ETH_P_8021AD):
168c7e2b968SJiri Pirko 				break;
169c7e2b968SJiri Pirko 			default:
1705a4931aeSDavide Caratti 				if (exists)
1715a4931aeSDavide Caratti 					tcf_idr_release(*a, bind);
1720190c1d4SVlad Buslov 				else
1730190c1d4SVlad Buslov 					tcf_idr_cleanup(tn, parm->index);
174c7e2b968SJiri Pirko 				return -EPROTONOSUPPORT;
175c7e2b968SJiri Pirko 			}
176c7e2b968SJiri Pirko 		} else {
177c7e2b968SJiri Pirko 			push_proto = htons(ETH_P_8021Q);
178c7e2b968SJiri Pirko 		}
179956af371SHadar Hen Zion 
180956af371SHadar Hen Zion 		if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY])
181956af371SHadar Hen Zion 			push_prio = nla_get_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]);
182c7e2b968SJiri Pirko 		break;
183c7e2b968SJiri Pirko 	default:
1845026c9b1SJamal Hadi Salim 		if (exists)
18565a206c0SChris Mi 			tcf_idr_release(*a, bind);
1860190c1d4SVlad Buslov 		else
1870190c1d4SVlad Buslov 			tcf_idr_cleanup(tn, parm->index);
188c7e2b968SJiri Pirko 		return -EINVAL;
189c7e2b968SJiri Pirko 	}
190c7e2b968SJiri Pirko 	action = parm->v_action;
191c7e2b968SJiri Pirko 
1925026c9b1SJamal Hadi Salim 	if (!exists) {
19365a206c0SChris Mi 		ret = tcf_idr_create(tn, parm->index, est, a,
194e0496cbbSManish Kurup 				     &act_vlan_ops, bind, true);
1950190c1d4SVlad Buslov 		if (ret) {
1960190c1d4SVlad Buslov 			tcf_idr_cleanup(tn, parm->index);
197c7e2b968SJiri Pirko 			return ret;
1980190c1d4SVlad Buslov 		}
199c7e2b968SJiri Pirko 
200c7e2b968SJiri Pirko 		ret = ACT_P_CREATED;
2014e8ddd7fSVlad Buslov 	} else if (!ovr) {
20265a206c0SChris Mi 		tcf_idr_release(*a, bind);
203c7e2b968SJiri Pirko 		return -EEXIST;
204c7e2b968SJiri Pirko 	}
205c7e2b968SJiri Pirko 
2067e0c8892SDavide Caratti 	err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
2077e0c8892SDavide Caratti 	if (err < 0)
2087e0c8892SDavide Caratti 		goto release_idr;
2097e0c8892SDavide Caratti 
210a85a970aSWANG Cong 	v = to_vlan(*a);
211c7e2b968SJiri Pirko 
2124c5b9d96SManish Kurup 	p = kzalloc(sizeof(*p), GFP_KERNEL);
2134c5b9d96SManish Kurup 	if (!p) {
2147e0c8892SDavide Caratti 		err = -ENOMEM;
2157e0c8892SDavide Caratti 		goto put_chain;
2164c5b9d96SManish Kurup 	}
217c7e2b968SJiri Pirko 
2184c5b9d96SManish Kurup 	p->tcfv_action = action;
2194c5b9d96SManish Kurup 	p->tcfv_push_vid = push_vid;
2204c5b9d96SManish Kurup 	p->tcfv_push_prio = push_prio;
2214c5b9d96SManish Kurup 	p->tcfv_push_proto = push_proto;
2224c5b9d96SManish Kurup 
223653cd284SVlad Buslov 	spin_lock_bh(&v->tcf_lock);
2247e0c8892SDavide Caratti 	goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
225764e9a24SVlad Buslov 	rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock));
226653cd284SVlad Buslov 	spin_unlock_bh(&v->tcf_lock);
2274c5b9d96SManish Kurup 
2287e0c8892SDavide Caratti 	if (goto_ch)
2297e0c8892SDavide Caratti 		tcf_chain_put_by_act(goto_ch);
230764e9a24SVlad Buslov 	if (p)
231764e9a24SVlad Buslov 		kfree_rcu(p, rcu);
232c7e2b968SJiri Pirko 
233c7e2b968SJiri Pirko 	if (ret == ACT_P_CREATED)
23465a206c0SChris Mi 		tcf_idr_insert(tn, *a);
235c7e2b968SJiri Pirko 	return ret;
2367e0c8892SDavide Caratti put_chain:
2377e0c8892SDavide Caratti 	if (goto_ch)
2387e0c8892SDavide Caratti 		tcf_chain_put_by_act(goto_ch);
2397e0c8892SDavide Caratti release_idr:
2407e0c8892SDavide Caratti 	tcf_idr_release(*a, bind);
2417e0c8892SDavide Caratti 	return err;
242c7e2b968SJiri Pirko }
243c7e2b968SJiri Pirko 
2449a63b255SCong Wang static void tcf_vlan_cleanup(struct tc_action *a)
2454c5b9d96SManish Kurup {
2464c5b9d96SManish Kurup 	struct tcf_vlan *v = to_vlan(a);
2474c5b9d96SManish Kurup 	struct tcf_vlan_params *p;
2484c5b9d96SManish Kurup 
2494c5b9d96SManish Kurup 	p = rcu_dereference_protected(v->vlan_p, 1);
2501edf8abeSDavide Caratti 	if (p)
2514c5b9d96SManish Kurup 		kfree_rcu(p, rcu);
2524c5b9d96SManish Kurup }
2534c5b9d96SManish Kurup 
254c7e2b968SJiri Pirko static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
255c7e2b968SJiri Pirko 			 int bind, int ref)
256c7e2b968SJiri Pirko {
257c7e2b968SJiri Pirko 	unsigned char *b = skb_tail_pointer(skb);
258a85a970aSWANG Cong 	struct tcf_vlan *v = to_vlan(a);
259764e9a24SVlad Buslov 	struct tcf_vlan_params *p;
260c7e2b968SJiri Pirko 	struct tc_vlan opt = {
261c7e2b968SJiri Pirko 		.index    = v->tcf_index,
262036bb443SVlad Buslov 		.refcnt   = refcount_read(&v->tcf_refcnt) - ref,
263036bb443SVlad Buslov 		.bindcnt  = atomic_read(&v->tcf_bindcnt) - bind,
264c7e2b968SJiri Pirko 	};
265c7e2b968SJiri Pirko 	struct tcf_t t;
266c7e2b968SJiri Pirko 
267653cd284SVlad Buslov 	spin_lock_bh(&v->tcf_lock);
268764e9a24SVlad Buslov 	opt.action = v->tcf_action;
269764e9a24SVlad Buslov 	p = rcu_dereference_protected(v->vlan_p, lockdep_is_held(&v->tcf_lock));
270764e9a24SVlad Buslov 	opt.v_action = p->tcfv_action;
271c7e2b968SJiri Pirko 	if (nla_put(skb, TCA_VLAN_PARMS, sizeof(opt), &opt))
272c7e2b968SJiri Pirko 		goto nla_put_failure;
273c7e2b968SJiri Pirko 
2744c5b9d96SManish Kurup 	if ((p->tcfv_action == TCA_VLAN_ACT_PUSH ||
2754c5b9d96SManish Kurup 	     p->tcfv_action == TCA_VLAN_ACT_MODIFY) &&
2764c5b9d96SManish Kurup 	    (nla_put_u16(skb, TCA_VLAN_PUSH_VLAN_ID, p->tcfv_push_vid) ||
2770b0f43feSJamal Hadi Salim 	     nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL,
2784c5b9d96SManish Kurup 			  p->tcfv_push_proto) ||
279956af371SHadar Hen Zion 	     (nla_put_u8(skb, TCA_VLAN_PUSH_VLAN_PRIORITY,
2804c5b9d96SManish Kurup 					      p->tcfv_push_prio))))
281c7e2b968SJiri Pirko 		goto nla_put_failure;
282c7e2b968SJiri Pirko 
28348d8ee16SJamal Hadi Salim 	tcf_tm_dump(&t, &v->tcf_tm);
2849854518eSNicolas Dichtel 	if (nla_put_64bit(skb, TCA_VLAN_TM, sizeof(t), &t, TCA_VLAN_PAD))
285c7e2b968SJiri Pirko 		goto nla_put_failure;
286653cd284SVlad Buslov 	spin_unlock_bh(&v->tcf_lock);
287764e9a24SVlad Buslov 
288c7e2b968SJiri Pirko 	return skb->len;
289c7e2b968SJiri Pirko 
290c7e2b968SJiri Pirko nla_put_failure:
291653cd284SVlad Buslov 	spin_unlock_bh(&v->tcf_lock);
292c7e2b968SJiri Pirko 	nlmsg_trim(skb, b);
293c7e2b968SJiri Pirko 	return -1;
294c7e2b968SJiri Pirko }
295c7e2b968SJiri Pirko 
296ddf97ccdSWANG Cong static int tcf_vlan_walker(struct net *net, struct sk_buff *skb,
297ddf97ccdSWANG Cong 			   struct netlink_callback *cb, int type,
29841780105SAlexander Aring 			   const struct tc_action_ops *ops,
29941780105SAlexander Aring 			   struct netlink_ext_ack *extack)
300ddf97ccdSWANG Cong {
301ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, vlan_net_id);
302ddf97ccdSWANG Cong 
303b3620145SAlexander Aring 	return tcf_generic_walker(tn, skb, cb, type, ops, extack);
304ddf97ccdSWANG Cong }
305ddf97ccdSWANG Cong 
306f061b48cSCong Wang static int tcf_vlan_search(struct net *net, struct tc_action **a, u32 index)
307ddf97ccdSWANG Cong {
308ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, vlan_net_id);
309ddf97ccdSWANG Cong 
31065a206c0SChris Mi 	return tcf_idr_search(tn, a, index);
311ddf97ccdSWANG Cong }
312ddf97ccdSWANG Cong 
313c7e2b968SJiri Pirko static struct tc_action_ops act_vlan_ops = {
314c7e2b968SJiri Pirko 	.kind		=	"vlan",
315eddd2cf1SEli Cohen 	.id		=	TCA_ID_VLAN,
316c7e2b968SJiri Pirko 	.owner		=	THIS_MODULE,
3178aa7f22eSJamal Hadi Salim 	.act		=	tcf_vlan_act,
318c7e2b968SJiri Pirko 	.dump		=	tcf_vlan_dump,
319c7e2b968SJiri Pirko 	.init		=	tcf_vlan_init,
3204c5b9d96SManish Kurup 	.cleanup	=	tcf_vlan_cleanup,
321ddf97ccdSWANG Cong 	.walk		=	tcf_vlan_walker,
322ddf97ccdSWANG Cong 	.lookup		=	tcf_vlan_search,
323a85a970aSWANG Cong 	.size		=	sizeof(struct tcf_vlan),
324ddf97ccdSWANG Cong };
325ddf97ccdSWANG Cong 
326ddf97ccdSWANG Cong static __net_init int vlan_init_net(struct net *net)
327ddf97ccdSWANG Cong {
328ddf97ccdSWANG Cong 	struct tc_action_net *tn = net_generic(net, vlan_net_id);
329ddf97ccdSWANG Cong 
330c7e460ceSCong Wang 	return tc_action_net_init(tn, &act_vlan_ops);
331ddf97ccdSWANG Cong }
332ddf97ccdSWANG Cong 
333039af9c6SCong Wang static void __net_exit vlan_exit_net(struct list_head *net_list)
334ddf97ccdSWANG Cong {
335039af9c6SCong Wang 	tc_action_net_exit(net_list, vlan_net_id);
336ddf97ccdSWANG Cong }
337ddf97ccdSWANG Cong 
338ddf97ccdSWANG Cong static struct pernet_operations vlan_net_ops = {
339ddf97ccdSWANG Cong 	.init = vlan_init_net,
340039af9c6SCong Wang 	.exit_batch = vlan_exit_net,
341ddf97ccdSWANG Cong 	.id   = &vlan_net_id,
342ddf97ccdSWANG Cong 	.size = sizeof(struct tc_action_net),
343c7e2b968SJiri Pirko };
344c7e2b968SJiri Pirko 
345c7e2b968SJiri Pirko static int __init vlan_init_module(void)
346c7e2b968SJiri Pirko {
347ddf97ccdSWANG Cong 	return tcf_register_action(&act_vlan_ops, &vlan_net_ops);
348c7e2b968SJiri Pirko }
349c7e2b968SJiri Pirko 
350c7e2b968SJiri Pirko static void __exit vlan_cleanup_module(void)
351c7e2b968SJiri Pirko {
352ddf97ccdSWANG Cong 	tcf_unregister_action(&act_vlan_ops, &vlan_net_ops);
353c7e2b968SJiri Pirko }
354c7e2b968SJiri Pirko 
355c7e2b968SJiri Pirko module_init(vlan_init_module);
356c7e2b968SJiri Pirko module_exit(vlan_cleanup_module);
357c7e2b968SJiri Pirko 
358c7e2b968SJiri Pirko MODULE_AUTHOR("Jiri Pirko <jiri@resnulli.us>");
359c7e2b968SJiri Pirko MODULE_DESCRIPTION("vlan manipulation actions");
360c7e2b968SJiri Pirko MODULE_LICENSE("GPL v2");
361