Skip to contentSkip to conversation

net: qualcomm: rmnet: Allow configuration updates to existing devices

PATCH Applied Subash Abhinov Kasiviswanathan 3 participants 4 messages Mar 31, 2020 – Apr 2, 2020

Subsystems (3)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: qualcomm: rmnet: Allow configuration updates to existing devices

This allows the changelink operation to succeed if the mux_id was specified as an argument. Note that the mux_id must match the existing mux_id of the rmnet device or should be an unused mux_id.

Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")
---
 .../ethernet/qualcomm/rmnet/rmnet_config.c    | 21 ++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +13 -8
index fbf4cbcf1a65..06332984399d 100644
@@ -294,19 +294,24 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
 
 	if (data[IFLA_RMNET_MUX_ID]) {
 		mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
-		if (rmnet_get_endpoint(port, mux_id)) {
-			NL_SET_ERR_MSG_MOD(extack, "MUX ID already exists");
-			return -EINVAL;
-		}
 		ep = rmnet_get_endpoint(port, priv->mux_id);
 		if (!ep)
 			return -ENODEV;
 
-		hlist_del_init_rcu(&ep->hlnode);
-		hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
+		if (mux_id != priv->mux_id) {
+			if (rmnet_get_endpoint(port, mux_id)) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "MUX ID already exists");
+				return -EINVAL;
+			}
 
-		ep->mux_id = mux_id;
-		priv->mux_id = mux_id;
+			hlist_del_init_rcu(&ep->hlnode);
+			hlist_add_head_rcu(&ep->hlnode,
+					   &port->muxed_ep[mux_id]);
+
+			ep->mux_id = mux_id;
+			priv->mux_id = mux_id;
+		}
 	}
 
 	if (data[IFLA_RMNET_FLAGS]) {
Signature · 1 line
2.26.0
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Subash Abhinov Kasiviswanathan

This allows the changelink operation to succeed if the mux_id was specified as an argument. Note that the mux_id must match the existing mux_id of the rmnet device or should be an unused mux_id.

Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")

This was a regression in 5.6, and got back-ported to 5.5.11 and possibly further back. Please be sure the fix gets applied to stable branches if appropriate.

If you happen to post a second version of this I have a suggestion, below. But the patch looks OK to me as-is.

Thanks.

Quoted 9 lines
---
 .../ethernet/qualcomm/rmnet/rmnet_config.c    | 21 ++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +0 -0
index fbf4cbcf1a65..06332984399d 100644

drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[], · line 300

Quoted 7 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +0 -4
@@ -294,19 +294,24 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
 
 	if (data[IFLA_RMNET_MUX_ID]) {
 		mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
-		if (rmnet_get_endpoint(port, mux_id)) {
-			NL_SET_ERR_MSG_MOD(extack, "MUX ID already exists");
-			return -EINVAL;
-		}

My suggestion is this: Since the endpoint pointer isn't used outside the "if (mux_id != priv->mux_id)" block, you could do the lookup inside that block.

Quoted 26 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +13 -4
 		ep = rmnet_get_endpoint(port, priv->mux_id);
 		if (!ep)
 			return -ENODEV;
 
-		hlist_del_init_rcu(&ep->hlnode);
-		hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
+		if (mux_id != priv->mux_id) {
+			if (rmnet_get_endpoint(port, mux_id)) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "MUX ID already exists");
+				return -EINVAL;
+			}
 
-		ep->mux_id = mux_id;
-		priv->mux_id = mux_id;
+			hlist_del_init_rcu(&ep->hlnode);
+			hlist_add_head_rcu(&ep->hlnode,
+					   &port->muxed_ep[mux_id]);
+
+			ep->mux_id = mux_id;
+			priv->mux_id = mux_id;
+		}
 	}
 
 	if (data[IFLA_RMNET_FLAGS]) {
#2 lore raw
Quoted 33 lines · Alex Elder
Quoted 8 lines · Subash Abhinov Kasiviswanathan

This allows the changelink operation to succeed if the mux_id was specified as an argument. Note that the mux_id must match the existing mux_id of the rmnet device or should be an unused mux_id.

Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")

This was a regression in 5.6, and got back-ported to 5.5.11 and possibly further back. Please be sure the fix gets applied to stable branches if appropriate.

If you happen to post a second version of this I have a suggestion, below. But the patch looks OK to me as-is.

Thanks.

Quoted 12 lines
---
 .../ethernet/qualcomm/rmnet/rmnet_config.c    | 21 
++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +0 -0
index fbf4cbcf1a65..06332984399d 100644
@@ -294,19 +294,24 @@ static int rmnet_changelink(struct net_device 
 *dev, struct nlattr *tb[],
 
Quoted 10 lines

drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[], · line 300

Quoted 6 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +0 -4
 	if (data[IFLA_RMNET_MUX_ID]) {
 		mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
-		if (rmnet_get_endpoint(port, mux_id)) {
-			NL_SET_ERR_MSG_MOD(extack, "MUX ID already exists");
-			return -EINVAL;
-		}

My suggestion is this: Since the endpoint pointer isn't used outside the "if (mux_id != priv->mux_id)" block, you could do the lookup inside that block.

I've sent a v2 now based on your comment.

maintainer Applied
#3 lore raw
In reply to Subash Abhinov Kasiviswanathan

From: Subash Abhinov Kasiviswanathan <[email protected]>
Date: Tue, 31 Mar 2020 16:43:48 -0600

Quoted 8 lines

This allows the changelink operation to succeed if the mux_id was specified as an argument. Note that the mux_id must match the existing mux_id of the rmnet device or should be an unused mux_id.

Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")

Applied, thanks.