diff mbox series

[net-next,v3] Squash-to: "mptcp: add netlink-based PM"

Message ID b733f047245027ea51dfc99e02d56fe8ff6aa13c.1585223512.git.pabeni@redhat.com
State Accepted, archived
Delegated to: Matthieu Baerts
Headers show
Series [net-next,v3] Squash-to: "mptcp: add netlink-based PM" | expand

Commit Message

Paolo Abeni March 26, 2020, 11:53 a.m. UTC
Let user space set a single limit at once and drop bogus
NL extack error message.

v2 -> v3:
 - better error message (Mat)
 - add spinlock
 - relax admin constraint on 'getters'

v1 -> v2:
 - do not include dumb dbg messages

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/pm_netlink.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

Comments

Matthieu Baerts March 26, 2020, 1:53 p.m. UTC | #1
Hi Paolo,

On 26/03/2020 12:53, Paolo Abeni wrote:
> Let user space set a single limit at once and drop bogus
> NL extack error message.
> 
> v2 -> v3:
>   - better error message (Mat)
>   - add spinlock
>   - relax admin constraint on 'getters'
> 
> v1 -> v2:
>   - do not include dumb dbg messages

Thank you for the v3, it looks good to  me!

Cheers,
Matt
Matthieu Baerts March 26, 2020, 2:45 p.m. UTC | #2
Hi Paolo,

On 26/03/2020 14:53, Matthieu Baerts wrote:
> Hi Paolo,
> 
> On 26/03/2020 12:53, Paolo Abeni wrote:
>> Let user space set a single limit at once and drop bogus
>> NL extack error message.
>>
>> v2 -> v3:
>>   - better error message (Mat)
>>   - add spinlock
>>   - relax admin constraint on 'getters'
>>
>> v1 -> v2:
>>   - do not include dumb dbg messages
> 
> Thank you for the v3, it looks good to  me!
> 
> Cheers,
> Matt

- 621737cebef3: "squashed" in "mptcp: add netlink-based PM"
- 8e8969983c72..cda56df42342: result

Tests + export are in progress.

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 743c3c58f826..a0ce7f324499 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -702,15 +702,12 @@  static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
 {
 	struct nlattr *attr = info->attrs[id];
 
-	if (!attr) {
-		GENL_SET_ERR_MSG(info, "missing announce accept limit");
-		return -EINVAL;
-	}
+	if (!attr)
+		return 0;
 
 	*limit = nla_get_u32(attr);
 	if (*limit > MPTCP_PM_ADDR_MAX) {
-		GENL_SET_ERR_MSG(info,
-				 "announce accept limit greater than maximum");
+		GENL_SET_ERR_MSG(info, "limit greater than maximum");
 		return -EINVAL;
 	}
 	return 0;
@@ -723,17 +720,23 @@  mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info)
 	unsigned int rcv_addrs, subflows;
 	int ret;
 
+	spin_lock_bh(&pernet->lock);
+	rcv_addrs = pernet->add_addr_accept_max;
 	ret = parse_limit(info, MPTCP_PM_ATTR_RCV_ADD_ADDRS, &rcv_addrs);
 	if (ret)
-		return ret;
+		goto unlock;
 
+	subflows = pernet->subflows_max;
 	ret = parse_limit(info, MPTCP_PM_ATTR_SUBFLOWS, &subflows);
 	if (ret)
-		return ret;
+		goto unlock;
 
 	WRITE_ONCE(pernet->add_addr_accept_max, rcv_addrs);
 	WRITE_ONCE(pernet->subflows_max, subflows);
-	return 0;
+
+unlock:
+	spin_unlock_bh(&pernet->lock);
+	return ret;
 }
 
 static int
@@ -789,7 +792,6 @@  static struct genl_ops mptcp_pm_ops[] = {
 		.cmd    = MPTCP_PM_CMD_GET_ADDR,
 		.doit   = mptcp_nl_cmd_get_addr,
 		.dumpit   = mptcp_nl_cmd_dump_addrs,
-		.flags  = GENL_ADMIN_PERM,
 	},
 	{
 		.cmd    = MPTCP_PM_CMD_SET_LIMITS,
@@ -799,7 +801,6 @@  static struct genl_ops mptcp_pm_ops[] = {
 	{
 		.cmd    = MPTCP_PM_CMD_GET_LIMITS,
 		.doit   = mptcp_nl_cmd_get_limits,
-		.flags  = GENL_ADMIN_PERM,
 	},
 };