diff mbox

[SLIRP] Fix total IP header length in forwarded TCP packets

Message ID CAPXQAKv-sa4e5gNwPkEQzS5yZM61Lxdip+khwzt0NAYhAYiY9w@mail.gmail.com
State New
Headers show

Commit Message

Sjors Gielen May 24, 2017, 5:51 p.m. UTC
When forwarding TCP packets, the internal tcpiphdr struct length was wrongly
used inside the IP header. This commit changes the behaviour to what is used
by tcp_output.c, using the correct full IP header + payload length.

Signed-off-by: Sjors Gielen <sjors@sjorsgielen.nl>
---
 slirp/tcp_subr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

     ip->ip_p = tcpiph_save.ti_pr;
@@ -224,7 +224,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti,
struct mbuf *m,
     m->m_len  -= sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
                                          - sizeof(struct ip6);
     ip6 = mtod(m, struct ip6 *);
-    ip6->ip_pl = tlen;
+    ip6->ip_pl = m->m_len;
     ip6->ip_dst = tcpiph_save.ti_dst6;
     ip6->ip_src = tcpiph_save.ti_src6;
     ip6->ip_nh = tcpiph_save.ti_nh6;

Comments

Samuel Thibault May 27, 2017, 9:35 p.m. UTC | #1
Sjors Gielen, on mer. 24 mai 2017 17:51:12 +0000, wrote:
> When forwarding TCP packets, the internal tcpiphdr struct length was wrongly
> used inside the IP header. This commit changes the behaviour to what is used
> by tcp_output.c, using the correct full IP header + payload length.

Indeed, applied, thanks.

Samuel
diff mbox

Patch

diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index ed16e1807f..3d6193657c 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -204,7 +204,7 @@  tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti,
struct mbuf *m,
     m->m_len  -= sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
                                          - sizeof(struct ip);
     ip = mtod(m, struct ip *);
-    ip->ip_len = tlen;
+    ip->ip_len = m->m_len;
     ip->ip_dst = tcpiph_save.ti_dst;
     ip->ip_src = tcpiph_save.ti_src;