14bba3925SPatrick McHardy /* 24bba3925SPatrick McHardy * net/sched/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> 214bba3925SPatrick McHardy #include <net/act_api.h> 22dc5fc579SArnaldo Carvalho de Melo #include <net/netlink.h> 234bba3925SPatrick McHardy 24e9bef55dSJesper Dangaard Brouer #define L2T(p,L) qdisc_l2t((p)->tcfp_R_tab, L) 25e9bef55dSJesper Dangaard Brouer #define L2T_P(p,L) qdisc_l2t((p)->tcfp_P_tab, L) 264bba3925SPatrick McHardy 27e9ce1cd3SDavid S. Miller #define POL_TAB_MASK 15 28e9ce1cd3SDavid S. Miller static struct tcf_common *tcf_police_ht[POL_TAB_MASK + 1]; 29e9ce1cd3SDavid S. Miller static u32 police_idx_gen; 304bba3925SPatrick McHardy static DEFINE_RWLOCK(police_lock); 314bba3925SPatrick McHardy 32e9ce1cd3SDavid S. Miller static struct tcf_hashinfo police_hash_info = { 33e9ce1cd3SDavid S. Miller .htab = tcf_police_ht, 34e9ce1cd3SDavid S. Miller .hmask = POL_TAB_MASK, 35e9ce1cd3SDavid S. Miller .lock = &police_lock, 36e9ce1cd3SDavid S. Miller }; 37e9ce1cd3SDavid S. Miller 381e9b3d53SPatrick McHardy /* old policer structure from before tc actions */ 391e9b3d53SPatrick McHardy struct tc_police_compat 401e9b3d53SPatrick McHardy { 411e9b3d53SPatrick McHardy u32 index; 421e9b3d53SPatrick McHardy int action; 431e9b3d53SPatrick McHardy u32 limit; 441e9b3d53SPatrick McHardy u32 burst; 451e9b3d53SPatrick McHardy u32 mtu; 461e9b3d53SPatrick McHardy struct tc_ratespec rate; 471e9b3d53SPatrick McHardy struct tc_ratespec peakrate; 481e9b3d53SPatrick McHardy }; 491e9b3d53SPatrick McHardy 504bba3925SPatrick McHardy /* Each policer is serialized by its individual spinlock */ 514bba3925SPatrick McHardy 5283b950c8SJamal Hadi Salim static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *cb, 534bba3925SPatrick McHardy int type, struct tc_action *a) 544bba3925SPatrick McHardy { 55e9ce1cd3SDavid S. Miller struct tcf_common *p; 564bba3925SPatrick McHardy int err = 0, index = -1, i = 0, s_i = 0, n_i = 0; 574b3550efSPatrick McHardy struct nlattr *nest; 584bba3925SPatrick McHardy 59e1e992e5SJamal Hadi Salim read_lock_bh(&police_lock); 604bba3925SPatrick McHardy 614bba3925SPatrick McHardy s_i = cb->args[0]; 624bba3925SPatrick McHardy 63e9ce1cd3SDavid S. Miller for (i = 0; i < (POL_TAB_MASK + 1); i++) { 64e9ce1cd3SDavid S. Miller p = tcf_police_ht[tcf_hash(i, POL_TAB_MASK)]; 654bba3925SPatrick McHardy 66e9ce1cd3SDavid S. Miller for (; p; p = p->tcfc_next) { 674bba3925SPatrick McHardy index++; 684bba3925SPatrick McHardy if (index < s_i) 694bba3925SPatrick McHardy continue; 704bba3925SPatrick McHardy a->priv = p; 714bba3925SPatrick McHardy a->order = index; 724b3550efSPatrick McHardy nest = nla_nest_start(skb, a->order); 734b3550efSPatrick McHardy if (nest == NULL) 744b3550efSPatrick McHardy goto nla_put_failure; 754bba3925SPatrick McHardy if (type == RTM_DELACTION) 764bba3925SPatrick McHardy err = tcf_action_dump_1(skb, a, 0, 1); 774bba3925SPatrick McHardy else 784bba3925SPatrick McHardy err = tcf_action_dump_1(skb, a, 0, 0); 794bba3925SPatrick McHardy if (err < 0) { 804bba3925SPatrick McHardy index--; 814b3550efSPatrick McHardy nla_nest_cancel(skb, nest); 824bba3925SPatrick McHardy goto done; 834bba3925SPatrick McHardy } 844b3550efSPatrick McHardy nla_nest_end(skb, nest); 854bba3925SPatrick McHardy n_i++; 864bba3925SPatrick McHardy } 874bba3925SPatrick McHardy } 884bba3925SPatrick McHardy done: 89e1e992e5SJamal Hadi Salim read_unlock_bh(&police_lock); 904bba3925SPatrick McHardy if (n_i) 914bba3925SPatrick McHardy cb->args[0] += n_i; 924bba3925SPatrick McHardy return n_i; 934bba3925SPatrick McHardy 947ba699c6SPatrick McHardy nla_put_failure: 954b3550efSPatrick McHardy nla_nest_cancel(skb, nest); 964bba3925SPatrick McHardy goto done; 974bba3925SPatrick McHardy } 984bba3925SPatrick McHardy 99c3bc7cffSPatrick McHardy static void tcf_police_destroy(struct tcf_police *p) 1004bba3925SPatrick McHardy { 101e9ce1cd3SDavid S. Miller unsigned int h = tcf_hash(p->tcf_index, POL_TAB_MASK); 102e9ce1cd3SDavid S. Miller struct tcf_common **p1p; 1034bba3925SPatrick McHardy 104e9ce1cd3SDavid S. Miller for (p1p = &tcf_police_ht[h]; *p1p; p1p = &(*p1p)->tcfc_next) { 105e9ce1cd3SDavid S. Miller if (*p1p == &p->common) { 1064bba3925SPatrick McHardy write_lock_bh(&police_lock); 107e9ce1cd3SDavid S. Miller *p1p = p->tcf_next; 1084bba3925SPatrick McHardy write_unlock_bh(&police_lock); 109e9ce1cd3SDavid S. Miller gen_kill_estimator(&p->tcf_bstats, 110e9ce1cd3SDavid S. Miller &p->tcf_rate_est); 111e9ce1cd3SDavid S. Miller if (p->tcfp_R_tab) 112e9ce1cd3SDavid S. Miller qdisc_put_rtab(p->tcfp_R_tab); 113e9ce1cd3SDavid S. Miller if (p->tcfp_P_tab) 114e9ce1cd3SDavid S. Miller qdisc_put_rtab(p->tcfp_P_tab); 1154bba3925SPatrick McHardy kfree(p); 1164bba3925SPatrick McHardy return; 1174bba3925SPatrick McHardy } 1184bba3925SPatrick McHardy } 1194bba3925SPatrick McHardy BUG_TRAP(0); 1204bba3925SPatrick McHardy } 1214bba3925SPatrick McHardy 122*53b2bf3fSPatrick McHardy static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { 123*53b2bf3fSPatrick McHardy [TCA_POLICE_RATE] = { .len = TC_RTAB_SIZE }, 124*53b2bf3fSPatrick McHardy [TCA_POLICE_PEAKRATE] = { .len = TC_RTAB_SIZE }, 125*53b2bf3fSPatrick McHardy [TCA_POLICE_AVRATE] = { .type = NLA_U32 }, 126*53b2bf3fSPatrick McHardy [TCA_POLICE_RESULT] = { .type = NLA_U32 }, 127*53b2bf3fSPatrick McHardy }; 128*53b2bf3fSPatrick McHardy 1297ba699c6SPatrick McHardy static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est, 1304bba3925SPatrick McHardy struct tc_action *a, int ovr, int bind) 1314bba3925SPatrick McHardy { 1324bba3925SPatrick McHardy unsigned h; 1334bba3925SPatrick McHardy int ret = 0, err; 1347ba699c6SPatrick McHardy struct nlattr *tb[TCA_POLICE_MAX + 1]; 1354bba3925SPatrick McHardy struct tc_police *parm; 136e9ce1cd3SDavid S. Miller struct tcf_police *police; 1374bba3925SPatrick McHardy struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 1381e9b3d53SPatrick McHardy int size; 1394bba3925SPatrick McHardy 140cee63723SPatrick McHardy if (nla == NULL) 1414bba3925SPatrick McHardy return -EINVAL; 1424bba3925SPatrick McHardy 143*53b2bf3fSPatrick McHardy err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, police_policy); 144cee63723SPatrick McHardy if (err < 0) 145cee63723SPatrick McHardy return err; 146cee63723SPatrick McHardy 1477ba699c6SPatrick McHardy if (tb[TCA_POLICE_TBF] == NULL) 1481e9b3d53SPatrick McHardy return -EINVAL; 1497ba699c6SPatrick McHardy size = nla_len(tb[TCA_POLICE_TBF]); 1501e9b3d53SPatrick McHardy if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat)) 1514bba3925SPatrick McHardy return -EINVAL; 1527ba699c6SPatrick McHardy parm = nla_data(tb[TCA_POLICE_TBF]); 1534bba3925SPatrick McHardy 154e9ce1cd3SDavid S. Miller if (parm->index) { 155e9ce1cd3SDavid S. Miller struct tcf_common *pc; 156e9ce1cd3SDavid S. Miller 157e9ce1cd3SDavid S. Miller pc = tcf_hash_lookup(parm->index, &police_hash_info); 158e9ce1cd3SDavid S. Miller if (pc != NULL) { 159e9ce1cd3SDavid S. Miller a->priv = pc; 160e9ce1cd3SDavid S. Miller police = to_police(pc); 1614bba3925SPatrick McHardy if (bind) { 162e9ce1cd3SDavid S. Miller police->tcf_bindcnt += 1; 163e9ce1cd3SDavid S. Miller police->tcf_refcnt += 1; 1644bba3925SPatrick McHardy } 1654bba3925SPatrick McHardy if (ovr) 1664bba3925SPatrick McHardy goto override; 1674bba3925SPatrick McHardy return ret; 1684bba3925SPatrick McHardy } 169e9ce1cd3SDavid S. Miller } 1704bba3925SPatrick McHardy 171e9ce1cd3SDavid S. Miller police = kzalloc(sizeof(*police), GFP_KERNEL); 172e9ce1cd3SDavid S. Miller if (police == NULL) 1734bba3925SPatrick McHardy return -ENOMEM; 1744bba3925SPatrick McHardy ret = ACT_P_CREATED; 175e9ce1cd3SDavid S. Miller police->tcf_refcnt = 1; 176e9ce1cd3SDavid S. Miller spin_lock_init(&police->tcf_lock); 1774bba3925SPatrick McHardy if (bind) 178e9ce1cd3SDavid S. Miller police->tcf_bindcnt = 1; 1794bba3925SPatrick McHardy override: 1804bba3925SPatrick McHardy if (parm->rate.rate) { 1814bba3925SPatrick McHardy err = -ENOMEM; 1827ba699c6SPatrick McHardy R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE]); 1834bba3925SPatrick McHardy if (R_tab == NULL) 1844bba3925SPatrick McHardy goto failure; 1854bba3925SPatrick McHardy if (parm->peakrate.rate) { 1864bba3925SPatrick McHardy P_tab = qdisc_get_rtab(&parm->peakrate, 1877ba699c6SPatrick McHardy tb[TCA_POLICE_PEAKRATE]); 188e9ce1cd3SDavid S. Miller if (P_tab == NULL) { 1894bba3925SPatrick McHardy qdisc_put_rtab(R_tab); 1904bba3925SPatrick McHardy goto failure; 1914bba3925SPatrick McHardy } 1924bba3925SPatrick McHardy } 1934bba3925SPatrick McHardy } 1944bba3925SPatrick McHardy /* No failure allowed after this point */ 195e9ce1cd3SDavid S. Miller spin_lock_bh(&police->tcf_lock); 1964bba3925SPatrick McHardy if (R_tab != NULL) { 197e9ce1cd3SDavid S. Miller qdisc_put_rtab(police->tcfp_R_tab); 198e9ce1cd3SDavid S. Miller police->tcfp_R_tab = R_tab; 1994bba3925SPatrick McHardy } 2004bba3925SPatrick McHardy if (P_tab != NULL) { 201e9ce1cd3SDavid S. Miller qdisc_put_rtab(police->tcfp_P_tab); 202e9ce1cd3SDavid S. Miller police->tcfp_P_tab = P_tab; 2034bba3925SPatrick McHardy } 2044bba3925SPatrick McHardy 2057ba699c6SPatrick McHardy if (tb[TCA_POLICE_RESULT]) 2061587bac4SPatrick McHardy police->tcfp_result = nla_get_u32(tb[TCA_POLICE_RESULT]); 207e9ce1cd3SDavid S. Miller police->tcfp_toks = police->tcfp_burst = parm->burst; 208e9ce1cd3SDavid S. Miller police->tcfp_mtu = parm->mtu; 209e9ce1cd3SDavid S. Miller if (police->tcfp_mtu == 0) { 210e9ce1cd3SDavid S. Miller police->tcfp_mtu = ~0; 211e9ce1cd3SDavid S. Miller if (police->tcfp_R_tab) 212e9ce1cd3SDavid S. Miller police->tcfp_mtu = 255<<police->tcfp_R_tab->rate.cell_log; 2134bba3925SPatrick McHardy } 214e9ce1cd3SDavid S. Miller if (police->tcfp_P_tab) 215e9ce1cd3SDavid S. Miller police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); 216e9ce1cd3SDavid S. Miller police->tcf_action = parm->action; 2174bba3925SPatrick McHardy 2187ba699c6SPatrick McHardy if (tb[TCA_POLICE_AVRATE]) 2191587bac4SPatrick McHardy police->tcfp_ewma_rate = nla_get_u32(tb[TCA_POLICE_AVRATE]); 2204bba3925SPatrick McHardy if (est) 221e9ce1cd3SDavid S. Miller gen_replace_estimator(&police->tcf_bstats, 222e9ce1cd3SDavid S. Miller &police->tcf_rate_est, 2237ba699c6SPatrick McHardy &police->tcf_lock, est); 2244bba3925SPatrick McHardy 225e9ce1cd3SDavid S. Miller spin_unlock_bh(&police->tcf_lock); 2264bba3925SPatrick McHardy if (ret != ACT_P_CREATED) 2274bba3925SPatrick McHardy return ret; 2284bba3925SPatrick McHardy 2293bebcda2SPatrick McHardy police->tcfp_t_c = psched_get_time(); 230e9ce1cd3SDavid S. Miller police->tcf_index = parm->index ? parm->index : 231e9ce1cd3SDavid S. Miller tcf_hash_new_index(&police_idx_gen, &police_hash_info); 232e9ce1cd3SDavid S. Miller h = tcf_hash(police->tcf_index, POL_TAB_MASK); 2334bba3925SPatrick McHardy write_lock_bh(&police_lock); 234e9ce1cd3SDavid S. Miller police->tcf_next = tcf_police_ht[h]; 235e9ce1cd3SDavid S. Miller tcf_police_ht[h] = &police->common; 2364bba3925SPatrick McHardy write_unlock_bh(&police_lock); 2374bba3925SPatrick McHardy 238e9ce1cd3SDavid S. Miller a->priv = police; 2394bba3925SPatrick McHardy return ret; 2404bba3925SPatrick McHardy 2414bba3925SPatrick McHardy failure: 2424bba3925SPatrick McHardy if (ret == ACT_P_CREATED) 243e9ce1cd3SDavid S. Miller kfree(police); 2444bba3925SPatrick McHardy return err; 2454bba3925SPatrick McHardy } 2464bba3925SPatrick McHardy 2474bba3925SPatrick McHardy static int tcf_act_police_cleanup(struct tc_action *a, int bind) 2484bba3925SPatrick McHardy { 249e9ce1cd3SDavid S. Miller struct tcf_police *p = a->priv; 250c3bc7cffSPatrick McHardy int ret = 0; 2514bba3925SPatrick McHardy 252c3bc7cffSPatrick McHardy if (p != NULL) { 253c3bc7cffSPatrick McHardy if (bind) 254c3bc7cffSPatrick McHardy p->tcf_bindcnt--; 255c3bc7cffSPatrick McHardy 256c3bc7cffSPatrick McHardy p->tcf_refcnt--; 257c3bc7cffSPatrick McHardy if (p->tcf_refcnt <= 0 && !p->tcf_bindcnt) { 258c3bc7cffSPatrick McHardy tcf_police_destroy(p); 259c3bc7cffSPatrick McHardy ret = 1; 260c3bc7cffSPatrick McHardy } 261c3bc7cffSPatrick McHardy } 262c3bc7cffSPatrick McHardy return ret; 2634bba3925SPatrick McHardy } 2644bba3925SPatrick McHardy 2654bba3925SPatrick McHardy static int tcf_act_police(struct sk_buff *skb, struct tc_action *a, 2664bba3925SPatrick McHardy struct tcf_result *res) 2674bba3925SPatrick McHardy { 268e9ce1cd3SDavid S. Miller struct tcf_police *police = a->priv; 2694bba3925SPatrick McHardy psched_time_t now; 2704bba3925SPatrick McHardy long toks; 2714bba3925SPatrick McHardy long ptoks = 0; 2724bba3925SPatrick McHardy 273e9ce1cd3SDavid S. Miller spin_lock(&police->tcf_lock); 2744bba3925SPatrick McHardy 275e9ce1cd3SDavid S. Miller police->tcf_bstats.bytes += skb->len; 276e9ce1cd3SDavid S. Miller police->tcf_bstats.packets++; 2774bba3925SPatrick McHardy 278e9ce1cd3SDavid S. Miller if (police->tcfp_ewma_rate && 279e9ce1cd3SDavid S. Miller police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { 280e9ce1cd3SDavid S. Miller police->tcf_qstats.overlimits++; 281e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 282e9ce1cd3SDavid S. Miller return police->tcf_action; 2834bba3925SPatrick McHardy } 2844bba3925SPatrick McHardy 285e9ce1cd3SDavid S. Miller if (skb->len <= police->tcfp_mtu) { 286e9ce1cd3SDavid S. Miller if (police->tcfp_R_tab == NULL) { 287e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 288e9ce1cd3SDavid S. Miller return police->tcfp_result; 2894bba3925SPatrick McHardy } 2904bba3925SPatrick McHardy 2913bebcda2SPatrick McHardy now = psched_get_time(); 29203cc45c0SPatrick McHardy toks = psched_tdiff_bounded(now, police->tcfp_t_c, 293e9ce1cd3SDavid S. Miller police->tcfp_burst); 294e9ce1cd3SDavid S. Miller if (police->tcfp_P_tab) { 295e9ce1cd3SDavid S. Miller ptoks = toks + police->tcfp_ptoks; 296e9ce1cd3SDavid S. Miller if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) 297e9ce1cd3SDavid S. Miller ptoks = (long)L2T_P(police, police->tcfp_mtu); 298e9ce1cd3SDavid S. Miller ptoks -= L2T_P(police, skb->len); 2994bba3925SPatrick McHardy } 300e9ce1cd3SDavid S. Miller toks += police->tcfp_toks; 301e9ce1cd3SDavid S. Miller if (toks > (long)police->tcfp_burst) 302e9ce1cd3SDavid S. Miller toks = police->tcfp_burst; 303e9ce1cd3SDavid S. Miller toks -= L2T(police, skb->len); 3044bba3925SPatrick McHardy if ((toks|ptoks) >= 0) { 305e9ce1cd3SDavid S. Miller police->tcfp_t_c = now; 306e9ce1cd3SDavid S. Miller police->tcfp_toks = toks; 307e9ce1cd3SDavid S. Miller police->tcfp_ptoks = ptoks; 308e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 309e9ce1cd3SDavid S. Miller return police->tcfp_result; 3104bba3925SPatrick McHardy } 3114bba3925SPatrick McHardy } 3124bba3925SPatrick McHardy 313e9ce1cd3SDavid S. Miller police->tcf_qstats.overlimits++; 314e9ce1cd3SDavid S. Miller spin_unlock(&police->tcf_lock); 315e9ce1cd3SDavid S. Miller return police->tcf_action; 3164bba3925SPatrick McHardy } 3174bba3925SPatrick McHardy 3184bba3925SPatrick McHardy static int 3194bba3925SPatrick McHardy tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) 3204bba3925SPatrick McHardy { 32127a884dcSArnaldo Carvalho de Melo unsigned char *b = skb_tail_pointer(skb); 322e9ce1cd3SDavid S. Miller struct tcf_police *police = a->priv; 3234bba3925SPatrick McHardy struct tc_police opt; 3244bba3925SPatrick McHardy 325e9ce1cd3SDavid S. Miller opt.index = police->tcf_index; 326e9ce1cd3SDavid S. Miller opt.action = police->tcf_action; 327e9ce1cd3SDavid S. Miller opt.mtu = police->tcfp_mtu; 328e9ce1cd3SDavid S. Miller opt.burst = police->tcfp_burst; 329e9ce1cd3SDavid S. Miller opt.refcnt = police->tcf_refcnt - ref; 330e9ce1cd3SDavid S. Miller opt.bindcnt = police->tcf_bindcnt - bind; 331e9ce1cd3SDavid S. Miller if (police->tcfp_R_tab) 332e9ce1cd3SDavid S. Miller opt.rate = police->tcfp_R_tab->rate; 3334bba3925SPatrick McHardy else 3344bba3925SPatrick McHardy memset(&opt.rate, 0, sizeof(opt.rate)); 335e9ce1cd3SDavid S. Miller if (police->tcfp_P_tab) 336e9ce1cd3SDavid S. Miller opt.peakrate = police->tcfp_P_tab->rate; 3374bba3925SPatrick McHardy else 3384bba3925SPatrick McHardy memset(&opt.peakrate, 0, sizeof(opt.peakrate)); 3397ba699c6SPatrick McHardy NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt); 340e9ce1cd3SDavid S. Miller if (police->tcfp_result) 34124beeab5SPatrick McHardy NLA_PUT_U32(skb, TCA_POLICE_RESULT, police->tcfp_result); 342e9ce1cd3SDavid S. Miller if (police->tcfp_ewma_rate) 34324beeab5SPatrick McHardy NLA_PUT_U32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate); 3444bba3925SPatrick McHardy return skb->len; 3454bba3925SPatrick McHardy 3467ba699c6SPatrick McHardy nla_put_failure: 347dc5fc579SArnaldo Carvalho de Melo nlmsg_trim(skb, b); 3484bba3925SPatrick McHardy return -1; 3494bba3925SPatrick McHardy } 3504bba3925SPatrick McHardy 3514bba3925SPatrick McHardy MODULE_AUTHOR("Alexey Kuznetsov"); 3524bba3925SPatrick McHardy MODULE_DESCRIPTION("Policing actions"); 3534bba3925SPatrick McHardy MODULE_LICENSE("GPL"); 3544bba3925SPatrick McHardy 3554bba3925SPatrick McHardy static struct tc_action_ops act_police_ops = { 3564bba3925SPatrick McHardy .kind = "police", 357e9ce1cd3SDavid S. Miller .hinfo = &police_hash_info, 3584bba3925SPatrick McHardy .type = TCA_ID_POLICE, 3594bba3925SPatrick McHardy .capab = TCA_CAP_NONE, 3604bba3925SPatrick McHardy .owner = THIS_MODULE, 3614bba3925SPatrick McHardy .act = tcf_act_police, 3624bba3925SPatrick McHardy .dump = tcf_act_police_dump, 3634bba3925SPatrick McHardy .cleanup = tcf_act_police_cleanup, 364e9ce1cd3SDavid S. Miller .lookup = tcf_hash_search, 3654bba3925SPatrick McHardy .init = tcf_act_police_locate, 36683b950c8SJamal Hadi Salim .walk = tcf_act_police_walker 3674bba3925SPatrick McHardy }; 3684bba3925SPatrick McHardy 3694bba3925SPatrick McHardy static int __init 3704bba3925SPatrick McHardy police_init_module(void) 3714bba3925SPatrick McHardy { 3724bba3925SPatrick McHardy return tcf_register_action(&act_police_ops); 3734bba3925SPatrick McHardy } 3744bba3925SPatrick McHardy 3754bba3925SPatrick McHardy static void __exit 3764bba3925SPatrick McHardy police_cleanup_module(void) 3774bba3925SPatrick McHardy { 3784bba3925SPatrick McHardy tcf_unregister_action(&act_police_ops); 3794bba3925SPatrick McHardy } 3804bba3925SPatrick McHardy 3814bba3925SPatrick McHardy module_init(police_init_module); 3824bba3925SPatrick McHardy module_exit(police_cleanup_module); 383