net: qualcomm: rmnet: Allow configuration updates to existing devices
Subsystems (3)
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.
--- .../ethernet/qualcomm/rmnet/rmnet_config.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +13 -8
@@ -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
Quoted 8 lines · Subash Abhinov Kasiviswanathan
This allows the changelink operation to succeed if the
mux_idwas specified as an argument. Note that themux_idmust match the existingmux_idof the rmnet device or should be an unusedmux_id.Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")Reported-by Alex Elder <[email protected]>Signed-off-by Sean Tranchetti <[email protected]>Signed-off-by Subash Abhinov Kasiviswanathan <[email protected]>
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
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
-4ep =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 ]) {
Quoted 33 lines · Alex Elder
Quoted 8 lines · Subash Abhinov Kasiviswanathan
This allows the changelink operation to succeed if the
mux_idwas specified as an argument. Note that themux_idmust match the existingmux_idof the rmnet device or should be an unusedmux_id.Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")Reported-by Alex Elder <[email protected]>Signed-off-by Sean Tranchetti <[email protected]>Signed-off-by Subash Abhinov Kasiviswanathan <[email protected]>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.
Tested-by Alex Elder <[email protected]>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@@ -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
-4if (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.
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_idwas specified as an argument. Note that themux_idmust match the existingmux_idof the rmnet device or should be an unusedmux_id.Fixes 1dc49e9d164c ("net: rmnet: do not allow to change mux id if mux id is duplicated")Reported-by Alex Elder <[email protected]>Signed-off-by Sean Tranchetti <[email protected]>Signed-off-by Subash Abhinov Kasiviswanathan <[email protected]>
Applied, thanks.