mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 03:10:12 +00:00
Merge branch 'net-tcp-make-txhash-use-consistent-for-ipv4'
Antoine Tenart says: ==================== net: tcp: make txhash use consistent for IPv4 Series is divided in two parts. First two commits make the txhash (used for the skb hash in TCP) to be consistent for all IPv4/TCP packets (IPv6 doesn't have the same issue). Last commit improve a hash-related doc. One example is when using OvS with dp_hash, which uses skb->hash, to select a path. We'd like packets from the same flow to be consistent, as well as the hash being stable over time when using net.core.txrehash=0. Same applies for kernel ECMP which also can use skb->hash. ==================== Link: https://lore.kernel.org/r/20230523161453.196094-1-atenart@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
e8f8b33230
5 changed files with 16 additions and 10 deletions
|
@ -386,8 +386,8 @@ Default : 0 (for compatibility reasons)
|
|||
txrehash
|
||||
--------
|
||||
|
||||
Controls default hash rethink behaviour on listening socket when SO_TXREHASH
|
||||
option is set to SOCK_TXREHASH_DEFAULT (i. e. not overridden by setsockopt).
|
||||
Controls default hash rethink behaviour on socket when SO_TXREHASH option is set
|
||||
to SOCK_TXREHASH_DEFAULT (i. e. not overridden by setsockopt).
|
||||
|
||||
If set to 1 (default), hash rethink is performed on listening socket.
|
||||
If set to 0, hash rethink is not performed.
|
||||
|
|
|
@ -286,7 +286,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
|
|||
const struct ip_options *sopt,
|
||||
__be32 daddr, __be32 saddr,
|
||||
const struct ip_reply_arg *arg,
|
||||
unsigned int len, u64 transmit_time);
|
||||
unsigned int len, u64 transmit_time, u32 txhash);
|
||||
|
||||
#define IP_INC_STATS(net, field) SNMP_INC_STATS64((net)->mib.ip_statistics, field)
|
||||
#define __IP_INC_STATS(net, field) __SNMP_INC_STATS64((net)->mib.ip_statistics, field)
|
||||
|
|
|
@ -1570,7 +1570,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
|
|||
const struct ip_options *sopt,
|
||||
__be32 daddr, __be32 saddr,
|
||||
const struct ip_reply_arg *arg,
|
||||
unsigned int len, u64 transmit_time)
|
||||
unsigned int len, u64 transmit_time, u32 txhash)
|
||||
{
|
||||
struct ip_options_data replyopts;
|
||||
struct ipcm_cookie ipc;
|
||||
|
@ -1633,6 +1633,8 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
|
|||
arg->csum));
|
||||
nskb->ip_summed = CHECKSUM_NONE;
|
||||
nskb->mono_delivery_time = !!transmit_time;
|
||||
if (txhash)
|
||||
skb_set_hash(nskb, txhash, PKT_HASH_TYPE_L4);
|
||||
ip_push_pending_frames(sk, &fl4);
|
||||
}
|
||||
out:
|
||||
|
|
|
@ -692,6 +692,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
|
|||
u64 transmit_time = 0;
|
||||
struct sock *ctl_sk;
|
||||
struct net *net;
|
||||
u32 txhash = 0;
|
||||
|
||||
/* Never send a reset in response to a reset. */
|
||||
if (th->rst)
|
||||
|
@ -829,6 +830,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
|
|||
inet_twsk(sk)->tw_priority : sk->sk_priority;
|
||||
transmit_time = tcp_transmit_time(sk);
|
||||
xfrm_sk_clone_policy(ctl_sk, sk);
|
||||
txhash = (sk->sk_state == TCP_TIME_WAIT) ?
|
||||
inet_twsk(sk)->tw_txhash : sk->sk_txhash;
|
||||
} else {
|
||||
ctl_sk->sk_mark = 0;
|
||||
ctl_sk->sk_priority = 0;
|
||||
|
@ -837,7 +840,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
|
|||
skb, &TCP_SKB_CB(skb)->header.h4.opt,
|
||||
ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
|
||||
&arg, arg.iov[0].iov_len,
|
||||
transmit_time);
|
||||
transmit_time, txhash);
|
||||
|
||||
xfrm_sk_free_policy(ctl_sk);
|
||||
sock_net_set(ctl_sk, &init_net);
|
||||
|
@ -859,7 +862,7 @@ static void tcp_v4_send_ack(const struct sock *sk,
|
|||
struct sk_buff *skb, u32 seq, u32 ack,
|
||||
u32 win, u32 tsval, u32 tsecr, int oif,
|
||||
struct tcp_md5sig_key *key,
|
||||
int reply_flags, u8 tos)
|
||||
int reply_flags, u8 tos, u32 txhash)
|
||||
{
|
||||
const struct tcphdr *th = tcp_hdr(skb);
|
||||
struct {
|
||||
|
@ -935,7 +938,7 @@ static void tcp_v4_send_ack(const struct sock *sk,
|
|||
skb, &TCP_SKB_CB(skb)->header.h4.opt,
|
||||
ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
|
||||
&arg, arg.iov[0].iov_len,
|
||||
transmit_time);
|
||||
transmit_time, txhash);
|
||||
|
||||
sock_net_set(ctl_sk, &init_net);
|
||||
__TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
|
||||
|
@ -955,7 +958,8 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
|
|||
tw->tw_bound_dev_if,
|
||||
tcp_twsk_md5_key(tcptw),
|
||||
tw->tw_transparent ? IP_REPLY_ARG_NOSRCCHECK : 0,
|
||||
tw->tw_tos
|
||||
tw->tw_tos,
|
||||
tw->tw_txhash
|
||||
);
|
||||
|
||||
inet_twsk_put(tw);
|
||||
|
@ -988,7 +992,7 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
|
|||
0,
|
||||
tcp_md5_do_lookup(sk, l3index, addr, AF_INET),
|
||||
inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0,
|
||||
ip_hdr(skb)->tos);
|
||||
ip_hdr(skb)->tos, tcp_rsk(req)->txhash);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -303,6 +303,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
|
|||
tcptw->tw_ts_offset = tp->tsoffset;
|
||||
tcptw->tw_last_oow_ack_time = 0;
|
||||
tcptw->tw_tx_delay = tp->tcp_tx_delay;
|
||||
tw->tw_txhash = sk->sk_txhash;
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
if (tw->tw_family == PF_INET6) {
|
||||
struct ipv6_pinfo *np = inet6_sk(sk);
|
||||
|
@ -311,7 +312,6 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
|
|||
tw->tw_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
|
||||
tw->tw_tclass = np->tclass;
|
||||
tw->tw_flowlabel = be32_to_cpu(np->flow_label & IPV6_FLOWLABEL_MASK);
|
||||
tw->tw_txhash = sk->sk_txhash;
|
||||
tw->tw_ipv6only = sk->sk_ipv6only;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue