search for: skb_data_align

Displaying 20 results from an estimated 63 matches for "skb_data_align".

2018 May 21
2
[RFC PATCH net-next 10/12] vhost_net: build xdp buff
...gt; + struct iov_iter *from, > + struct xdp_buff *xdp) > +{ > + struct vhost_virtqueue *vq = &nvq->vq; > + struct page_frag *alloc_frag = &current->task_frag; > + struct virtio_net_hdr *gso; > + size_t len = iov_iter_count(from); > + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + VHOST_NET_HEADROOM > + + nvq->sock_hlen); > + int sock_hlen = nvq->sock_hlen; > + void *buf; > + int copied; > + > + if (len < nvq->sock_hlen) > + return -EFAULT; > + > +...
2018 May 21
0
[RFC PATCH net-next 10/12] vhost_net: build xdp buff
...d_xdp(struct vhost_net_virtqueue *nvq, + struct iov_iter *from, + struct xdp_buff *xdp) +{ + struct vhost_virtqueue *vq = &nvq->vq; + struct page_frag *alloc_frag = &current->task_frag; + struct virtio_net_hdr *gso; + size_t len = iov_iter_count(from); + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + VHOST_NET_HEADROOM + + nvq->sock_hlen); + int sock_hlen = nvq->sock_hlen; + void *buf; + int copied; + + if (len < nvq->sock_hlen) + return -EFAULT; + + if (SKB_DATA_ALIGN(len + pad) + + SKB_DATA_ALI...
2023 Apr 13
1
[PATCH net] virtio_net: bugfix overflow inside xdp_linearize_page()
...28c0122..ea1bd4bb326d 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -814,8 +814,13 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, int page_off, unsigned int *len) { - struct page *page = alloc_page(GFP_ATOMIC); + int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + struct page *page; + + if (page_off + *len + tailroom > PAGE_SIZE) + return NULL; + page = alloc_page(GFP_ATOMIC); if (!page) return NULL; @@ -823,7 +828,6 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, page_off += *len; whi...
2023 Apr 14
1
[PATCH net v1] virtio_net: bugfix overflow inside xdp_linearize_page()
...28c0122..ea1bd4bb326d 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -814,8 +814,13 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, int page_off, unsigned int *len) { - struct page *page = alloc_page(GFP_ATOMIC); + int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + struct page *page; + + if (page_off + *len + tailroom > PAGE_SIZE) + return NULL; + page = alloc_page(GFP_ATOMIC); if (!page) return NULL; @@ -823,7 +828,6 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, page_off += *len; while...
2018 Sep 06
2
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...t; + struct page_frag *alloc_frag = &current->task_frag; > + struct virtio_net_hdr *gso; > + struct xdp_buff *xdp = &nvq->xdp[nvq->batched_xdp]; > + size_t len = iov_iter_count(from); > + int headroom = vhost_sock_xdp(sock) ? XDP_PACKET_HEADROOM : 0; > + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + headroom + nvq->sock_hlen); > + int sock_hlen = nvq->sock_hlen; > + void *buf; > + int copied; > + > + if (unlikely(len < nvq->sock_hlen)) > + return -EFAULT; > + > + if (SKB_DAT...
2018 Sep 06
2
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...t; + struct page_frag *alloc_frag = &current->task_frag; > + struct virtio_net_hdr *gso; > + struct xdp_buff *xdp = &nvq->xdp[nvq->batched_xdp]; > + size_t len = iov_iter_count(from); > + int headroom = vhost_sock_xdp(sock) ? XDP_PACKET_HEADROOM : 0; > + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + headroom + nvq->sock_hlen); > + int sock_hlen = nvq->sock_hlen; > + void *buf; > + int copied; > + > + if (unlikely(len < nvq->sock_hlen)) > + return -EFAULT; > + > + if (SKB_DAT...
2023 Mar 28
8
[PATCH net-next 0/8] virtio_net: refactor xdp codes
Due to historical reasons, the implementation of XDP in virtio-net is relatively chaotic. For example, the processing of XDP actions has two copies of similar code. Such as page, xdp_page processing, etc. The purpose of this patch set is to refactor these code. Reduce the difficulty of subsequent maintenance. Subsequent developers will not introduce new bugs because of some complex logical
2023 Mar 28
1
[PATCH net-next 2/8] virtio_net: mergeable xdp: introduce mergeable_xdp_prepare
...irtnet_get_headroom(vi))) { + /* linearize data for XDP */ + xdp_page = xdp_linearize_page(rq, num_buf, + *page, offset, + VIRTIO_XDP_HEADROOM, + len); + + if (!xdp_page) + return NULL; + } else if (unlikely(headroom < virtnet_get_headroom(vi))) { + xdp_room = SKB_DATA_ALIGN(VIRTIO_XDP_HEADROOM + + sizeof(struct skb_shared_info)); + if (*len + xdp_room > PAGE_SIZE) + return NULL; + + xdp_page = alloc_page(GFP_ATOMIC); + if (!xdp_page) + return NULL; + + memcpy(page_address(xdp_page) + VIRTIO_XDP_HEADROOM, + page_address(*page) + offset, *len);...
2023 Mar 31
1
[PATCH net-next 2/8] virtio_net: mergeable xdp: introduce mergeable_xdp_prepare
...ata for XDP */ > + xdp_page = xdp_linearize_page(rq, num_buf, > + *page, offset, > + VIRTIO_XDP_HEADROOM, > + len); > + > + if (!xdp_page) > + return NULL; > + } else if (unlikely(headroom < virtnet_get_headroom(vi))) { > + xdp_room = SKB_DATA_ALIGN(VIRTIO_XDP_HEADROOM + > + sizeof(struct skb_shared_info)); > + if (*len + xdp_room > PAGE_SIZE) > + return NULL; > + > + xdp_page = alloc_page(GFP_ATOMIC); > + if (!xdp_page) > + return NULL; > + > + memcpy(page_address(xdp_page) + VIRTIO_XDP_HEADROOM, &g...
2018 Sep 06
0
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...sock = vq->private_data; + struct page_frag *alloc_frag = &current->task_frag; + struct virtio_net_hdr *gso; + struct xdp_buff *xdp = &nvq->xdp[nvq->batched_xdp]; + size_t len = iov_iter_count(from); + int headroom = vhost_sock_xdp(sock) ? XDP_PACKET_HEADROOM : 0; + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + headroom + nvq->sock_hlen); + int sock_hlen = nvq->sock_hlen; + void *buf; + int copied; + + if (unlikely(len < nvq->sock_hlen)) + return -EFAULT; + + if (SKB_DATA_ALIGN(len + pad) + + SKB_DATA_ALIGN(siz...
2018 Sep 12
0
[PATCH net-next V2 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...+ struct page_frag *alloc_frag = &current->task_frag; + struct virtio_net_hdr *gso; + struct xdp_buff *xdp = &nvq->xdp[nvq->batched_xdp]; + struct tun_xdp_hdr *hdr; + size_t len = iov_iter_count(from); + int headroom = vhost_sock_xdp(sock) ? XDP_PACKET_HEADROOM : 0; + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + headroom + nvq->sock_hlen); + int sock_hlen = nvq->sock_hlen; + void *buf; + int copied; + + if (unlikely(len < nvq->sock_hlen)) + return -EFAULT; + + if (SKB_DATA_ALIGN(len + pad) + + SKB_DATA_ALIGN(siz...
2018 Sep 07
0
[PATCH net-next 11/11] vhost_net: batch submitting XDP buffers to underlayer sockets
...g *alloc_frag = &current->task_frag; >> + struct virtio_net_hdr *gso; >> + struct xdp_buff *xdp = &nvq->xdp[nvq->batched_xdp]; >> + size_t len = iov_iter_count(from); >> + int headroom = vhost_sock_xdp(sock) ? XDP_PACKET_HEADROOM : 0; >> + int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); >> + int pad = SKB_DATA_ALIGN(VHOST_NET_RX_PAD + headroom + nvq->sock_hlen); >> + int sock_hlen = nvq->sock_hlen; >> + void *buf; >> + int copied; >> + >> + if (unlikely(len < nvq->sock_hlen)) >> + return -EFAUL...
2023 Mar 22
9
[PATCH net-next 0/8] virtio_net: refactor xdp codes
Due to historical reasons, the implementation of XDP in virtio-net is relatively chaotic. For example, the processing of XDP actions has two copies of similar code. Such as page, xdp_page processing, etc. The purpose of this patch set is to refactor these code. Reduce the difficulty of subsequent maintenance. Subsequent developers will not introduce new bugs because of some complex logical
2018 Mar 02
6
[PATCH net V2] virtio-net: re enable XDP_REDIRECT for mergeable buffer
...--git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9bb9e56..426dcf7 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -504,6 +504,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, page_off += *len; while (--*num_buf) { + int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); unsigned int buflen; void *buf; int off; @@ -518,7 +519,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, /* guard against a misconfigured or uncooperative backend that * is sending packet larger than the MTU. */ - if ((page_...
2018 Mar 02
6
[PATCH net V2] virtio-net: re enable XDP_REDIRECT for mergeable buffer
...--git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9bb9e56..426dcf7 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -504,6 +504,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, page_off += *len; while (--*num_buf) { + int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); unsigned int buflen; void *buf; int off; @@ -518,7 +519,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, /* guard against a misconfigured or uncooperative backend that * is sending packet larger than the MTU. */ - if ((page_...
2018 Mar 01
0
[PATCH net-next 2/2] virtio-net: simplify XDP handling in small buffer
...en = page_off - VIRTIO_XDP_HEADROOM; - return page; -err_buf: - __free_pages(page, 0); - return NULL; -} - static struct sk_buff *virtnet_skb_xdp(struct receive_queue *rq, struct sk_buff *skb) { @@ -573,8 +510,7 @@ static struct sk_buff *receive_small(struct net_device *dev, SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); struct page *page = virt_to_head_page(buf); unsigned int delta = 0; - struct page *xdp_page; - bool sent; + bool sent, skb_xdp = false; int err; len -= vi->hdr_len; @@ -590,25 +526,14 @@ static struct sk_buff *receive_small(struct net_device *dev, if...
2023 Mar 15
10
[RFC net-next 0/8] virtio_net: refactor xdp codes
Due to historical reasons, the implementation of XDP in virtio-net is relatively chaotic. For example, the processing of XDP actions has two copies of similar code. Such as page, xdp_page processing, etc. The purpose of this patch set is to refactor these code. Reduce the difficulty of subsequent maintenance. Subsequent developers will not introduce new bugs because of some complex logical
2017 Jul 18
1
[PATCH net-next 4/5] virtio-net: do not reset during XDP set
...ruct bpf_prog *xdp_prog; > - unsigned int xdp_headroom = virtnet_get_headroom(vi); > + unsigned int xdp_headroom = (unsigned long)ctx; > unsigned int header_offset = VIRTNET_RX_PAD + xdp_headroom; > unsigned int headroom = vi->hdr_len + header_offset; > unsigned int buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + > SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + struct page *page = virt_to_head_page(buf); > unsigned int delta = 0; > + struct page *xdp_page; > len -= vi->hdr_len; > > rcu_read_lock(); > @@ -434,6 +497,27 @@ static...
2017 Jul 18
1
[PATCH net-next 4/5] virtio-net: do not reset during XDP set
...ruct bpf_prog *xdp_prog; > - unsigned int xdp_headroom = virtnet_get_headroom(vi); > + unsigned int xdp_headroom = (unsigned long)ctx; > unsigned int header_offset = VIRTNET_RX_PAD + xdp_headroom; > unsigned int headroom = vi->hdr_len + header_offset; > unsigned int buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + > SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + struct page *page = virt_to_head_page(buf); > unsigned int delta = 0; > + struct page *xdp_page; > len -= vi->hdr_len; > > rcu_read_lock(); > @@ -434,6 +497,27 @@ static...
2018 Mar 02
0
[PATCH net V2] virtio-net: re enable XDP_REDIRECT for mergeable buffer
...rs/net/virtio_net.c > index 9bb9e56..426dcf7 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -504,6 +504,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, > page_off += *len; > > while (--*num_buf) { > + int tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > unsigned int buflen; > void *buf; > int off; > @@ -518,7 +519,7 @@ static struct page *xdp_linearize_page(struct receive_queue *rq, > /* guard against a misconfigured or uncooperative backend that > * is sending packet larger than...