Skip to contentSkip to conversation

mptcp: make sure flag signal is set when add addr with port

PATCH In review Jianguo Wu 3 participants 3 messages Apr 23, 2021 – Apr 24, 2021

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH v2 1/1 mptcp: make sure flag signal is set when add addr with port

From: Jianguo Wu <[email protected]>

When add address with port, it is mean to create a listening socket, and send an ADD_ADDR to remote, so it must have flag signal set, add this check in mptcp_pm_parse_addr().

Fixes a77e9179c7651 ("mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink")
---
 net/mptcp/pm_netlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/mptcp/pm_netlink.c +7 -1
index becc32b..90bba32 100644
@@ -971,8 +971,14 @@ static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
 	if (tb[MPTCP_PM_ADDR_ATTR_FLAGS])
 		entry->flags = nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]);
 
-	if (tb[MPTCP_PM_ADDR_ATTR_PORT])
+	if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
+		if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
+			NL_SET_ERR_MSG_ATTR(info->extack, attr,
+					    "flags must have signal when using port");
+			return -EINVAL;
+		}
 		entry->addr.port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
+	}
 
 	return 0;
 }
Signature · 1 line
1.8.3.1
Acked-by on v2 1/1
#1 lore raw

Hi Jianguo,

Quoted 23 lines · Jianguo Wu <[email protected]> 于2021年4月23日周五 下午6:26写道:

From: Jianguo Wu <[email protected]>

When add address with port, it is mean to create a listening socket, and send an ADD_ADDR to remote, so it must have flag signal set, add this check in mptcp_pm_parse_addr().

Fixes a77e9179c7651 ("mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink")
---
 net/mptcp/pm_netlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/mptcp/pm_netlink.c +1 -1
index becc32b..90bba32 100644
@@ -971,8 +971,14 @@ static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
        if (tb[MPTCP_PM_ADDR_ATTR_FLAGS])
                entry->flags = nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]);
 
-       if (tb[MPTCP_PM_ADDR_ATTR_PORT])
+       if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {

net/mptcp/pm_netlink.c static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info, · line 984

Quoted 10 lines
net/mptcp/pm_netlink.c +6 -0
+               if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
+                       NL_SET_ERR_MSG_ATTR(info->extack, attr,
+                                           "flags must have signal when using port");
+                       return -EINVAL;
+               }
                entry->addr.port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
+       }
 
        return 0;
 }

LGTM.

-Geliang

Quoted 4 lines

--
1.8.3.1

#2 lore raw
In reply to Jianguo Wu

Hi Jianguo, Geliang,

Quoted 5 lines · Jianguo Wu

From: Jianguo Wu <[email protected]>

When add address with port, it is mean to create a listening socket, and send an ADD_ADDR to remote, so it must have flag signal set, add this check in mptcp_pm_parse_addr().

Thank you for your patch and the review!

This is now in our tree:

- eb86a8c1aeed: mptcp: make sure flag signal is set when add addr with port
- Results: 3692d2b92d9f..5c90fe877090

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210424T085242
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210424T085242

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net