From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVxQY-0006cL-Vy for qemu-devel@nongnu.org; Wed, 17 Feb 2016 03:25:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVxQV-0005Yj-L8 for qemu-devel@nongnu.org; Wed, 17 Feb 2016 03:25:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVxQV-0005YZ-BR for qemu-devel@nongnu.org; Wed, 17 Feb 2016 03:25:35 -0500 References: From: Thomas Huth Message-ID: <56C42E78.6070405@redhat.com> Date: Wed, 17 Feb 2016 09:25:28 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv7 5/9] slirp: Generalizing and neutralizing various TCP functions before adding IPv6 stuff List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , qemu-devel@nongnu.org Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , Dave Gilbert , Vasiliy Tolstov , Huangpeng , Gonglei , Jan Kiszka , Guillaume Subiron On 14.02.2016 18:47, Samuel Thibault wrote: > From: Guillaume Subiron >=20 > Basically, this patch adds some switch in various TCP functions to > prepare them for the IPv6 case. >=20 > To have something to "switch" in tcp_input() and tcp_respond(), a new > argument is used to give them the sa_family of the addresses they are > working on. >=20 > This patch does not include the entailed reindentation, to make proofre= ad > easier. Reindentation is adressed in the following no-op patch. >=20 > Signed-off-by: Guillaume Subiron > Signed-off-by: Samuel Thibault > --- ... > diff --git a/slirp/slirp.c b/slirp/slirp.c > index c2c4597..2321c41 100644 > --- a/slirp/slirp.c > +++ b/slirp/slirp.c > @@ -574,7 +574,8 @@ void slirp_pollfds_poll(GArray *pollfds, int select= _error) > /* > * Continue tcp_input > */ > - tcp_input((struct mbuf *)NULL, sizeof(struct i= p), so); > + tcp_input((struct mbuf *)NULL, sizeof(struct i= p), so, > + so->so_ffamily); Cosmetic nit: indentation of "so->so_ffamily" should IMHO use two more spaces. > /* continue; */ > } else { > ret =3D sowrite(so); > @@ -623,7 +624,8 @@ void slirp_pollfds_poll(GArray *pollfds, int select= _error) > } > =20 > } > - tcp_input((struct mbuf *)NULL, sizeof(struct ip), = so); > + tcp_input((struct mbuf *)NULL, sizeof(struct ip), = so, > + so->so_ffamily); dito > } /* SS_ISFCONNECTING */ > #endif > } ... > diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c > index 7fc6a87..1e5da73 100644 > --- a/slirp/tcp_output.c > +++ b/slirp/tcp_output.c > @@ -61,7 +61,8 @@ tcp_output(struct tcpcb *tp) > register long len, win; > int off, flags, error; > register struct mbuf *m; > - register struct tcpiphdr *ti; > + register struct tcpiphdr *ti, tcpiph_save; > + struct ip *ip; > u_char opt[MAX_TCPOPTLEN]; > unsigned optlen, hdrlen; > int idle, sendalot; > @@ -447,13 +448,15 @@ send: > * the template, but need a way to checksum without them. > */ > m->m_len =3D hdrlen + len; /* XXX Needed? m_len should be correct */ > + tcpiph_save =3D *(mtod(m, struct tcpiphdr *)); I think you could drop the outermost parentheses here. > - struct tcpiphdr tcpiph_save =3D *(mtod(m, struct tcpiphdr *)); > + switch (so->so_ffamily) { > + case AF_INET: > m->m_data +=3D sizeof(struct tcpiphdr) - sizeof(struct tcphdr) > - sizeof(struct ip); > m->m_len -=3D sizeof(struct tcpiphdr) - sizeof(struct tcphdr) > - sizeof(struct ip); > - struct ip *ip =3D mtod(m, struct ip *); > + ip =3D mtod(m, struct ip *); > =20 > ip->ip_len =3D m->m_len; > ip->ip_dst =3D tcpiph_save.ti_dst; > @@ -464,6 +467,11 @@ send: > ip->ip_tos =3D so->so_iptos; > =20 > error =3D ip_output(so, m); > + break; > + > + default: > + g_assert_not_reached(); > + } ... Only very minor cosmetic nits, patch generally looks fine, so: Reviewed-by: Thomas Huth