1*9952f691SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2ca9b0e27SAlexander Duyck /* 3ca9b0e27SAlexander Duyck * Copyright (c) 2008, Intel Corporation. 4ca9b0e27SAlexander Duyck * 5ca9b0e27SAlexander Duyck * Author: Alexander Duyck <alexander.h.duyck@intel.com> 6ca9b0e27SAlexander Duyck */ 7ca9b0e27SAlexander Duyck 8ca9b0e27SAlexander Duyck #include <linux/module.h> 9ca9b0e27SAlexander Duyck #include <linux/init.h> 10ca9b0e27SAlexander Duyck #include <linux/kernel.h> 11ca9b0e27SAlexander Duyck #include <linux/skbuff.h> 12ca9b0e27SAlexander Duyck #include <linux/rtnetlink.h> 13ca9b0e27SAlexander Duyck #include <net/netlink.h> 14ca9b0e27SAlexander Duyck #include <net/pkt_sched.h> 15e7e3728bSQiaobin Fu #include <net/ip.h> 16e7e3728bSQiaobin Fu #include <net/ipv6.h> 17e7e3728bSQiaobin Fu #include <net/dsfield.h> 18ec7727bbSDavide Caratti #include <net/pkt_cls.h> 19ca9b0e27SAlexander Duyck 20ca9b0e27SAlexander Duyck #include <linux/tc_act/tc_skbedit.h> 21ca9b0e27SAlexander Duyck #include <net/tc_act/tc_skbedit.h> 22ca9b0e27SAlexander Duyck 23c7d03a00SAlexey Dobriyan static unsigned int skbedit_net_id; 24a85a970aSWANG Cong static struct tc_action_ops act_skbedit_ops; 25ddf97ccdSWANG Cong 2645da1dacSJamal Hadi Salim static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a, 27ca9b0e27SAlexander Duyck struct tcf_result *res) 28ca9b0e27SAlexander Duyck { 29a85a970aSWANG Cong struct tcf_skbedit *d = to_skbedit(a); 30c749cddaSDavide Caratti struct tcf_skbedit_params *params; 31c749cddaSDavide Caratti int action; 32ca9b0e27SAlexander Duyck 339c4a4e48SJamal Hadi Salim tcf_lastuse_update(&d->tcf_tm); 346f3dfb0dSDavide Caratti bstats_cpu_update(this_cpu_ptr(d->common.cpu_bstats), skb); 35ca9b0e27SAlexander Duyck 367fd4b288SPaolo Abeni params = rcu_dereference_bh(d->params); 37c749cddaSDavide Caratti action = READ_ONCE(d->tcf_action); 38c749cddaSDavide Caratti 39c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_PRIORITY) 40c749cddaSDavide Caratti skb->priority = params->priority; 41c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_INHERITDSFIELD) { 42e7e3728bSQiaobin Fu int wlen = skb_network_offset(skb); 43e7e3728bSQiaobin Fu 44e7e3728bSQiaobin Fu switch (tc_skb_protocol(skb)) { 45e7e3728bSQiaobin Fu case htons(ETH_P_IP): 46e7e3728bSQiaobin Fu wlen += sizeof(struct iphdr); 47e7e3728bSQiaobin Fu if (!pskb_may_pull(skb, wlen)) 48e7e3728bSQiaobin Fu goto err; 49e7e3728bSQiaobin Fu skb->priority = ipv4_get_dsfield(ip_hdr(skb)) >> 2; 50e7e3728bSQiaobin Fu break; 51e7e3728bSQiaobin Fu 52e7e3728bSQiaobin Fu case htons(ETH_P_IPV6): 53e7e3728bSQiaobin Fu wlen += sizeof(struct ipv6hdr); 54e7e3728bSQiaobin Fu if (!pskb_may_pull(skb, wlen)) 55e7e3728bSQiaobin Fu goto err; 56e7e3728bSQiaobin Fu skb->priority = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; 57e7e3728bSQiaobin Fu break; 58e7e3728bSQiaobin Fu } 59e7e3728bSQiaobin Fu } 60c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_QUEUE_MAPPING && 61c749cddaSDavide Caratti skb->dev->real_num_tx_queues > params->queue_mapping) 62c749cddaSDavide Caratti skb_set_queue_mapping(skb, params->queue_mapping); 63c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_MARK) { 64c749cddaSDavide Caratti skb->mark &= ~params->mask; 65c749cddaSDavide Caratti skb->mark |= params->mark & params->mask; 664fe77d82SAntonio Quartulli } 67c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_PTYPE) 68c749cddaSDavide Caratti skb->pkt_type = params->ptype; 69c749cddaSDavide Caratti return action; 707fd4b288SPaolo Abeni 71e7e3728bSQiaobin Fu err: 726f3dfb0dSDavide Caratti qstats_drop_inc(this_cpu_ptr(d->common.cpu_qstats)); 737fd4b288SPaolo Abeni return TC_ACT_SHOT; 74ca9b0e27SAlexander Duyck } 75ca9b0e27SAlexander Duyck 76ca9b0e27SAlexander Duyck static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = { 77ca9b0e27SAlexander Duyck [TCA_SKBEDIT_PARMS] = { .len = sizeof(struct tc_skbedit) }, 78ca9b0e27SAlexander Duyck [TCA_SKBEDIT_PRIORITY] = { .len = sizeof(u32) }, 79ca9b0e27SAlexander Duyck [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) }, 801c55d62eSjamal [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) }, 81ff202ee1SJamal Hadi Salim [TCA_SKBEDIT_PTYPE] = { .len = sizeof(u16) }, 824fe77d82SAntonio Quartulli [TCA_SKBEDIT_MASK] = { .len = sizeof(u32) }, 83e7e3728bSQiaobin Fu [TCA_SKBEDIT_FLAGS] = { .len = sizeof(u64) }, 84ca9b0e27SAlexander Duyck }; 85ca9b0e27SAlexander Duyck 86c1b52739SBenjamin LaHaise static int tcf_skbedit_init(struct net *net, struct nlattr *nla, 87a85a970aSWANG Cong struct nlattr *est, struct tc_action **a, 88789871bbSVlad Buslov int ovr, int bind, bool rtnl_held, 8985d0966fSDavide Caratti struct tcf_proto *tp, 90789871bbSVlad Buslov struct netlink_ext_ack *extack) 91ca9b0e27SAlexander Duyck { 92ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 936d7a8df6SVlad Buslov struct tcf_skbedit_params *params_new; 94ca9b0e27SAlexander Duyck struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; 95ec7727bbSDavide Caratti struct tcf_chain *goto_ch = NULL; 96ca9b0e27SAlexander Duyck struct tc_skbedit *parm; 97ca9b0e27SAlexander Duyck struct tcf_skbedit *d; 984fe77d82SAntonio Quartulli u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; 99ff202ee1SJamal Hadi Salim u16 *queue_mapping = NULL, *ptype = NULL; 100b2313077SWANG Cong bool exists = false; 101b2313077SWANG Cong int ret = 0, err; 102ca9b0e27SAlexander Duyck 103ca9b0e27SAlexander Duyck if (nla == NULL) 104ca9b0e27SAlexander Duyck return -EINVAL; 105ca9b0e27SAlexander Duyck 1068cb08174SJohannes Berg err = nla_parse_nested_deprecated(tb, TCA_SKBEDIT_MAX, nla, 1078cb08174SJohannes Berg skbedit_policy, NULL); 108ca9b0e27SAlexander Duyck if (err < 0) 109ca9b0e27SAlexander Duyck return err; 110ca9b0e27SAlexander Duyck 111ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_PARMS] == NULL) 112ca9b0e27SAlexander Duyck return -EINVAL; 113ca9b0e27SAlexander Duyck 114ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_PRIORITY] != NULL) { 115ca9b0e27SAlexander Duyck flags |= SKBEDIT_F_PRIORITY; 116ca9b0e27SAlexander Duyck priority = nla_data(tb[TCA_SKBEDIT_PRIORITY]); 117ca9b0e27SAlexander Duyck } 118ca9b0e27SAlexander Duyck 119ca9b0e27SAlexander Duyck if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) { 120ca9b0e27SAlexander Duyck flags |= SKBEDIT_F_QUEUE_MAPPING; 121ca9b0e27SAlexander Duyck queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]); 122ca9b0e27SAlexander Duyck } 1231c55d62eSjamal 124ff202ee1SJamal Hadi Salim if (tb[TCA_SKBEDIT_PTYPE] != NULL) { 125ff202ee1SJamal Hadi Salim ptype = nla_data(tb[TCA_SKBEDIT_PTYPE]); 126ff202ee1SJamal Hadi Salim if (!skb_pkt_type_ok(*ptype)) 127ff202ee1SJamal Hadi Salim return -EINVAL; 128ff202ee1SJamal Hadi Salim flags |= SKBEDIT_F_PTYPE; 129ff202ee1SJamal Hadi Salim } 130ff202ee1SJamal Hadi Salim 1311c55d62eSjamal if (tb[TCA_SKBEDIT_MARK] != NULL) { 1321c55d62eSjamal flags |= SKBEDIT_F_MARK; 1331c55d62eSjamal mark = nla_data(tb[TCA_SKBEDIT_MARK]); 1341c55d62eSjamal } 1351c55d62eSjamal 1364fe77d82SAntonio Quartulli if (tb[TCA_SKBEDIT_MASK] != NULL) { 1374fe77d82SAntonio Quartulli flags |= SKBEDIT_F_MASK; 1384fe77d82SAntonio Quartulli mask = nla_data(tb[TCA_SKBEDIT_MASK]); 1394fe77d82SAntonio Quartulli } 1404fe77d82SAntonio Quartulli 141e7e3728bSQiaobin Fu if (tb[TCA_SKBEDIT_FLAGS] != NULL) { 142e7e3728bSQiaobin Fu u64 *pure_flags = nla_data(tb[TCA_SKBEDIT_FLAGS]); 143e7e3728bSQiaobin Fu 144e7e3728bSQiaobin Fu if (*pure_flags & SKBEDIT_F_INHERITDSFIELD) 145e7e3728bSQiaobin Fu flags |= SKBEDIT_F_INHERITDSFIELD; 146e7e3728bSQiaobin Fu } 147e7e3728bSQiaobin Fu 148ca9b0e27SAlexander Duyck parm = nla_data(tb[TCA_SKBEDIT_PARMS]); 149ca9b0e27SAlexander Duyck 1500190c1d4SVlad Buslov err = tcf_idr_check_alloc(tn, &parm->index, a, bind); 1510190c1d4SVlad Buslov if (err < 0) 1520190c1d4SVlad Buslov return err; 1530190c1d4SVlad Buslov exists = err; 1545e1567aeSJamal Hadi Salim if (exists && bind) 1555e1567aeSJamal Hadi Salim return 0; 1565e1567aeSJamal Hadi Salim 1575e1567aeSJamal Hadi Salim if (!flags) { 158af5d0184SRoman Mashak if (exists) 15965a206c0SChris Mi tcf_idr_release(*a, bind); 1600190c1d4SVlad Buslov else 1610190c1d4SVlad Buslov tcf_idr_cleanup(tn, parm->index); 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, 1676f3dfb0dSDavide Caratti &act_skbedit_ops, bind, true); 1680190c1d4SVlad Buslov if (ret) { 1690190c1d4SVlad Buslov tcf_idr_cleanup(tn, parm->index); 17086062033SWANG Cong return ret; 1710190c1d4SVlad Buslov } 172ca9b0e27SAlexander Duyck 173a85a970aSWANG Cong d = to_skbedit(*a); 174ca9b0e27SAlexander Duyck ret = ACT_P_CREATED; 175ca9b0e27SAlexander Duyck } else { 176a85a970aSWANG Cong d = to_skbedit(*a); 1774e8ddd7fSVlad Buslov if (!ovr) { 17865a206c0SChris Mi tcf_idr_release(*a, bind); 179ca9b0e27SAlexander Duyck return -EEXIST; 180ca9b0e27SAlexander Duyck } 1814e8ddd7fSVlad Buslov } 182ec7727bbSDavide Caratti err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); 183ec7727bbSDavide Caratti if (err < 0) 184ec7727bbSDavide Caratti goto release_idr; 185ca9b0e27SAlexander Duyck 186c749cddaSDavide Caratti params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); 187c749cddaSDavide Caratti if (unlikely(!params_new)) { 188ec7727bbSDavide Caratti err = -ENOMEM; 189ec7727bbSDavide Caratti goto put_chain; 190c749cddaSDavide Caratti } 191c749cddaSDavide Caratti 192c749cddaSDavide Caratti params_new->flags = flags; 193ca9b0e27SAlexander Duyck if (flags & SKBEDIT_F_PRIORITY) 194c749cddaSDavide Caratti params_new->priority = *priority; 195ca9b0e27SAlexander Duyck if (flags & SKBEDIT_F_QUEUE_MAPPING) 196c749cddaSDavide Caratti params_new->queue_mapping = *queue_mapping; 1971c55d62eSjamal if (flags & SKBEDIT_F_MARK) 198c749cddaSDavide Caratti params_new->mark = *mark; 199ff202ee1SJamal Hadi Salim if (flags & SKBEDIT_F_PTYPE) 200c749cddaSDavide Caratti params_new->ptype = *ptype; 2014fe77d82SAntonio Quartulli /* default behaviour is to use all the bits */ 202c749cddaSDavide Caratti params_new->mask = 0xffffffff; 2034fe77d82SAntonio Quartulli if (flags & SKBEDIT_F_MASK) 204c749cddaSDavide Caratti params_new->mask = *mask; 2051c55d62eSjamal 2066d7a8df6SVlad Buslov spin_lock_bh(&d->tcf_lock); 207ec7727bbSDavide Caratti goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); 2086d7a8df6SVlad Buslov rcu_swap_protected(d->params, params_new, 2096d7a8df6SVlad Buslov lockdep_is_held(&d->tcf_lock)); 2106d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 2116d7a8df6SVlad Buslov if (params_new) 2126d7a8df6SVlad Buslov kfree_rcu(params_new, rcu); 213ec7727bbSDavide Caratti if (goto_ch) 214ec7727bbSDavide Caratti tcf_chain_put_by_act(goto_ch); 215ca9b0e27SAlexander Duyck 216ca9b0e27SAlexander Duyck if (ret == ACT_P_CREATED) 21765a206c0SChris Mi tcf_idr_insert(tn, *a); 218ca9b0e27SAlexander Duyck return ret; 219ec7727bbSDavide Caratti put_chain: 220ec7727bbSDavide Caratti if (goto_ch) 221ec7727bbSDavide Caratti tcf_chain_put_by_act(goto_ch); 222ec7727bbSDavide Caratti release_idr: 223ec7727bbSDavide Caratti tcf_idr_release(*a, bind); 224ec7727bbSDavide Caratti return err; 225ca9b0e27SAlexander Duyck } 226ca9b0e27SAlexander Duyck 227cc7ec456SEric Dumazet static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, 228ca9b0e27SAlexander Duyck int bind, int ref) 229ca9b0e27SAlexander Duyck { 230ca9b0e27SAlexander Duyck unsigned char *b = skb_tail_pointer(skb); 231a85a970aSWANG Cong struct tcf_skbedit *d = to_skbedit(a); 232c749cddaSDavide Caratti struct tcf_skbedit_params *params; 2331c40be12SEric Dumazet struct tc_skbedit opt = { 2341c40be12SEric Dumazet .index = d->tcf_index, 235036bb443SVlad Buslov .refcnt = refcount_read(&d->tcf_refcnt) - ref, 236036bb443SVlad Buslov .bindcnt = atomic_read(&d->tcf_bindcnt) - bind, 2371c40be12SEric Dumazet }; 238e7e3728bSQiaobin Fu u64 pure_flags = 0; 239c749cddaSDavide Caratti struct tcf_t t; 240c749cddaSDavide Caratti 2416d7a8df6SVlad Buslov spin_lock_bh(&d->tcf_lock); 2426d7a8df6SVlad Buslov params = rcu_dereference_protected(d->params, 2436d7a8df6SVlad Buslov lockdep_is_held(&d->tcf_lock)); 2446d7a8df6SVlad Buslov opt.action = d->tcf_action; 245ca9b0e27SAlexander Duyck 2461b34ec43SDavid S. Miller if (nla_put(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt)) 2471b34ec43SDavid S. Miller goto nla_put_failure; 248c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_PRIORITY) && 249c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_PRIORITY, params->priority)) 2501b34ec43SDavid S. Miller goto nla_put_failure; 251c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_QUEUE_MAPPING) && 252c749cddaSDavide Caratti nla_put_u16(skb, TCA_SKBEDIT_QUEUE_MAPPING, params->queue_mapping)) 2531b34ec43SDavid S. Miller goto nla_put_failure; 254c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_MARK) && 255c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_MARK, params->mark)) 2561b34ec43SDavid S. Miller goto nla_put_failure; 257c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_PTYPE) && 258c749cddaSDavide Caratti nla_put_u16(skb, TCA_SKBEDIT_PTYPE, params->ptype)) 259ff202ee1SJamal Hadi Salim goto nla_put_failure; 260c749cddaSDavide Caratti if ((params->flags & SKBEDIT_F_MASK) && 261c749cddaSDavide Caratti nla_put_u32(skb, TCA_SKBEDIT_MASK, params->mask)) 2624fe77d82SAntonio Quartulli goto nla_put_failure; 263c749cddaSDavide Caratti if (params->flags & SKBEDIT_F_INHERITDSFIELD) 264e7e3728bSQiaobin Fu pure_flags |= SKBEDIT_F_INHERITDSFIELD; 265e7e3728bSQiaobin Fu if (pure_flags != 0 && 266e7e3728bSQiaobin Fu nla_put(skb, TCA_SKBEDIT_FLAGS, sizeof(pure_flags), &pure_flags)) 267e7e3728bSQiaobin Fu goto nla_put_failure; 26848d8ee16SJamal Hadi Salim 26948d8ee16SJamal Hadi Salim tcf_tm_dump(&t, &d->tcf_tm); 2709854518eSNicolas Dichtel if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD)) 2711b34ec43SDavid S. Miller goto nla_put_failure; 2726d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 2736d7a8df6SVlad Buslov 274ca9b0e27SAlexander Duyck return skb->len; 275ca9b0e27SAlexander Duyck 276ca9b0e27SAlexander Duyck nla_put_failure: 2776d7a8df6SVlad Buslov spin_unlock_bh(&d->tcf_lock); 278ca9b0e27SAlexander Duyck nlmsg_trim(skb, b); 279ca9b0e27SAlexander Duyck return -1; 280ca9b0e27SAlexander Duyck } 281ca9b0e27SAlexander Duyck 282c749cddaSDavide Caratti static void tcf_skbedit_cleanup(struct tc_action *a) 283c749cddaSDavide Caratti { 284c749cddaSDavide Caratti struct tcf_skbedit *d = to_skbedit(a); 285c749cddaSDavide Caratti struct tcf_skbedit_params *params; 286c749cddaSDavide Caratti 287c749cddaSDavide Caratti params = rcu_dereference_protected(d->params, 1); 288c749cddaSDavide Caratti if (params) 289c749cddaSDavide Caratti kfree_rcu(params, rcu); 290c749cddaSDavide Caratti } 291c749cddaSDavide Caratti 292ddf97ccdSWANG Cong static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb, 293ddf97ccdSWANG Cong struct netlink_callback *cb, int type, 29441780105SAlexander Aring const struct tc_action_ops *ops, 29541780105SAlexander Aring struct netlink_ext_ack *extack) 296ddf97ccdSWANG Cong { 297ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 298ddf97ccdSWANG Cong 299b3620145SAlexander Aring return tcf_generic_walker(tn, skb, cb, type, ops, extack); 300ddf97ccdSWANG Cong } 301ddf97ccdSWANG Cong 302f061b48cSCong Wang static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index) 303ddf97ccdSWANG Cong { 304ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 305ddf97ccdSWANG Cong 30665a206c0SChris Mi return tcf_idr_search(tn, a, index); 307ddf97ccdSWANG Cong } 308ddf97ccdSWANG Cong 309ca9b0e27SAlexander Duyck static struct tc_action_ops act_skbedit_ops = { 310ca9b0e27SAlexander Duyck .kind = "skbedit", 311eddd2cf1SEli Cohen .id = TCA_ID_SKBEDIT, 312ca9b0e27SAlexander Duyck .owner = THIS_MODULE, 31345da1dacSJamal Hadi Salim .act = tcf_skbedit_act, 314ca9b0e27SAlexander Duyck .dump = tcf_skbedit_dump, 315ca9b0e27SAlexander Duyck .init = tcf_skbedit_init, 316c749cddaSDavide Caratti .cleanup = tcf_skbedit_cleanup, 317ddf97ccdSWANG Cong .walk = tcf_skbedit_walker, 318ddf97ccdSWANG Cong .lookup = tcf_skbedit_search, 319a85a970aSWANG Cong .size = sizeof(struct tcf_skbedit), 320ddf97ccdSWANG Cong }; 321ddf97ccdSWANG Cong 322ddf97ccdSWANG Cong static __net_init int skbedit_init_net(struct net *net) 323ddf97ccdSWANG Cong { 324ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, skbedit_net_id); 325ddf97ccdSWANG Cong 326c7e460ceSCong Wang return tc_action_net_init(tn, &act_skbedit_ops); 327ddf97ccdSWANG Cong } 328ddf97ccdSWANG Cong 329039af9c6SCong Wang static void __net_exit skbedit_exit_net(struct list_head *net_list) 330ddf97ccdSWANG Cong { 331039af9c6SCong Wang tc_action_net_exit(net_list, skbedit_net_id); 332ddf97ccdSWANG Cong } 333ddf97ccdSWANG Cong 334ddf97ccdSWANG Cong static struct pernet_operations skbedit_net_ops = { 335ddf97ccdSWANG Cong .init = skbedit_init_net, 336039af9c6SCong Wang .exit_batch = skbedit_exit_net, 337ddf97ccdSWANG Cong .id = &skbedit_net_id, 338ddf97ccdSWANG Cong .size = sizeof(struct tc_action_net), 339ca9b0e27SAlexander Duyck }; 340ca9b0e27SAlexander Duyck 341ca9b0e27SAlexander Duyck MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>"); 342ca9b0e27SAlexander Duyck MODULE_DESCRIPTION("SKB Editing"); 343ca9b0e27SAlexander Duyck MODULE_LICENSE("GPL"); 344ca9b0e27SAlexander Duyck 345ca9b0e27SAlexander Duyck static int __init skbedit_init_module(void) 346ca9b0e27SAlexander Duyck { 347ddf97ccdSWANG Cong return tcf_register_action(&act_skbedit_ops, &skbedit_net_ops); 348ca9b0e27SAlexander Duyck } 349ca9b0e27SAlexander Duyck 350ca9b0e27SAlexander Duyck static void __exit skbedit_cleanup_module(void) 351ca9b0e27SAlexander Duyck { 352ddf97ccdSWANG Cong tcf_unregister_action(&act_skbedit_ops, &skbedit_net_ops); 353ca9b0e27SAlexander Duyck } 354ca9b0e27SAlexander Duyck 355ca9b0e27SAlexander Duyck module_init(skbedit_init_module); 356ca9b0e27SAlexander Duyck module_exit(skbedit_cleanup_module); 357