From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XAd2Mtjf; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 84C475A0008 for ; Wed, 19 Mar 2025 17:17:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742401062; 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=4ohDubKNBv04PAvMg6ppvYhXsvA/5wKkztcD7cOEO0U=; b=XAd2MtjfPBWNNc7IVQkYonZK0L/ItgfySVjAWVIMhI0wZL2KbKS7TMa1iVFo+3SP6mhkgQ qBAMDyE9hamy/5SMQa47CBB2HlI2IJjvRlDkHpyE0MbxHBimkiJKFYEY1xi4v2bHppxeJ7 VMIdeiTnh+XEz0W0lBhA2OvkQGtNOS0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-L9vLU9WBN2-NqYU9BTyHcQ-1; Wed, 19 Mar 2025 12:17:40 -0400 X-MC-Unique: L9vLU9WBN2-NqYU9BTyHcQ-1 X-Mimecast-MFC-AGG-ID: L9vLU9WBN2-NqYU9BTyHcQ_1742401060 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43ced8c2eb7so35729325e9.1 for ; Wed, 19 Mar 2025 09:17:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742401059; x=1743005859; 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=4ohDubKNBv04PAvMg6ppvYhXsvA/5wKkztcD7cOEO0U=; b=dxzJHZCeSw3D4rzXKncKHD+158qZMfMjAGFR8B45UlMT2rwHRAslOiTe3aHKXAbzhQ SNUkycDwCigbuKhHwuIJhgvV2Xmbf4E5nvw+UP/eTvE7+xLwT3ht3Rt7CngIBhAjC35m rXteN2t6+PcmAwp388KUSfAYLzlXEBbwy/sGtyLHJdSZwleQtBh4ySRapiDO7lsK2rrW ojLVAWIG5Z94PZKeKhT//w3jY/v6GTYapniajgLnnooCbqT+7LloS6qQO4oIIxhv1RTZ xGpuFmKYkd3PXgR2dZqWhu4zGMF20K4VR9IU4O8hk4DxrsMZIMVf7Pcvz9WG5BaoJSz9 o0mw== X-Gm-Message-State: AOJu0YwEy1skLM3ukczl4UzW5ftSx6shP51qz5kdKKoybqB+zPpwafC4 ZUSbWuQxd/QReQD8ytqc/3dbSzZrX1cpozx1OH5FsoGYbFy865C5Ij9IWDZPsgm8PcS2abuAF+I F2C8cH2aoUzoQTZEn1pWb328DvRnjIHMO0pkWMNlZfD3MW7XzBehHnNHtog== X-Gm-Gg: ASbGncvr5sRPUBn8Y39VH9ODPpSFlN3QU178nNaPEz5IK3ymuA6lJqCDcAhgf+OqVFy YVyB2wvNaINel36As5GAgYFVKRzyE2yuso1R+HZ8aYbxpjVADYhCjIi3Y4EKr+5HAfYV4Ukc9iq ZmJ0mt++QOXpzhcBlIwJIB9lTZjvphFFjGkQCcCNa7q8eAPquIKhqkDBZDqVYKaGp91IVjy6One gUvc7KCoV0VowyrVk4chqbaIwOHX5CMlR/QZ/Dt8Zuh5Y58FhCqvTTs6V3KAG5lekNqguC2vjkM /pWt7SnnmFQ4IsEJ0UpV/r/AXW5HblLCWBSpKrO9dV9v X-Received: by 2002:a05:600c:1e14:b0:43c:e70d:450c with SMTP id 5b1f17b1804b1-43d437feccfmr33837635e9.22.1742401058966; Wed, 19 Mar 2025 09:17:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETpessBB4rvHKCoxC/IwVtBVnoqMNtAuZ61QUABE00GZsv8Cbk13ci8BYAdKIeggbn/kL4Qw== X-Received: by 2002:a05:600c:1e14:b0:43c:e70d:450c with SMTP id 5b1f17b1804b1-43d437feccfmr33837395e9.22.1742401058474; Wed, 19 Mar 2025 09:17:38 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-395cb7eb9ccsm21734027f8f.96.2025.03.19.09.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Mar 2025 09:17:38 -0700 (PDT) Date: Wed, 19 Mar 2025 17:17:36 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/3] migrate, tcp: Migrate RFC7323 timestamp Message-ID: <20250319171736.22a7e6ca@elisabeth> In-Reply-To: <20250319051423.2378689-3-david@gibson.dropbear.id.au> References: <20250319051423.2378689-1-david@gibson.dropbear.id.au> <20250319051423.2378689-3-david@gibson.dropbear.id.au> 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-MFC-PROC-ID: 4AZ-iTLRs9_fwAskCF9ew_K2dfuPREP4lr-wP7S6zf8_1742401060 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: HKNSYGE74XYKVZCDDK2FUXHD5R2LZXDT X-Message-ID-Hash: HKNSYGE74XYKVZCDDK2FUXHD5R2LZXDT 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 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 Wed, 19 Mar 2025 16:14:22 +1100 David Gibson wrote: > Currently our migration of the state of TCP sockets omits the RFC7323 > timestamp. In some circumstances that can result in data sent from the > target machine not being received, because it is discarded on the peer due > to PAWS checking. > > Add code to dump and restore the timestamp across migration. > > Link: https://bugs.passt.top/show_bug.cgi?id=115 > > Signed-off-by: David Gibson Sneakily changed all "RFC7323" references to the actual name of the document, "RFC 7323", and dropped: > --- > tcp.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > tcp_conn.h | 2 ++ > 2 files changed, 61 insertions(+) > > diff --git a/tcp.c b/tcp.c > index 163ddd60..56df1636 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2861,6 +2861,57 @@ static int tcp_flow_dump_mss(const struct tcp_tap_conn *conn, > return 0; > } > > + > +/** > + * tcp_flow_dump_timestamp() - Dump RFC7323 timestamp via TCP_TIMESTAMP > + * @conn: Pointer to the TCP connection structure > + * @t: Extended migration data (tcpi_options must be populated) > + * > + * Return: 0 on success, negative error code on failure > + */ > +static int tcp_flow_dump_timestamp(const struct tcp_tap_conn *conn, > + struct tcp_tap_transfer_ext *t) > +{ > + int val = 0; > + > + if (t->tcpi_options & TCPI_OPT_TIMESTAMPS) { > + socklen_t sl = sizeof(val); > + > + if (getsockopt(conn->sock, SOL_TCP, TCP_TIMESTAMP, &val, &sl)) { > + int rc = -errno; > + flow_perror(conn, "Getting RFC7323 timestamp"); > + return rc; > + } > + } > + > + t->timestamp = (uint32_t)val; > + return 0; > +} > + > +/** > + * tcp_flow_repair_timestamp() - Restore RFC7323 timestamp via TCP_TIMESTAMP > + * @conn: Pointer to the TCP connection structure > + * @t: Extended migration data > + * > + * Return: 0 on success, negative error code on failure > + */ > +static int tcp_flow_repair_timestamp(const struct tcp_tap_conn *conn, > + const struct tcp_tap_transfer_ext *t) > +{ > + int val = (int)t->timestamp; > + > + if (t->tcpi_options & TCPI_OPT_TIMESTAMPS) { > + if (setsockopt(conn->sock, SOL_TCP, TCP_TIMESTAMP, > + &val, sizeof(val))) { > + int rc = -errno; > + flow_perror(conn, "Setting RFC7323 timestamp"); > + return rc; > + } > + } > + > + return 0; > +} > + > /** > * tcp_flow_dump_wnd() - Dump current tcp_repair_window parameters > * @conn: Pointer to the TCP connection structure > @@ -3260,6 +3311,9 @@ int tcp_flow_migrate_source_ext(int fd, const struct tcp_tap_conn *conn) > if ((rc = tcp_flow_dump_mss(conn, t))) > goto fail; > > + if ((rc = tcp_flow_dump_timestamp(conn, t))) > + goto fail; > + > if ((rc = tcp_flow_dump_wnd(conn, t))) > goto fail; > > @@ -3305,6 +3359,7 @@ int tcp_flow_migrate_source_ext(int fd, const struct tcp_tap_conn *conn) > t->notsent = htonl(t->notsent); > t->rcvq = htonl(t->rcvq); > t->mss = htonl(t->mss); > + t->timestamp = htonl(t->timestamp); > > t->snd_wl1 = htonl(t->snd_wl1); > t->snd_wnd = htonl(t->snd_wnd); > @@ -3519,6 +3574,7 @@ int tcp_flow_migrate_target_ext(struct ctx *c, struct tcp_tap_conn *conn, int fd > t.notsent = ntohl(t.notsent); > t.rcvq = ntohl(t.rcvq); > t.mss = ntohl(t.mss); > + t.timestamp = ntohl(t.timestamp); > > t.snd_wl1 = ntohl(t.snd_wl1); > t.snd_wnd = ntohl(t.snd_wnd); > @@ -3561,6 +3617,9 @@ int tcp_flow_migrate_target_ext(struct ctx *c, struct tcp_tap_conn *conn, int fd > /* We weren't able to create the socket, discard flow */ > goto fail; > > + if (tcp_flow_repair_timestamp(conn, &t)) > + goto fail; > + ...this stray tab. Series applied. > if (tcp_flow_select_queue(conn, TCP_SEND_QUEUE)) > goto fail; > > diff --git a/tcp_conn.h b/tcp_conn.h > index 9126a36f..c79f558b 100644 > --- a/tcp_conn.h > +++ b/tcp_conn.h > @@ -152,6 +152,7 @@ struct tcp_tap_transfer { > * @notsent: Part of pending send queue that wasn't sent out yet > * @rcvq: Length of pending receive queue > * @mss: Socket-side MSS clamp > + * @timestamp: RFC7323 timestamp > * @snd_wl1: Next sequence used in window probe (next sequence - 1) > * @snd_wnd: Socket-side sending window > * @max_window: Window clamp > @@ -171,6 +172,7 @@ struct tcp_tap_transfer_ext { > uint32_t rcvq; > > uint32_t mss; > + uint32_t timestamp; > > /* We can't just use struct tcp_repair_window: we need network order */ > uint32_t snd_wl1; -- Stefano