net/tcp: Merge TCP-MD5 inbound callbacks
Subsystems (3)
PATCH 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.
--- include/net/tcp.h | 11 +++++++ net/ipv4/tcp.c | 66 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 73 ++++----------------------------------------- net/ipv6/tcp_ipv6.c | 57 +++-------------------------------- 4 files changed, 86 insertions(+), 121 deletions(-)
include/net/tcp.h +11 -0
@@ -1673,6 +1673,10 @@ 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, +const void *saddr,const void *daddr, +int family,int dif,int sdif); +#define tcp_twsk_md5_key (twsk) ((twsk)->tw_md5_key)#else
@@ -1682,6 +1686,13 @@ 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, +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 +66 -0
72 lines not on this page · raw message
net/ipv4/tcp_ipv4.c +5 -68
91 lines not on this page · raw message
net/ipv6/tcp_ipv6.c +4 -53
75 lines not on this page · raw message
base-commit: 038101e6b2cd5c55f888f85db42ea2ad3aecb4b6
Signature · 1 line
2.35.1
Jakub Kicinski
maintainerQuoted 8 lines · On Tue, 22 Feb 2022 18:50:06 +0000 Dmitry Safonov 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.
Please rebase on top of net-next
Quoted 11 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 22 Feb 2022 18:50:06 +0000 Dmitry Safonov 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.Please rebase on top of net-next
Thanks!
I've previously checked it on linux-next, was not aware that net-next is not integrated or integrated with some delay?
Anyway, I've resent v2, based on net-next.
Thanks,
Dmitry