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 5CD075A027D for ; Thu, 29 Feb 2024 09:42:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709196173; bh=HYE2+Sb5OtIv5i4ra3JypXdVHYX4mwyzlceYxNXl1Mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VCPuXJkWgO9jhTM3ct2jSE6J7MVh7P/FOXSv2xLOJhbAYsQVl/gy4O38xDuSEOMRq WFReoo8a28qwVtaSY9x6Bd9sMtXxdlNejivhrhu71OedERBk3B/r4rv+Z/1tUsdayz 1tllc3cyrBakfAqQ0V5+0JhCBzYGxXtMGwL5+h8A+vNs0cLbU5dfdwB1Lyzar6i/j6 NFbmahyR1qS2c/BTZ0Q2tSHStbVXDbEtsRYTGbFTreh4FoRwlye4JrXQTZ/fPmjt0s oePEJ2NDBEx2PE9WnGRMpvlR4RIrGFNrpvCxW1I6gZRIyglpkz9tWiujwawHE9bneV 7CgYbF+toBdjQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Tll992CJNz4wyl; Thu, 29 Feb 2024 19:42:53 +1100 (AEDT) From: David Gibson To: Stefano Brivio , Laurent Vivier , passt-dev@passt.top Subject: [PATCH 4/6] udp: Consistent port variable names in udp_update_hdr[46] Date: Thu, 29 Feb 2024 19:42:48 +1100 Message-ID: <20240229084250.3202450-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240229084250.3202450-1-david@gibson.dropbear.id.au> References: <20240229084250.3202450-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: QB2RV272CWGKJNDLEV2B6HBBFV34LDNR X-Message-ID-Hash: QB2RV272CWGKJNDLEV2B6HBBFV34LDNR 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: In these functions we have 'dstport' for the destination port, but 'src_port' for the source port. Change the latter to 'srcport' for consistency. Signed-off-by: David Gibson --- udp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/udp.c b/udp.c index a07c1a62..0cca9531 100644 --- a/udp.c +++ b/udp.c @@ -589,22 +589,22 @@ static size_t udp_update_hdr4(const struct ctx *c, struct udp4_l2_buf_t *b, { size_t ip_len = datalen + sizeof(b->iph) + sizeof(b->uh); const struct in_addr *src = &b->s_in.sin_addr; - in_port_t src_port = ntohs(b->s_in.sin_port); + in_port_t srcport = ntohs(b->s_in.sin_port); if (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_match) && - IN4_ARE_ADDR_EQUAL(src, &c->ip4.dns_host) && src_port == 53) { + IN4_ARE_ADDR_EQUAL(src, &c->ip4.dns_host) && srcport == 53) { src = &c->ip4.dns_match; } else if (IN4_IS_ADDR_LOOPBACK(src) || IN4_ARE_ADDR_EQUAL(src, &c->ip4.addr_seen)) { - udp_tap_map[V4][src_port].ts = now->tv_sec; - udp_tap_map[V4][src_port].flags |= PORT_LOCAL; + udp_tap_map[V4][srcport].ts = now->tv_sec; + udp_tap_map[V4][srcport].flags |= PORT_LOCAL; if (IN4_IS_ADDR_LOOPBACK(src)) - udp_tap_map[V4][src_port].flags |= PORT_LOOPBACK; + udp_tap_map[V4][srcport].flags |= PORT_LOOPBACK; else - udp_tap_map[V4][src_port].flags &= ~PORT_LOOPBACK; + udp_tap_map[V4][srcport].flags &= ~PORT_LOOPBACK; - bitmap_set(udp_act[V4][UDP_ACT_TAP], src_port); + bitmap_set(udp_act[V4][UDP_ACT_TAP], srcport); src = &c->ip4.gw; } @@ -613,7 +613,7 @@ static size_t udp_update_hdr4(const struct ctx *c, struct udp4_l2_buf_t *b, b->iph.daddr = c->ip4.addr_seen.s_addr; b->iph.saddr = src->s_addr; udp_update_check4(b); - b->uh.source = htons(src_port); + b->uh.source = htons(srcport); b->uh.dest = htons(dstport); b->uh.len = htons(datalen + sizeof(b->uh)); @@ -637,31 +637,31 @@ static size_t udp_update_hdr6(const struct ctx *c, struct udp6_l2_buf_t *b, size_t ip_len = datalen + sizeof(b->ip6h) + sizeof(b->uh); const struct in6_addr *src = &b->s_in6.sin6_addr; const struct in6_addr *dst = &c->ip6.addr_seen; - in_port_t src_port = ntohs(b->s_in6.sin6_port); + in_port_t srcport = ntohs(b->s_in6.sin6_port); if (IN6_IS_ADDR_LINKLOCAL(src)) { dst = &c->ip6.addr_ll_seen; } else if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match) && IN6_ARE_ADDR_EQUAL(src, &c->ip6.dns_host) && - src_port == 53) { + srcport == 53) { src = &c->ip6.dns_match; } else if (IN6_IS_ADDR_LOOPBACK(src) || IN6_ARE_ADDR_EQUAL(src, &c->ip6.addr_seen) || IN6_ARE_ADDR_EQUAL(src, &c->ip6.addr)) { - udp_tap_map[V6][src_port].ts = now->tv_sec; - udp_tap_map[V6][src_port].flags |= PORT_LOCAL; + udp_tap_map[V6][srcport].ts = now->tv_sec; + udp_tap_map[V6][srcport].flags |= PORT_LOCAL; if (IN6_IS_ADDR_LOOPBACK(src)) - udp_tap_map[V6][src_port].flags |= PORT_LOOPBACK; + udp_tap_map[V6][srcport].flags |= PORT_LOOPBACK; else - udp_tap_map[V6][src_port].flags &= ~PORT_LOOPBACK; + udp_tap_map[V6][srcport].flags &= ~PORT_LOOPBACK; if (IN6_ARE_ADDR_EQUAL(src, &c->ip6.addr)) - udp_tap_map[V6][src_port].flags |= PORT_GUA; + udp_tap_map[V6][srcport].flags |= PORT_GUA; else - udp_tap_map[V6][src_port].flags &= ~PORT_GUA; + udp_tap_map[V6][srcport].flags &= ~PORT_GUA; - bitmap_set(udp_act[V6][UDP_ACT_TAP], src_port); + bitmap_set(udp_act[V6][UDP_ACT_TAP], srcport); dst = &c->ip6.addr_ll_seen; if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw)) @@ -673,7 +673,7 @@ static size_t udp_update_hdr6(const struct ctx *c, struct udp6_l2_buf_t *b, b->ip6h.payload_len = htons(datalen + sizeof(b->uh)); b->ip6h.saddr = *src; b->ip6h.daddr = *dst; - b->uh.source = htons(src_port); + b->uh.source = htons(srcport); b->uh.dest = htons(dstport); b->uh.len = b->ip6h.payload_len; -- 2.44.0