Correctly handle port field in ADD_ADDR option
Subsystems (3)
Peter Krystad
cover Correctly handle port field in ADD_ADDR option
Existing code allows ADD_ADDR option lengths that include the port field, so we should correctly parse options with those lengths.
Peter Krystad (2):
mptcp: Parse optional port field of ADD_ADDR
mptcp: Include ADD_ADDR port value for path manager
include/linux/tcp.h | 1 + net/mptcp/options.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
Signature · 1 line
2.17.2
Peter Krystad
PATCH 1/2 mptcp: Parse optional port field of ADD_ADDR
Since we allow the option lengths that include the port field we should correctly parse the field if present.
squashto: Add ADD_ADDR handling
--- include/linux/tcp.h | 1 + net/mptcp/options.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
include/linux/tcp.h +1 -0
@@ -109,6 +109,7 @@ struct mptcp_options_received { #endif };u64 ahmac; +u16 port; };#endif
net/mptcp/options.c +11 -0
@@ -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) {
Signature · 1 line
2.17.2
Peter Krystad
PATCH 2/2 mptcp: Include ADD_ADDR port value for path manager
In reply to Peter KrystadInclude the port value in the addr info passed tomptcp_pm_add_addr_received().
squashto: Add path manager interface
--- net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -652,7 +652,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,if (mp_opt->add_addr &&add_addr_hmac_valid (msk, mp_opt)) {struct mptcp_addr_info addr; - addr.port =0 ; + addr.port =htons (mp_opt->port); addr.id = mp_opt->addr_id;if (mp_opt->family ==MPTCP_ADDR_IPVERSION_4 ) { addr.family =AF_INET ;
Signature · 1 line
2.17.2
Mat Martineau
Quoted 4 lines · Peter Krystad
Existing code allows
ADD_ADDRoption lengths that include the port field, so we should correctly parse options with those lengths.
Quoted 8 lines
Peter Krystad (2):
mptcp: Parse optional port field ofADD_ADDR
mptcp: IncludeADD_ADDRport value for path manager
include/linux/tcp.h| 1 +net/mptcp/options.c| 11 +++++++++++2 files changed, 12 insertions(+)
Both patches look good to me - and they apply cleanly to the current export branch.
--
Mat Martineau
Intel
Matthieu Baerts
Hi Peter, Mat,
Quoted 11 lines · Mat Martineau
Quoted 8 lines · Peter Krystad
Existing code allows
ADD_ADDRoption lengths that include the port field, so we should correctly parse options with those lengths.Peter Krystad (2):
mptcp: Parse optional port field ofADD_ADDR
mptcp: IncludeADD_ADDRport value for path manager
Quoted 7 lines
Quoted 4 lines
include/linux/tcp.h| 1 +net/mptcp/options.c| 11 +++++++++++2 files changed, 12 insertions(+)Both patches look good to me - and they apply cleanly to the current export branch.
Thank you for the patches and the reviews!
- 6b71141d6040: "squashed" patch 1/2 in "mptcp: Add ADD_ADDR handling"
- 49bd5a76f678..212bed34defa: result
- 3dc91a03e4e8: "squashed" patch 2/2 in "mptcp: Add path manager interface"
- 212bed34defa..19b9d67eec8a: result
Tests + export are in progress!
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium