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=ISe9wQdN; 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 793B05A0272 for ; Tue, 30 Sep 2025 23:30:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759267806; 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=luS3Z9GLouzx9g+ecGTNESubUUhiiKKuMnKWvR1euus=; b=ISe9wQdNsu9raauZnmkOafVYX+Fi+hIvYMs/xAxvpmKN/PfmaayO1niCMQwevdaqpDZbd+ oIS9vc20Ij5p0HlJ1SnJ69jHJfxyjY6DFn9XX5wOq79cFoAs/U0nDiWLnKxzgZxbKowgP2 JZCdMA10gXYPhYxzh6RMqaMTIRvASyk= 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-553-9dJVSJX3NKqbx08zBf2cIQ-1; Tue, 30 Sep 2025 17:30:05 -0400 X-MC-Unique: 9dJVSJX3NKqbx08zBf2cIQ-1 X-Mimecast-MFC-AGG-ID: 9dJVSJX3NKqbx08zBf2cIQ_1759267804 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e44b9779eso21182555e9.1 for ; Tue, 30 Sep 2025 14:30:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759267803; x=1759872603; 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=luS3Z9GLouzx9g+ecGTNESubUUhiiKKuMnKWvR1euus=; b=nU2M7OCMsSXafx8CRGL338EBtUGWsJUbYkv59y5Ms8m1zUt/eWLYCm3oVN9znyKJyQ 2hq1CUDcC7YnQzIXXEe/4ihhhP17GsoPO5bFYLI0qcXmDYK2snFK+c+07uLpdRds4Q09 +ib73AYgZMUqPQkqzCX3P9O7Y+KbOdGv9N/Zo5V4xbz0PT4jpTCLPHbcUN03jM/qbALo pZmlBUJkF6Eonqm3CpF6I6kg34VWPksW55sBN6fonnaVWDFFGh/ht9GO072AQxolcp3V Q/7hHDVVzqA/dJg3io0gA5//zT3YOm065BEjlAJCC7fq2l6AqLb2iVxWRoJ/jm0wovow UdVw== X-Forwarded-Encrypted: i=1; AJvYcCU+9C1X82SIE5Bg0PvIJytMSo+qRtd7DZoLtAfjrKIHxZLXpWPs/OqbbhLofNB43J0vbvVoURXFZAM=@passt.top X-Gm-Message-State: AOJu0YzUoZ20rlZ1qraZ8ycwKMFeVhzecg8cpS059+3++goTLdgG1BH0 E+foOb9aPpWgd3AC4oyZd9NAMikxLCLrCH2KxpHAZVqjmtKOQV+8NVYwSPN9bvZbSOoB4Mr1hdz dTicp/BO16ZeZKXM8BsnE+cw/LDa43TeQzj0Y88sAQvafhiiM++pk6q1KVD0fCg== X-Gm-Gg: ASbGncufJWo8lunjJY7pPXIoNAMZt71C8EQqppMN4qtYiEjGBE7Ni/oVdPuacjiygRX jAVC9IMWDT6YknCD+rj73xX+cSTTSX8ZdoO3WFJ+zEVdY42rX5BGt5cuJXFlyyax+y4LpG9VtsS AHXZuJW/q6rRLPss3Au+JxAeuVFHDatt0R/9BSgFvmMNvUVqA4tQkLtMhL7hUeqEHebZx9EAULZ 1H2d/+ZbMYbEdtzswL0f44Y9L8woItIMdtkxD2isxqDka1+v6RwFgNunzJizZNGnA/J5NY091tE GHm41Fuz5eFW0FNL3ccCtT5PhckfUuoUs+I/c2v4nCWKcGiMUBXemRzRdHDQLL7rD6svxcdpwQ= = X-Received: by 2002:a05:6000:40ca:b0:408:ffd8:2742 with SMTP id ffacd0b85a97d-4255780b1e0mr928840f8f.33.1759267803384; Tue, 30 Sep 2025 14:30:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYhx5xuQ2Zgn7PLjp/SqiDRNEGraRwWpMqbKVhv6tEY6EGhnN4EI/6LjqAsDp1VjZShgfR7g== X-Received: by 2002:a05:6000:40ca:b0:408:ffd8:2742 with SMTP id ffacd0b85a97d-4255780b1e0mr928820f8f.33.1759267802850; Tue, 30 Sep 2025 14:30:02 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-41855fc661esm16587857f8f.45.2025.09.30.14.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Sep 2025 14:30:02 -0700 (PDT) Date: Tue, 30 Sep 2025 23:30:00 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH v11 7/9] tcp: forward external source MAC address through tap interface Message-ID: <20250930233000.0871c276@elisabeth> In-Reply-To: <20250927192522.3024554-8-jmaloy@redhat.com> References: <20250927192522.3024554-1-jmaloy@redhat.com> <20250927192522.3024554-8-jmaloy@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kqi_YTYiKS04uSxkXAHxPvLsGkM_AGh1ZR9CDlo1WAY_1759267804 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: PKRTLTP56A2FNPHKJIN6Q7LJWAWV7P6P X-Message-ID-Hash: PKRTLTP56A2FNPHKJIN6Q7LJWAWV7P6P 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: dgibson@redhat.com, david@gibson.dropbear.id.au, 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 Sat, 27 Sep 2025 15:25:20 -0400 Jon Maloy wrote: > We forward the incoming mac address through the tap interface when > receiving incoming packets from network local hosts. > > This is a part of the solution to bug > https://bugs.passt.top/show_bug.cgi?id=120 > > Signed-off-by: Jon Maloy > Reviewed-by: David Gibson > > --- > v3: - Adapted to the signature change in nl_mac_get() function, so that > we now consider only the template interface when checking the > ARP/NDP table. > v4: - Adapted to previous name changes in this series > v5: - Added lookup in ARP/NDP cache and/or table on incoming messages > in case flow->tap_omac wasn't initialized at flow creation, > i.e., the flow was initiated from the guest. > v6: - Using MAC_IS_ZERO() instead of mac_undefined() > - I ignored David's suggestion to move the test for > undefined flow->tap_omac to tcp_{buf,vu}_data_from_sock(), at > least for now. It looks like a sub-optimization to first have to > look up the flow instance in these calls, and then do the > test for MAC_IS_ZERO(), even though we might in theory end up > with fewer such calls (how often?). > --- > passt.c | 7 +++---- > passt.h | 3 +-- > pasta.c | 2 +- > tap.c | 2 +- > tcp.c | 13 +++++++++++-- > tcp.h | 2 +- > tcp_buf.c | 37 +++++++++++++++++-------------------- > tcp_internal.h | 4 ++-- > tcp_vu.c | 5 ++--- > 9 files changed, 39 insertions(+), 36 deletions(-) > > diff --git a/passt.c b/passt.c > index fdd275a..a2ce2d9 100644 > --- a/passt.c > +++ b/passt.c > @@ -159,11 +159,10 @@ static void timer_init(struct ctx *c, const struct timespec *now) > /** > * proto_update_l2_buf() - Update scatter-gather L2 buffers in protocol handlers > * @eth_d: Ethernet destination address, NULL if unchanged > - * @eth_s: Ethernet source address, NULL if unchanged > */ > -void proto_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s) > +void proto_update_l2_buf(const unsigned char *eth_d) > { > - tcp_update_l2_buf(eth_d, eth_s); > + tcp_update_l2_buf(eth_d); > udp_update_l2_buf(eth_d); > } > > @@ -314,7 +313,7 @@ int main(int argc, char **argv) > if ((!c.no_udp && udp_init(&c)) || (!c.no_tcp && tcp_init(&c))) > _exit(EXIT_FAILURE); > > - proto_update_l2_buf(c.guest_mac, c.our_tap_mac); > + proto_update_l2_buf(c.guest_mac); > > if (c.ifi4 && !c.no_dhcp) > dhcp_init(); > diff --git a/passt.h b/passt.h > index 0075eb4..ff0236c 100644 > --- a/passt.h > +++ b/passt.h > @@ -326,7 +326,6 @@ struct ctx { > bool migrate_exit; > }; > > -void proto_update_l2_buf(const unsigned char *eth_d, > - const unsigned char *eth_s); > +void proto_update_l2_buf(const unsigned char *eth_d); > > #endif /* PASST_H */ > diff --git a/pasta.c b/pasta.c > index 687406b..a42cfd8 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -411,7 +411,7 @@ void pasta_ns_conf(struct ctx *c) > } > } > > - proto_update_l2_buf(c->guest_mac, NULL); > + proto_update_l2_buf(c->guest_mac); > } > > /** > diff --git a/tap.c b/tap.c > index 399eeaa..250a0f6 100644 > --- a/tap.c > +++ b/tap.c > @@ -1101,7 +1101,7 @@ void tap_add_packet(struct ctx *c, struct iov_tail *data, > memcpy(c->guest_mac, eh->h_source, ETH_ALEN); > debug("New guest MAC address observed: %s", > eth_ntop(c->guest_mac, bufmac, sizeof(bufmac))); > - proto_update_l2_buf(c->guest_mac, NULL); > + proto_update_l2_buf(c->guest_mac); > } > > switch (ntohs(eh->h_proto)) { > diff --git a/tcp.c b/tcp.c > index 48b1ef2..af05d35 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -919,6 +919,7 @@ static void tcp_fill_header(struct tcphdr *th, > > /** > * tcp_fill_headers() - Fill 802.3, IP, TCP headers > + * @c: Execution context > * @conn: Connection pointer > * @taph: tap backend specific header > * @ip4h: Pointer to IPv4 header, or NULL > @@ -929,14 +930,15 @@ static void tcp_fill_header(struct tcphdr *th, > * @seq: Sequence number for this segment > * @no_tcp_csum: Do not set TCP checksum > */ > -void tcp_fill_headers(const struct tcp_tap_conn *conn, > - struct tap_hdr *taph, > +void tcp_fill_headers(const struct ctx *c, struct tcp_tap_conn *conn, > + struct tap_hdr *taph, struct ethhdr *eh, You now pass a 802.3 header here, but the function documentation isn't updated accordingly. > struct iphdr *ip4h, struct ipv6hdr *ip6h, > struct tcphdr *th, struct iov_tail *payload, > const uint16_t *ip4_check, uint32_t seq, bool no_tcp_csum) -- Stefano