virtio-net input closure: remove unneeded check for NULL xpbuf
The xbpuf pointer is assigned to the closure after allocating the
xpbuf structure in the post_receive() function, and cannot be NULL,
thus there is no need to check for a NULL value in the closure
function.
@@ -185,7 +185,6 @@ closure_function(1, 1, void, input,
xpbuf x = bound(x);
vnet vn= x->vn;
// under what conditions does a virtio queue give us zero?
- if (x != NULL) {
struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)x->p.pbuf.payload;
boolean err = false;
len -= vn->net_header_len;
@@ -194,24 +193,19 @@ closure_function(1, 1, void, input,
x->p.pbuf.payload += vn->net_header_len;
if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
if (hdr->csum_start + hdr->csum_offset <= len - sizeof(u16)) {
- u16 csum = vnet_csum(x->p.pbuf.payload + hdr->csum_start,
- len - hdr->csum_start);
- *(u16 *)(x->p.pbuf.payload + hdr->csum_start +
- hdr->csum_offset) = csum;
- } else
+ u16 csum = vnet_csum(x->p.pbuf.payload + hdr->csum_start, len - hdr->csum_start);
+ *(u16 *)(x->p.pbuf.payload + hdr->csum_start + hdr->csum_offset) = csum;
+ } else {
err = true;
}
+ }
if (!err) {
lwip_lock();
err = (vn->n->input(&x->p.pbuf, vn->n) != ERR_OK);
lwip_unlock();
}
- if (err) {
+ if (err)
receive_buffer_release(&x->p.pbuf);
- }
- } else {
- rprintf("virtio null\n");
- }
// we need to get a signal from the device side that there was
// an underrun here to open up the window
post_receive(vn);
