net: Reflect RX hash for transmit
Subsystems (3)
PATCH 1/1 net: Reflect RX hash for transmit
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in skb->hash for packets transmitted on the associated connection. The hash value returned by a device could have meaning when used in transmit to identify a flow, for instance the hash may by a flow ID for a flow created in a (virtual) device. With the flow ID provided on transmit this can obviate the need to create the hash and do the lookup on the fly in transmit.
Note that this is an opportunistic optimization, there is no separate negotiation between the stack and driver/device for the hash used in either TX or RX.
--- include/linux/skbuff.h | 3 ++- include/net/sock.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/skbuff.h +2 -1
@@ -605,7 +605,8 @@ struct sk_buff { __u8 ipvs_property:1; __u8 inner_protocol_type:1; __u8 remcsum_offload:1; -/* 3 or 5 bit hole */ + __u8 reflect_hash:1; +/* 2 or 4 bit hole */ #ifdef CONFIG_NET_SCHED __u16 tc_index;/* traffic control index */
include/net/sock.h +2 -0
@@ -871,6 +871,8 @@ static inline void sock_rps_save_rxhash(struct sock *sk,if (unlikely (sk->sk_rxhash != skb->hash)) sk->sk_rxhash = skb->hash;#endif +if (unlikely (skb->reflect_hash && sk->sk_txhash != skb->hash)) + sk->sk_txhash = skb->hash; }static inline void sock_rps_reset_rxhash (struct sock *sk)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Quoted 3 lines · Tom Herbert
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in
skb->hashfor packets transmitted on the associated connection.
[...]
include/net/sock.h static inline void sock_rps_save_rxhash(struct sock *sk, · line 875
Quoted 2 lines
include/net/sock.h +2
-0+if (unlikely (skb->reflect_hash && sk->sk_txhash != skb->hash)) + sk->sk_txhash = skb->hash;
Is there also an initial user setting this somewhere?
Quoted 6 lines · Daniel Borkmann
Quoted 4 lines · Tom Herbert
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in
skb->hashfor packets transmitted on the associated connection.
Quoted 7 lines
[...]
include/net/sock.h static inline void sock_rps_save_rxhash(struct sock *sk, · line 875
Quoted 3 lines
include/net/sock.h +2
-0+if (unlikely (skb->reflect_hash && sk->sk_txhash != skb->hash)) + sk->sk_txhash = skb->hash;Is there also an initial user setting this somewhere?
inet_set_txhash and ip6_set_txhash are called for connected sockets. There is no user API to set these.
Tom
Quoted 9 lines · Tom Herbert
Quoted 8 lines · Daniel Borkmann
Quoted 4 lines · Tom Herbert
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in
skb->hashfor packets transmitted on the associated connection.[...]
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
include/net/sock.h static inline void sock_rps_save_rxhash(struct sock *sk, · line 875
Quoted 2 lines
include/net/sock.h +2
-0+if (unlikely (skb->reflect_hash && sk->sk_txhash != skb->hash)) + sk->sk_txhash = skb->hash;Is there also an initial user setting this somewhere?
inet_set_txhashandip6_set_txhashare called for connected sockets. There is no user API to set these.
Yes sure, this was maybe a bit unclear; I was referring to reflect_hash.
Thanks,
Daniel
Quoted 8 lines · Tom Herbert
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in
skb->hashfor packets transmitted on the associated connection. The hash value returned by a device could have meaning when used in transmit to identify a flow, for instance the hash may by a flow ID for a flow created in a (virtual) device. With the flow ID provided on transmit this can obviate the need to create the hash and do the lookup on the fly in transmit.
Quoted 6 lines
Note that this is an opportunistic optimization, there is no separate negotiation between the stack and driver/device for the hash used in either TX or RX.
Signed-off-by Tom Herbert <[email protected]>---
It is not clear to me why we would want to consume yet another skb->bit for this.
This seems it might be a socket attribute, rather than a device provided one on every packet.
Anyway, this seems a premature change, as no driver currently needs this yet ?
David Miller
maintainerFrom: Tom Herbert <[email protected]>
Date: Sun, 15 Feb 2015 10:37:18 -0800
Quoted 8 lines
This patch allows a driver to request that the receive hash it provides to the stack is reflected back in
skb->hashfor packets transmitted on the associated connection. The hash value returned by a device could have meaning when used in transmit to identify a flow, for instance the hash may by a flow ID for a flow created in a (virtual) device. With the flow ID provided on transmit this can obviate the need to create the hash and do the lookup on the fly in transmit.
Quoted 5 lines
Note that this is an opportunistic optimization, there is no separate negotiation between the stack and driver/device for the hash used in either TX or RX.
Signed-off-by Tom Herbert <[email protected]>
Like Eric, I'd like to see this resubmitted alongside an actual user of the new facility.
Thanks!