]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: Move definition of XDR_UNIT
authorChuck Lever <chuck.lever@oracle.com>
Fri, 27 Nov 2020 22:37:02 +0000 (17:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jun 2024 12:52:50 +0000 (14:52 +0200)
[ Upstream commit 81d217474326b25d7f14274b02fe3da1e85ad934 ]

Clean up: The unit of XDR alignment is defined by RFC 4506,
not as part of the RPC message header. Thus it belongs in
include/linux/sunrpc/xdr.h.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/sunrpc/msg_prot.h
include/linux/sunrpc/xdr.h

index 43f854487539b24382c44df67f1014b4ced3e92b..938c2bf29db88a5a2ec99cb5e1184158c65d9489 100644 (file)
@@ -10,9 +10,6 @@
 
 #define RPC_VERSION 2
 
-/* size of an XDR encoding unit in bytes, i.e. 32bit */
-#define XDR_UNIT       (4)
-
 /* spec defines authentication flavor as an unsigned 32 bit integer */
 typedef u32    rpc_authflavor_t;
 
index f6569b620beabeb0b5130f34de7e783365f8c251..eba6204330b3c1aae714e7d249064aa6ae2b9c6e 100644 (file)
 struct bio_vec;
 struct rpc_rqst;
 
+/*
+ * Size of an XDR encoding unit in bytes, i.e. 32 bits,
+ * as defined in Section 3 of RFC 4506. All encoded
+ * XDR data items are aligned on a boundary of 32 bits.
+ */
+#define XDR_UNIT               sizeof(__be32)
+
 /*
  * Buffer adjustment
  */
@@ -329,7 +336,7 @@ ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str,
 static inline size_t
 xdr_align_size(size_t n)
 {
-       const size_t mask = sizeof(__u32) - 1;
+       const size_t mask = XDR_UNIT - 1;
 
        return (n + mask) & ~mask;
 }
@@ -359,7 +366,7 @@ static inline size_t xdr_pad_size(size_t n)
  */
 static inline ssize_t xdr_stream_encode_item_present(struct xdr_stream *xdr)
 {
-       const size_t len = sizeof(__be32);
+       const size_t len = XDR_UNIT;
        __be32 *p = xdr_reserve_space(xdr, len);
 
        if (unlikely(!p))
@@ -378,7 +385,7 @@ static inline ssize_t xdr_stream_encode_item_present(struct xdr_stream *xdr)
  */
 static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr)
 {
-       const size_t len = sizeof(__be32);
+       const size_t len = XDR_UNIT;
        __be32 *p = xdr_reserve_space(xdr, len);
 
        if (unlikely(!p))