Skip to content

Commit 33f8b9e

Browse files
congwangdavem330
authored andcommitted
net_sched: move tp->root allocation into fw_init()
Cc: Jamal Hadi Salim <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a05c2d1 commit 33f8b9e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

net/sched/cls_fw.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
struct fw_head {
3535
u32 mask;
36+
bool mask_set;
3637
struct fw_filter __rcu *ht[HTSIZE];
3738
struct rcu_head rcu;
3839
};
@@ -113,6 +114,14 @@ static unsigned long fw_get(struct tcf_proto *tp, u32 handle)
113114

114115
static int fw_init(struct tcf_proto *tp)
115116
{
117+
struct fw_head *head;
118+
119+
head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
120+
if (head == NULL)
121+
return -ENOBUFS;
122+
123+
head->mask_set = false;
124+
rcu_assign_pointer(tp->root, head);
116125
return 0;
117126
}
118127

@@ -286,17 +295,11 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
286295
if (!handle)
287296
return -EINVAL;
288297

289-
if (head == NULL) {
290-
u32 mask = 0xFFFFFFFF;
298+
if (!head->mask_set) {
299+
head->mask = 0xFFFFFFFF;
291300
if (tb[TCA_FW_MASK])
292-
mask = nla_get_u32(tb[TCA_FW_MASK]);
293-
294-
head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
295-
if (head == NULL)
296-
return -ENOBUFS;
297-
head->mask = mask;
298-
299-
rcu_assign_pointer(tp->root, head);
301+
head->mask = nla_get_u32(tb[TCA_FW_MASK]);
302+
head->mask_set = true;
300303
}
301304

302305
f = kzalloc(sizeof(struct fw_filter), GFP_KERNEL);

0 commit comments

Comments
 (0)