All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH net-next 01/11] mptcp: unify ADD_ADDR and echo suboptions writing
Date: Wed, 09 Dec 2020 15:51:18 -0800	[thread overview]
Message-ID: <20201209235128.175473-2-mathew.j.martineau@linux.intel.com> (raw)
In-Reply-To: 20201209235128.175473-1-mathew.j.martineau@linux.intel.com

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

From: Geliang Tang <geliangtang(a)gmail.com>

There are two differences between ADD_ADDR suboption and ADD_ADDR echo
suboption: The length of the former is 8 octets longer than the length
of the latter. The former's echo-flag is 0, and latter's echo-flag is 1.

This patch added two local variables, len and echo, to unify ADD_ADDR
and ADD_ADDR echo suboptions writing.

Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
Signed-off-by: Mat Martineau <mathew.j.martineau(a)linux.intel.com>
---
 net/mptcp/options.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index b63f26bf348f..a061b2106cfe 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1076,15 +1076,16 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
 mp_capable_done:
 	if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) {
-		if (opts->ahmac)
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR, 0,
-					      opts->addr_id);
-		else
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR_BASE,
-					      MPTCP_ADDR_ECHO,
-					      opts->addr_id);
+		u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE;
+		u8 echo = MPTCP_ADDR_ECHO;
+
+		if (opts->ahmac) {
+			len += sizeof(opts->ahmac);
+			echo = 0;
+		}
+
+		*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
+				      len, echo, opts->addr_id);
 		memcpy((u8 *)ptr, (u8 *)&opts->addr.s_addr, 4);
 		ptr += 1;
 		if (opts->ahmac) {
@@ -1095,15 +1096,15 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 	if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) {
-		if (opts->ahmac)
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR6, 0,
-					      opts->addr_id);
-		else
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR6_BASE,
-					      MPTCP_ADDR_ECHO,
-					      opts->addr_id);
+		u8 len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
+		u8 echo = MPTCP_ADDR_ECHO;
+
+		if (opts->ahmac) {
+			len += sizeof(opts->ahmac);
+			echo = 0;
+		}
+		*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
+				      len, echo, opts->addr_id);
 		memcpy((u8 *)ptr, opts->addr6.s6_addr, 16);
 		ptr += 4;
 		if (opts->ahmac) {
-- 
2.29.2

WARNING: multiple messages have this Message-ID (diff)
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: netdev@vger.kernel.org
Cc: Geliang Tang <geliangtang@gmail.com>,
	davem@davemloft.net, kuba@kernel.org, mptcp@lists.01.org,
	Mat Martineau <mathew.j.martineau@linux.intel.com>
Subject: [PATCH net-next 01/11] mptcp: unify ADD_ADDR and echo suboptions writing
Date: Wed,  9 Dec 2020 15:51:18 -0800	[thread overview]
Message-ID: <20201209235128.175473-2-mathew.j.martineau@linux.intel.com> (raw)
In-Reply-To: <20201209235128.175473-1-mathew.j.martineau@linux.intel.com>

From: Geliang Tang <geliangtang@gmail.com>

There are two differences between ADD_ADDR suboption and ADD_ADDR echo
suboption: The length of the former is 8 octets longer than the length
of the latter. The former's echo-flag is 0, and latter's echo-flag is 1.

This patch added two local variables, len and echo, to unify ADD_ADDR
and ADD_ADDR echo suboptions writing.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
 net/mptcp/options.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index b63f26bf348f..a061b2106cfe 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1076,15 +1076,16 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
 mp_capable_done:
 	if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) {
-		if (opts->ahmac)
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR, 0,
-					      opts->addr_id);
-		else
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR_BASE,
-					      MPTCP_ADDR_ECHO,
-					      opts->addr_id);
+		u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE;
+		u8 echo = MPTCP_ADDR_ECHO;
+
+		if (opts->ahmac) {
+			len += sizeof(opts->ahmac);
+			echo = 0;
+		}
+
+		*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
+				      len, echo, opts->addr_id);
 		memcpy((u8 *)ptr, (u8 *)&opts->addr.s_addr, 4);
 		ptr += 1;
 		if (opts->ahmac) {
@@ -1095,15 +1096,15 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 	if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) {
-		if (opts->ahmac)
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR6, 0,
-					      opts->addr_id);
-		else
-			*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
-					      TCPOLEN_MPTCP_ADD_ADDR6_BASE,
-					      MPTCP_ADDR_ECHO,
-					      opts->addr_id);
+		u8 len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
+		u8 echo = MPTCP_ADDR_ECHO;
+
+		if (opts->ahmac) {
+			len += sizeof(opts->ahmac);
+			echo = 0;
+		}
+		*ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
+				      len, echo, opts->addr_id);
 		memcpy((u8 *)ptr, opts->addr6.s6_addr, 16);
 		ptr += 4;
 		if (opts->ahmac) {
-- 
2.29.2


             reply	other threads:[~2020-12-09 23:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 23:51 Mat Martineau [this message]
2020-12-09 23:51 ` [PATCH net-next 01/11] mptcp: unify ADD_ADDR and echo suboptions writing Mat Martineau
  -- strict thread matches above, loose matches on Subject: below --
2020-12-10  3:04 [MPTCP] Re: [PATCH net-next 00/11] mptcp: Add port parameter to ADD_ADDR option David Miller
2020-12-10  3:04 ` David Miller
2020-12-09 23:51 [MPTCP] [PATCH net-next 11/11] mptcp: use the variable sk instead of open-coding Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 10/11] mptcp: rename add_addr_signal and mptcp_add_addr_status Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 09/11] mptcp: drop rm_addr_signal flag Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 08/11] mptcp: print out port and ahmac when receiving ADD_ADDR Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 07/11] mptcp: add port parameter for mptcp_pm_announce_addr Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 06/11] mptcp: send out dedicated packet for ADD_ADDR using port Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 05/11] mptcp: add the outgoing ADD_ADDR port support Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 04/11] mptcp: use adding up size to get ADD_ADDR length Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 03/11] mptcp: add port support for ADD_ADDR suboption writing Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 02/11] mptcp: unify ADD_ADDR and ADD_ADDR6 suboptions writing Mat Martineau
2020-12-09 23:51 ` Mat Martineau
2020-12-09 23:51 [MPTCP] [PATCH net-next 00/11] mptcp: Add port parameter to ADD_ADDR option Mat Martineau
2020-12-09 23:51 ` Mat Martineau

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=20201209235128.175473-2-mathew.j.martineau@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.