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.133.124]) by passt.top (Postfix) with ESMTP id AE1EC5A004E for ; Sun, 21 Jul 2024 11:21:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721553716; 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=UJd8rjXS6t2Qz7tGHlHhIi8EYl9n91nRYDFz9w1cSVM=; b=M/ROfRtYqc3nMTpbKBRDpBkL9/B8Gt5mV9HUNrJNyweX4IybkspqEW20anaeClGip/RtAk b90Ci/tYMi5oe1APyeSzpU3CaIqlt26Ttq0ZyHQUx1GeZMT/IpG/FqueVJ1RVPpjlqZ9w+ tHo8ukfhl78ze2s2i4geFt/6hUfnFeo= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-43dDuN1PMFCzPDAvYw5haw-1; Sun, 21 Jul 2024 05:21:55 -0400 X-MC-Unique: 43dDuN1PMFCzPDAvYw5haw-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-447f7dfa343so41780261cf.2 for ; Sun, 21 Jul 2024 02:21:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721553714; x=1722158514; 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=UJd8rjXS6t2Qz7tGHlHhIi8EYl9n91nRYDFz9w1cSVM=; b=Do5heiZB3ra+FbGaZDt0nUFHgNTbOByLU9quzn6RcbM1fO2i0CAMNMJIPNAAerfJe8 DzeIre88+/a8ZWS2HYoDjxklKKY20hryezbZP4TlA0c1MtoeIoAXTC0A5KsrgAyxyeld 0okeRws5Wv33MlUrIDos4scLMUgfL+Xa8k4IlCYcox58sr++C/IaNSGYgV1iH+2I32ii YbninC+aKc9eNyBv3ef/VoVbQMlKng4taM/voPTLy513HokvALHtGJTDHZPnmFdz8BeU BN1djGiUVkWzrzXsfQNoXA6dZGO+xUNkUFSzRsjM0zCnEFO780+q9xABUU6ZBcFFRNlF OygQ== X-Gm-Message-State: AOJu0YwuaO+27teAngD46lqXrVrMuZoo+bK/mPOx55gAOh/jkWIt/RLo 0Oh5Ol1KJLHegJ4VwkPNVW8U0KQIw+lalKl8h5TJslJs3IUfg2KyCN41C+jUA9pCmlbc6OHXzb0 mURclWN5DFuv7TOUiecPXVRvPFVB3zxae2kNLWyCpsZcgbuWTzzyzBiia9kY0YoWdncKYUrQe/3 cESYtkXgjN1MySGmjsSHWVOARVVp/razWxGyI= X-Received: by 2002:a05:622a:28f:b0:446:60c3:c297 with SMTP id d75a77b69052e-44fa5362c18mr68366461cf.58.1721553714243; Sun, 21 Jul 2024 02:21:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDP+6wf9KtpiwGyPOLxlkXISu/GdSpzEwlVnCtFNG5vZby11RywCNszGj7P+LtxfcOl3Knbw== X-Received: by 2002:a05:622a:28f:b0:446:60c3:c297 with SMTP id d75a77b69052e-44fa5362c18mr68366241cf.58.1721553713890; Sun, 21 Jul 2024 02:21:53 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f9cda7d48sm23180001cf.61.2024.07.21.02.21.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jul 2024 02:21:53 -0700 (PDT) Date: Sun, 21 Jul 2024 11:21:18 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH] tcp: probe for SO_PEEK_OFF both in tcpv4 and tcp6 Message-ID: <20240721112118.2adcc6cf@elisabeth> In-Reply-To: References: <20240720135453.2694694-1-jmaloy@redhat.com> 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=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WXFRPYQAK6MTR3SZLPUVMJJ5YENKOHIR X-Message-ID-Hash: WXFRPYQAK6MTR3SZLPUVMJJ5YENKOHIR 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, 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: On Sat, 20 Jul 2024 10:46:07 -0400 Jon Maloy wrote: > My first approach to this was to condition the use of SO_PEEK_OFF with=20 > tcpv4, e.g., basically > a test like if (v4 && peek_offset_cap) {...} everywhere, but then I made= =20 > an interesting discovery. >=20 > It turns out that, unless the =C2=B4-4' option is explicitly given on the= =20 > command line, all sockets are > v6, even those that are later used as v4 sockets. Not necessarily: if IPv6 support is disabled for other reasons, such as the fact that we didn't find any routable IPv6 address, sockets will also be IPv4-only. See tcp_sock_init(). > So, the set_peek_off()=20 > call failed even > for supposedly v4 sockets. >=20 > I checked this by adding a printout to the tcp_listen_handler(), and=20 > noticed that all returns from > the accept4() call goes into the AF_INET6 branch, even when the client=20 > (iperf3) call is using an IPv4 address. > During traffic, the very same socket is marked as v4 in the tcp_tap_conn= =20 > structure, and this seems to > have worked just fine until I added the set_peek_offset call(). >=20 > I believe this is an issue that has been introduced during the last=20 > months, since I didn't start > using the =C2=B4-4' option consistently until some months ago, and then i= t=20 > worked. That's not actually an issue, it's intended, see commit 8e914238b6de ("tcp: Use dual stack sockets for port forwarding when possible"). Could it be that you enabled IPv6 on your setup meanwhile, and that's why you see this now? I think I tested your changes on an isolated IPv4-only setup, as I didn't run a kernel version with SO_PEEK_OFF support at the time. --=20 Stefano