net/tcp: Merge TCP-MD5 inbound callbacks
Subsystems (3)
PATCH v3 1/1 net/tcp: Merge TCP-MD5 inbound callbacks
The functions do essentially the same work to verify TCP-MD5 sign. Code can be merged into one family-independent function in order to reduce copy'n'paste and generated code.
Later with TCP-AO option added, this will allow to create one function that's responsible for segment verification, that will have all the different checks for MD5/AO/non-signed packets, which in turn will help to see checks for all corner-cases in one function, rather than spread around different families and functions.
---
v2: Rebased on net-next
v3: Correct rebase on net-next for !CONFIG_TCP_MD5
include/net/tcp.h | 13 ++++++++ net/ipv4/tcp.c | 70 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 78 +++------------------------------------------ net/ipv6/tcp_ipv6.c | 62 +++-------------------------------- 4 files changed, 92 insertions(+), 131 deletions(-)
include/net/tcp.h +13 -0
@@ -1674,6 +1674,11 @@ tcp_md5_do_lookup(const struct sock *sk, int l3index,return NULL ; return __tcp_md5_do_lookup(sk, l3index, addr, family); } +bool tcp_inbound_md5_hash (const struct sock *sk,const struct sk_buff *skb, +enum skb_drop_reason *reason, +const void *saddr,const void *daddr, +int family,int dif,int sdif); +#define tcp_twsk_md5_key (twsk) ((twsk)->tw_md5_key)#else
@@ -1683,6 +1688,14 @@ tcp_md5_do_lookup(const struct sock *sk, int l3index, {return NULL ; } +static inline bool tcp_inbound_md5_hash (const struct sock *sk, +const struct sk_buff *skb, +enum skb_drop_reason *reason, +const void *saddr,const void *daddr, +int family,int dif,int sdif) +{ +return false; +}#define tcp_twsk_md5_key (twsk) NULL#endif
net/ipv4/tcp.c +70 -0
76 lines not on this page · raw message
net/ipv4/tcp_ipv4.c +5 -73
96 lines not on this page · raw message
net/ipv6/tcp_ipv6.c +4 -58
80 lines not on this page · raw message
base-commit: 922ea87ff6f2b63f413c6afa2c25b287dce76639
prerequisite-patch-id: f4dc7ba51eadb9fccabb755c41854bedeeaf8954
Signature · 1 line
2.35.1
Quoted 20 lines · Dmitry Safonov
The functions do essentially the same work to verify TCP-MD5 sign. Code can be merged into one family-independent function in order to reduce copy'n'paste and generated code.
Later with TCP-AO option added, this will allow to create one function that's responsible for segment verification, that will have all the different checks for MD5/AO/non-signed packets, which in turn will help to see checks for all corner-cases in one function, rather than spread around different families and functions.Cc Eric Dumazet <[email protected]>Cc "David S. Miller" <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc David Ahern <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: Rebased on net-next
v3: Correct rebase on net-next for !CONFIG_TCP_MD5
Quoted 6 lines
include/net/tcp.h | 13 ++++++++ net/ipv4/tcp.c | 70 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 78 +++------------------------------------------ net/ipv6/tcp_ipv6.c | 62 +++-------------------------------- 4 files changed, 92 insertions(+), 131 deletions(-)
Eric Dumazet
Reviewed-byQuoted 30 lines · David Ahern
Quoted 20 lines · Dmitry Safonov
The functions do essentially the same work to verify TCP-MD5 sign. Code can be merged into one family-independent function in order to reduce copy'n'paste and generated code.
Later with TCP-AO option added, this will allow to create one function that's responsible for segment verification, that will have all the different checks for MD5/AO/non-signed packets, which in turn will help to see checks for all corner-cases in one function, rather than spread around different families and functions.Cc Eric Dumazet <[email protected]>Cc "David S. Miller" <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Hideaki YOSHIFUJI <[email protected]>Cc David Ahern <[email protected]>Signed-off-by Dmitry Safonov <[email protected]>---
v2: Rebased on net-next
v3: Correct rebase on net-next for !CONFIG_TCP_MD5Quoted 6 lines
include/net/tcp.h | 13 ++++++++ net/ipv4/tcp.c | 70 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 78 +++------------------------------------------ net/ipv6/tcp_ipv6.c | 62 +++-------------------------------- 4 files changed, 92 insertions(+), 131 deletions(-)
Quoted 1 line
Reviewed-by David Ahern <[email protected]>
SGTM, thanks
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 23 Feb 2022 17:57:40 +0000 you wrote:
The functions do essentially the same work to verify TCP-MD5 sign. Code can be merged into one family-independent function in order to reduce copy'n'paste and generated code.
Later with TCP-AO option added, this will allow to create one function that's responsible for segment verification, that will have all the different checks for MD5/AO/non-signed packets, which in turn will help to see checks for all corner-cases in one function, rather than spread around different families and functions.[...]
Here is the summary with links:
- [v3] net/tcp: Merge TCP-MD5 inbound callbacks
https://git.kernel.org/netdev/net-next/c/7bbb765b7349
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html