All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krystad <peter.krystad at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH 1/2] mptcp: Parse optional port field of ADD_ADDR
Date: Fri, 20 Mar 2020 10:51:50 -0700	[thread overview]
Message-ID: <20200320175151.4665-2-peter.krystad@linux.intel.com> (raw)
In-Reply-To: 20200320175151.4665-1-peter.krystad@linux.intel.com

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

Since we allow the option lengths that include the port
field we should correctly parse the field if present.

squashto: Add ADD_ADDR handling

Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h |  1 +
 net/mptcp/options.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 41e5a0e3622f..1225db308957 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -109,6 +109,7 @@ struct mptcp_options_received {
 #endif
 	};
 	u64	ahmac;
+	u16	port;
 };
 #endif
 
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 9b90bdc419ac..d9e0d82fd1b9 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -205,16 +205,27 @@ void mptcp_parse_option(const struct sk_buff *skb, const unsigned char *ptr,
 		}
 
 		mp_opt->add_addr = 1;
+		mp_opt->port = 0;
 		mp_opt->addr_id = *ptr++;
 		pr_debug("ADD_ADDR: id=%d", mp_opt->addr_id);
 		if (mp_opt->family == MPTCP_ADDR_IPVERSION_4) {
 			memcpy((u8 *)&mp_opt->addr.s_addr, (u8 *)ptr, 4);
 			ptr += 4;
+			if (opsize == TCPOLEN_MPTCP_ADD_ADDR_PORT ||
+			    opsize == TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT) {
+				mp_opt->port = get_unaligned_be16(ptr);
+				ptr += 2;
+			}
 		}
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 		else {
 			memcpy(mp_opt->addr6.s6_addr, (u8 *)ptr, 16);
 			ptr += 16;
+			if (opsize == TCPOLEN_MPTCP_ADD_ADDR6_PORT ||
+			    opsize == TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT) {
+				mp_opt->port = get_unaligned_be16(ptr);
+				ptr += 2;
+			}
 		}
 #endif
 		if (!mp_opt->echo) {
-- 
2.17.2

                 reply	other threads:[~2020-03-20 17:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200320175151.4665-2-peter.krystad@linux.intel.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.