qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Chris Heinze <c.heinze@precibake.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] slirp, incoming packets get truncated
Date: Sun, 8 Sep 2019 01:29:24 +0200	[thread overview]
Message-ID: <20190907232924.a2maha6jyf7u6xbb@function> (raw)
In-Reply-To: <0115e29c-2254-09c3-13d5-6dfb5307d968@precibake.com>

[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]

Hello,

As usual, several things here.

Chris Heinze, le mar. 03 sept. 2019 17:02:15 +0200, a ecrit:
> root@guest:~# tcpdump -ni eth0 port 19003
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
> 16:49:39.430959 IP 10.0.2.2.33294 > 10.0.2.15.19003: UDP, bad length 9000 > 1472

tcpdump seems to be showing dumb output here. The packet is fragmented
by slirp, which makes tcpdump confused and show only the first
fragment. If you let tcpdump print everything, you will see the other
fragments. In reality, everything is going fine here.

> i tried to change slirp/src/if.h to: 
> 
> #define IF_MTU 9000
> #define IF_MRU 9000
> 
> but the resulting qemu-system-x86_64 binary did not behave differently.

Did you explicitly remove the qemu-system-x86_64 binary? As mentioned
previously on the list, there seems to be a missing Makefile dependency.

Now, with MTU set to 9000, the packets just don't go at all. Could you
try the attached patch? The lowest layer of slirp was indeed limited to
1600-byte frames for no good reason. With this and the virtio driver, I
could exchange 9000-byte packets.

Samuel

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1365 bytes --]

diff --git a/src/slirp.c b/src/slirp.c
index b0194cb..3fd6f68 100644
--- a/src/slirp.c
+++ b/src/slirp.c
@@ -890,20 +890,22 @@ static int if_encap6(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,
  */
 int if_encap(Slirp *slirp, struct mbuf *ifm)
 {
-    uint8_t buf[1600];
-    struct ethhdr *eh = (struct ethhdr *)buf;
+    uint8_t *buf;
+    struct ethhdr *eh;
     uint8_t ethaddr[ETH_ALEN];
     const struct ip *iph = (const struct ip *)ifm->m_data;
     int ret;
 
-    if (ifm->m_len + ETH_HLEN > sizeof(buf)) {
-        return 1;
-    }
+    buf = g_malloc(ifm->m_len + ETH_HLEN);
+    if (!buf)
+        return 0;
+    eh = (struct ethhdr *)buf;
 
     switch (iph->ip_v) {
     case IPVERSION:
         ret = if_encap4(slirp, ifm, eh, ethaddr);
         if (ret < 2) {
+            g_free(buf);
             return ret;
         }
         break;
@@ -911,6 +913,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
     case IP6VERSION:
         ret = if_encap6(slirp, ifm, eh, ethaddr);
         if (ret < 2) {
+            g_free(buf);
             return ret;
         }
         break;
@@ -929,6 +932,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
               eh->h_dest[5]);
     memcpy(buf + sizeof(struct ethhdr), ifm->m_data, ifm->m_len);
     slirp_send_packet_all(slirp, buf, ifm->m_len + ETH_HLEN);
+    g_free(buf);
     return 1;
 }
 

  parent reply	other threads:[~2019-09-07 23:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03 15:02 [Qemu-devel] slirp, incoming packets get truncated Chris Heinze
2019-09-06  9:59 ` Samuel Thibault
2019-09-06 10:54   ` Chris Heinze
2019-09-06 11:14     ` Samuel Thibault
2019-09-07 23:29 ` Samuel Thibault [this message]
2019-09-09 10:35   ` Chris Heinze
2019-09-09 10:51   ` Philippe Mathieu-Daudé
2019-09-09 10:59     ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190907232924.a2maha6jyf7u6xbb@function \
    --to=samuel.thibault@gnu.org \
    --cc=c.heinze@precibake.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).