net_sched: move tp->root allocation into route4_init()
Subsystems (3)
PATCH 1/1 net_sched: move tp->root allocation into route4_init()
--- net/sched/cls_route.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/sched/cls_route.c +7 -7
@@ -258,6 +258,13 @@ static unsigned long route4_get(struct tcf_proto *tp, u32 handle)static int route4_init (struct tcf_proto *tp) { +struct route4_head *head; + + head =kzalloc (sizeof (struct route4_head ),GFP_KERNEL ); +if (head ==NULL ) +return -ENOBUFS ; + +rcu_assign_pointer (tp->root, head);return 0 ; }
@@ -484,13 +491,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; err = -ENOBUFS ; -if (head ==NULL ) { - head =kzalloc (sizeof (struct route4_head ),GFP_KERNEL ); -if (head ==NULL ) - goto errout; -rcu_assign_pointer (tp->root, head); - } - f =kzalloc (sizeof (struct route4_filter ),GFP_KERNEL );if (!f) goto errout;
Signature · 1 line
1.8.1.4
PATCH 1/1 net_sched: move tp->root allocation into fw_init()
--- net/sched/cls_fw.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
net/sched/cls_fw.c +13 -10
@@ -33,6 +33,7 @@struct fw_head {u32 mask; +bool mask_set;struct fw_filter __rcu *ht[HTSIZE ];struct rcu_head rcu; };
@@ -113,6 +114,14 @@ static unsigned long fw_get(struct tcf_proto *tp, u32 handle)static int fw_init (struct tcf_proto *tp) { +struct fw_head *head; + + head =kzalloc (sizeof (struct fw_head ),GFP_KERNEL ); +if (head ==NULL ) +return -ENOBUFS ; + + head->mask_set = false; +rcu_assign_pointer (tp->root, head);return 0 ; }
@@ -286,17 +295,11 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,if (!handle)return -EINVAL ; -if (head ==NULL ) { -u32 mask =0xFFFFFFFF ; +if (!head->mask_set) { + head->mask =0xFFFFFFFF ;if (tb[TCA_FW_MASK ]) - mask =nla_get_u32 (tb[TCA_FW_MASK ]); - - head =kzalloc (sizeof (struct fw_head ),GFP_KERNEL ); -if (head ==NULL ) -return -ENOBUFS ; - head->mask = mask; - -rcu_assign_pointer (tp->root, head); + head->mask =nla_get_u32 (tb[TCA_FW_MASK ]); + head->mask_set = true; } f =kzalloc (sizeof (struct fw_filter ),GFP_KERNEL );
Signature · 1 line
1.8.1.4
Re: [Patch net-next] net_sched: move tp->root allocation into fw_init()
Quoted 2 lines · Cong Wang
Cc Jamal Hadi Salim <[email protected]>Signed-off-by Cong Wang <[email protected]>
cheers,
jamal
Re: [Patch net-next] net_sched: move tp->root allocation into fw_init()
In reply to Cong WangFrom: Cong Wang <[email protected]>
Date: Wed, 4 Mar 2015 20:11:44 -0800
Quoted 2 lines
Cc Jamal Hadi Salim <[email protected]>Signed-off-by Cong Wang <[email protected]>
Applied.
Quoted 2 lines · Cong Wang
Cc Jamal Hadi Salim <[email protected]>Signed-off-by Cong Wang <[email protected]>
cheers,
jamal
Hello.
Quoted 11 lines · Cong Wang
Cc Jamal Hadi Salim <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_route.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)net/sched/cls_route.c +0
-0
net/sched/cls_route.c static unsigned long route4_get(struct tcf_proto *tp, u32 handle) · line 263
Quoted 6 lines
net/sched/cls_route.c +3
-0@@ -258,6 +258,13 @@ static unsigned long route4_get(struct tcf_proto *tp, u32 handle)static int route4_init (struct tcf_proto *tp) { +struct route4_head *head; + + head =kzalloc (sizeof (struct route4_head ),GFP_KERNEL );
Hm, checkpatch.pl should have suggested using sizeof(*head) instead...
net/sched/cls_route.c static unsigned long route4_get(struct tcf_proto *tp, u32 handle) · line 264
Quoted 1 line
net/sched/cls_route.c +1
-0+if (head ==NULL )
And using !head instead.
net/sched/cls_route.c static unsigned long route4_get(struct tcf_proto *tp, u32 handle) · line 269
Quoted 5 lines
net/sched/cls_route.c +3
-0+return -ENOBUFS ; + +rcu_assign_pointer (tp->root, head);return 0 ; }
WBR, Sergei
From: Cong Wang <[email protected]>
Date: Wed, 4 Mar 2015 20:11:43 -0800
Quoted 2 lines
Cc Jamal Hadi Salim <[email protected]>Signed-off-by Cong Wang <[email protected]>
Applied.