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 3645da1dacSJamal Hadi Salim static int tcf_skbedit_act(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); 40c749cddaSDavide Caratti struct tcf_skbedit_params *params; 41c749cddaSDavide Caratti int action; 42ca9b0e27SAlexander Duyck 439c4a4e48SJamal Hadi Salim tcf_lastuse_update(&d->tcf_tm); 446f3dfb0dSDavide Caratti bstats_cpu_update(this_cpu_ptr(d->common.cpu_bstats), skb); 45ca9b0e27SAlexander Duyck 467fd4b288SPaolo Abeni params = rcu_dereference_bh(d->params); 47c749cddaSDavide Caratti action = READ_ONCE(d->tcf_action); 48c749cddaSDavide Caratti 49c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_PRIORITY) 50c749cddaSDavide Caratti skb->priority = params->priority; 51c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_INHERITDSFIELD) { 52e7e3728bSQiaobin Fu int wlen = skb_network_offset(skb); 53e7e3728bSQiaobin Fu 54e7e3728bSQiaobin Fu switch (tc_skb_protocol(skb)) { 55e7e3728bSQiaobin Fu case htons(ETH_P_IP): 56e7e3728bSQiaobin Fu wlen += sizeof(struct iphdr); 57e7e3728bSQiaobin Fu if (!pskb_may_pull(skb, wlen)) 58e7e3728bSQiaobin Fu goto err; 59e7e3728bSQiaobin Fu skb->priority = ipv4_get_dsfield(ip_hdr(skb)) >> 2; 60e7e3728bSQiaobin Fu break; 61e7e3728bSQiaobin Fu 62e7e3728bSQiaobin Fu case htons(ETH_P_IPV6): 63e7e3728bSQiaobin Fu wlen += sizeof(struct ipv6hdr); 64e7e3728bSQiaobin Fu if (!pskb_may_pull(skb, wlen)) 65e7e3728bSQiaobin Fu goto err; 66e7e3728bSQiaobin Fu skb->priority = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; 67e7e3728bSQiaobin Fu break; 68e7e3728bSQiaobin Fu } 69e7e3728bSQiaobin Fu } 70c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_QUEUE_MAPPING && 71c749cddaSDavide Caratti skb->dev->real_num_tx_queues > params->queue_mapping) 72c749cddaSDavide Caratti skb_set_queue_mapping(skb, params->queue_mapping); 73c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_MARK) { 74c749cddaSDavide Caratti skb->mark &= ~params->mask; 75c749cddaSDavide Caratti skb->mark |= params->mark & params->mask; 764fe77d82SAntonio Quartulli } 77c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_PTYPE) 78c749cddaSDavide Caratti skb->pkt_type = params->ptype; 79c749cddaSDavide Caratti return action; 807fd4b288SPaolo Abeni 81e7e3728bSQiaobin Fu err: 826f3dfb0dSDavide Caratti qstats_drop_inc(this_cpu_ptr(d->common.cpu_qstats)); 837fd4b288SPaolo Abeni return TC_ACT_SHOT; 84ca9b0e27SAlexander Duyck } 85ca9b0e27SAlexander Duyck 86ca9b0e27SAlexander Duyck static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = { 87ca9b0e27SAlexander Duyck [TCA_SKBEDIT_PARMS] = { .len = sizeof(struct tc_skbedit) }, 88ca9b0e27SAlexander Duyck [TCA_SKBEDIT_PRIORITY] = { .len = sizeof(u32) }, 89ca9b0e27SAlexander Duyck [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) }, 901c55d62eSjamal [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) }, 91ff202ee1SJamal Hadi Salim [TCA_SKBEDIT_PTYPE] = { .len = sizeof(u16) }, 924fe77d82SAntonio Quartulli [TCA_SKBEDIT_MASK] = { .len = sizeof(u32) }, 93e7e3728bSQiaobin Fu [TCA_SKBEDIT_FLAGS] = { .len = sizeof(u64) }, 94ca9b0e27SAlexander Duyck }; 95ca9b0e27SAlexander Duyck 96c1b52739SBenjamin LaHaise static int tcf_skbedit_init(struct net *net, struct nlattr *nla, 97a85a970aSWANG Cong struct nlattr *est, struct tc_action **a, 98789871bbSVlad Buslov int ovr, int bind, bool rtnl_held, 99*85d0966fSDavide Caratti struct tcf_proto *tp, 100789871bbSVlad Buslov struct netlink_ext_ack *extack) 101ca9b0e27SAlexander Duyck { 102ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 1036d7a8df6SVlad Buslov struct tcf_skbedit_params *params_new; 104ca9b0e27SAlexander Duyck struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; 105ca9b0e27SAlexander Duyck struct tc_skbedit *parm; 106ca9b0e27SAlexander Duyck struct tcf_skbedit *d; 1074fe77d82SAntonio Quartulli u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; 108ff202ee1SJamal Hadi Salim u16 *queue_mapping = NULL, *ptype = NULL; 109b2313077SWANG Cong bool exists = false; 110b2313077SWANG Cong int ret = 0, err; 111ca9b0e27SAlexander Duyck 112ca9b0e27SAlexander Duyck if (nla == NULL) 113ca9b0e27SAlexander Duyck return -EINVAL; 114ca9b0e27SAlexander Duyck 115fceb6435SJohannes Berg err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy, NULL); 116ca9b0e27SAlexander Duyck if (err < 0) 117ca9b0e27SAlexander Duyck return err; 118ca9b0e27SAlexander Duyck 119ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_PARMS] == NULL) 120ca9b0e27SAlexander Duyck return -EINVAL; 121ca9b0e27SAlexander Duyck 122ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_PRIORITY] != NULL) { 123ca9b0e27SAlexander Duyck flags |= SKBEDIT_F_PRIORITY; 124ca9b0e27SAlexander Duyck priority = nla_data(tb[TCA_SKBEDIT_PRIORITY]); 125ca9b0e27SAlexander Duyck } 126ca9b0e27SAlexander Duyck 127ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) { 128ca9b0e27SAlexander Duyck flags |= SKBEDIT_F_QUEUE_MAPPING; 129ca9b0e27SAlexander Duyck queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]); 130ca9b0e27SAlexander Duyck } 1311c55d62eSjamal 132ff202ee1SJamal Hadi Salim if (tb[TCA_SKBEDIT_PTYPE] != NULL) { 133ff202ee1SJamal Hadi Salim ptype = nla_data(tb[TCA_SKBEDIT_PTYPE]); 134ff202ee1SJamal Hadi Salim if (!skb_pkt_type_ok(*ptype)) 135ff202ee1SJamal Hadi Salim return -EINVAL; 136ff202ee1SJamal Hadi Salim flags |= SKBEDIT_F_PTYPE; 137ff202ee1SJamal Hadi Salim } 138ff202ee1SJamal Hadi Salim 1391c55d62eSjamal if (tb[TCA_SKBEDIT_MARK] != NULL) { 1401c55d62eSjamal flags |= SKBEDIT_F_MARK; 1411c55d62eSjamal mark = nla_data(tb[TCA_SKBEDIT_MARK]); 1421c55d62eSjamal } 1431c55d62eSjamal 1444fe77d82SAntonio Quartulli if (tb[TCA_SKBEDIT_MASK] != NULL) { 1454fe77d82SAntonio Quartulli flags |= SKBEDIT_F_MASK; 1464fe77d82SAntonio Quartulli mask = nla_data(tb[TCA_SKBEDIT_MASK]); 1474fe77d82SAntonio Quartulli } 1484fe77d82SAntonio Quartulli 149e7e3728bSQiaobin Fu if (tb[TCA_SKBEDIT_FLAGS] != NULL) { 150e7e3728bSQiaobin Fu u64 *pure_flags = nla_data(tb[TCA_SKBEDIT_FLAGS]); 151e7e3728bSQiaobin Fu 152e7e3728bSQiaobin Fu if (*pure_flags & SKBEDIT_F_INHERITDSFIELD) 153e7e3728bSQiaobin Fu flags |= SKBEDIT_F_INHERITDSFIELD; 154e7e3728bSQiaobin Fu } 155e7e3728bSQiaobin Fu 156ca9b0e27SAlexander Duyck parm = nla_data(tb[TCA_SKBEDIT_PARMS]); 157ca9b0e27SAlexander Duyck 1580190c1d4SVlad Buslov err = tcf_idr_check_alloc(tn, &parm->index, a, bind); 1590190c1d4SVlad Buslov if (err < 0) 1600190c1d4SVlad Buslov return err; 1610190c1d4SVlad Buslov exists = err; 1625e1567aeSJamal Hadi Salim if (exists && bind) 1635e1567aeSJamal Hadi Salim return 0; 1645e1567aeSJamal Hadi Salim 1655e1567aeSJamal Hadi Salim if (!flags) { 166af5d0184SRoman Mashak if (exists) 16765a206c0SChris Mi tcf_idr_release(*a, bind); 1680190c1d4SVlad Buslov else 1690190c1d4SVlad Buslov tcf_idr_cleanup(tn, parm->index); 1705e1567aeSJamal Hadi Salim return -EINVAL; 1715e1567aeSJamal Hadi Salim } 1725e1567aeSJamal Hadi Salim 1735e1567aeSJamal Hadi Salim if (!exists) { 17465a206c0SChris Mi ret = tcf_idr_create(tn, parm->index, est, a, 1756f3dfb0dSDavide Caratti &act_skbedit_ops, bind, true); 1760190c1d4SVlad Buslov if (ret) { 1770190c1d4SVlad Buslov tcf_idr_cleanup(tn, parm->index); 17886062033SWANG Cong return ret; 1790190c1d4SVlad Buslov } 180ca9b0e27SAlexander Duyck 181a85a970aSWANG Cong d = to_skbedit(*a); 182ca9b0e27SAlexander Duyck ret = ACT_P_CREATED; 183ca9b0e27SAlexander Duyck } else { 184a85a970aSWANG Cong d = to_skbedit(*a); 1854e8ddd7fSVlad Buslov if (!ovr) { 18665a206c0SChris Mi tcf_idr_release(*a, bind); 187ca9b0e27SAlexander Duyck return -EEXIST; 188ca9b0e27SAlexander Duyck } 1894e8ddd7fSVlad Buslov } 190ca9b0e27SAlexander Duyck 191c749cddaSDavide Caratti params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); 192c749cddaSDavide Caratti if (unlikely(!params_new)) { 193c749cddaSDavide Caratti tcf_idr_release(*a, bind); 194c749cddaSDavide Caratti return -ENOMEM; 195c749cddaSDavide Caratti } 196c749cddaSDavide Caratti 197c749cddaSDavide Caratti params_new->flags = flags; 198ca9b0e27SAlexander Duyck if (flags & SKBEDIT_F_PRIORITY) 199c749cddaSDavide Caratti params_new->priority = *priority; 200ca9b0e27SAlexander Duyck if (flags & SKBEDIT_F_QUEUE_MAPPING) 201c749cddaSDavide Caratti params_new->queue_mapping = *queue_mapping; 2021c55d62eSjamal if (flags & SKBEDIT_F_MARK) 203c749cddaSDavide Caratti params_new->mark = *mark; 204ff202ee1SJamal Hadi Salim if (flags & SKBEDIT_F_PTYPE) 205c749cddaSDavide Caratti params_new->ptype = *ptype; 2064fe77d82SAntonio Quartulli /* default behaviour is to use all the bits */ 207c749cddaSDavide Caratti params_new->mask = 0xffffffff; 2084fe77d82SAntonio Quartulli if (flags & SKBEDIT_F_MASK) 209c749cddaSDavide Caratti params_new->mask = *mask; 2101c55d62eSjamal 2116d7a8df6SVlad Buslov spin_lock_bh(&d->tcf_lock); 212ca9b0e27SAlexander Duyck d->tcf_action = parm->action; 2136d7a8df6SVlad Buslov rcu_swap_protected(d->params, params_new, 2146d7a8df6SVlad Buslov lockdep_is_held(&d->tcf_lock)); 2156d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 2166d7a8df6SVlad Buslov if (params_new) 2176d7a8df6SVlad Buslov kfree_rcu(params_new, rcu); 218ca9b0e27SAlexander Duyck 219ca9b0e27SAlexander Duyck if (ret == ACT_P_CREATED) 22065a206c0SChris Mi tcf_idr_insert(tn, *a); 221ca9b0e27SAlexander Duyck return ret; 222ca9b0e27SAlexander Duyck } 223ca9b0e27SAlexander Duyck 224cc7ec456SEric Dumazet static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, 225ca9b0e27SAlexander Duyck int bind, int ref) 226ca9b0e27SAlexander Duyck { 227ca9b0e27SAlexander Duyck unsigned char *b = skb_tail_pointer(skb); 228a85a970aSWANG Cong struct tcf_skbedit *d = to_skbedit(a); 229c749cddaSDavide Caratti struct tcf_skbedit_params *params; 2301c40be12SEric Dumazet struct tc_skbedit opt = { 2311c40be12SEric Dumazet .index = d->tcf_index, 232036bb443SVlad Buslov .refcnt = refcount_read(&d->tcf_refcnt) - ref, 233036bb443SVlad Buslov .bindcnt = atomic_read(&d->tcf_bindcnt) - bind, 2341c40be12SEric Dumazet }; 235e7e3728bSQiaobin Fu u64 pure_flags = 0; 236c749cddaSDavide Caratti struct tcf_t t; 237c749cddaSDavide Caratti 2386d7a8df6SVlad Buslov spin_lock_bh(&d->tcf_lock); 2396d7a8df6SVlad Buslov params = rcu_dereference_protected(d->params, 2406d7a8df6SVlad Buslov lockdep_is_held(&d->tcf_lock)); 2416d7a8df6SVlad Buslov opt.action = d->tcf_action; 242ca9b0e27SAlexander Duyck 2431b34ec43SDavid S. Miller if (nla_put(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt)) 2441b34ec43SDavid S. Miller goto nla_put_failure; 245c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_PRIORITY) && 246c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_PRIORITY, params->priority)) 2471b34ec43SDavid S. Miller goto nla_put_failure; 248c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_QUEUE_MAPPING) && 249c749cddaSDavide Caratti nla_put_u16(skb, TCA_SKBEDIT_QUEUE_MAPPING, params->queue_mapping)) 2501b34ec43SDavid S. Miller goto nla_put_failure; 251c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_MARK) && 252c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_MARK, params->mark)) 2531b34ec43SDavid S. Miller goto nla_put_failure; 254c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_PTYPE) && 255c749cddaSDavide Caratti nla_put_u16(skb, TCA_SKBEDIT_PTYPE, params->ptype)) 256ff202ee1SJamal Hadi Salim goto nla_put_failure; 257c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_MASK) && 258c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_MASK, params->mask)) 2594fe77d82SAntonio Quartulli goto nla_put_failure; 260c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_INHERITDSFIELD) 261e7e3728bSQiaobin Fu pure_flags |= SKBEDIT_F_INHERITDSFIELD; 262e7e3728bSQiaobin Fu if (pure_flags != 0 && 263e7e3728bSQiaobin Fu nla_put(skb, TCA_SKBEDIT_FLAGS, sizeof(pure_flags), &pure_flags)) 264e7e3728bSQiaobin Fu goto nla_put_failure; 26548d8ee16SJamal Hadi Salim 26648d8ee16SJamal Hadi Salim tcf_tm_dump(&t, &d->tcf_tm); 2679854518eSNicolas Dichtel if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD)) 2681b34ec43SDavid S. Miller goto nla_put_failure; 2696d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 2706d7a8df6SVlad Buslov 271ca9b0e27SAlexander Duyck return skb->len; 272ca9b0e27SAlexander Duyck 273ca9b0e27SAlexander Duyck nla_put_failure: 2746d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 275ca9b0e27SAlexander Duyck nlmsg_trim(skb, b); 276ca9b0e27SAlexander Duyck return -1; 277ca9b0e27SAlexander Duyck } 278ca9b0e27SAlexander Duyck 279c749cddaSDavide Caratti static void tcf_skbedit_cleanup(struct tc_action *a) 280c749cddaSDavide Caratti { 281c749cddaSDavide Caratti struct tcf_skbedit *d = to_skbedit(a); 282c749cddaSDavide Caratti struct tcf_skbedit_params *params; 283c749cddaSDavide Caratti 284c749cddaSDavide Caratti params = rcu_dereference_protected(d->params, 1); 285c749cddaSDavide Caratti if (params) 286c749cddaSDavide Caratti kfree_rcu(params, rcu); 287c749cddaSDavide Caratti } 288c749cddaSDavide Caratti 289ddf97ccdSWANG Cong static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb, 290ddf97ccdSWANG Cong struct netlink_callback *cb, int type, 29141780105SAlexander Aring const struct tc_action_ops *ops, 29241780105SAlexander Aring struct netlink_ext_ack *extack) 293ddf97ccdSWANG Cong { 294ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 295ddf97ccdSWANG Cong 296b3620145SAlexander Aring return tcf_generic_walker(tn, skb, cb, type, ops, extack); 297ddf97ccdSWANG Cong } 298ddf97ccdSWANG Cong 299f061b48cSCong Wang static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index) 300ddf97ccdSWANG Cong { 301ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 302ddf97ccdSWANG Cong 30365a206c0SChris Mi return tcf_idr_search(tn, a, index); 304ddf97ccdSWANG Cong } 305ddf97ccdSWANG Cong 306ca9b0e27SAlexander Duyck static struct tc_action_ops act_skbedit_ops = { 307ca9b0e27SAlexander Duyck .kind = "skbedit", 308eddd2cf1SEli Cohen .id = TCA_ID_SKBEDIT, 309ca9b0e27SAlexander Duyck .owner = THIS_MODULE, 31045da1dacSJamal Hadi Salim .act = tcf_skbedit_act, 311ca9b0e27SAlexander Duyck .dump = tcf_skbedit_dump, 312ca9b0e27SAlexander Duyck .init = tcf_skbedit_init, 313c749cddaSDavide Caratti .cleanup = tcf_skbedit_cleanup, 314ddf97ccdSWANG Cong .walk = tcf_skbedit_walker, 315ddf97ccdSWANG Cong .lookup = tcf_skbedit_search, 316a85a970aSWANG Cong .size = sizeof(struct tcf_skbedit), 317ddf97ccdSWANG Cong }; 318ddf97ccdSWANG Cong 319ddf97ccdSWANG Cong static __net_init int skbedit_init_net(struct net *net) 320ddf97ccdSWANG Cong { 321ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 322ddf97ccdSWANG Cong 323c7e460ceSCong Wang return tc_action_net_init(tn, &act_skbedit_ops); 324ddf97ccdSWANG Cong } 325ddf97ccdSWANG Cong 326039af9c6SCong Wang static void __net_exit skbedit_exit_net(struct list_head *net_list) 327ddf97ccdSWANG Cong { 328039af9c6SCong Wang tc_action_net_exit(net_list, skbedit_net_id); 329ddf97ccdSWANG Cong } 330ddf97ccdSWANG Cong 331ddf97ccdSWANG Cong static struct pernet_operations skbedit_net_ops = { 332ddf97ccdSWANG Cong .init = skbedit_init_net, 333039af9c6SCong Wang .exit_batch = skbedit_exit_net, 334ddf97ccdSWANG Cong .id = &skbedit_net_id, 335ddf97ccdSWANG Cong .size = sizeof(struct tc_action_net), 336ca9b0e27SAlexander Duyck }; 337ca9b0e27SAlexander Duyck 338ca9b0e27SAlexander Duyck MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>"); 339ca9b0e27SAlexander Duyck MODULE_DESCRIPTION("SKB Editing"); 340ca9b0e27SAlexander Duyck MODULE_LICENSE("GPL"); 341ca9b0e27SAlexander Duyck 342ca9b0e27SAlexander Duyck static int __init skbedit_init_module(void) 343ca9b0e27SAlexander Duyck { 344ddf97ccdSWANG Cong return tcf_register_action(&act_skbedit_ops, &skbedit_net_ops); 345ca9b0e27SAlexander Duyck } 346ca9b0e27SAlexander Duyck 347ca9b0e27SAlexander Duyck static void __exit skbedit_cleanup_module(void) 348ca9b0e27SAlexander Duyck { 349ddf97ccdSWANG Cong tcf_unregister_action(&act_skbedit_ops, &skbedit_net_ops); 350ca9b0e27SAlexander Duyck } 351ca9b0e27SAlexander Duyck 352ca9b0e27SAlexander Duyck module_init(skbedit_init_module); 353ca9b0e27SAlexander Duyck module_exit(skbedit_cleanup_module); 354