Skip to contentSkip to conversation

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

PATCH In review Jianguo Wu 2 participants 2 messages Apr 23, 2021

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 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 1729cf186d8a ("mptcp: create the listening socket for new port")
---
 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
#1 lore raw

Hi Jianguo,

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

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 1729cf186d8a ("mptcp: create the listening socket for new port")

Fixes this one:

a77e9179c7651 ("mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink")

Quoted 29 lines
---
 net/mptcp/pm_netlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/mptcp/pm_netlink.c +7 -2
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;
 }
--

1.8.3.1