]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mptcp: clean-up MPJ option writing
authorPaolo Abeni <pabeni@redhat.com>
Fri, 7 Jan 2022 00:20:21 +0000 (16:20 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 7 Jan 2022 11:27:07 +0000 (11:27 +0000)
Check for all MPJ variant at once, this reduces the number
of conditionals traversed on average and will simplify the
next patch.

No functional change intended.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/options.c

index 46d35a235f35b02b0ca029a99a35c040900ba3ca..38e34a1fb2dd0a2a4fe6385942dbab32a59ff832 100644 (file)
@@ -1385,27 +1385,29 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 
                /* MPC is additionally mutually exclusive with MP_PRIO */
                goto mp_capable_done;
-       } else if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
-               *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
-                                     TCPOLEN_MPTCP_MPJ_SYN,
-                                     opts->backup, opts->join_id);
-               put_unaligned_be32(opts->token, ptr);
-               ptr += 1;
-               put_unaligned_be32(opts->nonce, ptr);
-               ptr += 1;
-       } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) {
-               *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
-                                     TCPOLEN_MPTCP_MPJ_SYNACK,
-                                     opts->backup, opts->join_id);
-               put_unaligned_be64(opts->thmac, ptr);
-               ptr += 2;
-               put_unaligned_be32(opts->nonce, ptr);
-               ptr += 1;
-       } else if (OPTION_MPTCP_MPJ_ACK & opts->suboptions) {
-               *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
-                                     TCPOLEN_MPTCP_MPJ_ACK, 0, 0);
-               memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN);
-               ptr += 5;
+       } else if (OPTIONS_MPTCP_MPJ & opts->suboptions) {
+               if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
+                       *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
+                                             TCPOLEN_MPTCP_MPJ_SYN,
+                                             opts->backup, opts->join_id);
+                       put_unaligned_be32(opts->token, ptr);
+                       ptr += 1;
+                       put_unaligned_be32(opts->nonce, ptr);
+                       ptr += 1;
+               } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) {
+                       *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
+                                             TCPOLEN_MPTCP_MPJ_SYNACK,
+                                             opts->backup, opts->join_id);
+                       put_unaligned_be64(opts->thmac, ptr);
+                       ptr += 2;
+                       put_unaligned_be32(opts->nonce, ptr);
+                       ptr += 1;
+               } else {
+                       *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
+                                             TCPOLEN_MPTCP_MPJ_ACK, 0, 0);
+                       memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN);
+                       ptr += 5;
+               }
        } else if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) {
                u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE;
                u8 echo = MPTCP_ADDR_ECHO;