From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D9E915A027E for ; Wed, 6 Mar 2024 06:58:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709704722; bh=+YnEMFcOb+m91V/pxXB35wGt84gaQpNXHA3RUiEFgQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z1tEQanMzeHz4/Dh+dd6MauTuXOsZasivgCo2v0AvzzpirNMrKfJA1UYEttVjdphX HEXaryQX89ytN8U40mx496XZlfQW9XZIVtmdJesl2VxmV8Pl/Kel+e+6+X/vZl/Zk8 8/Jo8r57Dp11RGrJH6FIUl1h5R2zuhP/Ec7ZbHz9TznGb50py/mNpxsCjxcDQk+oge 0OLSeBgo4R3ONPOEILPgKvocGm4LpiVJMqFRQLYF2oXiC3/XP5PqqDMspQtFQ2+7RP CAbDRhOgmGkGDhbtnidNJKpV5+f5z6V4hX9GqMvL49yAYrNcLA+/2/iSlTW+MVXc9T Mt6CuzRpbjOaw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TqMDy2fNhz4wxZ; Wed, 6 Mar 2024 16:58:42 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 8/9] tap: make tap_update_mac() generic Date: Wed, 6 Mar 2024 16:58:37 +1100 Message-ID: <20240306055838.1180477-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240306055838.1180477-1-david@gibson.dropbear.id.au> References: <20240306055838.1180477-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: QEJ5R62JWX3CMDZ5ZINX3EJE7OD4YBMK X-Message-ID-Hash: QEJ5R62JWX3CMDZ5ZINX3EJE7OD4YBMK 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: lvivier@redhat.com, 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: From: Laurent Vivier Use ethhdr rather than tap_hdr. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson Message-ID: <20240303135114.1023026-9-lvivier@redhat.com> Signed-off-by: David Gibson --- tap.c | 10 +++++----- tap.h | 2 +- tcp.c | 8 ++++---- udp.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tap.c b/tap.c index f971461c..c7b93726 100644 --- a/tap.c +++ b/tap.c @@ -419,18 +419,18 @@ size_t tap_send_frames(const struct ctx *c, const struct iovec *iov, size_t n) } /** - * tap_update_mac() - Update tap L2 header with new Ethernet addresses - * @taph: Tap headers to update + * eth_update_mac() - Update tap L2 header with new Ethernet addresses + * @eh: Ethernet headers to update * @eth_d: Ethernet destination address, NULL if unchanged * @eth_s: Ethernet source address, NULL if unchanged */ -void tap_update_mac(struct tap_hdr *taph, +void eth_update_mac(struct ethhdr *eh, const unsigned char *eth_d, const unsigned char *eth_s) { if (eth_d) - memcpy(taph->eh.h_dest, eth_d, sizeof(taph->eh.h_dest)); + memcpy(eh->h_dest, eth_d, sizeof(eh->h_dest)); if (eth_s) - memcpy(taph->eh.h_source, eth_s, sizeof(taph->eh.h_source)); + memcpy(eh->h_source, eth_s, sizeof(eh->h_source)); } PACKET_POOL_DECL(pool_l4, UIO_MAXIOV, pkt_buf); diff --git a/tap.h b/tap.h index 466d9146..437b9aa2 100644 --- a/tap.h +++ b/tap.h @@ -74,7 +74,7 @@ void tap_icmp6_send(const struct ctx *c, const void *in, size_t len); int tap_send(const struct ctx *c, const void *data, size_t len); size_t tap_send_frames(const struct ctx *c, const struct iovec *iov, size_t n); -void tap_update_mac(struct tap_hdr *taph, +void eth_update_mac(struct ethhdr *eh, const unsigned char *eth_d, const unsigned char *eth_s); void tap_listen_handler(struct ctx *c, uint32_t events); void tap_handler_pasta(struct ctx *c, uint32_t events, diff --git a/tcp.c b/tcp.c index a7156ee1..db42d535 100644 --- a/tcp.c +++ b/tcp.c @@ -981,10 +981,10 @@ void tcp_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s) struct tcp4_l2_buf_t *b4 = &tcp4_l2_buf[i]; struct tcp6_l2_buf_t *b6 = &tcp6_l2_buf[i]; - tap_update_mac(&b4->taph, eth_d, eth_s); - tap_update_mac(&b6->taph, eth_d, eth_s); - tap_update_mac(&b4f->taph, eth_d, eth_s); - tap_update_mac(&b6f->taph, eth_d, eth_s); + eth_update_mac(&b4->taph.eh, eth_d, eth_s); + eth_update_mac(&b6->taph.eh, eth_d, eth_s); + eth_update_mac(&b4f->taph.eh, eth_d, eth_s); + eth_update_mac(&b6f->taph.eh, eth_d, eth_s); } } diff --git a/udp.c b/udp.c index 2fd67925..1f46afb2 100644 --- a/udp.c +++ b/udp.c @@ -288,8 +288,8 @@ void udp_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s) struct udp4_l2_buf_t *b4 = &udp4_l2_buf[i]; struct udp6_l2_buf_t *b6 = &udp6_l2_buf[i]; - tap_update_mac(&b4->taph, eth_d, eth_s); - tap_update_mac(&b6->taph, eth_d, eth_s); + eth_update_mac(&b4->taph.eh, eth_d, eth_s); + eth_update_mac(&b6->taph.eh, eth_d, eth_s); } } -- 2.44.0