summaryrefslogtreecommitdiff
path: root/net/mptcp/options.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2020-12-10 02:51:20 +0300
committerDavid S. Miller <davem@davemloft.net>2020-12-10 06:02:15 +0300
commit22fb85ffaefb80a22c815008a500273b3f61bba3 (patch)
tree77ba46a7f23fba32cd5de9bc990591f1ccdb3dcc /net/mptcp/options.c
parente1ef6832224aa62b36ba98a1a7c183e41962590c (diff)
downloadlinux-22fb85ffaefb80a22c815008a500273b3f61bba3.tar.xz
mptcp: add port support for ADD_ADDR suboption writing
In rfc8684, the length of ADD_ADDR suboption with IPv4 address and port is 18 octets, but mptcp_write_options is 32-bit aligned, so we need to pad it to 20 octets. All the other port related option lengths need to be added up 2 octets similarly. This patch added a new field 'port' in mptcp_out_options. When this field is set with a port number, we need to add up 4 octets for the ADD_ADDR suboption, and put the port number into the suboption. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mptcp/options.c')
-rw-r--r--net/mptcp/options.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index ab86f897c08b..f841128a86c6 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1083,6 +1083,9 @@ mp_capable_done:
len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
#endif
+ if (opts->port)
+ len += TCPOLEN_MPTCP_PORT_LEN;
+
if (opts->ahmac) {
len += sizeof(opts->ahmac);
echo = 0;
@@ -1100,9 +1103,30 @@ mp_capable_done:
ptr += 4;
}
#endif
- if (opts->ahmac) {
- put_unaligned_be64(opts->ahmac, ptr);
- ptr += 2;
+
+ if (!opts->port) {
+ if (opts->ahmac) {
+ put_unaligned_be64(opts->ahmac, ptr);
+ ptr += 2;
+ }
+ } else {
+ if (opts->ahmac) {
+ u8 *bptr = (u8 *)ptr;
+
+ put_unaligned_be16(opts->port, bptr);
+ bptr += 2;
+ put_unaligned_be64(opts->ahmac, bptr);
+ bptr += 8;
+ put_unaligned_be16(TCPOPT_NOP << 8 |
+ TCPOPT_NOP, bptr);
+
+ ptr += 3;
+ } else {
+ put_unaligned_be32(opts->port << 16 |
+ TCPOPT_NOP << 8 |
+ TCPOPT_NOP, ptr);
+ ptr += 1;
+ }
}
}