diff mbox

[3/5] NetRxPkt: Do not try to pull more data than present

Message ID 1487248176-29602-4-git-send-email-dmitry@daynix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dmitry Fleytman Feb. 16, 2017, 12:29 p.m. UTC
In case of VLAN stripping, ETH header put into a
separate buffer, therefore amont of data copied
from original IOV should be smaller.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
---
 hw/net/net_rx_pkt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé March 3, 2017, 4:43 p.m. UTC | #1
this seems correct but unit-test would confirm any doubt.

On 02/16/2017 09:29 AM, Dmitry Fleytman wrote:
> In case of VLAN stripping, ETH header put into a
> separate buffer, therefore amont of data copied
> from original IOV should be smaller.
>
> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  hw/net/net_rx_pkt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
> index 7c0beac..d38babe 100644
> --- a/hw/net/net_rx_pkt.c
> +++ b/hw/net/net_rx_pkt.c
> @@ -96,7 +96,8 @@ net_rx_pkt_pull_data(struct NetRxPkt *pkt,
>
>          pkt->tot_len = iov_size(iov, iovcnt) - ploff + pkt->ehdr_buf_len;
>          pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,
> -                                iov, iovcnt, ploff, pkt->tot_len);
> +                                iov, iovcnt, ploff,
> +                                pkt->tot_len - pkt->ehdr_buf_len);
>      } else {
>          net_rx_pkt_iovec_realloc(pkt, iovcnt);
>
>
diff mbox

Patch

diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 7c0beac..d38babe 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -96,7 +96,8 @@  net_rx_pkt_pull_data(struct NetRxPkt *pkt,
 
         pkt->tot_len = iov_size(iov, iovcnt) - ploff + pkt->ehdr_buf_len;
         pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,
-                                iov, iovcnt, ploff, pkt->tot_len);
+                                iov, iovcnt, ploff,
+                                pkt->tot_len - pkt->ehdr_buf_len);
     } else {
         net_rx_pkt_iovec_realloc(pkt, iovcnt);