From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 04/10] treewide: Remove misleading and redundant endianness notes
Date: Wed, 1 May 2024 16:53:47 +1000 [thread overview]
Message-ID: <20240501065353.1682358-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240501065353.1682358-1-david@gibson.dropbear.id.au>
In general, it's much less error-prone to have the endianness of values
implied by the type, rather than just noting it in comments. We can't
always easily avoid it, because C, but we can do so when possible. struct
in_addr and in6_addr are always encoded network endian, so noting it
explicitly isn't useful. Remove them.
In some cases we also have endianness notes on uint8_t parameters, which
doesn't make sense: for a single byte endianness is irrelevant. Remove
those too.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
checksum.c | 18 +++++++++---------
passt.h | 8 ++++----
tap.c | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/checksum.c b/checksum.c
index 9cbe0b29..a5a506c7 100644
--- a/checksum.c
+++ b/checksum.c
@@ -117,9 +117,9 @@ uint16_t csum_fold(uint32_t sum)
/**
* csum_ip4_header() - Calculate IPv4 header checksum
* @tot_len: IPv4 payload length (data + IP header, network order)
- * @protocol: Protocol number (network order)
- * @saddr: IPv4 source address (network order)
- * @daddr: IPv4 destination address (network order)
+ * @protocol: Protocol number
+ * @saddr: IPv4 source address
+ * @daddr: IPv4 destination address
*
* Return: 16-bit folded sum of the IPv4 header
*/
@@ -141,9 +141,9 @@ uint16_t csum_ip4_header(uint16_t tot_len, uint8_t protocol,
* proto_ipv4_header_psum() - Calculates the partial checksum of an
* IPv4 header for UDP or TCP
* @tot_len: IPv4 Payload length (host order)
- * @proto: Protocol number (host order)
- * @saddr: Source address (network order)
- * @daddr: Destination address (network order)
+ * @proto: Protocol number
+ * @saddr: Source address
+ * @daddr: Destination address
* Returns: Partial checksum of the IPv4 header
*/
uint32_t proto_ipv4_header_psum(uint16_t tot_len, uint8_t protocol,
@@ -206,9 +206,9 @@ void csum_icmp4(struct icmphdr *icmp4hr, const void *payload, size_t len)
* proto_ipv6_header_psum() - Calculates the partial checksum of an
* IPv6 header for UDP or TCP
* @payload_len: IPv6 payload length (host order)
- * @proto: Protocol number (host order)
- * @saddr: Source address (network order)
- * @daddr: Destination address (network order)
+ * @proto: Protocol number
+ * @saddr: Source address
+ * @daddr: Destination address
* Returns: Partial checksum of the IPv6 header
*/
uint32_t proto_ipv6_header_psum(uint16_t payload_len, uint8_t protocol,
diff --git a/passt.h b/passt.h
index 89a7d094..bc58d647 100644
--- a/passt.h
+++ b/passt.h
@@ -124,10 +124,10 @@ enum passt_modes {
* @addr: IPv4 address for external, routable interface
* @addr_seen: Latest IPv4 address seen as source from tap
* @prefixlen: IPv4 prefix length (netmask)
- * @gw: Default IPv4 gateway, network order
- * @dns: DNS addresses for DHCP, zero-terminated, network order
- * @dns_match: Forward DNS query if sent to this address, network order
- * @dns_host: Use this DNS on the host for forwarding, network order
+ * @gw: Default IPv4 gateway
+ * @dns: DNS addresses for DHCP, zero-terminated
+ * @dns_match: Forward DNS query if sent to this address
+ * @dns_host: Use this DNS on the host for forwarding
* @addr_out: Optional source address for outbound traffic
* @ifname_out: Optional interface name to bind outbound sockets to
*/
diff --git a/tap.c b/tap.c
index 13e4da79..d0ef6b5c 100644
--- a/tap.c
+++ b/tap.c
@@ -95,7 +95,7 @@ void tap_send_single(const struct ctx *c, const void *data, size_t len)
* tap_ip4_daddr() - Normal IPv4 destination address for inbound packets
* @c: Execution context
*
- * Return: IPv4 address, network order
+ * Return: IPv4 address
*/
struct in_addr tap_ip4_daddr(const struct ctx *c)
{
@@ -139,8 +139,8 @@ static void *tap_push_l2h(const struct ctx *c, void *buf, uint16_t proto)
/**
* tap_push_ip4h() - Build IPv4 header for inbound packet, with checksum
* @c: Execution context
- * @src: IPv4 source address, network order
- * @dst: IPv4 destination address, network order
+ * @src: IPv4 source address
+ * @dst: IPv4 destination address
* @len: L4 payload length
* @proto: L4 protocol number
*
--
@@ -95,7 +95,7 @@ void tap_send_single(const struct ctx *c, const void *data, size_t len)
* tap_ip4_daddr() - Normal IPv4 destination address for inbound packets
* @c: Execution context
*
- * Return: IPv4 address, network order
+ * Return: IPv4 address
*/
struct in_addr tap_ip4_daddr(const struct ctx *c)
{
@@ -139,8 +139,8 @@ static void *tap_push_l2h(const struct ctx *c, void *buf, uint16_t proto)
/**
* tap_push_ip4h() - Build IPv4 header for inbound packet, with checksum
* @c: Execution context
- * @src: IPv4 source address, network order
- * @dst: IPv4 destination address, network order
+ * @src: IPv4 source address
+ * @dst: IPv4 destination address
* @len: L4 payload length
* @proto: L4 protocol number
*
--
2.44.0
next prev parent reply other threads:[~2024-05-01 6:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 6:53 [PATCH v2 00/10] Small improvements to IOV handling David Gibson
2024-05-01 6:53 ` [PATCH v2 01/10] checksum: Use proto_ipv6_header_psum() for ICMPv6 as well David Gibson
2024-05-01 6:53 ` [PATCH v2 02/10] tap: Split tap specific and L2 (ethernet) headers David Gibson
2024-05-01 6:53 ` [PATCH v2 03/10] tap: Remove unused structs tap_msg, tap_l4_msg David Gibson
2024-05-01 6:53 ` David Gibson [this message]
2024-05-01 6:53 ` [PATCH v2 05/10] checksum: Make csum_ip4_header() take a host endian length David Gibson
2024-05-01 6:53 ` [PATCH v2 06/10] treewide: Standardise variable names for various packet lengths David Gibson
2024-05-01 6:53 ` [PATCH v2 07/10] tcp: Simplify packet length calculation when preparing headers David Gibson
2024-05-01 6:53 ` [PATCH v2 08/10] tap, tcp: (Re-)abstract TAP specific header handling David Gibson
2024-05-01 6:53 ` [PATCH v2 09/10] iov: Helper macro to construct iovs covering existing variables or fields David Gibson
2024-05-01 6:53 ` [PATCH v2 10/10] tcp: Update tap specific header too in tcp_fill_headers[46]() David Gibson
2024-05-02 14:52 ` [PATCH v2 00/10] Small improvements to IOV handling 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=20240501065353.1682358-5-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--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).