From: Mat Martineau <mathew.j.martineau at linux.intel.com> To: mptcp at lists.01.org Subject: [MPTCP] [PATCH net-next 02/11] mptcp: unify ADD_ADDR and ADD_ADDR6 suboptions writing Date: Wed, 09 Dec 2020 15:51:19 -0800 [thread overview] Message-ID: <20201209235128.175473-3-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: 2451 bytes --] From: Geliang Tang <geliangtang(a)gmail.com> The length of ADD_ADDR6 is 12 octets longer than ADD_ADDR. That's the only difference between them. This patch dropped the duplicate code between ADD_ADDR and ADD_ADDR6 suboptions writing, and unify them into one. 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, 17 insertions(+), 20 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index a061b2106cfe..639d47e6e2d0 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1075,10 +1075,19 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, } mp_capable_done: - if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { + if ((OPTION_MPTCP_ADD_ADDR +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + | OPTION_MPTCP_ADD_ADDR6 +#endif + ) & opts->suboptions) { u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE; u8 echo = MPTCP_ADDR_ECHO; +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) + len = TCPOLEN_MPTCP_ADD_ADDR6_BASE; +#endif + if (opts->ahmac) { len += sizeof(opts->ahmac); echo = 0; @@ -1086,33 +1095,21 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, *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) { - put_unaligned_be64(opts->ahmac, ptr); - ptr += 2; + if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { + memcpy((u8 *)ptr, (u8 *)&opts->addr.s_addr, 4); + ptr += 1; } - } - #if IS_ENABLED(CONFIG_MPTCP_IPV6) - if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) { - u8 len = TCPOLEN_MPTCP_ADD_ADDR6_BASE; - u8 echo = MPTCP_ADDR_ECHO; - - if (opts->ahmac) { - len += sizeof(opts->ahmac); - echo = 0; + else if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) { + memcpy((u8 *)ptr, opts->addr6.s6_addr, 16); + ptr += 4; } - *ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR, - len, echo, opts->addr_id); - memcpy((u8 *)ptr, opts->addr6.s6_addr, 16); - ptr += 4; +#endif if (opts->ahmac) { put_unaligned_be64(opts->ahmac, ptr); ptr += 2; } } -#endif if (OPTION_MPTCP_RM_ADDR & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_RM_ADDR, -- 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 02/11] mptcp: unify ADD_ADDR and ADD_ADDR6 suboptions writing Date: Wed, 9 Dec 2020 15:51:19 -0800 [thread overview] Message-ID: <20201209235128.175473-3-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> The length of ADD_ADDR6 is 12 octets longer than ADD_ADDR. That's the only difference between them. This patch dropped the duplicate code between ADD_ADDR and ADD_ADDR6 suboptions writing, and unify them into one. 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, 17 insertions(+), 20 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index a061b2106cfe..639d47e6e2d0 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1075,10 +1075,19 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, } mp_capable_done: - if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { + if ((OPTION_MPTCP_ADD_ADDR +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + | OPTION_MPTCP_ADD_ADDR6 +#endif + ) & opts->suboptions) { u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE; u8 echo = MPTCP_ADDR_ECHO; +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) + len = TCPOLEN_MPTCP_ADD_ADDR6_BASE; +#endif + if (opts->ahmac) { len += sizeof(opts->ahmac); echo = 0; @@ -1086,33 +1095,21 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, *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) { - put_unaligned_be64(opts->ahmac, ptr); - ptr += 2; + if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { + memcpy((u8 *)ptr, (u8 *)&opts->addr.s_addr, 4); + ptr += 1; } - } - #if IS_ENABLED(CONFIG_MPTCP_IPV6) - if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) { - u8 len = TCPOLEN_MPTCP_ADD_ADDR6_BASE; - u8 echo = MPTCP_ADDR_ECHO; - - if (opts->ahmac) { - len += sizeof(opts->ahmac); - echo = 0; + else if (OPTION_MPTCP_ADD_ADDR6 & opts->suboptions) { + memcpy((u8 *)ptr, opts->addr6.s6_addr, 16); + ptr += 4; } - *ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR, - len, echo, opts->addr_id); - memcpy((u8 *)ptr, opts->addr6.s6_addr, 16); - ptr += 4; +#endif if (opts->ahmac) { put_unaligned_be64(opts->ahmac, ptr); ptr += 2; } } -#endif if (OPTION_MPTCP_RM_ADDR & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_RM_ADDR, -- 2.29.2
next 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 02/11] mptcp: unify ADD_ADDR and ADD_ADDR6 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 01/11] mptcp: unify ADD_ADDR and echo 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-3-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: linkBe 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.