All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net, uapi: remove inclusion of arpa/inet.h
@ 2022-03-29 21:29 Nick Desaulniers
  2022-03-29 21:50 ` Nick Desaulniers
  0 siblings, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 21:29 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue
  Cc: Nick Desaulniers, Nathan Chancellor, netdev, tipc-discussion,
	linux-kernel, llvm

Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
from Android's SDK, I encountered an error:

  HDRTEST usr/include/linux/fsi.h
In file included from <built-in>:1:
In file included from ./usr/include/linux/tipc_config.h:46:
prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
error: unknown type name 'in_addr_t'
in_addr_t inet_addr(const char* __s);
^

This is because Bionic has a bug in its inclusion chain. I sent a patch
to fix that, but looking closer at include/uapi/linux/tipc_config.h,
there's a comment that it includes arpa/inet.h for ntohs; but ntohs is
already defined in include/linux/byteorder/generic.h which is already
included in include/uapi/linux/tipc_config.h. There are no __KERNEL__
guards on include/linux/byteorder/generic.h's definition of ntohs. So
besides fixing Bionic, it looks like we can additionally remove this
unnecessary header inclusion.

Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 include/uapi/linux/tipc_config.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 4dfc05651c98..b38374d5f192 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -43,10 +43,6 @@
 #include <linux/tipc.h>
 #include <asm/byteorder.h>
 
-#ifndef __KERNEL__
-#include <arpa/inet.h> /* for ntohs etc. */
-#endif
-
 /*
  * Configuration
  *

base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
prerequisite-patch-id: 0c2abf2af8051f4b37a70ef11b7d2fc2a3ec7181
-- 
2.35.1.1021.g381101b075-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 21:29 [PATCH] net, uapi: remove inclusion of arpa/inet.h Nick Desaulniers
@ 2022-03-29 21:50 ` Nick Desaulniers
  2022-03-29 22:09   ` Nick Desaulniers
  0 siblings, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 21:50 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada
  Cc: Nathan Chancellor, netdev, tipc-discussion, linux-kernel, llvm

On Tue, Mar 29, 2022 at 2:29 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> from Android's SDK, I encountered an error:
>
>   HDRTEST usr/include/linux/fsi.h
> In file included from <built-in>:1:
> In file included from ./usr/include/linux/tipc_config.h:46:
> prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> error: unknown type name 'in_addr_t'
> in_addr_t inet_addr(const char* __s);
> ^

Oh, this might not quite be the correct fix for this particular issue.

Cherry picking this diff back into my Android kernel tree, I now observe:
  HDRTEST usr/include/linux/tipc_config.h
In file included from <built-in>:1:
./usr/include/linux/tipc_config.h:268:4: error: implicit declaration
of function 'ntohs' [-Werror,-Wimplicit-function-declaration]
                (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
                 ^

Is there more than one byteorder.h? Oh, I see what I did; ntohs is defined in
linux/byteorder/generic.h
not
usr/include/asm/byteorder.h
Sorry, I saw `byteorder` and mixed up the path with the filename.

So rather than just remove the latter, I should additionally be adding
the former. Though that then produces

common/include/linux/byteorder/generic.h:146:9: error: implicit
declaration of function '__cpu_to_le16'
[-Werror,-Wimplicit-function-declaration]
        *var = cpu_to_le16(le16_to_cpu(*var) + val);
               ^

Oh?

>
> This is because Bionic has a bug in its inclusion chain. I sent a patch
> to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> there's a comment that it includes arpa/inet.h for ntohs; but ntohs is
> already defined in include/linux/byteorder/generic.h which is already
> included in include/uapi/linux/tipc_config.h. There are no __KERNEL__
> guards on include/linux/byteorder/generic.h's definition of ntohs. So
> besides fixing Bionic, it looks like we can additionally remove this
> unnecessary header inclusion.
>
> Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  include/uapi/linux/tipc_config.h | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> index 4dfc05651c98..b38374d5f192 100644
> --- a/include/uapi/linux/tipc_config.h
> +++ b/include/uapi/linux/tipc_config.h
> @@ -43,10 +43,6 @@
>  #include <linux/tipc.h>
>  #include <asm/byteorder.h>
>
> -#ifndef __KERNEL__
> -#include <arpa/inet.h> /* for ntohs etc. */
> -#endif
> -
>  /*
>   * Configuration
>   *
>
> base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
> prerequisite-patch-id: 0c2abf2af8051f4b37a70ef11b7d2fc2a3ec7181
> --
> 2.35.1.1021.g381101b075-goog
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 21:50 ` Nick Desaulniers
@ 2022-03-29 22:09   ` Nick Desaulniers
  2022-03-29 22:26     ` Nick Desaulniers
  2022-03-29 23:03     ` Nick Desaulniers
  0 siblings, 2 replies; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 22:09 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada
  Cc: Nathan Chancellor, netdev, tipc-discussion, linux-kernel, llvm,
	David Howells

On Tue, Mar 29, 2022 at 2:50 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Tue, Mar 29, 2022 at 2:29 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> > from Android's SDK, I encountered an error:
> >
> >   HDRTEST usr/include/linux/fsi.h
> > In file included from <built-in>:1:
> > In file included from ./usr/include/linux/tipc_config.h:46:
> > prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> > error: unknown type name 'in_addr_t'
> > in_addr_t inet_addr(const char* __s);
> > ^
>
> Oh, this might not quite be the correct fix for this particular issue.
>
> Cherry picking this diff back into my Android kernel tree, I now observe:
>   HDRTEST usr/include/linux/tipc_config.h
> In file included from <built-in>:1:
> ./usr/include/linux/tipc_config.h:268:4: error: implicit declaration
> of function 'ntohs' [-Werror,-Wimplicit-function-declaration]
>                 (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
>                  ^
>
> Is there more than one byteorder.h? Oh, I see what I did; ntohs is defined in
> linux/byteorder/generic.h
> not
> usr/include/asm/byteorder.h
> Sorry, I saw `byteorder` and mixed up the path with the filename.
>
> So rather than just remove the latter, I should additionally be adding
> the former. Though that then produces
>
> common/include/linux/byteorder/generic.h:146:9: error: implicit
> declaration of function '__cpu_to_le16'
> [-Werror,-Wimplicit-function-declaration]
>         *var = cpu_to_le16(le16_to_cpu(*var) + val);
>                ^
>
> Oh?

Should there be a definition of ntohs (and friends) under
include/uapi/linux/ somewhere, rather than have the kernel header
include/uapi/linux/tipc_config.h depend on the libc header
arpa/inet.h?

It looks like we already have
include/uapi/linux/byteorder/{big|little}_endian.h to define
__be16_to_cpu and friends, just no definition of ntohs under
include/uapi/linux/.

Also, it looks like include/uapi/linux/ has definitions for
__constant_ntohs in
include/uapi/linux/byteorder/{big|little}_endian.h.  Should those 2
headers also define ntohs (and friends) unprefixed, i.e. the versions
that don't depend on constant expressions?

(I wish there was an entry in MAINTAINERS for UAPI questions like this...)

>
> >
> > This is because Bionic has a bug in its inclusion chain. I sent a patch
> > to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> > there's a comment that it includes arpa/inet.h for ntohs; but ntohs is
> > already defined in include/linux/byteorder/generic.h which is already
> > included in include/uapi/linux/tipc_config.h. There are no __KERNEL__
> > guards on include/linux/byteorder/generic.h's definition of ntohs. So
> > besides fixing Bionic, it looks like we can additionally remove this
> > unnecessary header inclusion.
> >
> > Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > ---
> >  include/uapi/linux/tipc_config.h | 4 ----
> >  1 file changed, 4 deletions(-)
> >
> > diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> > index 4dfc05651c98..b38374d5f192 100644
> > --- a/include/uapi/linux/tipc_config.h
> > +++ b/include/uapi/linux/tipc_config.h
> > @@ -43,10 +43,6 @@
> >  #include <linux/tipc.h>
> >  #include <asm/byteorder.h>
> >
> > -#ifndef __KERNEL__
> > -#include <arpa/inet.h> /* for ntohs etc. */
> > -#endif
> > -
> >  /*
> >   * Configuration
> >   *
> >
> > base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
> > prerequisite-patch-id: 0c2abf2af8051f4b37a70ef11b7d2fc2a3ec7181
> > --
> > 2.35.1.1021.g381101b075-goog
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 22:09   ` Nick Desaulniers
@ 2022-03-29 22:26     ` Nick Desaulniers
  2022-03-29 22:39       ` [PATCH v2] " Nick Desaulniers
  2022-03-30  6:08       ` [PATCH] " Arnd Bergmann
  2022-03-29 23:03     ` Nick Desaulniers
  1 sibling, 2 replies; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 22:26 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada
  Cc: Nathan Chancellor, netdev, tipc-discussion, linux-kernel, llvm,
	David Howells

On Tue, Mar 29, 2022 at 3:09 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Tue, Mar 29, 2022 at 2:50 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Tue, Mar 29, 2022 at 2:29 PM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> > > from Android's SDK, I encountered an error:
> > >
> > >   HDRTEST usr/include/linux/fsi.h
> > > In file included from <built-in>:1:
> > > In file included from ./usr/include/linux/tipc_config.h:46:
> > > prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> > > error: unknown type name 'in_addr_t'
> > > in_addr_t inet_addr(const char* __s);
> > > ^
> >
> > Oh, this might not quite be the correct fix for this particular issue.
> >
> > Cherry picking this diff back into my Android kernel tree, I now observe:
> >   HDRTEST usr/include/linux/tipc_config.h
> > In file included from <built-in>:1:
> > ./usr/include/linux/tipc_config.h:268:4: error: implicit declaration
> > of function 'ntohs' [-Werror,-Wimplicit-function-declaration]
> >                 (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
> >                  ^
> >
> > Is there more than one byteorder.h? Oh, I see what I did; ntohs is defined in
> > linux/byteorder/generic.h
> > not
> > usr/include/asm/byteorder.h
> > Sorry, I saw `byteorder` and mixed up the path with the filename.
> >
> > So rather than just remove the latter, I should additionally be adding
> > the former. Though that then produces
> >
> > common/include/linux/byteorder/generic.h:146:9: error: implicit
> > declaration of function '__cpu_to_le16'
> > [-Werror,-Wimplicit-function-declaration]
> >         *var = cpu_to_le16(le16_to_cpu(*var) + val);
> >                ^
> >
> > Oh?
>
> Should there be a definition of ntohs (and friends) under
> include/uapi/linux/ somewhere, rather than have the kernel header
> include/uapi/linux/tipc_config.h depend on the libc header
> arpa/inet.h?
>
> It looks like we already have
> include/uapi/linux/byteorder/{big|little}_endian.h to define
> __be16_to_cpu and friends, just no definition of ntohs under
> include/uapi/linux/.
>
> Also, it looks like include/uapi/linux/ has definitions for
> __constant_ntohs in
> include/uapi/linux/byteorder/{big|little}_endian.h.  Should those 2
> headers also define ntohs (and friends) unprefixed, i.e. the versions
> that don't depend on constant expressions?

I think the answer is yes; in addition to the diff in this patch, the
following seems to be working:
```
diff --git a/include/uapi/linux/byteorder/little_endian.h
b/include/uapi/linux/byteorder/little_endian.h
index cd98982e7523..c14f2c3728e2 100644
--- a/include/uapi/linux/byteorder/little_endian.h
+++ b/include/uapi/linux/byteorder/little_endian.h
@@ -103,5 +103,8 @@ static __always_inline __u16 __be16_to_cpup(const __be16 *p)
 #define __cpu_to_be16s(x) __swab16s((x))
 #define __be16_to_cpus(x) __swab16s((x))

+#define htonl(x) __cpu_to_be32(x)
+#define htons(x) __cpu_to_be16(x)
+#define ntohs(x) __be16_to_cpu(x)

 #endif /* _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H */
```
I think if I flush out the rest for both endiannesses, then we should
be in good shape?

>
> (I wish there was an entry in MAINTAINERS for UAPI questions like this...)
>
> >
> > >
> > > This is because Bionic has a bug in its inclusion chain. I sent a patch
> > > to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> > > there's a comment that it includes arpa/inet.h for ntohs; but ntohs is
> > > already defined in include/linux/byteorder/generic.h which is already
> > > included in include/uapi/linux/tipc_config.h. There are no __KERNEL__
> > > guards on include/linux/byteorder/generic.h's definition of ntohs. So
> > > besides fixing Bionic, it looks like we can additionally remove this
> > > unnecessary header inclusion.
> > >
> > > Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > ---
> > >  include/uapi/linux/tipc_config.h | 4 ----
> > >  1 file changed, 4 deletions(-)
> > >
> > > diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> > > index 4dfc05651c98..b38374d5f192 100644
> > > --- a/include/uapi/linux/tipc_config.h
> > > +++ b/include/uapi/linux/tipc_config.h
> > > @@ -43,10 +43,6 @@
> > >  #include <linux/tipc.h>
> > >  #include <asm/byteorder.h>
> > >
> > > -#ifndef __KERNEL__
> > > -#include <arpa/inet.h> /* for ntohs etc. */
> > > -#endif
> > > -
> > >  /*
> > >   * Configuration
> > >   *
> > >
> > > base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
> > > prerequisite-patch-id: 0c2abf2af8051f4b37a70ef11b7d2fc2a3ec7181
> > > --
> > > 2.35.1.1021.g381101b075-goog
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
>
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 22:26     ` Nick Desaulniers
@ 2022-03-29 22:39       ` Nick Desaulniers
  2022-03-29 23:01         ` Jakub Kicinski
  2022-03-30  6:08       ` [PATCH] " Arnd Bergmann
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 22:39 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue
  Cc: Arnd Bergmann, Masahiro Yamada, David Howells, Nick Desaulniers,
	Nathan Chancellor, netdev, tipc-discussion, linux-kernel, llvm

Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
from Android's SDK, I encountered an error:

  HDRTEST usr/include/linux/fsi.h
In file included from <built-in>:1:
In file included from ./usr/include/linux/tipc_config.h:46:
prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
error: unknown type name 'in_addr_t'
in_addr_t inet_addr(const char* __s);
^

This is because Bionic has a bug in its inclusion chain. I sent a patch
to fix that, but looking closer at include/uapi/linux/tipc_config.h,
there's a comment that it includes arpa/inet.h for ntohs;
but ntohs is not defined in any UAPI header. For now, reuse the
definitions from include/linux/byteorder/generic.h, since the various
conversion functions do exist in UAPI headers:
include/uapi/linux/byteorder/big_endian.h
include/uapi/linux/byteorder/little_endian.h

Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 include/uapi/linux/tipc_config.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 4dfc05651c98..2c494b7ae008 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -43,10 +43,6 @@
 #include <linux/tipc.h>
 #include <asm/byteorder.h>
 
-#ifndef __KERNEL__
-#include <arpa/inet.h> /* for ntohs etc. */
-#endif
-
 /*
  * Configuration
  *
@@ -257,6 +253,10 @@ struct tlv_desc {
 #define TLV_SPACE(datalen) (TLV_ALIGN(TLV_LENGTH(datalen)))
 #define TLV_DATA(tlv) ((void *)((char *)(tlv) + TLV_LENGTH(0)))
 
+#define __htonl(x) __cpu_to_be32(x)
+#define __htons(x) __cpu_to_be16(x)
+#define __ntohs(x) __be16_to_cpu(x)
+
 static inline int TLV_OK(const void *tlv, __u16 space)
 {
 	/*
@@ -269,33 +269,33 @@ static inline int TLV_OK(const void *tlv, __u16 space)
 	 */
 
 	return (space >= TLV_SPACE(0)) &&
-		(ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
+		(__ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
 }
 
 static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
 {
 	return TLV_OK(tlv, space) &&
-		(ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
+		(__ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
 }
 
 static inline int TLV_GET_LEN(struct tlv_desc *tlv)
 {
-	return ntohs(tlv->tlv_len);
+	return __ntohs(tlv->tlv_len);
 }
 
 static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
 {
-	tlv->tlv_len = htons(len);
+	tlv->tlv_len = __htons(len);
 }
 
 static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv,  __u16 type)
 {
-	return (ntohs(tlv->tlv_type) == type);
+	return (__ntohs(tlv->tlv_type) == type);
 }
 
 static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
 {
-	tlv->tlv_type = htons(type);
+	tlv->tlv_type = __htons(type);
 }
 
 static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
@@ -305,8 +305,8 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
 
 	tlv_len = TLV_LENGTH(len);
 	tlv_ptr = (struct tlv_desc *)tlv;
-	tlv_ptr->tlv_type = htons(type);
-	tlv_ptr->tlv_len  = htons(tlv_len);
+	tlv_ptr->tlv_type = __htons(type);
+	tlv_ptr->tlv_len  = __htons(tlv_len);
 	if (len && data) {
 		memcpy(TLV_DATA(tlv_ptr), data, len);
 		memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);
@@ -348,7 +348,7 @@ static inline void *TLV_LIST_DATA(struct tlv_list_desc *list)
 
 static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
 {
-	__u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
+	__u16 tlv_space = TLV_ALIGN(__ntohs(list->tlv_ptr->tlv_len));
 
 	list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
 	list->tlv_space -= tlv_space;
@@ -404,9 +404,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags,
 
 	msg_len = TCM_LENGTH(data_len);
 	tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
-	tcm_hdr->tcm_len   = htonl(msg_len);
-	tcm_hdr->tcm_type  = htons(cmd);
-	tcm_hdr->tcm_flags = htons(flags);
+	tcm_hdr->tcm_len   = __htonl(msg_len);
+	tcm_hdr->tcm_type  = __htons(cmd);
+	tcm_hdr->tcm_flags = __htons(flags);
 	if (data_len && data) {
 		memcpy(TCM_DATA(msg), data, data_len);
 		memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);

base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
-- 
2.35.1.1021.g381101b075-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 22:39       ` [PATCH v2] " Nick Desaulniers
@ 2022-03-29 23:01         ` Jakub Kicinski
  2022-03-29 23:12           ` Nick Desaulniers
  2022-04-04 17:54           ` [PATCH net-next v3] " Nick Desaulniers
  0 siblings, 2 replies; 12+ messages in thread
From: Jakub Kicinski @ 2022-03-29 23:01 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada,
	David Howells, Nathan Chancellor, netdev, tipc-discussion,
	linux-kernel, llvm

On Tue, 29 Mar 2022 15:39:56 -0700 Nick Desaulniers wrote:
> Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> from Android's SDK, I encountered an error:
> 
>   HDRTEST usr/include/linux/fsi.h
> In file included from <built-in>:1:
> In file included from ./usr/include/linux/tipc_config.h:46:
> prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> error: unknown type name 'in_addr_t'
> in_addr_t inet_addr(const char* __s);
> ^
> 
> This is because Bionic has a bug in its inclusion chain. I sent a patch
> to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> there's a comment that it includes arpa/inet.h for ntohs;
> but ntohs is not defined in any UAPI header. For now, reuse the
> definitions from include/linux/byteorder/generic.h, since the various
> conversion functions do exist in UAPI headers:
> include/uapi/linux/byteorder/big_endian.h
> include/uapi/linux/byteorder/little_endian.h
> 
> Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  include/uapi/linux/tipc_config.h | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> index 4dfc05651c98..2c494b7ae008 100644
> --- a/include/uapi/linux/tipc_config.h
> +++ b/include/uapi/linux/tipc_config.h
> @@ -43,10 +43,6 @@
>  #include <linux/tipc.h>
>  #include <asm/byteorder.h>
>  
> -#ifndef __KERNEL__
> -#include <arpa/inet.h> /* for ntohs etc. */
> -#endif

Hm, how do we know no user space depends on this include?

If nobody screams at us we can try, but then it needs to go into -next,
and net-next is closed ATM, you'll need to repost once the merge window
is over.

>  /*
>   * Configuration
>   *
> @@ -257,6 +253,10 @@ struct tlv_desc {
>  #define TLV_SPACE(datalen) (TLV_ALIGN(TLV_LENGTH(datalen)))
>  #define TLV_DATA(tlv) ((void *)((char *)(tlv) + TLV_LENGTH(0)))
>  
> +#define __htonl(x) __cpu_to_be32(x)
> +#define __htons(x) __cpu_to_be16(x)
> +#define __ntohs(x) __be16_to_cpu(x)
> +
>  static inline int TLV_OK(const void *tlv, __u16 space)
>  {
>  	/*
> @@ -269,33 +269,33 @@ static inline int TLV_OK(const void *tlv, __u16 space)
>  	 */
>  
>  	return (space >= TLV_SPACE(0)) &&
> -		(ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
> +		(__ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);

Also why add the defines / macros? 
We could switch to __cpu_to_be16() etc. directly, it seems.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 22:09   ` Nick Desaulniers
  2022-03-29 22:26     ` Nick Desaulniers
@ 2022-03-29 23:03     ` Nick Desaulniers
  1 sibling, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 23:03 UTC (permalink / raw)
  To: Masahiro Yamada, Arnd Bergmann
  Cc: Nathan Chancellor, netdev, tipc-discussion, linux-kernel, llvm,
	David Howells, Ying Xue, Jon Maloy, David Woodhouse, Greg KH,
	Linus Torvalds

On Tue, Mar 29, 2022 at 3:09 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Tue, Mar 29, 2022 at 2:50 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Tue, Mar 29, 2022 at 2:29 PM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> > > from Android's SDK, I encountered an error:
> > >
> > >   HDRTEST usr/include/linux/fsi.h
> > > In file included from <built-in>:1:
> > > In file included from ./usr/include/linux/tipc_config.h:46:
> > > prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> > > error: unknown type name 'in_addr_t'
> > > in_addr_t inet_addr(const char* __s);
> > > ^
> >
> > Oh, this might not quite be the correct fix for this particular issue.
> >
> > Cherry picking this diff back into my Android kernel tree, I now observe:
> >   HDRTEST usr/include/linux/tipc_config.h
> > In file included from <built-in>:1:
> > ./usr/include/linux/tipc_config.h:268:4: error: implicit declaration
> > of function 'ntohs' [-Werror,-Wimplicit-function-declaration]
> >                 (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
> >                  ^
> >
> > Is there more than one byteorder.h? Oh, I see what I did; ntohs is defined in
> > linux/byteorder/generic.h
> > not
> > usr/include/asm/byteorder.h
> > Sorry, I saw `byteorder` and mixed up the path with the filename.
> >
> > So rather than just remove the latter, I should additionally be adding
> > the former. Though that then produces
> >
> > common/include/linux/byteorder/generic.h:146:9: error: implicit
> > declaration of function '__cpu_to_le16'
> > [-Werror,-Wimplicit-function-declaration]
> >         *var = cpu_to_le16(le16_to_cpu(*var) + val);
> >                ^
> >
> > Oh?
>
> Should there be a definition of ntohs (and friends) under
> include/uapi/linux/ somewhere, rather than have the kernel header
> include/uapi/linux/tipc_config.h depend on the libc header
> arpa/inet.h?
>
> It looks like we already have
> include/uapi/linux/byteorder/{big|little}_endian.h to define
> __be16_to_cpu and friends, just no definition of ntohs under
> include/uapi/linux/.
>
> Also, it looks like include/uapi/linux/ has definitions for
> __constant_ntohs in
> include/uapi/linux/byteorder/{big|little}_endian.h.  Should those 2
> headers also define ntohs (and friends) unprefixed, i.e. the versions
> that don't depend on constant expressions?
>
> (I wish there was an entry in MAINTAINERS for UAPI questions like this...)

I also think that Documentation/kbuild/headers_install.rst should
probably include text from
https://lore.kernel.org/all/Pine.LNX.4.58.0411281710490.22796@ppc970.osdl.org/
or something along the lines of "kernel headers MUST NOT depend on
userspace headers; any instance of that in tree is a bug that should
be fixed."

For people I just cc'ed, here's the lore link to this thread:
https://lore.kernel.org/lkml/20220329212946.2861648-1-ndesaulniers@google.com/

>
> >
> > >
> > > This is because Bionic has a bug in its inclusion chain. I sent a patch
> > > to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> > > there's a comment that it includes arpa/inet.h for ntohs; but ntohs is
> > > already defined in include/linux/byteorder/generic.h which is already
> > > included in include/uapi/linux/tipc_config.h. There are no __KERNEL__
> > > guards on include/linux/byteorder/generic.h's definition of ntohs. So
> > > besides fixing Bionic, it looks like we can additionally remove this
> > > unnecessary header inclusion.
> > >
> > > Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > ---
> > >  include/uapi/linux/tipc_config.h | 4 ----
> > >  1 file changed, 4 deletions(-)
> > >
> > > diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> > > index 4dfc05651c98..b38374d5f192 100644
> > > --- a/include/uapi/linux/tipc_config.h
> > > +++ b/include/uapi/linux/tipc_config.h
> > > @@ -43,10 +43,6 @@
> > >  #include <linux/tipc.h>
> > >  #include <asm/byteorder.h>
> > >
> > > -#ifndef __KERNEL__
> > > -#include <arpa/inet.h> /* for ntohs etc. */
> > > -#endif
> > > -
> > >  /*
> > >   * Configuration
> > >   *
> > >
> > > base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf
> > > prerequisite-patch-id: 0c2abf2af8051f4b37a70ef11b7d2fc2a3ec7181
> > > --
> > > 2.35.1.1021.g381101b075-goog
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
>
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 23:01         ` Jakub Kicinski
@ 2022-03-29 23:12           ` Nick Desaulniers
  2022-04-04 17:54           ` [PATCH net-next v3] " Nick Desaulniers
  1 sibling, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2022-03-29 23:12 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada,
	David Howells, Nathan Chancellor, netdev, tipc-discussion,
	linux-kernel, llvm, Linus Torvalds

On Tue, Mar 29, 2022 at 4:01 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 29 Mar 2022 15:39:56 -0700 Nick Desaulniers wrote:
> > Testing out CONFIG_UAPI_HEADER_TEST=y with a prebuilt Bionic sysroot
> > from Android's SDK, I encountered an error:
> >
> >   HDRTEST usr/include/linux/fsi.h
> > In file included from <built-in>:1:
> > In file included from ./usr/include/linux/tipc_config.h:46:
> > prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arpa/inet.h:39:1:
> > error: unknown type name 'in_addr_t'
> > in_addr_t inet_addr(const char* __s);
> > ^
> >
> > This is because Bionic has a bug in its inclusion chain. I sent a patch
> > to fix that, but looking closer at include/uapi/linux/tipc_config.h,
> > there's a comment that it includes arpa/inet.h for ntohs;
> > but ntohs is not defined in any UAPI header. For now, reuse the
> > definitions from include/linux/byteorder/generic.h, since the various
> > conversion functions do exist in UAPI headers:
> > include/uapi/linux/byteorder/big_endian.h
> > include/uapi/linux/byteorder/little_endian.h
> >
> > Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > ---
> >  include/uapi/linux/tipc_config.h | 32 ++++++++++++++++----------------
> >  1 file changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
> > index 4dfc05651c98..2c494b7ae008 100644
> > --- a/include/uapi/linux/tipc_config.h
> > +++ b/include/uapi/linux/tipc_config.h
> > @@ -43,10 +43,6 @@
> >  #include <linux/tipc.h>
> >  #include <asm/byteorder.h>
> >
> > -#ifndef __KERNEL__
> > -#include <arpa/inet.h> /* for ntohs etc. */
> > -#endif
>
> Hm, how do we know no user space depends on this include?

Without the ability to scan all source code in existence, I guess I
can't prove or disprove that either way.

If this is a reference to "thou shall not break userspace," I don't
think that was in reference to UAPI headers, libc's, or inclusion
chains.

Worst case, someone might have to #include <arpa/inet.h> if they were
relying on transitive dependencies from <linux/tipc_config.h>.  I
don't think we should be helping people write bad code with such
transitive dependencies though.

>
> If nobody screams at us we can try, but then it needs to go into -next,
> and net-next is closed ATM, you'll need to repost once the merge window
> is over.

Ack.

>
> >  /*
> >   * Configuration
> >   *
> > @@ -257,6 +253,10 @@ struct tlv_desc {
> >  #define TLV_SPACE(datalen) (TLV_ALIGN(TLV_LENGTH(datalen)))
> >  #define TLV_DATA(tlv) ((void *)((char *)(tlv) + TLV_LENGTH(0)))
> >
> > +#define __htonl(x) __cpu_to_be32(x)
> > +#define __htons(x) __cpu_to_be16(x)
> > +#define __ntohs(x) __be16_to_cpu(x)
> > +
> >  static inline int TLV_OK(const void *tlv, __u16 space)
> >  {
> >       /*
> > @@ -269,33 +269,33 @@ static inline int TLV_OK(const void *tlv, __u16 space)
> >        */
> >
> >       return (space >= TLV_SPACE(0)) &&
> > -             (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
> > +             (__ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
>
> Also why add the defines / macros?
> We could switch to __cpu_to_be16() etc. directly, it seems.

Sure, I thought they might be more readable, but whatever you all
prefer.  Will send a v3 once the merge window closes.
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 22:26     ` Nick Desaulniers
  2022-03-29 22:39       ` [PATCH v2] " Nick Desaulniers
@ 2022-03-30  6:08       ` Arnd Bergmann
  2022-03-30  6:11         ` Arnd Bergmann
  1 sibling, 1 reply; 12+ messages in thread
From: Arnd Bergmann @ 2022-03-30  6:08 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada,
	Nathan Chancellor, Networking, tipc-discussion,
	Linux Kernel Mailing List, llvm, David Howells

On Wed, Mar 30, 2022 at 12:26 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
> On Tue, Mar 29, 2022 at 3:09 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
> ```
> diff --git a/include/uapi/linux/byteorder/little_endian.h
> b/include/uapi/linux/byteorder/little_endian.h
> index cd98982e7523..c14f2c3728e2 100644
> --- a/include/uapi/linux/byteorder/little_endian.h
> +++ b/include/uapi/linux/byteorder/little_endian.h
> @@ -103,5 +103,8 @@ static __always_inline __u16 __be16_to_cpup(const __be16 *p)
>  #define __cpu_to_be16s(x) __swab16s((x))
>  #define __be16_to_cpus(x) __swab16s((x))
>
> +#define htonl(x) __cpu_to_be32(x)
> +#define htons(x) __cpu_to_be16(x)
> +#define ntohs(x) __be16_to_cpu(x)
>

This is unfortunately a namespace violation, you can't define things in uapi
headers that conflict with standard library interfaces.

         Arnd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net, uapi: remove inclusion of arpa/inet.h
  2022-03-30  6:08       ` [PATCH] " Arnd Bergmann
@ 2022-03-30  6:11         ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2022-03-30  6:11 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Nick Desaulniers, Jon Maloy, Ying Xue, Masahiro Yamada,
	Nathan Chancellor, Networking, tipc-discussion,
	Linux Kernel Mailing List, llvm, David Howells

On Wed, Mar 30, 2022 at 8:08 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Wed, Mar 30, 2022 at 12:26 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> > On Tue, Mar 29, 2022 at 3:09 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
> > ```
> > diff --git a/include/uapi/linux/byteorder/little_endian.h
> > b/include/uapi/linux/byteorder/little_endian.h
> > index cd98982e7523..c14f2c3728e2 100644
> > --- a/include/uapi/linux/byteorder/little_endian.h
> > +++ b/include/uapi/linux/byteorder/little_endian.h
> > @@ -103,5 +103,8 @@ static __always_inline __u16 __be16_to_cpup(const __be16 *p)
> >  #define __cpu_to_be16s(x) __swab16s((x))
> >  #define __be16_to_cpus(x) __swab16s((x))
> >
> > +#define htonl(x) __cpu_to_be32(x)
> > +#define htons(x) __cpu_to_be16(x)
> > +#define ntohs(x) __be16_to_cpu(x)
> >
>
> This is unfortunately a namespace violation, you can't define things in uapi
> headers that conflict with standard library interfaces.

nevermind, I just saw the thread continues and you arrived at a good solution
withusing the __cpu_to_be16() etc directly.

       Arnd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next v3] net, uapi: remove inclusion of arpa/inet.h
  2022-03-29 23:01         ` Jakub Kicinski
  2022-03-29 23:12           ` Nick Desaulniers
@ 2022-04-04 17:54           ` Nick Desaulniers
  2022-04-06 13:10             ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2022-04-04 17:54 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jon Maloy, Ying Xue, Arnd Bergmann, Masahiro Yamada,
	David Howells, Nick Desaulniers, netdev, tipc-discussion,
	linux-kernel

In include/uapi/linux/tipc_config.h, there's a comment that it includes
arpa/inet.h for ntohs; but ntohs is not defined in any UAPI header. For
now, reuse the definitions from include/linux/byteorder/generic.h, since
the various conversion functions do exist in UAPI headers:
include/uapi/linux/byteorder/big_endian.h
include/uapi/linux/byteorder/little_endian.h

We would like to get to the point where we can build UAPI header tests
with -nostdinc, meaning that kernel UAPI headers should not have a
circular dependency on libc headers.

Link: https://android-review.googlesource.com/c/platform/bionic/+/2048127
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Changes V2 -> V3:
* Use __be16_to_cpu and friends directly.
* Rebase on net-next now that the merge window is closed.
* Cut down commit message.
Changes V1 -> V2:
* Fix broken patch.

 include/uapi/linux/tipc_config.h | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 4dfc05651c98..c00adf2fe868 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -43,10 +43,6 @@
 #include <linux/tipc.h>
 #include <asm/byteorder.h>
 
-#ifndef __KERNEL__
-#include <arpa/inet.h> /* for ntohs etc. */
-#endif
-
 /*
  * Configuration
  *
@@ -269,33 +265,33 @@ static inline int TLV_OK(const void *tlv, __u16 space)
 	 */
 
 	return (space >= TLV_SPACE(0)) &&
-		(ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
+		(__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_len) <= space);
 }
 
 static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
 {
 	return TLV_OK(tlv, space) &&
-		(ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
+		(__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
 }
 
 static inline int TLV_GET_LEN(struct tlv_desc *tlv)
 {
-	return ntohs(tlv->tlv_len);
+	return __be16_to_cpu(tlv->tlv_len);
 }
 
 static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
 {
-	tlv->tlv_len = htons(len);
+	tlv->tlv_len = __cpu_to_be16(len);
 }
 
 static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv,  __u16 type)
 {
-	return (ntohs(tlv->tlv_type) == type);
+	return (__be16_to_cpu(tlv->tlv_type) == type);
 }
 
 static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
 {
-	tlv->tlv_type = htons(type);
+	tlv->tlv_type = __cpu_to_be16(type);
 }
 
 static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
@@ -305,8 +301,8 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
 
 	tlv_len = TLV_LENGTH(len);
 	tlv_ptr = (struct tlv_desc *)tlv;
-	tlv_ptr->tlv_type = htons(type);
-	tlv_ptr->tlv_len  = htons(tlv_len);
+	tlv_ptr->tlv_type = __cpu_to_be16(type);
+	tlv_ptr->tlv_len  = __cpu_to_be16(tlv_len);
 	if (len && data) {
 		memcpy(TLV_DATA(tlv_ptr), data, len);
 		memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);
@@ -348,7 +344,7 @@ static inline void *TLV_LIST_DATA(struct tlv_list_desc *list)
 
 static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
 {
-	__u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
+	__u16 tlv_space = TLV_ALIGN(__be16_to_cpu(list->tlv_ptr->tlv_len));
 
 	list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
 	list->tlv_space -= tlv_space;
@@ -404,9 +400,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags,
 
 	msg_len = TCM_LENGTH(data_len);
 	tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
-	tcm_hdr->tcm_len   = htonl(msg_len);
-	tcm_hdr->tcm_type  = htons(cmd);
-	tcm_hdr->tcm_flags = htons(flags);
+	tcm_hdr->tcm_len   = __cpu_to_be32(msg_len);
+	tcm_hdr->tcm_type  = __cpu_to_be16(cmd);
+	tcm_hdr->tcm_flags = __cpu_to_be16(flags);
 	if (data_len && data) {
 		memcpy(TCM_DATA(msg), data, data_len);
 		memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);
-- 
2.35.1.1094.g7c7d902a7c-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v3] net, uapi: remove inclusion of arpa/inet.h
  2022-04-04 17:54           ` [PATCH net-next v3] " Nick Desaulniers
@ 2022-04-06 13:10             ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-06 13:10 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: kuba, jmaloy, ying.xue, arnd, masahiroy, dhowells, netdev,
	tipc-discussion, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon,  4 Apr 2022 10:54:47 -0700 you wrote:
> In include/uapi/linux/tipc_config.h, there's a comment that it includes
> arpa/inet.h for ntohs; but ntohs is not defined in any UAPI header. For
> now, reuse the definitions from include/linux/byteorder/generic.h, since
> the various conversion functions do exist in UAPI headers:
> include/uapi/linux/byteorder/big_endian.h
> include/uapi/linux/byteorder/little_endian.h
> 
> [...]

Here is the summary with links:
  - [net-next,v3] net, uapi: remove inclusion of arpa/inet.h
    https://git.kernel.org/netdev/net-next/c/1ee375d77bb9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-04-06 15:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 21:29 [PATCH] net, uapi: remove inclusion of arpa/inet.h Nick Desaulniers
2022-03-29 21:50 ` Nick Desaulniers
2022-03-29 22:09   ` Nick Desaulniers
2022-03-29 22:26     ` Nick Desaulniers
2022-03-29 22:39       ` [PATCH v2] " Nick Desaulniers
2022-03-29 23:01         ` Jakub Kicinski
2022-03-29 23:12           ` Nick Desaulniers
2022-04-04 17:54           ` [PATCH net-next v3] " Nick Desaulniers
2022-04-06 13:10             ` patchwork-bot+netdevbpf
2022-03-30  6:08       ` [PATCH] " Arnd Bergmann
2022-03-30  6:11         ` Arnd Bergmann
2022-03-29 23:03     ` Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.