diff mbox series

[net-next] tipc: replace open-code bearer rcu_dereference access in bearer.c

Message ID 1072588a8691f970bda950c7e2834d1f2983f58e.1685976044.git.lucien.xin@gmail.com (mailing list archive)
State Accepted
Commit ae28ea5cbdee9956464223b304d6c767238b2506
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tipc: replace open-code bearer rcu_dereference access in bearer.c | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 1 maintainers not CCed: ying.xue@windriver.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 56 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Xin Long June 5, 2023, 2:40 p.m. UTC
Replace these open-code bearer rcu_dereference access with bearer_get(),
like other places in bearer.c. While at it, also use tipc_net() instead
of net_generic(net, tipc_net_id) to get "tn" in bearer.c.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/tipc/bearer.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Comments

Larysa Zaremba June 6, 2023, 9:13 a.m. UTC | #1
On Mon, Jun 05, 2023 at 10:40:44AM -0400, Xin Long wrote:
> Replace these open-code bearer rcu_dereference access with bearer_get(),
> like other places in bearer.c. While at it, also use tipc_net() instead
> of net_generic(net, tipc_net_id) to get "tn" in bearer.c.
>

From what I see, logic was not changed.

Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/tipc/bearer.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
> index 114140c49108..1d5d3677bdaf 100644
> --- a/net/tipc/bearer.c
> +++ b/net/tipc/bearer.c
> @@ -176,7 +176,7 @@ static int bearer_name_validate(const char *name,
>   */
>  struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
>  {
> -	struct tipc_net *tn = net_generic(net, tipc_net_id);
> +	struct tipc_net *tn = tipc_net(net);
>  	struct tipc_bearer *b;
>  	u32 i;
>  
> @@ -211,11 +211,10 @@ int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
>  
>  void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
>  {
> -	struct tipc_net *tn = net_generic(net, tipc_net_id);
>  	struct tipc_bearer *b;
>  
>  	rcu_read_lock();
> -	b = rcu_dereference(tn->bearer_list[bearer_id]);
> +	b = bearer_get(net, bearer_id);
>  	if (b)
>  		tipc_disc_add_dest(b->disc);
>  	rcu_read_unlock();
> @@ -223,11 +222,10 @@ void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
>  
>  void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
>  {
> -	struct tipc_net *tn = net_generic(net, tipc_net_id);
>  	struct tipc_bearer *b;
>  
>  	rcu_read_lock();
> -	b = rcu_dereference(tn->bearer_list[bearer_id]);
> +	b = bearer_get(net, bearer_id);
>  	if (b)
>  		tipc_disc_remove_dest(b->disc);
>  	rcu_read_unlock();
> @@ -534,7 +532,7 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id)
>  	struct tipc_bearer *b;
>  
>  	rcu_read_lock();
> -	b = rcu_dereference(tipc_net(net)->bearer_list[bearer_id]);
> +	b = bearer_get(net, bearer_id);
>  	if (b)
>  		mtu = b->mtu;
>  	rcu_read_unlock();
> @@ -745,7 +743,7 @@ void tipc_bearer_cleanup(void)
>  
>  void tipc_bearer_stop(struct net *net)
>  {
> -	struct tipc_net *tn = net_generic(net, tipc_net_id);
> +	struct tipc_net *tn = tipc_net(net);
>  	struct tipc_bearer *b;
>  	u32 i;
>  
> @@ -881,7 +879,7 @@ int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb)
>  	struct tipc_bearer *bearer;
>  	struct tipc_nl_msg msg;
>  	struct net *net = sock_net(skb->sk);
> -	struct tipc_net *tn = net_generic(net, tipc_net_id);
> +	struct tipc_net *tn = tipc_net(net);
>  
>  	if (i == MAX_BEARERS)
>  		return 0;
> -- 
> 2.39.1
> 
>
Tung Quang Nguyen June 6, 2023, 9:35 a.m. UTC | #2
>Subject: [PATCH net-next] tipc: replace open-code bearer rcu_dereference access in bearer.c
>
>Replace these open-code bearer rcu_dereference access with bearer_get(),
>like other places in bearer.c. While at it, also use tipc_net() instead
>of net_generic(net, tipc_net_id) to get "tn" in bearer.c.
>
>Signed-off-by: Xin Long <lucien.xin@gmail.com>
>---
Reviewed-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>

> net/tipc/bearer.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
>diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
>index 114140c49108..1d5d3677bdaf 100644
>--- a/net/tipc/bearer.c
>+++ b/net/tipc/bearer.c
>@@ -176,7 +176,7 @@ static int bearer_name_validate(const char *name,
>  */
> struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
> {
>-	struct tipc_net *tn = net_generic(net, tipc_net_id);
>+	struct tipc_net *tn = tipc_net(net);
> 	struct tipc_bearer *b;
> 	u32 i;
>
>@@ -211,11 +211,10 @@ int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
>
> void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
> {
>-	struct tipc_net *tn = net_generic(net, tipc_net_id);
> 	struct tipc_bearer *b;
>
> 	rcu_read_lock();
>-	b = rcu_dereference(tn->bearer_list[bearer_id]);
>+	b = bearer_get(net, bearer_id);
> 	if (b)
> 		tipc_disc_add_dest(b->disc);
> 	rcu_read_unlock();
>@@ -223,11 +222,10 @@ void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
>
> void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
> {
>-	struct tipc_net *tn = net_generic(net, tipc_net_id);
> 	struct tipc_bearer *b;
>
> 	rcu_read_lock();
>-	b = rcu_dereference(tn->bearer_list[bearer_id]);
>+	b = bearer_get(net, bearer_id);
> 	if (b)
> 		tipc_disc_remove_dest(b->disc);
> 	rcu_read_unlock();
>@@ -534,7 +532,7 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id)
> 	struct tipc_bearer *b;
>
> 	rcu_read_lock();
>-	b = rcu_dereference(tipc_net(net)->bearer_list[bearer_id]);
>+	b = bearer_get(net, bearer_id);
> 	if (b)
> 		mtu = b->mtu;
> 	rcu_read_unlock();
>@@ -745,7 +743,7 @@ void tipc_bearer_cleanup(void)
>
> void tipc_bearer_stop(struct net *net)
> {
>-	struct tipc_net *tn = net_generic(net, tipc_net_id);
>+	struct tipc_net *tn = tipc_net(net);
> 	struct tipc_bearer *b;
> 	u32 i;
>
>@@ -881,7 +879,7 @@ int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb)
> 	struct tipc_bearer *bearer;
> 	struct tipc_nl_msg msg;
> 	struct net *net = sock_net(skb->sk);
>-	struct tipc_net *tn = net_generic(net, tipc_net_id);
>+	struct tipc_net *tn = tipc_net(net);
>
> 	if (i == MAX_BEARERS)
> 		return 0;
>--
>2.39.1
patchwork-bot+netdevbpf@kernel.org June 7, 2023, 5 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  5 Jun 2023 10:40:44 -0400 you wrote:
> Replace these open-code bearer rcu_dereference access with bearer_get(),
> like other places in bearer.c. While at it, also use tipc_net() instead
> of net_generic(net, tipc_net_id) to get "tn" in bearer.c.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/tipc/bearer.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

Here is the summary with links:
  - [net-next] tipc: replace open-code bearer rcu_dereference access in bearer.c
    https://git.kernel.org/netdev/net-next/c/ae28ea5cbdee

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 114140c49108..1d5d3677bdaf 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -176,7 +176,7 @@  static int bearer_name_validate(const char *name,
  */
 struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
 {
-	struct tipc_net *tn = net_generic(net, tipc_net_id);
+	struct tipc_net *tn = tipc_net(net);
 	struct tipc_bearer *b;
 	u32 i;
 
@@ -211,11 +211,10 @@  int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
 
 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
 {
-	struct tipc_net *tn = net_generic(net, tipc_net_id);
 	struct tipc_bearer *b;
 
 	rcu_read_lock();
-	b = rcu_dereference(tn->bearer_list[bearer_id]);
+	b = bearer_get(net, bearer_id);
 	if (b)
 		tipc_disc_add_dest(b->disc);
 	rcu_read_unlock();
@@ -223,11 +222,10 @@  void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
 
 void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
 {
-	struct tipc_net *tn = net_generic(net, tipc_net_id);
 	struct tipc_bearer *b;
 
 	rcu_read_lock();
-	b = rcu_dereference(tn->bearer_list[bearer_id]);
+	b = bearer_get(net, bearer_id);
 	if (b)
 		tipc_disc_remove_dest(b->disc);
 	rcu_read_unlock();
@@ -534,7 +532,7 @@  int tipc_bearer_mtu(struct net *net, u32 bearer_id)
 	struct tipc_bearer *b;
 
 	rcu_read_lock();
-	b = rcu_dereference(tipc_net(net)->bearer_list[bearer_id]);
+	b = bearer_get(net, bearer_id);
 	if (b)
 		mtu = b->mtu;
 	rcu_read_unlock();
@@ -745,7 +743,7 @@  void tipc_bearer_cleanup(void)
 
 void tipc_bearer_stop(struct net *net)
 {
-	struct tipc_net *tn = net_generic(net, tipc_net_id);
+	struct tipc_net *tn = tipc_net(net);
 	struct tipc_bearer *b;
 	u32 i;
 
@@ -881,7 +879,7 @@  int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb)
 	struct tipc_bearer *bearer;
 	struct tipc_nl_msg msg;
 	struct net *net = sock_net(skb->sk);
-	struct tipc_net *tn = net_generic(net, tipc_net_id);
+	struct tipc_net *tn = tipc_net(net);
 
 	if (i == MAX_BEARERS)
 		return 0;