Skip to content

Commit cc7ec45

Browse files
Eric Dumazetdavem330
authored andcommitted
net_sched: cleanups
Cleanup net/sched code to current CodingStyle and practices. Reduce inline abuse Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7180a03 commit cc7ec45

41 files changed

Lines changed: 842 additions & 801 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎net/sched/act_api.c‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
7878
struct tc_action *a, struct tcf_hashinfo *hinfo)
7979
{
8080
struct tcf_common *p;
81-
int err = 0, index = -1,i = 0, s_i = 0, n_i = 0;
81+
int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
8282
struct nlattr *nest;
8383

8484
read_lock_bh(hinfo->lock);
@@ -126,7 +126,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
126126
{
127127
struct tcf_common *p, *s_p;
128128
struct nlattr *nest;
129-
int i= 0, n_i = 0;
129+
int i = 0, n_i = 0;
130130

131131
nest = nla_nest_start(skb, a->order);
132132
if (nest == NULL)
@@ -138,7 +138,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
138138
while (p != NULL) {
139139
s_p = p->tcfc_next;
140140
if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo))
141-
module_put(a->ops->owner);
141+
module_put(a->ops->owner);
142142
n_i++;
143143
p = s_p;
144144
}
@@ -447,7 +447,8 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
447447
nest = nla_nest_start(skb, TCA_OPTIONS);
448448
if (nest == NULL)
449449
goto nla_put_failure;
450-
if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) {
450+
err = tcf_action_dump_old(skb, a, bind, ref);
451+
if (err > 0) {
451452
nla_nest_end(skb, nest);
452453
return err;
453454
}
@@ -491,7 +492,7 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
491492
struct tc_action *a;
492493
struct tc_action_ops *a_o;
493494
char act_name[IFNAMSIZ];
494-
struct nlattr *tb[TCA_ACT_MAX+1];
495+
struct nlattr *tb[TCA_ACT_MAX + 1];
495496
struct nlattr *kind;
496497
int err;
497498

@@ -549,9 +550,9 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
549550
goto err_free;
550551

551552
/* module count goes up only when brand new policy is created
552-
if it exists and is only bound to in a_o->init() then
553-
ACT_P_CREATED is not returned (a zero is).
554-
*/
553+
* if it exists and is only bound to in a_o->init() then
554+
* ACT_P_CREATED is not returned (a zero is).
555+
*/
555556
if (err != ACT_P_CREATED)
556557
module_put(a_o->owner);
557558
a->ops = a_o;
@@ -569,7 +570,7 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
569570
struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
570571
char *name, int ovr, int bind)
571572
{
572-
struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
573+
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
573574
struct tc_action *head = NULL, *act, *act_prev = NULL;
574575
int err;
575576
int i;
@@ -697,7 +698,7 @@ act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n,
697698
static struct tc_action *
698699
tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
699700
{
700-
struct nlattr *tb[TCA_ACT_MAX+1];
701+
struct nlattr *tb[TCA_ACT_MAX + 1];
701702
struct tc_action *a;
702703
int index;
703704
int err;
@@ -770,7 +771,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
770771
struct tcamsg *t;
771772
struct netlink_callback dcb;
772773
struct nlattr *nest;
773-
struct nlattr *tb[TCA_ACT_MAX+1];
774+
struct nlattr *tb[TCA_ACT_MAX + 1];
774775
struct nlattr *kind;
775776
struct tc_action *a = create_a(0);
776777
int err = -ENOMEM;
@@ -821,7 +822,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
821822
nlh->nlmsg_flags |= NLM_F_ROOT;
822823
module_put(a->ops->owner);
823824
kfree(a);
824-
err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
825+
err = rtnetlink_send(skb, net, pid, RTNLGRP_TC,
826+
n->nlmsg_flags & NLM_F_ECHO);
825827
if (err > 0)
826828
return 0;
827829

@@ -842,14 +844,14 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
842844
u32 pid, int event)
843845
{
844846
int i, ret;
845-
struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
847+
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
846848
struct tc_action *head = NULL, *act, *act_prev = NULL;
847849

848850
ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
849851
if (ret < 0)
850852
return ret;
851853

852-
if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
854+
if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) {
853855
if (tb[1] != NULL)
854856
return tca_action_flush(net, tb[1], n, pid);
855857
else
@@ -892,7 +894,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
892894
/* now do the delete */
893895
tcf_action_destroy(head, 0);
894896
ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC,
895-
n->nlmsg_flags&NLM_F_ECHO);
897+
n->nlmsg_flags & NLM_F_ECHO);
896898
if (ret > 0)
897899
return 0;
898900
return ret;
@@ -936,7 +938,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
936938
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
937939
NETLINK_CB(skb).dst_group = RTNLGRP_TC;
938940

939-
err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
941+
err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags & NLM_F_ECHO);
940942
if (err > 0)
941943
err = 0;
942944
return err;
@@ -967,7 +969,7 @@ tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
967969

968970
/* dump then free all the actions after update; inserted policy
969971
* stays intact
970-
* */
972+
*/
971973
ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags);
972974
for (a = act; a; a = act) {
973975
act = a->next;
@@ -993,8 +995,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
993995
return -EINVAL;
994996
}
995997

996-
/* n->nlmsg_flags&NLM_F_CREATE
997-
* */
998+
/* n->nlmsg_flags & NLM_F_CREATE */
998999
switch (n->nlmsg_type) {
9991000
case RTM_NEWACTION:
10001001
/* we are going to assume all other flags
@@ -1003,7 +1004,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
10031004
* but since we want avoid ambiguity (eg when flags
10041005
* is zero) then just set this
10051006
*/
1006-
if (n->nlmsg_flags&NLM_F_REPLACE)
1007+
if (n->nlmsg_flags & NLM_F_REPLACE)
10071008
ovr = 1;
10081009
replay:
10091010
ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr);
@@ -1028,7 +1029,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
10281029
static struct nlattr *
10291030
find_dump_kind(const struct nlmsghdr *n)
10301031
{
1031-
struct nlattr *tb1, *tb2[TCA_ACT_MAX+1];
1032+
struct nlattr *tb1, *tb2[TCA_ACT_MAX + 1];
10321033
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
10331034
struct nlattr *nla[TCAA_MAX + 1];
10341035
struct nlattr *kind;
@@ -1071,9 +1072,8 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
10711072
}
10721073

10731074
a_o = tc_lookup_action(kind);
1074-
if (a_o == NULL) {
1075+
if (a_o == NULL)
10751076
return 0;
1076-
}
10771077

10781078
memset(&a, 0, sizeof(struct tc_action));
10791079
a.ops = a_o;

‎net/sched/act_csum.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int tcf_csum_init(struct nlattr *nla, struct nlattr *est,
6363
if (nla == NULL)
6464
return -EINVAL;
6565

66-
err = nla_parse_nested(tb, TCA_CSUM_MAX, nla,csum_policy);
66+
err = nla_parse_nested(tb, TCA_CSUM_MAX, nla, csum_policy);
6767
if (err < 0)
6868
return err;
6969

‎net/sched/act_gact.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int gact_determ(struct tcf_gact *gact)
5050
}
5151

5252
typedef int (*g_rand)(struct tcf_gact *gact);
53-
static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ };
53+
static g_rand gact_rand[MAX_RAND] = { NULL, gact_net_rand, gact_determ };
5454
#endif /* CONFIG_GACT_PROB */
5555

5656
static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = {
@@ -89,7 +89,7 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
8989
pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
9090
bind, &gact_idx_gen, &gact_hash_info);
9191
if (IS_ERR(pc))
92-
return PTR_ERR(pc);
92+
return PTR_ERR(pc);
9393
ret = ACT_P_CREATED;
9494
} else {
9595
if (!ovr) {
@@ -205,9 +205,9 @@ MODULE_LICENSE("GPL");
205205
static int __init gact_init_module(void)
206206
{
207207
#ifdef CONFIG_GACT_PROB
208-
printk(KERN_INFO "GACT probability on\n");
208+
pr_info("GACT probability on\n");
209209
#else
210-
printk(KERN_INFO "GACT probability NOT on\n");
210+
pr_info("GACT probability NOT on\n");
211211
#endif
212212
return tcf_register_action(&act_gact_ops);
213213
}

‎net/sched/act_ipt.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
138138
pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind,
139139
&ipt_idx_gen, &ipt_hash_info);
140140
if (IS_ERR(pc))
141-
return PTR_ERR(pc);
141+
return PTR_ERR(pc);
142142
ret = ACT_P_CREATED;
143143
} else {
144144
if (!ovr) {
@@ -162,7 +162,8 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
162162
if (unlikely(!t))
163163
goto err2;
164164

165-
if ((err = ipt_init_target(t, tname, hook)) < 0)
165+
err = ipt_init_target(t, tname, hook);
166+
if (err < 0)
166167
goto err3;
167168

168169
spin_lock_bh(&ipt->tcf_lock);
@@ -212,8 +213,9 @@ static int tcf_ipt(struct sk_buff *skb, struct tc_action *a,
212213
bstats_update(&ipt->tcf_bstats, skb);
213214

214215
/* yes, we have to worry about both in and out dev
215-
worry later - danger - this API seems to have changed
216-
from earlier kernels */
216+
* worry later - danger - this API seems to have changed
217+
* from earlier kernels
218+
*/
217219
par.in = skb->dev;
218220
par.out = NULL;
219221
par.hooknum = ipt->tcfi_hook;
@@ -253,9 +255,9 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
253255
struct tc_cnt c;
254256

255257
/* for simple targets kernel size == user size
256-
** user name = target name
257-
** for foolproof you need to not assume this
258-
*/
258+
* user name = target name
259+
* for foolproof you need to not assume this
260+
*/
259261

260262
t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
261263
if (unlikely(!t))

‎net/sched/act_mirred.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ static struct tcf_hashinfo mirred_hash_info = {
4141
.lock = &mirred_lock,
4242
};
4343

44-
static inline int tcf_mirred_release(struct tcf_mirred *m, int bind)
44+
static int tcf_mirred_release(struct tcf_mirred *m, int bind)
4545
{
4646
if (m) {
4747
if (bind)
4848
m->tcf_bindcnt--;
4949
m->tcf_refcnt--;
50-
if(!m->tcf_bindcnt && m->tcf_refcnt <= 0) {
50+
if (!m->tcf_bindcnt && m->tcf_refcnt <= 0) {
5151
list_del(&m->tcfm_list);
5252
if (m->tcfm_dev)
5353
dev_put(m->tcfm_dev);

‎net/sched/act_nat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
6969
pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
7070
&nat_idx_gen, &nat_hash_info);
7171
if (IS_ERR(pc))
72-
return PTR_ERR(pc);
72+
return PTR_ERR(pc);
7373
p = to_tcf_nat(pc);
7474
ret = ACT_P_CREATED;
7575
} else {

‎net/sched/act_pedit.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est,
7070
pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
7171
&pedit_idx_gen, &pedit_hash_info);
7272
if (IS_ERR(pc))
73-
return PTR_ERR(pc);
73+
return PTR_ERR(pc);
7474
p = to_pedit(pc);
7575
keys = kmalloc(ksize, GFP_KERNEL);
7676
if (keys == NULL) {
@@ -127,11 +127,9 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a,
127127
int i, munged = 0;
128128
unsigned int off;
129129

130-
if (skb_cloned(skb)) {
131-
if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
132-
return p->tcf_action;
133-
}
134-
}
130+
if (skb_cloned(skb) &&
131+
pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
132+
return p->tcf_action;
135133

136134
off = skb_network_offset(skb);
137135

‎net/sched/act_police.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <net/act_api.h>
2323
#include <net/netlink.h>
2424

25-
#define L2T(p,L) qdisc_l2t((p)->tcfp_R_tab, L)
26-
#define L2T_P(p,L) qdisc_l2t((p)->tcfp_P_tab, L)
25+
#define L2T(p, L) qdisc_l2t((p)->tcfp_R_tab, L)
26+
#define L2T_P(p, L) qdisc_l2t((p)->tcfp_P_tab, L)
2727

2828
#define POL_TAB_MASK 15
2929
static struct tcf_common *tcf_police_ht[POL_TAB_MASK + 1];
@@ -37,8 +37,7 @@ static struct tcf_hashinfo police_hash_info = {
3737
};
3838

3939
/* old policer structure from before tc actions */
40-
struct tc_police_compat
41-
{
40+
struct tc_police_compat {
4241
u32 index;
4342
int action;
4443
u32 limit;
@@ -139,7 +138,7 @@ static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
139138
static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
140139
struct tc_action *a, int ovr, int bind)
141140
{
142-
unsigned h;
141+
unsigned int h;
143142
int ret = 0, err;
144143
struct nlattr *tb[TCA_POLICE_MAX + 1];
145144
struct tc_police *parm;

‎net/sched/act_simple.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result
4747
/* print policy string followed by _ then packet count
4848
* Example if this was the 3rd packet and the string was "hello"
4949
* then it would look like "hello_3" (without quotes)
50-
**/
50+
*/
5151
pr_info("simple: %s_%d\n",
5252
(char *)d->tcfd_defdata, d->tcf_bstats.packets);
5353
spin_unlock(&d->tcf_lock);
@@ -125,7 +125,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
125125
pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
126126
&simp_idx_gen, &simp_hash_info);
127127
if (IS_ERR(pc))
128-
return PTR_ERR(pc);
128+
return PTR_ERR(pc);
129129

130130
d = to_defact(pc);
131131
ret = alloc_defdata(d, defdata);
@@ -149,7 +149,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
149149
return ret;
150150
}
151151

152-
static inline int tcf_simp_cleanup(struct tc_action *a, int bind)
152+
static int tcf_simp_cleanup(struct tc_action *a, int bind)
153153
{
154154
struct tcf_defact *d = a->priv;
155155

@@ -158,8 +158,8 @@ static inline int tcf_simp_cleanup(struct tc_action *a, int bind)
158158
return 0;
159159
}
160160

161-
static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
162-
int bind, int ref)
161+
static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
162+
int bind, int ref)
163163
{
164164
unsigned char *b = skb_tail_pointer(skb);
165165
struct tcf_defact *d = a->priv;

0 commit comments

Comments
 (0)