diff mbox series

[net-next,1/3] ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers

Message ID 20240812-ipv6_addr-helpers-v1-1-aab5d1f35c40@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 39 this patch: 39
netdev/build_tools success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 50 this patch: 50
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1903 this patch: 1903
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-13--12-00 (tests: 706)

Commit Message

Simon Horman Aug. 12, 2024, 12:11 p.m. UTC
Add helper to convert an ipv6 addr, expressed as an array
of words, from cpy to big-endian byte order.

No functional change intended.
Compile tested only.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/netdev/c7684349-535c-45a4-9a74-d47479a50020@lunn.ch/
Signed-off-by: Simon Horman <horms@kernel.org>
---
 include/net/ipv6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Andrew Lunn Aug. 12, 2024, 12:37 p.m. UTC | #1
On Mon, Aug 12, 2024 at 01:11:55PM +0100, Simon Horman wrote:
> Add helper to convert an ipv6 addr, expressed as an array
> of words, from cpy to big-endian byte order.

Hi Simon

Is cpy supposed to be cpu?

Otherwise, please add: Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Simon Horman Aug. 12, 2024, 12:50 p.m. UTC | #2
On Mon, Aug 12, 2024 at 02:37:36PM +0200, Andrew Lunn wrote:
> On Mon, Aug 12, 2024 at 01:11:55PM +0100, Simon Horman wrote:
> > Add helper to convert an ipv6 addr, expressed as an array
> > of words, from cpy to big-endian byte order.
> 
> Hi Simon
> 
> Is cpy supposed to be cpu?

Yes, sorry about that.

> 
> Otherwise, please add: Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> 
>     Andrew
>
diff mbox series

Patch

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 88a8e554f7a1..e7113855a10f 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -1365,4 +1365,16 @@  static inline void ip6_sock_set_recvpktinfo(struct sock *sk)
 	release_sock(sk);
 }
 
+#define IPV6_ADDR_WORDS 4
+
+static inline void ipv6_addr_cpu_to_be32(__be32 *dst, const u32 *src)
+{
+	cpu_to_be32_array(dst, src, IPV6_ADDR_WORDS);
+}
+
+static inline void ipv6_addr_be32_to_cpu(u32 *dst, const __be32 *src)
+{
+	be32_to_cpu_array(dst, src, IPV6_ADDR_WORDS);
+}
+
 #endif /* _NET_IPV6_H */