From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=GgoEzwSu; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D6FC25A0277 for ; Mon, 14 Oct 2024 07:03:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1728882164; bh=nZcpcgm2ctccc4DeR6Q/qtI9PqvxjWhxcoAqMVy4eJE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GgoEzwSuk60c/aRAjNVIp5FCxoh+1G0HcWA2y3eRwvXZdaC13QD0ua5JL48Hhy54s waA2vZdYJfdCp1aqwGaTpkOFwS2748+7gshhvRqBmcykm4hFMEqJqiUp3an9U6k6q0 NngOfxtnFA7UspoQuCc4JAcHR0fPpzaNjb9Qg+bk4oBS6DqqtAuzCp/CYq1aK1i+cu r0Ok/WugQ4fNG2MOVtTU2W9lPJlK4M+NsN6JuQug+14iyegKJ10PVMhueAIi6DL31T kpiHN9mj2d8rg/yFXuhFJRTkt8Wi9+LuRJGlNfcNnFdKU4dvahKktvbIH9P/pU3tyq ce8sx+v40OllQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XRlTw2Z7Jz4x8T; Mon, 14 Oct 2024 16:02:44 +1100 (AEDT) Date: Mon, 14 Oct 2024 15:24:31 +1100 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v4 2/2] tcp: unify l2 TCPv4 and TCPv6 queues and structures Message-ID: References: <20241011183540.3045143-1-jmaloy@redhat.com> <20241011183540.3045143-3-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vLa1Wnf6TufYxeqq" Content-Disposition: inline In-Reply-To: <20241011183540.3045143-3-jmaloy@redhat.com> Message-ID-Hash: MSIMFEUDXMXOIXJV6DTIA7RC4RYG5VAO X-Message-ID-Hash: MSIMFEUDXMXOIXJV6DTIA7RC4RYG5VAO X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com, dgibson@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --vLa1Wnf6TufYxeqq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 11, 2024 at 02:35:40PM -0400, Jon Maloy wrote: > Following the preparations in the previous commit, we can now remove > the payload and flag queues dedicated for TCPv6 and TCPv4 and move all > traffic into common queues handling both protocol types. >=20 > Apart from reducing code and memory footprint, this change reduces > a potential risk for TCPv4 traffic starving out TCPv6 traffic. > Since we always flush out the TCPv4 frame queue before the TCPv6 queue, > the latter will never be handled if the former fails to send all its > frames. >=20 > Tests with iperf3 shows no measurable change in performance after this > change. >=20 > Signed-off-by: Jon Maloy Reviewed-by: David Gibson With the caveat that of course it will need to be rebased on a new version of 1/2 with the small but serious bug fixed. >=20 > --- > v2: Merged previous patch #3, where the tcp4_ prefix was changed to > tcp_ into this patch. > v3: Fixes based on feedback from D. Gibson > v4: Rebased to latest version on master branch > --- > tcp.c | 6 +- > tcp_buf.c | 246 ++++++++++++++++-------------------------------------- > tcp_buf.h | 3 +- > 3 files changed, 75 insertions(+), 180 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index 9617b7a..1509130 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2632,11 +2632,7 @@ int tcp_init(struct ctx *c) > { > ASSERT(!c->no_tcp); > =20 > - if (c->ifi4) > - tcp_sock4_iov_init(c); > - > - if (c->ifi6) > - tcp_sock6_iov_init(c); > + tcp_sock_iov_init(c); > =20 > memset(init_sock_pool4, 0xff, sizeof(init_sock_pool4)); > memset(init_sock_pool6, 0xff, sizeof(init_sock_pool6)); > diff --git a/tcp_buf.c b/tcp_buf.c > index e4fa59f..487f677 100644 > --- a/tcp_buf.c > +++ b/tcp_buf.c > @@ -38,59 +38,44 @@ > (c->mode =3D=3D MODE_PASTA ? 1 : TCP_FRAMES_MEM) > =20 > /* Static buffers */ > -/* Ethernet header for IPv4 frames */ > + > +/* Ethernet header for IPv4 and IPv6 frames */ > static struct ethhdr tcp4_eth_src; > +static struct ethhdr tcp6_eth_src; > + > +static struct tap_hdr tcp_payload_tap_hdr[TCP_FRAMES_MEM]; > + > +/* IP headers for IPv4 and IPv6 */ > +struct iphdr tcp4_payload_ip[TCP_FRAMES_MEM]; > +struct ipv6hdr tcp6_payload_ip[TCP_FRAMES_MEM]; > =20 > -static struct tap_hdr tcp4_payload_tap_hdr[TCP_FRAMES_MEM]; > -/* IPv4 headers */ > -static struct iphdr tcp4_payload_ip[TCP_FRAMES_MEM]; > -/* TCP segments with payload for IPv4 frames */ > -static struct tcp_payload_t tcp4_payload[TCP_FRAMES_MEM]; > +/* TCP segments with payload for IPv4 and IPv6 frames */ > +static struct tcp_payload_t tcp_payload[TCP_FRAMES_MEM]; > =20 > -static_assert(MSS4 <=3D sizeof(tcp4_payload[0].data), "MSS4 is greater t= han 65516"); > +static_assert(MSS4 <=3D sizeof(tcp_payload[0].data), "MSS4 is greater th= an 65516"); > +static_assert(MSS6 <=3D sizeof(tcp_payload[0].data), "MSS6 is greater th= an 65516"); > =20 > /* References tracking the owner connection of frames in the tap outqueu= e */ > -static struct tcp_tap_conn *tcp4_frame_conns[TCP_FRAMES_MEM]; > -static unsigned int tcp4_payload_used; > +static struct tcp_tap_conn *tcp_frame_conns[TCP_FRAMES_MEM]; > +static unsigned int tcp_payload_used; > =20 > -static struct tap_hdr tcp4_flags_tap_hdr[TCP_FRAMES_MEM]; > +static struct tap_hdr tcp_flags_tap_hdr[TCP_FRAMES_MEM]; > /* IPv4 headers for TCP segment without payload */ > static struct iphdr tcp4_flags_ip[TCP_FRAMES_MEM]; > /* TCP segments without payload for IPv4 frames */ > -static struct tcp_flags_t tcp4_flags[TCP_FRAMES_MEM]; > - > -static unsigned int tcp4_flags_used; > - > -/* Ethernet header for IPv6 frames */ > -static struct ethhdr tcp6_eth_src; > - > -static struct tap_hdr tcp6_payload_tap_hdr[TCP_FRAMES_MEM]; > -/* IPv6 headers */ > -static struct ipv6hdr tcp6_payload_ip[TCP_FRAMES_MEM]; > -/* TCP headers and data for IPv6 frames */ > -static struct tcp_payload_t tcp6_payload[TCP_FRAMES_MEM]; > +static struct tcp_flags_t tcp_flags[TCP_FRAMES_MEM]; > =20 > -static_assert(MSS6 <=3D sizeof(tcp6_payload[0].data), "MSS6 is greater t= han 65516"); > +static unsigned int tcp_flags_used; > =20 > -/* References tracking the owner connection of frames in the tap outqueu= e */ > -static struct tcp_tap_conn *tcp6_frame_conns[TCP_FRAMES_MEM]; > -static unsigned int tcp6_payload_used; > - > -static struct tap_hdr tcp6_flags_tap_hdr[TCP_FRAMES_MEM]; > /* IPv6 headers for TCP segment without payload */ > static struct ipv6hdr tcp6_flags_ip[TCP_FRAMES_MEM]; > -/* TCP segment without payload for IPv6 frames */ > -static struct tcp_flags_t tcp6_flags[TCP_FRAMES_MEM]; > - > -static unsigned int tcp6_flags_used; > =20 > /* recvmsg()/sendmsg() data for tap */ > static struct iovec iov_sock [TCP_FRAMES_MEM + 1]; > =20 > -static struct iovec tcp4_l2_iov [TCP_FRAMES_MEM][TCP_NUM_IOVS]; > -static struct iovec tcp6_l2_iov [TCP_FRAMES_MEM][TCP_NUM_IOVS]; > -static struct iovec tcp4_l2_flags_iov [TCP_FRAMES_MEM][TCP_NUM_IOVS]; > -static struct iovec tcp6_l2_flags_iov [TCP_FRAMES_MEM][TCP_NUM_IOVS]; > +static struct iovec tcp_l2_iov[TCP_FRAMES_MEM][TCP_NUM_IOVS]; > +static struct iovec tcp_l2_flags_iov[TCP_FRAMES_MEM][TCP_NUM_IOVS]; > + > /** > * tcp_update_l2_buf() - Update Ethernet header buffers with addresses > * @eth_d: Ethernet destination address, NULL if unchanged > @@ -103,86 +88,46 @@ void tcp_update_l2_buf(const unsigned char *eth_d, c= onst unsigned char *eth_s) > } > =20 > /** > - * tcp_sock4_iov_init() - Initialise scatter-gather L2 buffers for IPv4 = sockets > + * tcp_sock_iov_init() - Initialise scatter-gather L2 buffers for IPv4 s= ockets > * @c: Execution context > */ > -void tcp_sock4_iov_init(const struct ctx *c) > +void tcp_sock_iov_init(const struct ctx *c) > { > + struct ipv6hdr ip6 =3D L2_BUF_IP6_INIT(IPPROTO_TCP); > struct iphdr iph =3D L2_BUF_IP4_INIT(IPPROTO_TCP); > - struct iovec *iov; > int i; > =20 > + tcp6_eth_src.h_proto =3D htons_constant(ETH_P_IPV6); > tcp4_eth_src.h_proto =3D htons_constant(ETH_P_IP); > =20 > - for (i =3D 0; i < ARRAY_SIZE(tcp4_payload); i++) { > + for (i =3D 0; i < ARRAY_SIZE(tcp_payload); i++) { > + tcp6_payload_ip[i] =3D ip6; > tcp4_payload_ip[i] =3D iph; > - tcp4_payload[i].th.doff =3D sizeof(struct tcphdr) / 4; > - tcp4_payload[i].th.ack =3D 1; > + tcp_payload[i].th.doff =3D sizeof(struct tcphdr) / 4; > + tcp_payload[i].th.ack =3D 1; > } > =20 > - for (i =3D 0; i < ARRAY_SIZE(tcp4_flags); i++) { > + for (i =3D 0; i < ARRAY_SIZE(tcp_flags); i++) { > + tcp6_flags_ip[i] =3D ip6; > tcp4_flags_ip[i] =3D iph; > - tcp4_flags[i].th.doff =3D sizeof(struct tcphdr) / 4; > - tcp4_flags[i].th.ack =3D 1; > + tcp_flags[i].th.doff =3D sizeof(struct tcphdr) / 4; > + tcp_flags[i].th.ack =3D 1; > } > =20 > for (i =3D 0; i < TCP_FRAMES_MEM; i++) { > - iov =3D tcp4_l2_iov[i]; > + struct iovec *iov =3D tcp_l2_iov[i]; > =20 > - iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp4_payload_tap_hdr[i]); > + iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp_payload_tap_hdr[i]); > iov[TCP_IOV_ETH].iov_len =3D sizeof(struct ethhdr); > - iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp4_payload[i]; > - } > - > - for (i =3D 0; i < TCP_FRAMES_MEM; i++) { > - iov =3D tcp4_l2_flags_iov[i]; > - > - iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp4_flags_tap_hdr[i]); > - iov[TCP_IOV_ETH] =3D IOV_OF_LVALUE(tcp4_eth_src); > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_flags_ip[i]); > - iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp4_flags[i]; > - } > -} > - > -/** > - * tcp_sock6_iov_init() - Initialise scatter-gather L2 buffers for IPv6 = sockets > - * @c: Execution context > - */ > -void tcp_sock6_iov_init(const struct ctx *c) > -{ > - struct ipv6hdr ip6 =3D L2_BUF_IP6_INIT(IPPROTO_TCP); > - struct iovec *iov; > - int i; > - > - tcp6_eth_src.h_proto =3D htons_constant(ETH_P_IPV6); > - > - for (i =3D 0; i < ARRAY_SIZE(tcp6_payload); i++) { > - tcp6_payload_ip[i] =3D ip6; > - tcp6_payload[i].th.doff =3D sizeof(struct tcphdr) / 4; > - tcp6_payload[i].th.ack =3D 1; > - } > - > - for (i =3D 0; i < ARRAY_SIZE(tcp6_flags); i++) { > - tcp6_flags_ip[i] =3D ip6; > - tcp6_flags[i].th.doff =3D sizeof(struct tcphdr) / 4; > - tcp6_flags[i].th .ack =3D 1; > + iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp_payload[i]; > } > =20 > for (i =3D 0; i < TCP_FRAMES_MEM; i++) { > - iov =3D tcp6_l2_iov[i]; > + struct iovec *iov =3D tcp_l2_flags_iov[i]; > =20 > - iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp6_payload_tap_hdr[i]); > + iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp_flags_tap_hdr[i]); > iov[TCP_IOV_ETH].iov_len =3D sizeof(struct ethhdr); > - iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp6_payload[i]; > - } > - > - for (i =3D 0; i < TCP_FRAMES_MEM; i++) { > - iov =3D tcp6_l2_flags_iov[i]; > - > - iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp6_flags_tap_hdr[i]); > - iov[TCP_IOV_ETH] =3D IOV_OF_LVALUE(tcp6_eth_src); > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_flags_ip[i]); > - iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp6_flags[i]; > + iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp_flags[i]; > } > } > =20 > @@ -192,13 +137,9 @@ void tcp_sock6_iov_init(const struct ctx *c) > */ > void tcp_flags_flush(const struct ctx *c) > { > - tap_send_frames(c, &tcp6_l2_flags_iov[0][0], TCP_NUM_IOVS, > - tcp6_flags_used); > - tcp6_flags_used =3D 0; > - > - tap_send_frames(c, &tcp4_l2_flags_iov[0][0], TCP_NUM_IOVS, > - tcp4_flags_used); > - tcp4_flags_used =3D 0; > + tap_send_frames(c, &tcp_l2_flags_iov[0][0], TCP_NUM_IOVS, > + tcp_flags_used); > + tcp_flags_used =3D 0; > } > =20 > /** > @@ -237,21 +178,13 @@ void tcp_payload_flush(const struct ctx *c) > { > size_t m; > =20 > - m =3D tap_send_frames(c, &tcp6_l2_iov[0][0], TCP_NUM_IOVS, > - tcp6_payload_used); > - if (m !=3D tcp6_payload_used) { > - tcp_revert_seq(c, &tcp6_frame_conns[m], &tcp6_l2_iov[m], > - tcp6_payload_used - m); > + m =3D tap_send_frames(c, &tcp_l2_iov[0][0], TCP_NUM_IOVS, > + tcp_payload_used); > + if (m !=3D tcp_payload_used) { > + tcp_revert_seq(c, &tcp_frame_conns[m], &tcp_l2_iov[m], > + tcp_payload_used - m); > } > - tcp6_payload_used =3D 0; > - > - m =3D tap_send_frames(c, &tcp4_l2_iov[0][0], TCP_NUM_IOVS, > - tcp4_payload_used); > - if (m !=3D tcp4_payload_used) { > - tcp_revert_seq(c, &tcp4_frame_conns[m], &tcp4_l2_iov[m], > - tcp4_payload_used - m); > - } > - tcp4_payload_used =3D 0; > + tcp_payload_used =3D 0; > } > =20 > /** > @@ -271,41 +204,30 @@ int tcp_buf_send_flag(const struct ctx *c, struct t= cp_tap_conn *conn, int flags) > uint32_t seq; > int ret; > =20 > + iov =3D tcp_l2_flags_iov[tcp_flags_used]; > if (CONN_V4(conn)) { > - iov =3D tcp4_l2_flags_iov[tcp4_flags_used]; > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_flags_ip[tcp4_flags_used]); > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_flags_ip[tcp_flags_used]); > iov[TCP_IOV_ETH].iov_base =3D &tcp4_eth_src; > - tcp4_flags_used++; > } else { > - iov =3D tcp6_l2_flags_iov[tcp6_flags_used]; > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_flags_ip[tcp6_flags_used]); > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_flags_ip[tcp_flags_used]); > iov[TCP_IOV_ETH].iov_base =3D &tcp6_eth_src; > - tcp6_flags_used++; > } > - payload =3D iov[TCP_IOV_PAYLOAD].iov_base; > =20 > + payload =3D iov[TCP_IOV_PAYLOAD].iov_base; > seq =3D conn->seq_to_tap; > ret =3D tcp_prepare_flags(c, conn, flags, &payload->th, > payload->opts, &optlen); > - if (ret <=3D 0) { > - if (CONN_V4(conn)) > - tcp4_flags_used--; > - else > - tcp6_flags_used--; > + if (ret <=3D 0) > return ret; > - } > =20 > + tcp_flags_used++; > l4len =3D tcp_l2_buf_fill_headers(conn, iov, optlen, NULL, seq, false); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > =20 > if (flags & DUP_ACK) { > struct iovec *dup_iov; > =20 > - if (CONN_V4(conn)) > - dup_iov =3D tcp4_l2_flags_iov[tcp4_flags_used++]; > - else > - dup_iov =3D tcp4_l2_flags_iov[tcp6_flags_used++]; > - > + dup_iov =3D tcp_l2_flags_iov[tcp_flags_used++]; > memcpy(dup_iov[TCP_IOV_TAP].iov_base, iov[TCP_IOV_TAP].iov_base, > iov[TCP_IOV_TAP].iov_len); > dup_iov[TCP_IOV_ETH].iov_base =3D iov[TCP_IOV_ETH].iov_base; > @@ -315,13 +237,8 @@ int tcp_buf_send_flag(const struct ctx *c, struct tc= p_tap_conn *conn, int flags) > dup_iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > } > =20 > - if (CONN_V4(conn)) { > - if (tcp4_flags_used > TCP_FRAMES_MEM - 2) > - tcp_flags_flush(c); > - } else { > - if (tcp6_flags_used > TCP_FRAMES_MEM - 2) > - tcp_flags_flush(c); > - } > + if (tcp_flags_used > TCP_FRAMES_MEM - 2) > + tcp_flags_flush(c); > =20 > return 0; > } > @@ -337,42 +254,30 @@ int tcp_buf_send_flag(const struct ctx *c, struct t= cp_tap_conn *conn, int flags) > static void tcp_data_to_tap(const struct ctx *c, struct tcp_tap_conn *co= nn, > ssize_t dlen, int no_csum, uint32_t seq) > { > + const uint16_t *check =3D NULL; > struct iovec *iov; > size_t l4len; > =20 > conn->seq_to_tap =3D seq + dlen; > - > + tcp_frame_conns[tcp_payload_used] =3D conn; > + iov =3D tcp_l2_iov[tcp_payload_used]; > if (CONN_V4(conn)) { > - struct iovec *iov_prev =3D tcp4_l2_iov[tcp4_payload_used - 1]; > - const uint16_t *check =3D NULL; > - > if (no_csum) { > + struct iovec *iov_prev =3D tcp_l2_iov[tcp_payload_used - 1]; > struct iphdr *iph =3D iov_prev[TCP_IOV_IP].iov_base; > + > check =3D &iph->check; > } > - > - tcp4_frame_conns[tcp4_payload_used] =3D conn; > - iov =3D tcp4_l2_iov[tcp4_payload_used]; > - iov[TCP_IOV_IP] =3D > - IOV_OF_LVALUE(tcp4_payload_ip[tcp4_payload_used++]); > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_payload_ip[tcp_payload_used]); > iov[TCP_IOV_ETH].iov_base =3D &tcp4_eth_src; > - l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, check, seq, > - false); > - iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > - if (tcp4_payload_used > TCP_FRAMES_MEM - 1) > - tcp_payload_flush(c); > } else if (CONN_V6(conn)) { > - tcp6_frame_conns[tcp6_payload_used] =3D conn; > - iov =3D tcp6_l2_iov[tcp6_payload_used]; > - iov[TCP_IOV_IP] =3D > - IOV_OF_LVALUE(tcp6_payload_ip[tcp6_payload_used++]); > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_payload_ip[tcp_payload_used]); > iov[TCP_IOV_ETH].iov_base =3D &tcp6_eth_src; > - l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, NULL, seq, > - false); > - iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > - if (tcp6_payload_used > TCP_FRAMES_MEM - 1) > - tcp_payload_flush(c); > } > + l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, check, seq, false); > + iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > + if (++tcp_payload_used > TCP_FRAMES_MEM - 1) > + tcp_payload_flush(c); > } > =20 > /** > @@ -388,8 +293,7 @@ int tcp_buf_data_from_sock(const struct ctx *c, struc= t tcp_tap_conn *conn) > { > uint32_t wnd_scaled =3D conn->wnd_from_tap << conn->ws_from_tap; > int fill_bufs, send_bufs =3D 0, last_len, iov_rem =3D 0; > - int sendlen, len, dlen, v4 =3D CONN_V4(conn); > - int s =3D conn->sock, i, ret =3D 0; > + int sendlen, len, dlen, i, s =3D conn->sock, ret =3D 0; > struct msghdr mh_sock =3D { 0 }; > uint16_t mss =3D MSS_GET(conn); > uint32_t already_sent, seq; > @@ -436,19 +340,15 @@ int tcp_buf_data_from_sock(const struct ctx *c, str= uct tcp_tap_conn *conn) > mh_sock.msg_iovlen =3D fill_bufs; > } > =20 > - if (( v4 && tcp4_payload_used + fill_bufs > TCP_FRAMES_MEM) || > - (!v4 && tcp6_payload_used + fill_bufs > TCP_FRAMES_MEM)) { > + if (tcp_payload_used + fill_bufs > TCP_FRAMES_MEM) { > tcp_payload_flush(c); > =20 > /* Silence Coverity CWE-125 false positive */ > - tcp4_payload_used =3D tcp6_payload_used =3D 0; > + tcp_payload_used =3D 0; > } > =20 > for (i =3D 0, iov =3D iov_sock + 1; i < fill_bufs; i++, iov++) { > - if (v4) > - iov->iov_base =3D &tcp4_payload[tcp4_payload_used + i].data; > - else > - iov->iov_base =3D &tcp6_payload[tcp6_payload_used + i].data; > + iov->iov_base =3D &tcp_payload[tcp_payload_used + i].data; > iov->iov_len =3D mss; > } > if (iov_rem) > @@ -496,7 +396,7 @@ int tcp_buf_data_from_sock(const struct ctx *c, struc= t tcp_tap_conn *conn) > dlen =3D mss; > seq =3D conn->seq_to_tap; > for (i =3D 0; i < send_bufs; i++) { > - int no_csum =3D i && i !=3D send_bufs - 1 && tcp4_payload_used; > + int no_csum =3D i && i !=3D send_bufs - 1 && tcp_payload_used; > =20 > if (i =3D=3D send_bufs - 1) > dlen =3D last_len; > diff --git a/tcp_buf.h b/tcp_buf.h > index 8d4b615..49c04d4 100644 > --- a/tcp_buf.h > +++ b/tcp_buf.h > @@ -6,8 +6,7 @@ > #ifndef TCP_BUF_H > #define TCP_BUF_H > =20 > -void tcp_sock4_iov_init(const struct ctx *c); > -void tcp_sock6_iov_init(const struct ctx *c); > +void tcp_sock_iov_init(const struct ctx *c); > void tcp_flags_flush(const struct ctx *c); > void tcp_payload_flush(const struct ctx *c); > int tcp_buf_data_from_sock(const struct ctx *c, struct tcp_tap_conn *con= n); --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --vLa1Wnf6TufYxeqq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmcMnO8ACgkQzQJF27ox 2Gc8Ig/+PY+5/hFRHjrENx/xA2vswcEist0WFYWJ0O8WUm5PDlBYAr1/4sICMl2z t1c4pK7MI+GItUeb6BHNIEusINykIjtNCZ/RD5VrZAwveUBz4xFFv2mLDkqKltmo gfl35AtkEFf9HHvs+JDTP/YNfuUhiDYJGaMy80M/NqV2eADJR12MVtR6lGE5IF55 yAXsnT8JyJmknqVarJz3cWDUNsfqvG4YtAlwPwgqHjArL6whgpt6w2z+sHii1vRB 8NKXz1R26n8Q/leUDpR7s6HHFbNPzSnDGBCAKnes/vygcxzf9SC39v60IFg37BlU 6pHrvIp1kyfARdtIIR+ZkbLy3uviXws1WzxDdZNQoGbTMHLbfLrWx8tAtgn2QPsM Vm06E3DEh3ty1Z7TT1IDRu9DEU7LpEvgQMdQQfswWnKWjpe8emTQ/rFghBBTM18N fEZV9AlDtYXiLDJcDdebjPuKzGzmDqguc7/1nUxEtewa9aeKC0PvqpKkoJQzTQDN 4kXM1JsMRrAFMVkuea9DodkxJePs78NM2TCUQ09iKvID9yAc+dUx9xlamVL6Uml4 W/qW2pdHrp8oIpsiEnneAsaqcfNs5LZ8fO4+5m81p4O2lZUIpCqhiyjU7OuzdgcA tNuVaSrSAnZRXI0PjBuwmhIBKIocggXArL4ZZ/kGzSuaGRQrRdI= =0ZN9 -----END PGP SIGNATURE----- --vLa1Wnf6TufYxeqq--