All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [MPTCP][PATCH mptcp-next] Squash to "mptcp: add port number announced check"
@ 2020-11-25  5:28 Geliang Tang
  0 siblings, 0 replies; only message in thread
From: Geliang Tang @ 2020-11-25  5:28 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1540 bytes --]

Use a more strict check in mptcp_pm_sport_in_anno_list.

Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 09e96007a56a..da8d2c77a02d 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -111,6 +111,19 @@ static void remote_address(const struct sock_common *skc,
 #endif
 }
 
+static void source_address(const struct sock *sk,
+			   struct mptcp_addr_info *addr)
+{
+	addr->family = ((struct sock_common *)sk)->skc_family;
+	addr->port = inet_sk(sk)->inet_sport;
+	if (addr->family == AF_INET)
+		addr->addr.s_addr = inet_sk(sk)->inet_saddr;
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+	else if (addr->family == AF_INET6)
+		addr->addr6 = inet_sk(sk)->pinet6->saddr;
+#endif
+}
+
 static bool lookup_subflow_by_saddr(const struct list_head *list,
 				    struct mptcp_addr_info *saddr)
 {
@@ -205,11 +218,14 @@ lookup_anno_list_by_saddr(struct mptcp_sock *msk,
 bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk)
 {
 	struct mptcp_pm_add_entry *entry;
+	struct mptcp_addr_info saddr;
 	bool ret = false;
 
+	source_address(sk, &saddr);
+
 	spin_lock_bh(&msk->pm.lock);
 	list_for_each_entry(entry, &msk->pm.anno_list, list) {
-		if (entry->addr.port == inet_sk(sk)->inet_sport) {
+		if (addresses_equal(&entry->addr, &saddr, true)) {
 			ret = true;
 			goto out;
 		}
-- 
2.26.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-25  5:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25  5:28 [MPTCP] [MPTCP][PATCH mptcp-next] Squash to "mptcp: add port number announced check" Geliang Tang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.