Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net_sched: act: move idx_gen into struct tcf_hashinfo

There is no need to store the index separatedly
since tcf_hashinfo is allocated statically too.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

WANG Cong and committed by
David S. Miller
ddafd34f 600adc18

+18 -26
+4 -3
include/net/act_api.h
··· 39 39 struct hlist_head *htab; 40 40 unsigned int hmask; 41 41 spinlock_t lock; 42 + u32 index; 42 43 }; 43 44 44 45 static inline unsigned int tcf_hash(u32 index, unsigned int hmask) ··· 52 51 int i; 53 52 54 53 spin_lock_init(&hf->lock); 54 + hf->index = 0; 55 55 hf->hmask = mask; 56 56 hf->htab = kzalloc((mask + 1) * sizeof(struct hlist_head), 57 57 GFP_KERNEL); ··· 107 105 void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo); 108 106 int tcf_hash_release(struct tcf_common *p, int bind, 109 107 struct tcf_hashinfo *hinfo); 110 - u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo); 108 + u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo); 111 109 struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, 112 110 int bind, struct tcf_hashinfo *hinfo); 113 111 struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, 114 112 struct tc_action *a, int size, 115 - int bind, u32 *idx_gen, 116 - struct tcf_hashinfo *hinfo); 113 + int bind, struct tcf_hashinfo *hinfo); 117 114 void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo); 118 115 119 116 int tcf_register_action(struct tc_action_ops *a);
+5 -5
net/sched/act_api.c
··· 173 173 } 174 174 EXPORT_SYMBOL(tcf_hash_lookup); 175 175 176 - u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo) 176 + u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo) 177 177 { 178 - u32 val = *idx_gen; 178 + u32 val = hinfo->index; 179 179 180 180 do { 181 181 if (++val == 0) 182 182 val = 1; 183 183 } while (tcf_hash_lookup(val, hinfo)); 184 184 185 - *idx_gen = val; 185 + hinfo->index = val; 186 186 return val; 187 187 } 188 188 EXPORT_SYMBOL(tcf_hash_new_index); ··· 215 215 216 216 struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, 217 217 struct tc_action *a, int size, int bind, 218 - u32 *idx_gen, struct tcf_hashinfo *hinfo) 218 + struct tcf_hashinfo *hinfo) 219 219 { 220 220 struct tcf_common *p = kzalloc(size, GFP_KERNEL); 221 221 ··· 227 227 228 228 spin_lock_init(&p->tcfc_lock); 229 229 INIT_HLIST_NODE(&p->tcfc_head); 230 - p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo); 230 + p->tcfc_index = index ? index : tcf_hash_new_index(hinfo); 231 231 p->tcfc_tm.install = jiffies; 232 232 p->tcfc_tm.lastuse = jiffies; 233 233 if (est) {
+1 -2
net/sched/act_csum.c
··· 37 37 #include <net/tc_act/tc_csum.h> 38 38 39 39 #define CSUM_TAB_MASK 15 40 - static u32 csum_idx_gen; 41 40 static struct tcf_hashinfo csum_hash_info; 42 41 43 42 static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { ··· 66 67 pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info); 67 68 if (!pc) { 68 69 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, 69 - &csum_idx_gen, &csum_hash_info); 70 + &csum_hash_info); 70 71 if (IS_ERR(pc)) 71 72 return PTR_ERR(pc); 72 73 ret = ACT_P_CREATED;
+1 -2
net/sched/act_gact.c
··· 24 24 #include <net/tc_act/tc_gact.h> 25 25 26 26 #define GACT_TAB_MASK 15 27 - static u32 gact_idx_gen; 28 27 static struct tcf_hashinfo gact_hash_info; 29 28 30 29 #ifdef CONFIG_GACT_PROB ··· 89 90 pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info); 90 91 if (!pc) { 91 92 pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), 92 - bind, &gact_idx_gen, &gact_hash_info); 93 + bind, &gact_hash_info); 93 94 if (IS_ERR(pc)) 94 95 return PTR_ERR(pc); 95 96 ret = ACT_P_CREATED;
+1 -2
net/sched/act_ipt.c
··· 29 29 30 30 31 31 #define IPT_TAB_MASK 15 32 - static u32 ipt_idx_gen; 33 32 static struct tcf_hashinfo ipt_hash_info; 34 33 35 34 static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook) ··· 128 129 pc = tcf_hash_check(index, a, bind, &ipt_hash_info); 129 130 if (!pc) { 130 131 pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind, 131 - &ipt_idx_gen, &ipt_hash_info); 132 + &ipt_hash_info); 132 133 if (IS_ERR(pc)) 133 134 return PTR_ERR(pc); 134 135 ret = ACT_P_CREATED;
+1 -2
net/sched/act_mirred.c
··· 30 30 #include <linux/if_arp.h> 31 31 32 32 #define MIRRED_TAB_MASK 7 33 - static u32 mirred_idx_gen; 34 33 static LIST_HEAD(mirred_list); 35 34 static struct tcf_hashinfo mirred_hash_info; 36 35 ··· 106 107 if (dev == NULL) 107 108 return -EINVAL; 108 109 pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind, 109 - &mirred_idx_gen, &mirred_hash_info); 110 + &mirred_hash_info); 110 111 if (IS_ERR(pc)) 111 112 return PTR_ERR(pc); 112 113 ret = ACT_P_CREATED;
+1 -2
net/sched/act_nat.c
··· 30 30 31 31 32 32 #define NAT_TAB_MASK 15 33 - static u32 nat_idx_gen; 34 33 35 34 static struct tcf_hashinfo nat_hash_info; 36 35 ··· 60 61 pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info); 61 62 if (!pc) { 62 63 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, 63 - &nat_idx_gen, &nat_hash_info); 64 + &nat_hash_info); 64 65 if (IS_ERR(pc)) 65 66 return PTR_ERR(pc); 66 67 ret = ACT_P_CREATED;
+1 -2
net/sched/act_pedit.c
··· 24 24 #include <net/tc_act/tc_pedit.h> 25 25 26 26 #define PEDIT_TAB_MASK 15 27 - static u32 pedit_idx_gen; 28 27 29 28 static struct tcf_hashinfo pedit_hash_info; 30 29 ··· 62 63 if (!parm->nkeys) 63 64 return -EINVAL; 64 65 pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, 65 - &pedit_idx_gen, &pedit_hash_info); 66 + &pedit_hash_info); 66 67 if (IS_ERR(pc)) 67 68 return PTR_ERR(pc); 68 69 p = to_pedit(pc);
+1 -2
net/sched/act_police.c
··· 41 41 container_of(pc, struct tcf_police, common) 42 42 43 43 #define POL_TAB_MASK 15 44 - static u32 police_idx_gen; 45 44 static struct tcf_hashinfo police_hash_info; 46 45 47 46 /* old policer structure from before tc actions */ ··· 250 251 251 252 police->tcfp_t_c = ktime_to_ns(ktime_get()); 252 253 police->tcf_index = parm->index ? parm->index : 253 - tcf_hash_new_index(&police_idx_gen, &police_hash_info); 254 + tcf_hash_new_index(&police_hash_info); 254 255 h = tcf_hash(police->tcf_index, POL_TAB_MASK); 255 256 spin_lock_bh(&police_hash_info.lock); 256 257 hlist_add_head(&police->tcf_head, &police_hash_info.htab[h]);
+1 -2
net/sched/act_simple.c
··· 25 25 #include <net/tc_act/tc_defact.h> 26 26 27 27 #define SIMP_TAB_MASK 7 28 - static u32 simp_idx_gen; 29 28 static struct tcf_hashinfo simp_hash_info; 30 29 31 30 #define SIMP_MAX_DATA 32 ··· 117 118 pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); 118 119 if (!pc) { 119 120 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, 120 - &simp_idx_gen, &simp_hash_info); 121 + &simp_hash_info); 121 122 if (IS_ERR(pc)) 122 123 return PTR_ERR(pc); 123 124
+1 -2
net/sched/act_skbedit.c
··· 28 28 #include <net/tc_act/tc_skbedit.h> 29 29 30 30 #define SKBEDIT_TAB_MASK 15 31 - static u32 skbedit_idx_gen; 32 31 static struct tcf_hashinfo skbedit_hash_info; 33 32 34 33 static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a, ··· 103 104 pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info); 104 105 if (!pc) { 105 106 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, 106 - &skbedit_idx_gen, &skbedit_hash_info); 107 + &skbedit_hash_info); 107 108 if (IS_ERR(pc)) 108 109 return PTR_ERR(pc); 109 110