net/tcp: Merge TCP-MD5 inbound callbacks
Subsystems (3)
PATCH v2 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
include/net/tcp.h | 12 +++++++ net/ipv4/tcp.c | 70 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 78 +++------------------------------------------ net/ipv6/tcp_ipv6.c | 62 +++-------------------------------- 4 files changed, 91 insertions(+), 131 deletions(-)
include/net/tcp.h +12 -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,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 +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 16 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]>
Quoted 2 lines
---
v2: Rebased on net-next
On rebase I didn't check !CONFIG_TCP_MD5, and managed to forget to change the function declaration for the stub. Duh!
I've sent version3.
Thanks, sorry for the noise,
Dmitry