public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 2/6] udp: Consistent port variable names in udp_update_hdr[46]
Date: Wed,  6 Mar 2024 16:34:24 +1100	[thread overview]
Message-ID: <20240306053428.1176129-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240306053428.1176129-1-david@gibson.dropbear.id.au>

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 <david@gibson.dropbear.id.au>
---
 udp.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/udp.c b/udp.c
index df5f3c48..79f0a63c 100644
--- a/udp.c
+++ b/udp.c
@@ -574,7 +574,7 @@ static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport,
 {
 	struct udp4_l2_buf_t *b = &udp4_l2_buf[n];
 	const struct in_addr *src;
-	in_port_t src_port;
+	in_port_t srcport;
 	size_t ip_len;
 
 	ip_len = udp4_l2_mh_sock[n].msg_len + sizeof(b->iph) + sizeof(b->uh);
@@ -583,22 +583,22 @@ static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport,
 	b->iph.daddr = c->ip4.addr_seen.s_addr;
 
 	src = &b->s_in.sin_addr;
-	src_port = ntohs(b->s_in.sin_port);
+	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;
 	}
@@ -628,12 +628,12 @@ static size_t udp_update_hdr6(const struct ctx *c, int n, in_port_t dstport,
 	struct udp6_l2_buf_t *b = &udp6_l2_buf[n];
 	const struct in6_addr *src, *dst;
 	uint16_t payload_len;
-	in_port_t src_port;
+	in_port_t srcport;
 	size_t ip_len;
 
 	dst = &c->ip6.addr_seen;
 	src = &b->s_in6.sin6_addr;
-	src_port = ntohs(b->s_in6.sin6_port);
+	srcport = ntohs(b->s_in6.sin6_port);
 
 	ip_len = udp6_l2_mh_sock[n].msg_len + sizeof(b->ip6h) + sizeof(b->uh);
 
@@ -644,25 +644,25 @@ static size_t udp_update_hdr6(const struct ctx *c, int n, in_port_t dstport,
 		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;
 
-- 
@@ -574,7 +574,7 @@ static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport,
 {
 	struct udp4_l2_buf_t *b = &udp4_l2_buf[n];
 	const struct in_addr *src;
-	in_port_t src_port;
+	in_port_t srcport;
 	size_t ip_len;
 
 	ip_len = udp4_l2_mh_sock[n].msg_len + sizeof(b->iph) + sizeof(b->uh);
@@ -583,22 +583,22 @@ static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport,
 	b->iph.daddr = c->ip4.addr_seen.s_addr;
 
 	src = &b->s_in.sin_addr;
-	src_port = ntohs(b->s_in.sin_port);
+	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;
 	}
@@ -628,12 +628,12 @@ static size_t udp_update_hdr6(const struct ctx *c, int n, in_port_t dstport,
 	struct udp6_l2_buf_t *b = &udp6_l2_buf[n];
 	const struct in6_addr *src, *dst;
 	uint16_t payload_len;
-	in_port_t src_port;
+	in_port_t srcport;
 	size_t ip_len;
 
 	dst = &c->ip6.addr_seen;
 	src = &b->s_in6.sin6_addr;
-	src_port = ntohs(b->s_in6.sin6_port);
+	srcport = ntohs(b->s_in6.sin6_port);
 
 	ip_len = udp6_l2_mh_sock[n].msg_len + sizeof(b->ip6h) + sizeof(b->uh);
 
@@ -644,25 +644,25 @@ static size_t udp_update_hdr6(const struct ctx *c, int n, in_port_t dstport,
 		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;
 
-- 
2.44.0


  parent reply	other threads:[~2024-03-06  5:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06  5:34 [PATCH v2 0/6] udp: Small cleanups David Gibson
2024-03-06  5:34 ` [PATCH v2 1/6] udp: Refactor udp_sock[46]_iov_init() David Gibson
2024-03-06  5:34 ` David Gibson [this message]
2024-03-06  5:34 ` [PATCH v2 3/6] udp: Pass data length explicitly to to udp_update_hdr[46] David Gibson
2024-03-06  5:34 ` [PATCH v2 4/6] udp: Re-order udp_update_hdr[46] for clarity and brevity David Gibson
2024-03-06  5:34 ` [PATCH v2 5/6] udp: Avoid unnecessary pointer in udp_update_hdr4() David Gibson
2024-03-06  5:34 ` [PATCH v2 6/6] udp: Use existing helper for UDP checksum on inbound IPv6 packets David Gibson
2024-03-13 14:21 ` [PATCH v2 0/6] udp: Small cleanups Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240306053428.1176129-3-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).