From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 690395A004E for ; Thu, 13 Jun 2024 12:14:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718273696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fJlsJOA3+NoXHa8bw6+KqavMAIwVVoCZ2qoyYcBDIf8=; b=KaR1HhoZpqr5pGOUcJy9WsMTuSTNGoPitz66pr9XeLiBwSxdEmbo3hyoAUjY6M41V0+niE qPpZocjexBohgojPNUxiQnIUwCGw7AqQFwZNOLMMsB3PZcHp3sP6QcDbrifNNjdvDXIxbj 9Jplut9SoI+QfM/ptJWgGF3peeoXTWU= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-3Ge47PwsPKy-I7N1TiWQPg-1; Thu, 13 Jun 2024 06:14:54 -0400 X-MC-Unique: 3Ge47PwsPKy-I7N1TiWQPg-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-6313189f622so7939117b3.2 for ; Thu, 13 Jun 2024 03:14:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718273693; x=1718878493; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fJlsJOA3+NoXHa8bw6+KqavMAIwVVoCZ2qoyYcBDIf8=; b=BtwiOCubXBSFTVYheY/jaYUB4YXEQNJeH0JPHPJaY6CFDHDBF7+/PQDBT6rmy4p4kP 64lmi3rBEmw9oKEgPl+4Vk6XdwMfQePnQHxcP8sZtVHYwammQG4j5wtI3DxMgmsCTtRt PElPq74qoxV/0+RXYf/mQfzO+FCoGRetg6e4Z98FUqxOZdGqlWsMekjxgUTHsuUZcHwR /HUZtZFvy/DXY23YbnuKSvWb1r9HfW2dJL5uGIj3n0VtbY3ar9euMU6DIkxAQYUXxIv7 riEWw3FQqhMI9bfQpg+hNVK4qFVdh81XtsfB4qLKs5v72BmOKGyd9/rPuvRnsos2Zf// 6Wxg== X-Gm-Message-State: AOJu0YwrhD6kag56jKWJWYrQgc5bBxl/jgLmCoGoOZxVE86qrsfSWcIp CXCe2D3wCJaGfyuUtHbfTHi0FRMQzqUTS9+jky1AnkEZnrl6VvG0NWgCPJsssMjPNYsJQmql8Ju ZXFyOEmpMV7/tpsA1JCM8YEJKBUGcoCG0hq836A052hTFKOFvtWmQOWUvIhiK X-Received: by 2002:a25:2154:0:b0:dfd:b921:1c9c with SMTP id 3f1490d57ef6-dfe68c0d560mr4088140276.43.1718273692782; Thu, 13 Jun 2024 03:14:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8DYeJuYN7jBHtZsI3gtLLivhI9hHC0S9HNv8Rl0j/6QTKqA6wVjBbkhXIN/t3FQ/PhfhWyg== X-Received: by 2002:a25:2154:0:b0:dfd:b921:1c9c with SMTP id 3f1490d57ef6-dfe68c0d560mr4088121276.43.1718273692063; Thu, 13 Jun 2024 03:14:52 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5bf2315sm5181666d6.28.2024.06.13.03.14.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2024 03:14:51 -0700 (PDT) Date: Thu, 13 Jun 2024 12:14:15 +0200 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v6 1/8] tcp: extract buffer management from tcp_send_flag() Message-ID: <20240613121415.4c92b62e@elisabeth> In-Reply-To: References: <20240612154734.1044883-1-lvivier@redhat.com> <20240612154734.1044883-2-lvivier@redhat.com> <20240612232210.3b1f975f@elisabeth> <20240613080719.67933d22@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: P5AA3VJSEID2BALPOQWISNBHPKJ7PS4J X-Message-ID-Hash: P5AA3VJSEID2BALPOQWISNBHPKJ7PS4J X-MailFrom: sbrivio@redhat.com 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, David Gibson 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: On Thu, 13 Jun 2024 10:24:11 +0200 Laurent Vivier wrote: > Hi, > > I think the problem can be because tcp_l2_buf_fill_headers() has been moved out of > tcp_prepare_flags() and so moved after: > > if (th->fin || th->syn) > conn->seq_to_tap++; > > and con->seq_to_tap is also a parameter of tcp_l2_buf_fill_headers(). So it is increased > before and not after. > > Could you try: > > diff --git a/tcp.c b/tcp.c > index 6800209d4122..647f42291fcf 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1607,6 +1607,7 @@ static int tcp_prepare_flags(struct ctx *c, struct tcp_tap_conn *conn, > if (!tcp_update_seqack_wnd(c, conn, flags, &tinfo) && !flags) > return 0; > > + *optlen = 0; > if (flags & SYN) { > int mss; > > @@ -1643,7 +1644,6 @@ static int tcp_prepare_flags(struct ctx *c, struct tcp_tap_conn *conn, > *data++ = conn->ws_to_tap; > } else if (!(flags & RST)) { > flags |= ACK; > - *optlen = 0; > } > > th->doff = (sizeof(*th) + *optlen) / 4; > @@ -1663,10 +1663,6 @@ static int tcp_prepare_flags(struct ctx *c, struct tcp_tap_conn *conn, > if (th->fin) > conn_flag(c, conn, ACK_FROM_TAP_DUE); > > - /* RFC 793, 3.1: "[...] and the first data octet is ISN+1." */ > - if (th->fin || th->syn) > - conn->seq_to_tap++; > - > return 1; > } > > @@ -1702,6 +1698,10 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, > int flags) > conn->seq_to_tap); > iov[TCP_IOV_PAYLOAD].iov_len = l4len; > > + /* RFC 793, 3.1: "[...] and the first data octet is ISN+1." */ > + if (th->fin || th->syn) > + conn->seq_to_tap++; > + > if (flags & DUP_ACK) { > struct iovec *dup_iov; > int i; Ah, yes, good catch, I missed this one! It works. Note that it needs to be: if ((flags & FIN) || (flags & SYN)) ... because we don't have a TCP header there, yet. -- Stefano