linux/net/sched/act_simple.c
<<
>>
Prefs
   1/*
   2 * net/sched/simp.c     Simple example of an action
   3 *
   4 *              This program is free software; you can redistribute it and/or
   5 *              modify it under the terms of the GNU General Public License
   6 *              as published by the Free Software Foundation; either version
   7 *              2 of the License, or (at your option) any later version.
   8 *
   9 * Authors:     Jamal Hadi Salim (2005-8)
  10 *
  11 */
  12
  13#include <linux/module.h>
  14#include <linux/slab.h>
  15#include <linux/init.h>
  16#include <linux/kernel.h>
  17#include <linux/skbuff.h>
  18#include <linux/rtnetlink.h>
  19#include <net/netlink.h>
  20#include <net/pkt_sched.h>
  21
  22#define TCA_ACT_SIMP 22
  23
  24#include <linux/tc_act/tc_defact.h>
  25#include <net/tc_act/tc_defact.h>
  26
  27#define SIMP_TAB_MASK     7
  28static struct tcf_common *tcf_simp_ht[SIMP_TAB_MASK + 1];
  29static u32 simp_idx_gen;
  30static DEFINE_RWLOCK(simp_lock);
  31
  32static struct tcf_hashinfo simp_hash_info = {
  33        .htab   =       tcf_simp_ht,
  34        .hmask  =       SIMP_TAB_MASK,
  35        .lock   =       &simp_lock,
  36};
  37
  38#define SIMP_MAX_DATA   32
  39static int tcf_simp(struct sk_buff *skb, const struct tc_action *a,
  40                    struct tcf_result *res)
  41{
  42        struct tcf_defact *d = a->priv;
  43
  44        spin_lock(&d->tcf_lock);
  45        d->tcf_tm.lastuse = jiffies;
  46        bstats_update(&d->tcf_bstats, ref="+code=skb" class="sref">skb, co);
  Emple.c#L38" id="L38" class="line" name=4L38">  34#define   34static int   45                   5struc5span>
  45{
  45        struct bstprnfo = {
"ine" n: %s_%d\n"simple..c#L40" id="L40" class="line" name=5L43">  45
->tcf_bstatdclas clef="+code=priv" tatdclas cleef">skb, co);
tcf_bstats, ref="+code=skb" class="sref">"sref">lastuse  45        spin_lock(&(&ass="sref">d->tcf_lock);
   5idden" d->tcf_lock/a> *  45          5mple.c#L38" id="L38" class="line" name=5L38">  35#define tcf_simp(str" cleask_buff *d = tcf_simpbin="+code=a" classbin=mple.c#L41" id="L41" class="line" name=5L39">  35static int   46                   6struc6 tcf_simpre*  46{
simp_lo="+code=a" class="sre)e.c#L33" id="L33" class="line" name=6L42">  46        struct simp_lobin="+code=a" classbin=mple.c#L41" id="L41" class="line" name=6L43">  46
, co);
tcf_bstats  46        , co);
tcf_bstatsrefcn*   5<6/a>simp_loef="+code=tcf_bstats" class="sref">tcf_bstats, co);
tcf_bstatsrefcn*   6simp_loef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">e.c#L45" id="L45" class="line" name=6a" id="L61" class="line" name="L61">  67d->tcf_lock *simp_lock = {
  36#define , co);
  36static int   47                   7struc7   47{
->  47        struct   47
  47        tcf_simpalct_clas clef="+code=priv" alct_clas cleuff" class="sref">sk_buff *d = ec#L44" id="L44" class="line" name=75">   5<7/a>   6<7/a>bstef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">s="sref">jiffiessimp_loP_MAX_DATA   32
   7  77simp_loun>ikely simp_loef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">eec#L44" id="L44" class="line" name=7L38">  37#define tcf_bsENOMEMf="+code=priv" ENOMEMclas.c#L45" id="L45" class="line" name=7L39">  37static int bstclalcpy simp_loef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">skb, co);
skb, co);
   32
  48                   8struc80  48{
  48        struct   48
sk_buff *d = .c#L40" id="L40" class="line" name=8L44">  48        tc_action< *d = ec#L44" id="L44" class="line" name=85">   5<8/a>   6<8/a>bstde=d" cla_bh d->tcf_lock);
   7<8/a>  87ts_update" class="sref">bstef="+code=tcf_lock" class="sref">tcf_lock/a> *jiffieslass="sref">tcf_lock/a> *   8bstmemse*simp_loef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">sk0skb, co);
   32
  38static int bstclalcpy simp_loef="+code=tcf_bstats" class="sref">tcf_bstatdclas clef="+code=priv" tatdclas cleef">skb, co);
skb, co);
   32
  49                   9struc90ts_update" class="sref">bstde=d"un>(&a_bh (&a_bhss="sref">d->tcf_lock);
  49{
  49        struct   49
tc_actinla_policy="net/sched/actnla_policyts_up="sref">simp_lockSIMt/scDEF/sch="net/sched/actt/scDEF/schts_upmpleple.c#L33" id="L33" class="line" name=9L44">  49        SIMt/scDEF/PARMS="net/sched/actt/scDEF/PARMSlock   = a>;
sk_buff *   5<9/a>SIMt/scDEF/A   32
lock   =" idjiffiesskef">lock   = a>;
   6<9/a>   7<9/a>  9mple.c#L38" id="L38" class="line" name=98">   8<9/a>tcf_simp(str"ed/a href="+code=ji(str"ed/auff" class="sref">sk_buffd = skclass="sref">sk_buffd = .c#L40" id="L40" class="line" name=99">   9tc_action *a,
tcf_simpovr="net/sched/actovr"sre,oass="sref">tcf_simpbin="+code=a" classbin=mple.c#L41" id="L41" class="line" name=10L10">  10<  110sk_buffd = SIMt/scDEF/sch="net/sched/actt/scDEF/schts_upmple.c#L19" id="L19" class="line" name="0L12">  120
tcf_defa< *d =   130#include <tcf_defact *d =   140#include <tcf_defact *tcf_sp_  150#include <.c#L45" id="L45" class="line" name=10L16">  160#include <tcf_simpre*, co);
.c#L45" id="L45" class="line" name=10L17">  170#include <  180#include <simp_lonla="net/sched/actnlaef"> =="sref">jiffies   32
  190#include <tcf_bsEINVAL>   32
.c#L45" id="L45" class="line" name=1"L10">  100 *1/span>c#L45" id="L45" class="line" name=1"L11">  11<s="b, co);
simp_lotef="net/sched/actbts_uskb, co);
sk="sref">simp_lock  122
simp_loerr="net/sched/acterref">s/tc_ 0.c#L41" id="L41" class="line" name=1"L13">  133#include <->.c#L45" id="L45" class="line" name=1"L14">  144#include <  155#include <simp_lotef="net/sched/actbts_uclass="sref">SIMt/scDEF/PARMS="net/sched/actt/scDEF/PARMSjiffies   32
  166#include <tcf_bsEINVAL>   32
.c#L45" id="L45" class="line" name=1"L17">  177#include <  188#include <simp_lotef="net/sched/actbts_uclass="sref">SIMt/scDEF/A   32
jiffies   32
  199#include <tcf_bsEINVAL>   32
.c#L45" id="L45" class="line" name=1"L20">  210#include <  211
, co);
, co);
simp_lotef="net/sched/actbts_uclass="sref">SIMt/scDEF/PARMS="net/sched/actt/scDEF/PARMS  212#define bst=as clef="+code=priv" las cleef">s="b, co);
simp_lotef="net/sched/actbts_uclass="sref">SIMt/scDEF/A   32
  133
  214#include <spin_lop_simp_lorarref="+code=lasturarrsreflass="sref">tcf_lockindexef="+code=lastuindexef">sk="sref">simp_lo"net/sched/act_simple.o"sref">tcf_simpbin="+code=a" classbin=mple, class="sref">simp_lock = {
  215#include <simp_lop_  216
spin_lop_simp_lorarref="+code=lasturarrsreflass="sref">tcf_lockindexef="+code=lastuindexef">sk="sref">simp_loesa href="+code=jiesaef">.k="sref">simp_lo"net/sched/act_simple.osizeof >d = tcf_simpbin="+code=a" classbin=mple,c#L33" id="L33" class="line" name=1"L17">  177#define simp_lock;
simp_lock = {
  188static struct simp_loIS_ERRa> = {
simp_lor_  219static -> = {
simp_lor_  310static   311
spin_lo="+code=a" class="sref">a-> *simp_lor_  212static struct tcf_simpre*simp_lo"lct_clas clef="+code=priv" alct_clas cleuff" ="sref">spin_lo="+code=a" class="sreskb, co);
).c#L45" id="L45" class="line" name=1"L13">  13<#include <simp_lore*  314        .simp_loesa href="+code=jiesaef">.c#L41" id="L41" class="line" name=1"L35">  315        .tcf_simp_si_kill_esaimator="net/sched/act_si_kill_esaimatoruff" class="sref">simp_lor_tcf_lock, ref="+code=skb" clcass="sref">sc#L41" id="L41" class="line" name=1"L26">  216};
simp_lor_tcf_lock).c#L45" id="L45" class="line" name=1"L17">  177
, co);
simp_lor_, co);
).c#L45" id="L45" class="line" name=1"L18">  188#define ->  319static int   410                   1 stru1t spin_lo="+code=a" class="srelass="sref">tcf_lock/a> *jiffiestcf_lock/a> *  411{
spin_lore*simp_lohed/P_CREATED  212        struct   413
spin_lo="+code=a" class="sref">a-> *simp_lor_  414        simp_loovr="net/sched/actovr"sre.e.c#L33" id="L33" class="line" name=1"L45">  415        tcf_lock(str" cleaspin_lo="+code=a" class="sreskb, co);
  216        tcf_bsEEXIST>   32
  1741" class="line" name="L141"> 147  184#define spin_loreset_policy="net/sched/act_siet_policyuff" ="sref">spin_lo="+code=a" class="sreskb, co);
skb, co);
  314static int   415                   15stru15span>c#L45" id="L45" class="line" name=15L41">  415{
simp_lore*simp_lohed/P_CREATED  415        struct tcf_simp=simp_hacinser*simp_lor_simp_lock = {
  415
->  415          41//a>  215        tcf_simp(str"cleanuruct tc_action *a,
tcf_simpbin="+code=a" classbin=mple.c#L41" id="L41" class="line" name=15a" id="L151" class="line" name="L151"> 15mple..c#L33" id="L33" class="line" name=15L38">  315#define tcf_defact *d = a->priv;
  315static int   416                   16stru16 simp_lo="+code=a" class="sre)c#L43" id="L43" class="line" name=16L41">  416{
->(str" cleaspin_lo="+code=a" class="sreskb, co);
  416        struct   416
  416           5<16/a>tcf_simp(str"dutruct tc_actia> *skb, const struct tc_action *a,
   6<1//a>tcf_simpbin="+code=a" classbin=mple.oass="sref">tcf_simpclasa href="+code=ref"sre)c#L43" id="L43" class="line" name=16a" id="L161" class="line" name="L161"> 16mple..c#L33" id="L33" class="line" name=16L38">  316#define  = a->spin_lohref="net/sched/act_simple.c#L4act_simp4);
  316static int tcf_defact *d = a->priv;
  417                   17stru17 tcf_defa< *simp_loop*.c#L33" id="L33" class="line" name=17L41">  417{
lock   =indexef="+code=lastuindexef">  f">a->tcf_lockindexef="+code=lastuindexmple.c#L40" id="L40" class="line" name=17L42">  417        struct lock   =refcn*a->tcf_lockrefcn*tcf_simpclasa href="+code=ref"sre.c#L40" id="L40" class="line" name=17L43">  417
lock   =a->tcf_locktcf_simpbin="+code=a" classbin=mple,c#L33" id="L33" class="line" name=17L44">  417        lock   =/a> *a->tcf_lock/a> *   5<17/a>   6<17/a>tcf_defact*simp_lo*  17<#include < 17mple.c#L38" id="L38" class="line" name=17L38">  317#define simp_lonla_pu*spin_lohref="net/sched/act_simplskb, co);
simp_loop*simp_loop*  317static int simp_lonla_pu*_t" ing"a href="+code=nla_pu*_t" inguff" ="sref">spin_lohref="net/sched/act_simplskb, co);
   32
, co);
tcf_bstatdclas clef="+code=priv" tatdclas cleef">eec#L44" id="L44" class="line" name=18L40">  418                   18stru18 simp_lonla_pu*_failura href="+code=jinla_pu*_failurample.c#L43" id="L43" class="line" name=18L41">  418{
, co);
lock   =inf_cllef="+code=lastuinf_cllats"t">a->(&a_*spin_loa>;
tcf_simpef="+code=tcf_tm" class="sref">tcf_tm.lastuse  418        struct bst*lock   =l> = jiffies;
(&a_*spin_loa>;
tcf_simpef="+code=tcf_tm" class="sref">tcf_tm.lastuse =   418
bst*lock   =expiref="net/sched/actexpirefclass="sref">jiffies;
(&a_*spin_loef="+code=tcf_tm" class="sref">tcf_tm.lastuse  418        simp_lonla_pu*spin_lohref="net/sched/act_simplskb, co);
simp_lo*simp_lo*   5<18/a>simp_lonla_pu*_failura href="+code=jinla_pu*_failurample.c#L43" id="L43" class="line" name=186">   6<18/a>->tcf_tm a>;
  178/a> 18mple.c#L38" id="L38" class="line" name=188">   8<1//a>simp_lonla_pu*_failura href="+code=jinla_pu*_failurample:c#L38" id="L38" class="line" name=18L39">  318static int bstnlmsg_" iref="+code=lastunlmsg_" iruff" ="sref">spin_lohref="net/sched/act_simplskb, co);
  419                   19stru190  419{
  419        struct   419
tc_action *<_op ref="+code=skb" c *<_op sref"="sref">simp_los="line"_op ref="+code=skb"s="line"_op "sref">.c#L33" id="L33" class="line" name=19L44">  419        lastuse"ine" n"simple..c#L40" id="L40" class="line" name=195">   5<19/a>hmask  =fo = {
simp_lock = {
   6<19/a>hmask  " id, co);
  179/a> 197hmask  cap     , co);
   8<19/a>hmask  owner="net/sched/actownernfo" ode=tcf_o_MASK" cl, co);
  31//a>lock   =/a>ref="+code=skb"s="tcf_simp_ht  12<lock   =dutruct tcf_simp_ht  12<{
hmask  cleanuruct tcf_simp_ht  12<        struct lastusetcf_simp_ht(str"ed/auff".c#L40" id="L40" class="line" name=20310">  12<
lastusetcf_simp_generic_wal  12<          120#include <  120#include <tcf_sMODULE_AUTHORa> = {
"Jamal Hadi Salim(2005)"simple.e.c#L4act_simp4);
  120#include <tcf_sMODULE_DESCRIPTIONa> = {
"Snet/s eref="ne/a> *<"simple.e.c#L4act_simp4);
  120/a>simp_loMODULE_LICENSEf="+code=priv" MODULE_LICENSEuff" =
"GPL"simple.e.c#L4act_simp4);
  120/a>  120 *2/span>f_commoass="sref">tcf_simp_"ed/a href="+code=ji_"ed/auff"k="sref">simp_lock  12<tcf_simpre*tcf_lockregister>/a> */a> *simp_los="line"_op ref="+code=skb"s="line"_op "sree.c#L4act_simp4);
  123#include <simp_lore*  124#include <, co);
 = {
"Snet/s TCe/a> *< Loaded\n"simple.e.c#L4act_simp4);
  125#include <->  126#include <  127#include <  128#include <simp_lock  129#include <  220#include <bst" fcunregister>/a> */a> *simp_los="line"_op ref="+code=skb"s="line"_op "sree.c#L4act_simp4);
  221
  222#define   123
simp_lomoduld"ed/a href="+code=jimoduld"ed/auff" ="sref">spin_lohk  124#include <simp_lomoduld"ex/a href="+code=jimoduld"ex/auff" ="sref">spin_lohk  125#include <lxr@de ux.noass="
#inclusubfooser=> lxr.de ux.no kin=ly hosae= by #L4act_sihttp://www.redpill-de pro.no">Redpill Le pro AS *