Optimize mptcp_received_options
Subsystems (3)
Peter Krystad
cover Optimize mptcp_received_options
This reduces the size from 104 to 32, at the cost of some loss of clarity. I deliberately did not change the names of any fields, reducing the impact on code (and the squasher).
This also seems like a good opportunity to remove all of the pr_debug() statements from options processing which occupy so much of the log.
Peter Krystad (1):
mptcp: Optimize struct mptcp_received_options.
include/linux/tcp.h | 97 ++++++++++++++++++++++++---------------- net/mptcp/options.c | 102 ++++++++++++++++++++++++------------------- net/mptcp/pm.c | 2 +- net/mptcp/protocol.h | 2 +- 4 files changed, 118 insertions(+), 85 deletions(-)
Signature · 1 line
2.17.2
Peter Krystad
RFC 1/1 mptcp: Optimize struct mptcp_received_options.
Re-organize struct mptcp_received_options to be more efficient with space, reducing size impact to struct tcp_sock.
Remove unneeded flags fields, make version a bit field. Use unions to reflect that available option space is limited to 28 bytes, not all options may be received at once. Options that may be received at the same time are MP_CAPABLE and DSS ack-only or DSS ack-only and IPv4 ADD_ADDR.
--- include/linux/tcp.h | 97 ++++++++++++++++++++++++---------------- net/mptcp/options.c | 102 ++++++++++++++++++++++++------------------- net/mptcp/pm.c | 2 +- net/mptcp/protocol.h | 2 +- 4 files changed, 118 insertions(+), 85 deletions(-)
include/linux/tcp.h +59 -38
@@ -78,6 +78,62 @@ struct tcp_sack_block {#define TCP_SACK_SEEN (1 << 0)/*1 = peer is SACK capable, */ #define TCP_DSACK_SEEN (1 << 2)/*1 = DSACK was received from peer*/ +#if IS_ENABLED (CONFIG_MPTCP ) +struct mptcp_options_received { +union { +struct { +u32 data_ack32; +u32 data_seq32; +union { +struct { +u64 sndr_key; +u64 rcvr_key; + }; +struct { +struct in_addr addr; +u8 addr_id; + }; + }; + }; +struct { +u64 data_ack; +u64 data_seq; + }; +union { +struct { +u64 thmac; +u32 token; +u32 nonce; +u8 join_id; + }; +u8 hmac[20 ]; + }; +#if IS_ENABLED (CONFIG_IPV6 ) +struct in6_addr addr6; +#endif + }; +u32 subflow_seq; +union { +u16 data_len; +u8 addr6_id; + }; +u8 mp_capable :1 , + mp_join :1 , + dss :1 , + add_addr :1 , + add_addr6 :1 , + rm_addr :1 , + backup :1 , + version :1 ; +u8 use_map :1 , + dsn64 :1 , + use_ack :1 , + ack64 :1 , + data_fin :1 , + __unused :3 ; +}; +#endif +struct tcp_options_received {/* PAWS/RTTM data */ int ts_recent_stamp;/* Time we stored ts_recent (for aging) */
@@ -96,42 +152,7 @@ struct tcp_options_received {u16 user_mss;/* mss requested by user in ioctl */ u16 mss_clamp;/* Maximal mss, negotiated at connection setup */ #if IS_ENABLED (CONFIG_MPTCP ) -struct mptcp_options_received { -u64 sndr_key; -u64 rcvr_key; -u64 data_ack; -u64 data_seq; -u32 subflow_seq; -u16 data_len; -u8 mp_capable :1 , - mp_join :1 , - dss :1 , - backup :1 , - version :4 ; -u8 flags; -u8 join_id; -u32 token; -u32 nonce; -u64 thmac; -u8 hmac[20 ]; -u8 dss_flags; -u8 use_map:1 , - dsn64:1 , - data_fin:1 , - use_ack:1 , - ack64:1 , - __unused:3 ; -u8 add_addr :1 , - rm_addr :1 , - family :4 ; -u8 addr_id; -union { -struct in_addr addr; -#if IS_ENABLED (CONFIG_IPV6 ) -struct in6_addr addr6; -#endif - }; - } mptcp; +struct mptcp_options_received mptcp;#endif };
@@ -144,8 +165,8 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt)#endif #if IS_ENABLED (CONFIG_MPTCP ) rx_opt->mptcp.mp_capable = rx_opt->mptcp.mp_join =0 ; - rx_opt->mptcp.add_addr = rx_opt->mptcp.rm_addr =0 ; - rx_opt->mptcp.dss =0 ; + rx_opt->mptcp.add_addr = rx_opt->mptcp.add_addr6 =0 ; + rx_opt->mptcp.rm_addr = rx_opt->mptcp.dss =0 ;#endif }
net/mptcp/options.c +57 -45
212 lines not on this page · raw message
net/mptcp/pm.c +1 -1
@@ -259,7 +259,7 @@ int mptcp_pm_get_local_id(struct request_sock *req, struct sock *sk,/* @@ check if address actually matches... */ -pr_debug ("msk=%p, addr_id=%d" , msk, msk->pm.local_id); +pr_debug ("msk=%p, local_id=%d" , msk, msk->pm.local_id); subflow_req->local_id = msk->pm.local_id;return 0 ;
net/mptcp/protocol.h +1 -1
@@ -208,7 +208,7 @@ struct mptcp_subflow_context { u32 request_mptcp : 1, /* send MP_CAPABLE */ request_join : 1, /* send MP_JOIN */ request_bkup : 1, - request_version : 4, + request_version : 1, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */ fourth_ack : 1, /* send initial DSS */
Signature · 1 line
2.17.2
Matthieu Baerts
[MPTCP] Re: [RFC 1/1] mptcp: Optimize struct mptcp_received_options.
Hi Peter,
Quoted 8 lines · Peter Krystad
Re-organize struct
mptcp_received_optionsto be more efficient with space, reducing size impact to structtcp_sock.Remove unneeded flags fields, make version a bit field. Use unions to reflect that available option space is limited to 28 bytes, not all options may be received at once. Options that may be received at the same time are
MP_CAPABLEand DSS ack-only or DSS ack-only and IPv4ADD_ADDR.
Thank you for the patch!
I was looking at applying it but I have a few comments here below and in the source code.
I see that the two recent patches you sent are part of this RFC one. I guess the best is to these patches first while they are still "fresh", should be easier to apply. Then a rebase/split will be needed but from a smaller patch
Because we decided to send patches in one week, I will not rush to apply the rest. I will then wait for your reply and possible other reviews to do anything. Of course, do not hesitate to continue the rebase and split :-D (but I can also help next week.)
(please see other questions below)
Quoted 37 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>--- include/linux/tcp.h | 97 ++++++++++++++++++++++++---------------- net/mptcp/options.c | 102 ++++++++++++++++++++++++------------------- net/mptcp/pm.c | 2 +- net/mptcp/protocol.h | 2 +- 4 files changed, 118 insertions(+), 85 deletions(-)include/linux/tcp.h +21
-0@@ -78,6 +78,62 @@ struct tcp_sack_block {#define TCP_SACK_SEEN (1 << 0)/*1 = peer is SACK capable, */ #define TCP_DSACK_SEEN (1 << 2)/*1 = DSACK was received from peer*/ +#if IS_ENABLED(CONFIG_MPTCP) +struct mptcp_options_received { + union { + struct { + u32 data_ack32; + u32 data_seq32; + union { + struct { + u64 sndr_key; + u64 rcvr_key; + }; + struct { + struct in_addr addr; + u8 addr_id; + }; + }; + }; + struct { + u64 data_ack; + u64 data_seq; + };
include/linux/tcp.h struct tcp_sack_block { · line 111
Quoted 10 lines
include/linux/tcp.h +10
-0+union { +struct { +u64 thmac; +u32 token; +u32 nonce; +u8 join_id; + }; +u8 hmac[20 ]; + }; +#if IS_ENABLED (CONFIG_IPV6 )
Should we use the MPTCP one? I mean: CONFIG_MPTCP_IPV6
include/linux/tcp.h struct tcp_sack_block { · line 118
Quoted 7 lines
include/linux/tcp.h +7
-0+struct in6_addr addr6; +#endif + }; +u32 subflow_seq; +union { +u16 data_len; +u8 addr6_id;
Why these two? Why not addr6_id and addr_id?
Should we not add "#if IS_ENABLED(CONFIG_IPV6)" around "addr6_id" to save 8 bits if we never use it in the code?
Quoted 7 lines
include/linux/tcp.h +7
-0+ }; + u8 mp_capable : 1, + mp_join : 1, + dss : 1, + add_addr : 1, + add_addr6 : 1, + rm_addr : 1,
include/linux/tcp.h struct tcp_sack_block { · line 135
Quoted 10 lines
include/linux/tcp.h +10
-0+ backup :1 , + version : 1; + u8 use_map : 1, + dsn64 : 1, + use_ack : 1, + ack64 : 1, + data_fin : 1, + __unused : 3; +}; +#endif
Should we not move this structure to mptcp.h file? Or better there because it directly impact TCP header size?
(or maybe not possible to include mptcp.h?)
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
Peter Krystad
[MPTCP] Re: [RFC 1/1] mptcp: Optimize struct mptcp_received_options.
Quoted 14 lines · Matthieu Baerts
Hi Peter,
Quoted 8 lines · Peter Krystad
Re-organize struct
mptcp_received_optionsto be more efficient with space, reducing size impact to structtcp_sock.Remove unneeded flags fields, make version a bit field. Use unions to reflect that available option space is limited to 28 bytes, not all options may be received at once. Options that may be received at the same time are
MP_CAPABLEand DSS ack-only or DSS ack-only and IPv4ADD_ADDR.Thank you for the patch!
Quoted 7 lines
I was looking at applying it but I have a few comments here below and in the source code.
I see that the two recent patches you sent are part of this RFC one. I guess the best is to these patches first while they are still "fresh", should be easier to apply. Then a rebase/split will be needed but from a smaller patch.
Yes I split out the two recent patches, and plan to split the rest of the contents of this RFC too, with adjustments for v1. The next patches are not needed for part 1. You don't need to apply this RFC.
Quoted 49 lines
Because we decided to send patches in one week, I will not rush to apply the rest. I will then wait for your reply and possible other reviews to do anything. Of course, do not hesitate to continue the rebase and split :-D (but I can also help next week.)
(please see other questions below)
Quoted 41 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>--- include/linux/tcp.h | 97 ++++++++++++++++++++++++---------------- net/mptcp/options.c | 102 ++++++++++++++++++++++++------------------- net/mptcp/pm.c | 2 +- net/mptcp/protocol.h | 2 +- 4 files changed, 118 insertions(+), 85 deletions(-)include/linux/tcp.h +25
-0@@ -78,6 +78,62 @@ struct tcp_sack_block {#define TCP_SACK_SEEN (1 << 0)/*1 = peer is SACK capable, */ #define TCP_DSACK_SEEN (1 << 2)/*1 = DSACK was received from peer*/ +#if IS_ENABLED(CONFIG_MPTCP) +struct mptcp_options_received { + union { + struct { + u32 data_ack32; + u32 data_seq32; + union { + struct { + u64 sndr_key; + u64 rcvr_key; + }; + struct { + struct in_addr addr; + u8 addr_id; + }; + }; + }; + struct { + u64 data_ack; + u64 data_seq; + }; + union { + struct { + u64 thmac; + u32 token;
Quoted 8 lines
include/linux/tcp.h struct tcp_sack_block { · line 111
Quoted 6 lines
include/linux/tcp.h +6
-0+u32 nonce; +u8 join_id; + }; +u8 hmac[20 ]; + }; +#if IS_ENABLED (CONFIG_IPV6 )Should we use the MPTCP one? I mean:
CONFIG_MPTCP_IPV6
You're right, we should. It looks like I forgot there was an enclosing CONFIG_MPTCP.
Quoted 11 lines
include/linux/tcp.h struct tcp_sack_block { · line 118
Quoted 7 lines
include/linux/tcp.h +7
-0+struct in6_addr addr6; +#endif + }; +u32 subflow_seq; +union { +u16 data_len; +u8 addr6_id;Why these two? Why not
addr6_idandaddr_id?
Should we not add "#ifIS_ENABLED(CONFIG_IPV6)" around "addr6_id" to save 8 bits if we never use it in the code?
For completeness addr6_id should be #if, but it doesn't save any space because data_len will still use it. I can put addr6_id in a struct next to addr6 as that will still be smaller than the largest item in the main union, like this
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
struct {
struct in6_addr addr6
u8 addr_id;
};#endif
Quoted 13 lines
Quoted 13 lines
include/linux/tcp.h +13
-0+ }; + u8 mp_capable : 1, + mp_join : 1, + dss : 1, + add_addr : 1, + add_addr6 : 1, + rm_addr : 1, + backup : 1, + version : 1; + u8 use_map : 1, + dsn64 : 1, + use_ack : 1, + ack64 : 1,
Quoted 8 lines
include/linux/tcp.h struct tcp_sack_block { · line 135
Quoted 4 lines
include/linux/tcp.h +4
-0+ data_fin :1 , + __unused : 3; +}; +#endif Should we not move this structure to
mptcp.hfile? Or better there because it directly impact TCP header size?
(or maybe not possible to includemptcp.h?)
It would be better there but I'm not sure if it is possible to add #include "mptcp.h".
Peter.
Quoted 2 lines
Cheers,
Matt