Skip to content

Commit f72860a

Browse files
haiyangzdavem330
authored andcommitted
hv_netvsc: Exclude non-TCP port numbers from vRSS hashing
Azure hosts are not supporting non-TCP port numbers in vRSS hashing for now. For example, UDP packet loss rate will be high if port numbers are also included in vRSS hash. So, we created this patch to use only IP numbers for hashing in non-TCP traffic. Signed-off-by: Haiyang Zhang <[email protected]> Reviewed-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8db91f6 commit f72860a

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

drivers/net/hyperv/netvsc_drv.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,44 @@ static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size,
191191
return ppi;
192192
}
193193

194+
/* Azure hosts don't support non-TCP port numbers in hashing yet. We compute
195+
* hash for non-TCP traffic with only IP numbers.
196+
*/
197+
static inline u32 netvsc_get_hash(struct sk_buff *skb, struct sock *sk)
198+
{
199+
struct flow_keys flow;
200+
u32 hash;
201+
static u32 hashrnd __read_mostly;
202+
203+
net_get_random_once(&hashrnd, sizeof(hashrnd));
204+
205+
if (!skb_flow_dissect_flow_keys(skb, &flow, 0))
206+
return 0;
207+
208+
if (flow.basic.ip_proto == IPPROTO_TCP) {
209+
return skb_get_hash(skb);
210+
} else {
211+
if (flow.basic.n_proto == htons(ETH_P_IP))
212+
hash = jhash2((u32 *)&flow.addrs.v4addrs, 2, hashrnd);
213+
else if (flow.basic.n_proto == htons(ETH_P_IPV6))
214+
hash = jhash2((u32 *)&flow.addrs.v6addrs, 8, hashrnd);
215+
else
216+
hash = 0;
217+
218+
skb_set_hash(skb, hash, PKT_HASH_TYPE_L3);
219+
}
220+
221+
return hash;
222+
}
223+
194224
static inline int netvsc_get_tx_queue(struct net_device *ndev,
195225
struct sk_buff *skb, int old_idx)
196226
{
197227
const struct net_device_context *ndc = netdev_priv(ndev);
198228
struct sock *sk = skb->sk;
199229
int q_idx;
200230

201-
q_idx = ndc->tx_send_table[skb_get_hash(skb) &
231+
q_idx = ndc->tx_send_table[netvsc_get_hash(skb, sk) &
202232
(VRSS_SEND_TAB_SIZE - 1)];
203233

204234
/* If queue index changed record the new value */

0 commit comments

Comments
 (0)