[Devel] [PATCH RHEL8 COMMIT] venet: drop redundant RCU lock in venet_newlink()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 8 18:44:34 MSK 2019


The commit is pushed to "branch-rh8-4.18.0-32.vz8.1.x" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-32.el8
------>
commit 479f57ebc5c6eeeefddb521c9c81e90cbb67683b
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Mon Apr 8 15:23:53 2019 +0300

    venet: drop redundant RCU lock in venet_newlink()
    
    src_net is references by caller in venet_newlink() => won't die,
    src_net->owner_ve is also referenced on assignment => ve won't die
    => rcu_read_lock()/unlock not needed here.
    
    Fixes: 6acfab0c3b64 ("drivers/net/ve: venet network device introduced")
    https://jira.sw.ru/browse/PSBM-93640
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 drivers/net/venetdev.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index 858d7c79c362..8bd7ccd5fd8b 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -736,15 +736,18 @@ static int venet_newlink(struct net *src_net,
 	struct net *net;
 	int err = 0;
 
-	net = ve_net_lock(ve);
+	/*
+	 * src_net is references by caller => won't die, src_net->owner_ve is
+	 * also referenced on assignment => ve won't die =>
+	 * rcu_read_lock()/unlock not needed here.
+	 */
+	net = rcu_dereference(ve->ve_ns)->net_ns;
 	if (!net)
-		err = -EBUSY;
-	else if (src_net != net)
+		return -EBUSY;
+
+	if (src_net != net)
 		/* Don't create venet-s in sub net namespaces */
-		err = -ENOSYS;
-	ve_net_unlock(ve);
-	if (err)
-		return err;
+		return -ENOSYS;
 
 	if (ve->veip)
 		return -EEXIST;



More information about the Devel mailing list