14bba3925SPatrick McHardy /* 20c6965ddSJiri Pirko * net/sched/act_police.c Input police filter 34bba3925SPatrick McHardy * 44bba3925SPatrick McHardy * This program is free software; you can redistribute it and/or 54bba3925SPatrick McHardy * modify it under the terms of the GNU General Public License 64bba3925SPatrick McHardy * as published by the Free Software Foundation; either version 74bba3925SPatrick McHardy * 2 of the License, or (at your option) any later version. 84bba3925SPatrick McHardy * 94bba3925SPatrick McHardy * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 104bba3925SPatrick McHardy * J Hadi Salim (action changes) 114bba3925SPatrick McHardy */ 124bba3925SPatrick McHardy 134bba3925SPatrick McHardy #include <linux/module.h> 144bba3925SPatrick McHardy #include <linux/types.h> 154bba3925SPatrick McHardy #include <linux/kernel.h> 164bba3925SPatrick McHardy #include <linux/string.h> 174bba3925SPatrick McHardy #include <linux/errno.h> 184bba3925SPatrick McHardy #include <linux/skbuff.h> 194bba3925SPatrick McHardy #include <linux/rtnetlink.h> 204bba3925SPatrick McHardy #include <linux/init.h> 215a0e3ad6STejun Heo #include <linux/slab.h> 224bba3925SPatrick McHardy #include <net/act_api.h> 23dc5fc579SArnaldo Carvalho de Melo #include <net/netlink.h> 244bba3925SPatrick McHardy 250e243218SJiri Pirko struct tcf_police { 26ec0595ccSWANG Cong struct tc_action common; 270e243218SJiri Pirko int tcfp_result; 280e243218SJiri Pirko u32 tcfp_ewma_rate; 29c6d14ff1SJiri Pirko s64 tcfp_burst; 300e243218SJiri Pirko u32 tcfp_mtu; 31c6d14ff1SJiri Pirko s64 tcfp_toks; 32c6d14ff1SJiri Pirko s64 tcfp_ptoks; 33c6d14ff1SJiri Pirko s64 tcfp_mtu_ptoks; 34c6d14ff1SJiri Pirko s64 tcfp_t_c; 35c6d14ff1SJiri Pirko struct psched_ratecfg rate; 36c6d14ff1SJiri Pirko bool rate_present; 37c6d14ff1SJiri Pirko struct psched_ratecfg peak; 38c6d14ff1SJiri Pirko bool peak_present; 390e243218SJiri Pirko }; 40a85a970aSWANG Cong 41a85a970aSWANG Cong #define to_police(pc) ((struct tcf_police *)pc) 420e243218SJiri Pirko 431e9b3d53SPatrick McHardy /* old policer structure from before tc actions */ 44cc7ec456SEric Dumazet struct tc_police_compat { 451e9b3d53SPatrick McHardy u32 index; 461e9b3d53SPatrick McHardy int action; 471e9b3d53SPatrick McHardy u32 limit; 481e9b3d53SPatrick McHardy u32 burst; 491e9b3d53SPatrick McHardy u32 mtu; 501e9b3d53SPatrick McHardy struct tc_ratespec rate; 511e9b3d53SPatrick McHardy struct tc_ratespec peakrate; 521e9b3d53SPatrick McHardy }; 531e9b3d53SPatrick McHardy 544bba3925SPatrick McHardy /* Each policer is serialized by its individual spinlock */ 554bba3925SPatrick McHardy 56c7d03a00SAlexey Dobriyan static unsigned int police_net_id; 57a85a970aSWANG Cong static struct tc_action_ops act_police_ops; 58ddf97ccdSWANG Cong 59ddf97ccdSWANG Cong static int tcf_act_police_walker(struct net *net, struct sk_buff *skb, 60ddf97ccdSWANG Cong struct netlink_callback *cb, int type, 6141780105SAlexander Aring const struct tc_action_ops *ops, 6241780105SAlexander Aring struct netlink_ext_ack *extack) 634bba3925SPatrick McHardy { 64ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, police_net_id); 654bba3925SPatrick McHardy 66b3620145SAlexander Aring return tcf_generic_walker(tn, skb, cb, type, ops, extack); 674bba3925SPatrick McHardy } 684bba3925SPatrick McHardy 6953b2bf3fSPatrick McHardy static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { 7053b2bf3fSPatrick McHardy [TCA_POLICE_RATE] = { .len = TC_RTAB_SIZE }, 7153b2bf3fSPatrick McHardy [TCA_POLICE_PEAKRATE] = { .len = TC_RTAB_SIZE }, 7253b2bf3fSPatrick McHardy [TCA_POLICE_AVRATE] = { .type = NLA_U32 }, 7353b2bf3fSPatrick McHardy [TCA_POLICE_RESULT] = { .type = NLA_U32 }, 7453b2bf3fSPatrick McHardy }; 7553b2bf3fSPatrick McHardy 76d9fa17efSWANG Cong static int tcf_act_police_init(struct net *net, struct nlattr *nla, 77a85a970aSWANG Cong struct nlattr *est, struct tc_action **a, 78789871bbSVlad Buslov int ovr, int bind, bool rtnl_held, 79589dad6dSAlexander Aring struct netlink_ext_ack *extack) 804bba3925SPatrick McHardy { 814bba3925SPatrick McHardy int ret = 0, err; 827ba699c6SPatrick McHardy struct nlattr *tb[TCA_POLICE_MAX + 1]; 834bba3925SPatrick McHardy struct tc_police *parm; 84e9ce1cd3SDavid S. Miller struct tcf_police *police; 854bba3925SPatrick McHardy struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 86ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, police_net_id); 870852e455SWANG Cong bool exists = false; 881e9b3d53SPatrick McHardy int size; 894bba3925SPatrick McHardy 90cee63723SPatrick McHardy if (nla == NULL) 914bba3925SPatrick McHardy return -EINVAL; 924bba3925SPatrick McHardy 93fceb6435SJohannes Berg err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, police_policy, NULL); 94cee63723SPatrick McHardy if (err < 0) 95cee63723SPatrick McHardy return err; 96cee63723SPatrick McHardy 977ba699c6SPatrick McHardy if (tb[TCA_POLICE_TBF] == NULL) 981e9b3d53SPatrick McHardy return -EINVAL; 997ba699c6SPatrick McHardy size = nla_len(tb[TCA_POLICE_TBF]); 1001e9b3d53SPatrick McHardy if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat)) 1014bba3925SPatrick McHardy return -EINVAL; 1024bba3925SPatrick McHardy 1030852e455SWANG Cong parm = nla_data(tb[TCA_POLICE_TBF]); 104*0190c1d4SVlad Buslov err = tcf_idr_check_alloc(tn, &parm->index, a, bind); 105*0190c1d4SVlad Buslov if (err < 0) 106*0190c1d4SVlad Buslov return err; 107*0190c1d4SVlad Buslov exists = err; 1080852e455SWANG Cong if (exists && bind) 1090852e455SWANG Cong return 0; 1100852e455SWANG Cong 1110852e455SWANG Cong if (!exists) { 11265a206c0SChris Mi ret = tcf_idr_create(tn, parm->index, NULL, a, 113a85a970aSWANG Cong &act_police_ops, bind, false); 114*0190c1d4SVlad Buslov if (ret) { 115*0190c1d4SVlad Buslov tcf_idr_cleanup(tn, parm->index); 116a03e6fe5SWANG Cong return ret; 117*0190c1d4SVlad Buslov } 118a03e6fe5SWANG Cong ret = ACT_P_CREATED; 1194e8ddd7fSVlad Buslov } else if (!ovr) { 12065a206c0SChris Mi tcf_idr_release(*a, bind); 1210852e455SWANG Cong return -EEXIST; 122e9ce1cd3SDavid S. Miller } 1234bba3925SPatrick McHardy 124a85a970aSWANG Cong police = to_police(*a); 1254bba3925SPatrick McHardy if (parm->rate.rate) { 1264bba3925SPatrick McHardy err = -ENOMEM; 127e9bc3fa2SAlexander Aring R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE], NULL); 1284bba3925SPatrick McHardy if (R_tab == NULL) 1294bba3925SPatrick McHardy goto failure; 130c1b56878SStephen Hemminger 1314bba3925SPatrick McHardy if (parm->peakrate.rate) { 1324bba3925SPatrick McHardy P_tab = qdisc_get_rtab(&parm->peakrate, 133e9bc3fa2SAlexander Aring tb[TCA_POLICE_PEAKRATE], NULL); 13471bcb09aSStephen Hemminger if (P_tab == NULL) 1354bba3925SPatrick McHardy goto failure; 1364bba3925SPatrick McHardy } 1374bba3925SPatrick McHardy } 13871bcb09aSStephen Hemminger 13971bcb09aSStephen Hemminger if (est) { 14022e0f8b9SJohn Fastabend err = gen_replace_estimator(&police->tcf_bstats, NULL, 14171bcb09aSStephen Hemminger &police->tcf_rate_est, 142edb09eb1SEric Dumazet &police->tcf_lock, 143edb09eb1SEric Dumazet NULL, est); 14471bcb09aSStephen Hemminger if (err) 14574030603SWANG Cong goto failure; 146a883bf56SJarek Poplawski } else if (tb[TCA_POLICE_AVRATE] && 147a883bf56SJarek Poplawski (ret == ACT_P_CREATED || 1481c0d32fdSEric Dumazet !gen_estimator_active(&police->tcf_rate_est))) { 149a883bf56SJarek Poplawski err = -EINVAL; 15074030603SWANG Cong goto failure; 15171bcb09aSStephen Hemminger } 15271bcb09aSStephen Hemminger 15374030603SWANG Cong spin_lock_bh(&police->tcf_lock); 15471bcb09aSStephen Hemminger /* No failure allowed after this point */ 155c6d14ff1SJiri Pirko police->tcfp_mtu = parm->mtu; 156c6d14ff1SJiri Pirko if (police->tcfp_mtu == 0) { 157c6d14ff1SJiri Pirko police->tcfp_mtu = ~0; 158c6d14ff1SJiri Pirko if (R_tab) 159c6d14ff1SJiri Pirko police->tcfp_mtu = 255 << R_tab->rate.cell_log; 1604bba3925SPatrick McHardy } 161c6d14ff1SJiri Pirko if (R_tab) { 162c6d14ff1SJiri Pirko police->rate_present = true; 1633e1e3aaeSEric Dumazet psched_ratecfg_precompute(&police->rate, &R_tab->rate, 0); 164c6d14ff1SJiri Pirko qdisc_put_rtab(R_tab); 165c6d14ff1SJiri Pirko } else { 166c6d14ff1SJiri Pirko police->rate_present = false; 167c6d14ff1SJiri Pirko } 168c6d14ff1SJiri Pirko if (P_tab) { 169c6d14ff1SJiri Pirko police->peak_present = true; 1703e1e3aaeSEric Dumazet psched_ratecfg_precompute(&police->peak, &P_tab->rate, 0); 171c6d14ff1SJiri Pirko qdisc_put_rtab(P_tab); 172c6d14ff1SJiri Pirko } else { 173c6d14ff1SJiri Pirko police->peak_present = false; 1744bba3925SPatrick McHardy } 1754bba3925SPatrick McHardy 1767ba699c6SPatrick McHardy if (tb[TCA_POLICE_RESULT]) 1771587bac4SPatrick McHardy police->tcfp_result = nla_get_u32(tb[TCA_POLICE_RESULT]); 178c6d14ff1SJiri Pirko police->tcfp_burst = PSCHED_TICKS2NS(parm->burst); 179c6d14ff1SJiri Pirko police->tcfp_toks = police->tcfp_burst; 180c6d14ff1SJiri Pirko if (police->peak_present) { 181c6d14ff1SJiri Pirko police->tcfp_mtu_ptoks = (s64) psched_l2t_ns(&police->peak, 182c6d14ff1SJiri Pirko police->tcfp_mtu); 183c6d14ff1SJiri Pirko police->tcfp_ptoks = police->tcfp_mtu_ptoks; 1844bba3925SPatrick McHardy } 185e9ce1cd3SDavid S. Miller police->tcf_action = parm->action; 1864bba3925SPatrick McHardy 1877ba699c6SPatrick McHardy if (tb[TCA_POLICE_AVRATE]) 1881587bac4SPatrick McHardy police->tcfp_ewma_rate = nla_get_u32(tb[TCA_POLICE_AVRATE]); 1894bba3925SPatrick McHardy 190e9ce1cd3SDavid S. Miller spin_unlock_bh(&police->tcf_lock); 1914bba3925SPatrick McHardy if (ret != ACT_P_CREATED) 1924bba3925SPatrick McHardy return ret; 1934bba3925SPatrick McHardy 194d2de875cSEric Dumazet police->tcfp_t_c = ktime_get_ns(); 19565a206c0SChris Mi tcf_idr_insert(tn, *a); 1964bba3925SPatrick McHardy 1974bba3925SPatrick McHardy return ret; 1984bba3925SPatrick McHardy 1994bba3925SPatrick McHardy failure: 20071bcb09aSStephen Hemminger qdisc_put_rtab(P_tab); 20171bcb09aSStephen Hemminger qdisc_put_rtab(R_tab); 2025bf7f818SDavide Caratti tcf_idr_release(*a, bind); 2034bba3925SPatrick McHardy return err; 2044bba3925SPatrick McHardy } 2054bba3925SPatrick McHardy 206dc7f9f6eSEric Dumazet static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a, 2074bba3925SPatrick McHardy struct tcf_result *res) 2084bba3925SPatrick McHardy { 209a85a970aSWANG Cong struct tcf_police *police = to_police(a); 210c6d14ff1SJiri Pirko s64 now; 211c6d14ff1SJiri Pirko s64 toks; 212c6d14ff1SJiri Pirko s64 ptoks = 0; 2134bba3925SPatrick McHardy 214e9ce1cd3SDavid S. Miller spin_lock(&police->tcf_lock); 2154bba3925SPatrick McHardy 216bfe0d029SEric Dumazet bstats_update(&police->tcf_bstats, skb); 2173d3ed181SJamal Hadi Salim tcf_lastuse_update(&police->tcf_tm); 2184bba3925SPatrick McHardy 2191c0d32fdSEric Dumazet if (police->tcfp_ewma_rate) { 2201c0d32fdSEric Dumazet struct gnet_stats_rate_est64 sample; 2211c0d32fdSEric Dumazet 2221c0d32fdSEric Dumazet if (!gen_estimator_read(&police->tcf_rate_est, &sample) || 2231c0d32fdSEric Dumazet sample.bps >= police->tcfp_ewma_rate) { 224e9ce1cd3SDavid S. Miller police->tcf_qstats.overlimits++; 225b9647580SJarek Poplawski if (police->tcf_action == TC_ACT_SHOT) 226b9647580SJarek Poplawski police->tcf_qstats.drops++; 227e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 228e9ce1cd3SDavid S. Miller return police->tcf_action; 2294bba3925SPatrick McHardy } 2301c0d32fdSEric Dumazet } 2314bba3925SPatrick McHardy 2320abf77e5SJussi Kivilinna if (qdisc_pkt_len(skb) <= police->tcfp_mtu) { 233c6d14ff1SJiri Pirko if (!police->rate_present) { 234e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 235e9ce1cd3SDavid S. Miller return police->tcfp_result; 2364bba3925SPatrick McHardy } 2374bba3925SPatrick McHardy 238d2de875cSEric Dumazet now = ktime_get_ns(); 239c6d14ff1SJiri Pirko toks = min_t(s64, now - police->tcfp_t_c, 240e9ce1cd3SDavid S. Miller police->tcfp_burst); 241c6d14ff1SJiri Pirko if (police->peak_present) { 242e9ce1cd3SDavid S. Miller ptoks = toks + police->tcfp_ptoks; 243c6d14ff1SJiri Pirko if (ptoks > police->tcfp_mtu_ptoks) 244c6d14ff1SJiri Pirko ptoks = police->tcfp_mtu_ptoks; 245c6d14ff1SJiri Pirko ptoks -= (s64) psched_l2t_ns(&police->peak, 246c6d14ff1SJiri Pirko qdisc_pkt_len(skb)); 2474bba3925SPatrick McHardy } 248e9ce1cd3SDavid S. Miller toks += police->tcfp_toks; 249c6d14ff1SJiri Pirko if (toks > police->tcfp_burst) 250e9ce1cd3SDavid S. Miller toks = police->tcfp_burst; 251c6d14ff1SJiri Pirko toks -= (s64) psched_l2t_ns(&police->rate, qdisc_pkt_len(skb)); 2524bba3925SPatrick McHardy if ((toks|ptoks) >= 0) { 253e9ce1cd3SDavid S. Miller police->tcfp_t_c = now; 254e9ce1cd3SDavid S. Miller police->tcfp_toks = toks; 255e9ce1cd3SDavid S. Miller police->tcfp_ptoks = ptoks; 256f71b109fSRoman Mashak if (police->tcfp_result == TC_ACT_SHOT) 257f71b109fSRoman Mashak police->tcf_qstats.drops++; 258e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 259e9ce1cd3SDavid S. Miller return police->tcfp_result; 2604bba3925SPatrick McHardy } 2614bba3925SPatrick McHardy } 2624bba3925SPatrick McHardy 263e9ce1cd3SDavid S. Miller police->tcf_qstats.overlimits++; 264b9647580SJarek Poplawski if (police->tcf_action == TC_ACT_SHOT) 265b9647580SJarek Poplawski police->tcf_qstats.drops++; 266e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 267e9ce1cd3SDavid S. Miller return police->tcf_action; 2684bba3925SPatrick McHardy } 2694bba3925SPatrick McHardy 2705a7a5555SJamal Hadi Salim static int tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, 2715a7a5555SJamal Hadi Salim int bind, int ref) 2724bba3925SPatrick McHardy { 27327a884dcSArnaldo Carvalho de Melo unsigned char *b = skb_tail_pointer(skb); 274a85a970aSWANG Cong struct tcf_police *police = to_police(a); 2750f04cfd0SJeff Mahoney struct tc_police opt = { 2760f04cfd0SJeff Mahoney .index = police->tcf_index, 2770f04cfd0SJeff Mahoney .action = police->tcf_action, 2780f04cfd0SJeff Mahoney .mtu = police->tcfp_mtu, 279c6d14ff1SJiri Pirko .burst = PSCHED_NS2TICKS(police->tcfp_burst), 280036bb443SVlad Buslov .refcnt = refcount_read(&police->tcf_refcnt) - ref, 281036bb443SVlad Buslov .bindcnt = atomic_read(&police->tcf_bindcnt) - bind, 2820f04cfd0SJeff Mahoney }; 2833d3ed181SJamal Hadi Salim struct tcf_t t; 2844bba3925SPatrick McHardy 285c6d14ff1SJiri Pirko if (police->rate_present) 28601cb71d2SEric Dumazet psched_ratecfg_getrate(&opt.rate, &police->rate); 287c6d14ff1SJiri Pirko if (police->peak_present) 28801cb71d2SEric Dumazet psched_ratecfg_getrate(&opt.peakrate, &police->peak); 2891b34ec43SDavid S. Miller if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt)) 2901b34ec43SDavid S. Miller goto nla_put_failure; 2911b34ec43SDavid S. Miller if (police->tcfp_result && 2921b34ec43SDavid S. Miller nla_put_u32(skb, TCA_POLICE_RESULT, police->tcfp_result)) 2931b34ec43SDavid S. Miller goto nla_put_failure; 2941b34ec43SDavid S. Miller if (police->tcfp_ewma_rate && 2951b34ec43SDavid S. Miller nla_put_u32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate)) 2961b34ec43SDavid S. Miller goto nla_put_failure; 2973d3ed181SJamal Hadi Salim 2983d3ed181SJamal Hadi Salim t.install = jiffies_to_clock_t(jiffies - police->tcf_tm.install); 2993d3ed181SJamal Hadi Salim t.lastuse = jiffies_to_clock_t(jiffies - police->tcf_tm.lastuse); 30053eb440fSJamal Hadi Salim t.firstuse = jiffies_to_clock_t(jiffies - police->tcf_tm.firstuse); 3013d3ed181SJamal Hadi Salim t.expires = jiffies_to_clock_t(police->tcf_tm.expires); 3023d3ed181SJamal Hadi Salim if (nla_put_64bit(skb, TCA_POLICE_TM, sizeof(t), &t, TCA_POLICE_PAD)) 3033d3ed181SJamal Hadi Salim goto nla_put_failure; 3043d3ed181SJamal Hadi Salim 3054bba3925SPatrick McHardy return skb->len; 3064bba3925SPatrick McHardy 3077ba699c6SPatrick McHardy nla_put_failure: 308dc5fc579SArnaldo Carvalho de Melo nlmsg_trim(skb, b); 3094bba3925SPatrick McHardy return -1; 3104bba3925SPatrick McHardy } 3114bba3925SPatrick McHardy 312331a9295SAlexander Aring static int tcf_police_search(struct net *net, struct tc_action **a, u32 index, 313331a9295SAlexander Aring struct netlink_ext_ack *extack) 314ddf97ccdSWANG Cong { 315ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, police_net_id); 316ddf97ccdSWANG Cong 31765a206c0SChris Mi return tcf_idr_search(tn, a, index); 318ddf97ccdSWANG Cong } 319ddf97ccdSWANG Cong 320b409074eSVlad Buslov static int tcf_police_delete(struct net *net, u32 index) 321b409074eSVlad Buslov { 322b409074eSVlad Buslov struct tc_action_net *tn = net_generic(net, police_net_id); 323b409074eSVlad Buslov 324b409074eSVlad Buslov return tcf_idr_delete_index(tn, index); 325b409074eSVlad Buslov } 326b409074eSVlad Buslov 3274bba3925SPatrick McHardy MODULE_AUTHOR("Alexey Kuznetsov"); 3284bba3925SPatrick McHardy MODULE_DESCRIPTION("Policing actions"); 3294bba3925SPatrick McHardy MODULE_LICENSE("GPL"); 3304bba3925SPatrick McHardy 3314bba3925SPatrick McHardy static struct tc_action_ops act_police_ops = { 3324bba3925SPatrick McHardy .kind = "police", 3334bba3925SPatrick McHardy .type = TCA_ID_POLICE, 3344bba3925SPatrick McHardy .owner = THIS_MODULE, 3354bba3925SPatrick McHardy .act = tcf_act_police, 3364bba3925SPatrick McHardy .dump = tcf_act_police_dump, 337d9fa17efSWANG Cong .init = tcf_act_police_init, 338ddf97ccdSWANG Cong .walk = tcf_act_police_walker, 339ddf97ccdSWANG Cong .lookup = tcf_police_search, 340b409074eSVlad Buslov .delete = tcf_police_delete, 341a85a970aSWANG Cong .size = sizeof(struct tcf_police), 342ddf97ccdSWANG Cong }; 343ddf97ccdSWANG Cong 344ddf97ccdSWANG Cong static __net_init int police_init_net(struct net *net) 345ddf97ccdSWANG Cong { 346ddf97ccdSWANG Cong struct tc_action_net *tn = net_generic(net, police_net_id); 347ddf97ccdSWANG Cong 348c7e460ceSCong Wang return tc_action_net_init(tn, &act_police_ops); 349ddf97ccdSWANG Cong } 350ddf97ccdSWANG Cong 351039af9c6SCong Wang static void __net_exit police_exit_net(struct list_head *net_list) 352ddf97ccdSWANG Cong { 353039af9c6SCong Wang tc_action_net_exit(net_list, police_net_id); 354ddf97ccdSWANG Cong } 355ddf97ccdSWANG Cong 356ddf97ccdSWANG Cong static struct pernet_operations police_net_ops = { 357ddf97ccdSWANG Cong .init = police_init_net, 358039af9c6SCong Wang .exit_batch = police_exit_net, 359ddf97ccdSWANG Cong .id = &police_net_id, 360ddf97ccdSWANG Cong .size = sizeof(struct tc_action_net), 3614bba3925SPatrick McHardy }; 3624bba3925SPatrick McHardy 3635a7a5555SJamal Hadi Salim static int __init police_init_module(void) 3644bba3925SPatrick McHardy { 365ddf97ccdSWANG Cong return tcf_register_action(&act_police_ops, &police_net_ops); 3664bba3925SPatrick McHardy } 3674bba3925SPatrick McHardy 3685a7a5555SJamal Hadi Salim static void __exit police_cleanup_module(void) 3694bba3925SPatrick McHardy { 370ddf97ccdSWANG Cong tcf_unregister_action(&act_police_ops, &police_net_ops); 3714bba3925SPatrick McHardy } 3724bba3925SPatrick McHardy 3734bba3925SPatrick McHardy module_init(police_init_module); 3744bba3925SPatrick McHardy module_exit(police_cleanup_module); 375