From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 768D05A0278 for ; Tue, 16 Jan 2024 06:16:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1705382181; bh=NRdtflx9Cxt98kUmtfVMHhdfRt6+tBTd/PZ9ctMUNfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=REVGupCq3VCEreeuJOBG5WlaqIOPkKQ6lymprVTQJguSeHUO+/goaR0PYpIYtSoUo +gXylocLbUpUD9mljKpHvsxImgTmT68aqruaYS+/mwYffeTh+ApMvOpU8+6eNF8lMo 8geTWlwEp1/xHVLjW2XutSVhnN99X0GFuL5gqPvonrXfwTaHOlQe6+1wsmpldeVPM7 xRGMW1nsjQh2c6Kz+/RH7GPzC7/YVEHBI4PZGgR9QG587Tn+A6Th8D9Ng0yfcdEs8/ vVBdgHwEFTnHPthL4RJPfcylpM9J1oowqkP65b1wRYCB8WDpHe9JSBWy5u3L0eownx 8EO4BeKwbuVIw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TDcg90MHxz4wc8; Tue, 16 Jan 2024 16:16:21 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 01/11] icmp: Don't set "port" on destination sockaddr for ping sockets Date: Tue, 16 Jan 2024 16:16:08 +1100 Message-ID: <20240116051618.2746103-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116051618.2746103-1-david@gibson.dropbear.id.au> References: <20240116051618.2746103-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 2V3OJDOF33WAAH5GUEKRA5IETLCEL7BD X-Message-ID-Hash: 2V3OJDOF33WAAH5GUEKRA5IETLCEL7BD 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: 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: We set the port to the ICMP id on the sendto() address when using ICMP ping sockets. However, this has no effect: the ICMP id the kernel uses is determined only by the "port" on the socket's *bound* address (which is constructed inside sock_l4(), using the id we also pass to it). For unclear reasons this change triggers cppcheck 2.13.0 to give new "variable could be const pointer" warnings, so make *ih const as well to fix that. Signed-off-by: David Gibson --- icmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/icmp.c b/icmp.c index 325dfb0..ca039f0 100644 --- a/icmp.c +++ b/icmp.c @@ -172,7 +172,7 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, .sin_addr = IN4ADDR_ANY_INIT, }; union icmp_epoll_ref iref; - struct icmphdr *ih; + const struct icmphdr *ih; int id, s; ih = packet_get(p, 0, 0, sizeof(*ih), &plen); @@ -182,8 +182,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, if (ih->type != ICMP_ECHO && ih->type != ICMP_ECHOREPLY) return 1; - sa.sin_port = ih->un.echo.id; - iref.id = id = ntohs(ih->un.echo.id); if ((s = icmp_id_map[V4][id].sock) <= 0) { @@ -219,7 +217,7 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, .sin6_scope_id = c->ifi6, }; union icmp_epoll_ref iref; - struct icmp6hdr *ih; + const struct icmp6hdr *ih; int id, s; ih = packet_get(p, 0, 0, sizeof(struct icmp6hdr), &plen); @@ -229,8 +227,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, if (ih->icmp6_type != 128 && ih->icmp6_type != 129) return 1; - sa.sin6_port = ih->icmp6_identifier; - iref.id = id = ntohs(ih->icmp6_identifier); if ((s = icmp_id_map[V6][id].sock) <= 0) { s = sock_l4(c, AF_INET6, IPPROTO_ICMPV6, -- 2.43.0