Commit e88f7e07 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by David S. Miller

hv_netvsc: try linearizing big SKBs before dropping them

In netvsc_start_xmit() we can handle packets which are scattered around not
more than MAX_PAGE_BUFFER_COUNT-2 pages. It is, however, easy to create a
packet which is not big in size but occupies more pages (e.g. if it uses frags
on compound pages boundaries). When we drop such packet it cases sender to try
resending it but in most cases it will try resending the same packet which will
also get dropped, this will cause the particular connection to stick. To solve
the issue we can try linearizing skb.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 981a1bd8
...@@ -377,27 +377,42 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -377,27 +377,42 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
struct rndis_packet *rndis_pkt; struct rndis_packet *rndis_pkt;
u32 rndis_msg_size; u32 rndis_msg_size;
bool isvlan; bool isvlan;
bool linear = false;
struct rndis_per_packet_info *ppi; struct rndis_per_packet_info *ppi;
struct ndis_tcp_ip_checksum_info *csum_info; struct ndis_tcp_ip_checksum_info *csum_info;
struct ndis_tcp_lso_info *lso_info; struct ndis_tcp_lso_info *lso_info;
int hdr_offset; int hdr_offset;
u32 net_trans_info; u32 net_trans_info;
u32 hash; u32 hash;
u32 skb_length = skb->len; u32 skb_length;
u32 head_room = skb_headroom(skb); u32 head_room;
u32 pkt_sz; u32 pkt_sz;
struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT]; struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
/* We will atmost need two pages to describe the rndis /* We will atmost need two pages to describe the rndis
* header. We can only transmit MAX_PAGE_BUFFER_COUNT number * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
* of pages in a single packet. * of pages in a single packet. If skb is scattered around
* more pages we try linearizing it.
*/ */
check_size:
skb_length = skb->len;
head_room = skb_headroom(skb);
num_data_pgs = netvsc_get_slots(skb) + 2; num_data_pgs = netvsc_get_slots(skb) + 2;
if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) { if (num_data_pgs > MAX_PAGE_BUFFER_COUNT && linear) {
netdev_err(net, "Packet too big: %u\n", skb->len); net_alert_ratelimited("packet too big: %u pages (%u bytes)\n",
num_data_pgs, skb->len);
ret = -EFAULT; ret = -EFAULT;
goto drop; goto drop;
} else if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) {
if (skb_linearize(skb)) {
net_alert_ratelimited("failed to linearize skb\n");
ret = -ENOMEM;
goto drop;
}
linear = true;
goto check_size;
} }
pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE; pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment