: tc actions: whitespace and coding style cleanup
Subsystems (3)
PATCH 9/22 : tc actions: whitespace and coding style cleanup
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/01/09 23:35:01+01:00 [email protected]
# [PKT_SCHED]: tc actions: whitespace and coding style cleanup
#
# Signed-off-by: Patrick McHardy <[email protected]>
#
# net/sched/police.c # 2005/01/09 23:34:55+01:00 [email protected] +49 -48 # [PKT_SCHED]: tc actions: whitespace and coding style cleanup # # Signed-off-by: Patrick McHardy <[email protected]> # # net/sched/pedit.c # 2005/01/09 23:34:55+01:00 [email protected] +36 -52 # [PKT_SCHED]: tc actions: whitespace and coding style cleanup # # Signed-off-by: Patrick McHardy <[email protected]> # # net/sched/mirred.c # 2005/01/09 23:34:55+01:00 [email protected] +48 -58 # [PKT_SCHED]: tc actions: whitespace and coding style cleanup # # Signed-off-by: Patrick McHardy <[email protected]> # # net/sched/ipt.c # 2005/01/09 23:34:55+01:00 [email protected] +28 -41 # [PKT_SCHED]: tc actions: whitespace and coding style cleanup # # Signed-off-by: Patrick McHardy <[email protected]> # # net/sched/gact.c # 2005/01/09 23:34:55+01:00 [email protected] +35 -47 # [PKT_SCHED]: tc actions: whitespace and coding style cleanup # # Signed-off-by: Patrick McHardy <[email protected]> # diff -Nru a/net/sched/gact.c b/net/sched/gact.c --- a/net/sched/gact.c 2005-01-10 06:22:20 +01:00 +++ b/net/sched/gact.c 2005-01-10 06:22:20 +01:00 @@ -38,41 +38,41 @@ /* use generic hash table */ #define MY_TAB_SIZE 16 #define MY_TAB_MASK 15 + static u32 idx_gen; static struct tcf_gact *tcf_gact_ht[MY_TAB_SIZE]; static rwlock_t gact_lock = RW_LOCK_UNLOCKED;
/* ovewrride the defaults */
-#define tcf_st tcf_gact
-#define tc_st tc_gact
-#define tcf_t_lock gact_lock
-#define tcf_ht tcf_gact_ht
+#define tcf_st tcf_gact
+#define tc_st tc_gact
+#define tcf_t_lock gact_lock
+#define tcf_ht tcf_gact_ht
#define CONFIG_NET_ACT_INIT 1
#include <net/pkt_act.h>
#ifdef CONFIG_GACT_PROB
-typedef int (*g_rand)(struct tcf_gact *p);
-static int
-gact_net_rand(struct tcf_gact *p) {
+static int gact_net_rand(struct tcf_gact *p)
+{
if (net_random()%p->pval)
return p->action;
return p->paction;
}
-static int
-gact_determ(struct tcf_gact *p) {
+static int gact_determ(struct tcf_gact *p)
+{
if (p->bstats.packets%p->pval)
return p->action;
return p->paction;
}
-
-static g_rand gact_rand[MAX_RAND]= { NULL,gact_net_rand, gact_determ};
-
+typedef int (*g_rand)(struct tcf_gact *p);
+static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ };
#endif
-static int
-tcf_gact_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,int ovr,int bind) +
+static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
+ struct tc_action *a, int ovr, int bind)
{
struct rtattr *tb[TCA_GACT_MAX];
struct tc_gact *parm = NULL;
@@ -81,31 +81,26 @@
#endif
struct tcf_gact *p = NULL;
int ret = 0;
- int size = sizeof (*p);
if (rtattr_parse(tb, TCA_GACT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0)
return -1;
- if (NULL == a || NULL == tb[TCA_GACT_PARMS - 1]) {
+ if (a == NULL || tb[TCA_GACT_PARMS - 1] == NULL) { printk("BUG: tcf_gact_init called with NULL params\n"); return -1;
}
parm = RTA_DATA(tb[TCA_GACT_PARMS - 1]);
#ifdef CONFIG_GACT_PROB
- if (NULL != tb[TCA_GACT_PROB - 1]) {
+ if (tb[TCA_GACT_PROB - 1] != NULL)
p_parm = RTA_DATA(tb[TCA_GACT_PROB - 1]);
- }
#endif
-
p = tcf_hash_check(parm, a, ovr, bind);
-
- if (NULL == p) {
- p = tcf_hash_create(parm,est,a,size,ovr, bind);
-
- if (NULL == p) {
+ if (p == NULL) {
+ p = tcf_hash_create(parm, est, a, sizeof(*p), ovr, bind);
+ if (p == NULL)
return -1;
- } else {
+ else {
p->refcnt = 1;
ret = 1;
goto override;
@@ -116,7 +111,7 @@
override:
p->action = parm->action;
#ifdef CONFIG_GACT_PROB
- if (NULL != p_parm) {
+ if (p_parm != NULL) {
p->paction = p_parm->paction; p->pval = p_parm->pval; p->ptype = p_parm->ptype;
@@ -125,16 +120,15 @@
}
#endif
}
-
return ret;
}
static int
tcf_gact_cleanup(struct tc_action *a, int bind) {
- struct tcf_gact *p;
- p = PRIV(a,gact);
- if (NULL != p)
+ struct tcf_gact *p = PRIV(a, gact);
+
+ if (p != NULL)
return tcf_hash_release(p, bind);
return 0;
}
@@ -142,13 +136,11 @@
static int
tcf_gact(struct sk_buff **pskb, struct tc_action *a) {
- struct tcf_gact *p;
+ struct tcf_gact *p = PRIV(a, gact);
struct sk_buff *skb = *pskb;
int action = TC_ACT_SHOT;
- p = PRIV(a,gact);
-
- if (NULL == p) {
+ if (p == NULL) {
if (net_ratelimit())
printk("BUG: tcf_gact called with NULL params\n");
return -1;
@@ -156,7 +148,7 @@
spin_lock(&p->lock);
#ifdef CONFIG_GACT_PROB
- if (p->ptype && NULL != gact_rand[p->ptype])
+ if (p->ptype && gact_rand[p->ptype] != NULL)
action = gact_rand[p->ptype](p);
else
action = p->action;
@@ -165,7 +157,7 @@
#endif
p->bstats.bytes += skb->len;
p->bstats.packets++;
- if (TC_ACT_SHOT == action)
+ if (action == TC_ACT_SHOT)
p->qstats.drops++;
p->tm.lastuse = jiffies;
spin_unlock(&p->lock);
@@ -178,14 +170,10 @@
{
unsigned char *b = skb->tail;
struct tc_gact opt;
-#ifdef CONFIG_GACT_PROB
- struct tc_gact_p p_opt;
-#endif
- struct tcf_gact *p;
+ struct tcf_gact *p = PRIV(a, gact);
struct tcf_t t;
- p = PRIV(a,gact);
- if (NULL == p) {
+ if (p == NULL) {
printk("BUG: tcf_gact_dump called with NULL params\n"); goto rtattr_failure;
}
@@ -194,19 +182,20 @@
opt.refcnt = p->refcnt - ref;
opt.bindcnt = p->bindcnt - bind;
opt.action = p->action;
- RTA_PUT(skb, TCA_GACT_PARMS, sizeof (opt), &opt);
+ RTA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt);
#ifdef CONFIG_GACT_PROB
if (p->ptype) {
+ struct tc_gact_p p_opt;
p_opt.paction = p->paction;
p_opt.pval = p->pval;
p_opt.ptype = p->ptype;
- RTA_PUT(skb, TCA_GACT_PROB, sizeof (p_opt), &p_opt);
- }
+ RTA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt);
+ }
#endif
t.install = jiffies_to_clock_t(jiffies - p->tm.install); t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse); t.expires = jiffies_to_clock_t(p->tm.expires);
- RTA_PUT(skb, TCA_GACT_TM, sizeof (t), &t);
+ RTA_PUT(skb, TCA_GACT_TM, sizeof(t), &t);
return skb->len;
rtattr_failure:
@@ -215,7 +204,6 @@
}
static struct tc_action_ops act_gact_ops = {
- .next = NULL,
.kind = "gact",
.type = TCA_ACT_GACT,
.capab = TCA_CAP_NONE,
net/sched/ipt.c +28 -41
@@ -49,9 +49,9 @@static rwlock_t ipt_lock =RW_LOCK_UNLOCKED ;/* ovewrride the defaults */ -#define tcf_st tcf_ipt -#define tcf_t_lock ipt_lock -#define tcf_ht tcf_ipt_ht +#define tcf_st tcf_ipt +#define tcf_t_lock ipt_lock +#define tcf_ht tcf_ipt_ht#include <net/pkt_act.h>
@@ -73,8 +73,8 @@if (t->u.kernel.target->checkentry && !t->u.kernel.target->checkentry (p->tname,NULL , t->data, - t->u.target_size - -sizeof (*t), p->hook)) { + t->u.target_size -sizeof (*t), + p->hook)) {DPRINTK ("ip_tables: check failed for `%s'.\n" , t->u.kernel.target->name);module_put (t->u.kernel.target->me);
@@ -85,7 +85,8 @@ }static int -tcf_ipt_init (struct rtattr *rta,struct rtattr *est,struct tc_action *a,int ovr,int bind) +tcf_ipt_init (struct rtattr *rta,struct rtattr *est,struct tc_action *a, +int ovr,int bind) {struct ipt_entry_target *t;unsigned h;
@@ -95,12 +96,9 @@u32 index =0 ;u32 hook =0 ; -if (NULL == a ||NULL == rta || - (rtattr_parse (tb,TCA_IPT_MAX ,RTA_DATA (rta),RTA_PAYLOAD (rta)) < -0 )) { +if (a ==NULL || rta ==NULL || +rtattr_parse (tb,TCA_IPT_MAX ,RTA_DATA (rta),RTA_PAYLOAD (rta)) <0 )return -1 ; - } -if (tb[TCA_IPT_INDEX -1 ]) { index = *(u32 *)RTA_DATA (tb[TCA_IPT_INDEX -1 ]);
@@ -114,22 +112,19 @@ p->bindcnt +=1 ; p->refcnt +=1 ; } -if (ovr) { +if (ovr) goto override; - }spin_unlock (&p->lock);return ret; } -if (NULL == tb[TCA_IPT_TARG -1 ] ||NULL == tb[TCA_IPT_HOOK -1 ]) { +if (tb[TCA_IPT_TARG -1 ] ==NULL || tb[TCA_IPT_HOOK -1 ] ==NULL )return -1 ; - } - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kmalloc (sizeof (*p),GFP_KERNEL );if (p ==NULL )return -1 ; - -memset (p,0 ,sizeof (*p)); +memset (p,0 ,sizeof (*p)); p->refcnt =1 ; ret =1 ;spin_lock_init (&p->lock);
@@ -184,7 +179,7 @@ } } -if (0 >init_targ (p)) { +if (init_targ (p) <0 ) {if (ovr) {printk ("ipt policy messed up 2 \n" );spin_unlock (&p->lock);
@@ -217,7 +212,7 @@ p->next = tcf_ipt_ht[h]; tcf_ipt_ht[h] = p;write_unlock_bh (&ipt_lock); - a->priv = (void *) p; + a->priv = p;return ret; }
@@ -225,8 +220,8 @@static int tcf_ipt_cleanup (struct tc_action *a,int bind) { -struct tcf_ipt *p; - p =PRIV (a,ipt); +struct tcf_ipt *p =PRIV (a,ipt); +if (NULL != p) {struct ipt_entry_target *t = p->t;if (t && t->u.kernel.target)
@@ -240,14 +235,11 @@ tcf_ipt(struct sk_buff **pskb, struct tc_action *a) { int ret = 0, result = 0; -struct tcf_ipt *p; +struct tcf_ipt *p =PRIV (a, ipt);struct sk_buff *skb = *pskb; - p =PRIV (a,ipt); - -if (NULL == p ||NULL == skb) { +if (p ==NULL || skb ==NULL )return -1 ; - }spin_lock (&p->lock);
@@ -256,16 +248,15 @@ p->bstats.packets++;if (skb_cloned (skb) ) { -if (pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) { +if (pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))return -1 ; - } }/* yes, we have to worry about both in and out dev worry later - danger - this API seems to have changed from earlier kernels */ ret = p->t->u.kernel.target->target (&skb, skb->dev,NULL , - p->hook, p->t->data, (void *)NULL ); + p->hook, p->t->data,NULL );switch (ret) {case NF_ACCEPT : result =TC_ACT_OK ;
@@ -295,11 +286,9 @@struct tcf_t tm;struct tc_cnt c;unsigned char *b = skb->tail; +struct tcf_ipt *p =PRIV (a, ipt); -struct tcf_ipt *p; - - p =PRIV (a,ipt); -if (NULL == p) { +if (p ==NULL ) {printk ("BUG: tcf_ipt_dump called with NULL params\n" ); goto rtattr_failure; }
@@ -309,8 +298,7 @@*/ t =kmalloc (p->t->u.user.target_size,GFP_ATOMIC ); - -if (NULL == t) +if (t ==NULL ) goto rtattr_failure; c.bindcnt = p->bindcnt - bind;
@@ -320,10 +308,10 @@DPRINTK ("\ttcf_ipt_dump tablename %s length %d\n" , p->tname,strlen (p->tname)); -DPRINTK - ("\tdump target name %s size %d size user %d data[0] %x data[1] %x\n" , - p->t->u.kernel.target->name, p->t->u.target_size, p->t->u.user.target_size, - p->t->data[0 ], p->t->data[1 ]); +DPRINTK ("\tdump target name %s size %d size user %d " +"data[0] %x data[1] %x\n" , p->t->u.kernel.target->name, + p->t->u.target_size, p->t->u.user.target_size, + p->t->data[0 ], p->t->data[1 ]);RTA_PUT (skb,TCA_IPT_TARG , p->t->u.user.target_size, t);RTA_PUT (skb,TCA_IPT_INDEX ,4 , &p->index);RTA_PUT (skb,TCA_IPT_HOOK ,4 , &p->hook);
@@ -341,7 +329,6 @@ }static struct tc_action_ops act_ipt_ops = { - .next =NULL , .kind ="ipt" , .type =TCA_ACT_IPT , .capab =TCA_CAP_NONE ,
net/sched/mirred.c +48 -58
242 lines not on this page · raw message
net/sched/pedit.c +36 -52
191 lines not on this page · raw message
net/sched/police.c +49 -48
221 lines not on this page · raw message