diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 98de8ab..66a7f9e 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -215,6 +215,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif *vif, struct xenvif_rx_meta *meta; struct xen_netif_rx_request *req; + if((vif->rx.req_cons + 1 > vif->rx.sring->req_prod) && net_ratelimit()){netdev_warn(vif->dev, "?!? npo->meta_prod:%d vif->rx.sring->req_prod:%d vif->rx.req_cons:%d", npo->meta_prod , vif->rx.sring->req_prod, vif->rx.req_cons + 1);} req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++); meta = npo->meta + npo->meta_prod++; @@ -356,6 +357,7 @@ static int xenvif_gop_skb(struct sk_buff *skb, /* Set up a GSO prefix descriptor, if necessary */ if ((1 << gso_type) & vif->gso_prefix_mask) { + if((vif->rx.req_cons + 1 > vif->rx.sring->req_prod) && net_ratelimit()){netdev_warn(vif->dev, "?!? npo->meta_prod:%d vif->rx.sring->req_prod:%d vif->rx.req_cons:%d", npo->meta_prod , vif->rx.sring->req_prod, vif->rx.req_cons + 1);} req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++); meta = npo->meta + npo->meta_prod++; meta->gso_type = gso_type; @@ -363,7 +365,7 @@ static int xenvif_gop_skb(struct sk_buff *skb, meta->size = 0; meta->id = req->id; } - + if((vif->rx.req_cons + 1 > vif->rx.sring->req_prod) && net_ratelimit()){netdev_warn(vif->dev, "?!? npo->meta_prod:%d vif->rx.sring->req_prod:%d vif->rx.req_cons:%d", npo->meta_prod , vif->rx.sring->req_prod, vif->rx.req_cons + 1);} req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++); meta = npo->meta + npo->meta_prod++; @@ -380,6 +382,7 @@ static int xenvif_gop_skb(struct sk_buff *skb, npo->copy_off = 0; npo->copy_gref = req->gref; + data = skb->data; while (data < skb_tail_pointer(skb)) { unsigned int offset = offset_in_page(data); @@ -420,11 +423,14 @@ static int xenvif_check_gop(struct xenvif *vif, int nr_meta_slots, for (i = 0; i < nr_meta_slots; i++) { copy_op = npo->copy + npo->copy_cons++; if (copy_op->status != GNTST_okay) { - netdev_dbg(vif->dev, + if (net_ratelimit()){ + netdev_warn(vif->dev, "Bad status %d from copy to DOM%d.\n", copy_op->status, vif->domid); status = XEN_NETIF_RSP_ERROR; - } + netdev_warn(vif->dev, "?!? %s status err? status:%d i:%d nr_meta_slots:%d copy_op->status:%d npo->copy_cons:%d \n", __FUNCTION__,status, i, nr_meta_slots, copy_op->status, npo->copy_cons ); + } + } } return status; @@ -451,8 +457,14 @@ static void xenvif_add_frag_responses(struct xenvif *vif, int status, flags = XEN_NETRXF_more_data; offset = 0; + + if(status > 10000 || status < 0){ + if (net_ratelimit()) + netdev_warn(vif->dev, "?!? %s status err? status:%d i:%d nr_meta_slots:%d flags:%d size:%d\n", __FUNCTION__,status, i, nr_meta_slots, flags, meta[i].size); + } make_rx_response(vif, meta[i].id, status, offset, meta[i].size, flags); + } } @@ -514,6 +526,9 @@ static void xenvif_rx_action(struct xenvif *vif) sco = (struct skb_cb_overlay *)skb->cb; sco->meta_slots_used = xenvif_gop_skb(skb, &npo); + + + BUG_ON(sco->meta_slots_used > max_slots_needed); __skb_queue_tail(&rxq, skb); @@ -551,6 +566,8 @@ static void xenvif_rx_action(struct xenvif *vif) status = xenvif_check_gop(vif, sco->meta_slots_used, &npo); + + if (sco->meta_slots_used == 1) flags = 0; else @@ -563,6 +580,12 @@ static void xenvif_rx_action(struct xenvif *vif) flags |= XEN_NETRXF_data_validated; offset = 0; + + if(status > 10000 || status < 0){ + if (net_ratelimit()) + netdev_warn(vif->dev, "?!? %s status err? status:%d meta_slots_used:%d flags:%d size:%d ip_summed:%d is_gso:%d skb_shinfo(skb)->gso_type:%d vif->meta[npo.meta_cons].gso_type:%d nr_frags:%d npo.copy_prod:%d, npo.meta_cons:%d\n", __FUNCTION__,status, sco->meta_slots_used, flags, skb_is_gso(skb) , skb_shinfo(skb)->gso_type, vif->meta[npo.meta_cons].gso_type, vif->meta[npo.meta_cons].size, skb->ip_summed, skb_shinfo(skb)->nr_frags , npo.copy_prod, npo.meta_cons); + } + resp = make_rx_response(vif, vif->meta[npo.meta_cons].id, status, offset, vif->meta[npo.meta_cons].size, @@ -713,7 +736,6 @@ static int xenvif_count_requests(struct xenvif *vif, if (drop_err) txp = &dropped_tx; - memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + slots), sizeof(*txp)); @@ -823,6 +845,12 @@ static struct gnttab_copy *xenvif_get_requests(struct xenvif *vif, gop->dest.offset = dst_offset; gop->dest.u.gmfn = virt_to_mfn(page_address(page)); + if(txp->gref > 10000 || txp->gref <=0){ + if (net_ratelimit()) + netdev_warn(vif->dev, "?!? %s ref out of bounds? gref:%d srcdomid:%d dstdomid:%d slot:%d \n",__FUNCTION__, txp->gref, vif->domid, DOMID_SELF, slot); + } + + if (dst_offset + txp->size > PAGE_SIZE) { /* This page can only merge a portion * of tx request. Do not increment any @@ -1000,7 +1028,6 @@ static int xenvif_get_extras(struct xenvif *vif, xenvif_fatal_tx_err(vif); return -EBADR; } - memcpy(&extra, RING_GET_REQUEST(&vif->tx, cons), sizeof(extra)); if (unlikely(!extra.type || @@ -1393,6 +1420,7 @@ static unsigned xenvif_tx_build_gops(struct xenvif *vif, int budget) break; idx = vif->tx.req_cons; + rmb(); /* Ensure that we see the request before we copy it. */ memcpy(&txreq, RING_GET_REQUEST(&vif->tx, idx), sizeof(txreq));