From nobody Fri Jun 19 20:14:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5BA8C433F5 for ; Tue, 29 Mar 2022 22:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237979AbiC2Wlr (ORCPT ); Tue, 29 Mar 2022 18:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237738AbiC2Wlp (ORCPT ); Tue, 29 Mar 2022 18:41:45 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10C4232110 for ; Tue, 29 Mar 2022 15:40:00 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id n207-20020a25d6d8000000b0063bd7a74ae4so8699478ybg.21 for ; Tue, 29 Mar 2022 15:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=55JjpPbk3Y7WOpykUyXt7wH1TGQR1/LtZdMUbAvIVMs=; b=qX3i/Nw/HqKEYHup8amZuE+i2wPURXKr/5BAcB7jIFF0+msEMixUa3UgLAJ50Se7OV uyr1nQ6tC+OzNsJhFFNKJpFlRYQEOdfrdmiIWYryZa9U+Oubgo07ryvepE9B6ETZ1VoG UgCgRUKM31ncZtpopbDAkAKfN/EYCNoCtyOncNGFR1OywMDt0C/fRIEKMz658xXY3sXz rSCP5IEfR/m1/WpN3EHDf6KpUXvKTWPuCkcrboqxZxIzmtVZ70BVZAu4gwl4Usln/kv1 nnP/oWRnTdxeamBSk6xxLsmD1wCbX6Qj0YN0PFJL5eqJ/dKthgzcbg5NZVw8Qz3vRyo1 Fraw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=55JjpPbk3Y7WOpykUyXt7wH1TGQR1/LtZdMUbAvIVMs=; b=f/8oLvtPepfX64PUh3h8trsJN03K3+83dUumXs8GvDa8cjSXBPfMY4YwQRpaZWlPvQ KQg6jIIz6MVh06SRP+FfLa1ArLDERzCtYiI3r/uSmR1g29LyKD0wDVwwnVPn49iTpPQL KPBVQKoOwsMG9oFNSRdmyZs3mq4/4Sy7NqYLzhQzjGRcIoynfjmI06V4K1yiNW4lHaWj TCpNfk9S3yZqAghBhnlPb9B+y/5FIWnteK8LQFY5VKfz/WkzAqBhiAimAm90BPwoxP+I Bv9GaH5SldBi6oBlNVBWXbyOOSdSmdlWxXkZ9pzzpqIOOzg5iidqDuU7IF+mszHlLKrn DWNQ== X-Gm-Message-State: AOAM533JF+lwcU2ZKEDDxlWN1VmHFYJJDJzUanOl1V9vdzq50eWxoNcs ZB0bc4IA7jFo7wv6uEVeZ/IPUYrIHneolOpSYBI= X-Google-Smtp-Source: ABdhPJySXpfYyG6+zVpTR4IIDEDIftMPbYNbI9MH3Y4DgnMswi8Vyagy7p0fxXZFTK+T6UpIhTF2rkLIX8Tq2/alwxU= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:75a:7c26:987c:fd71]) (user=ndesaulniers job=sendgmr) by 2002:a25:26c4:0:b0:633:64d4:2b84 with SMTP id m187-20020a2526c4000000b0063364d42b84mr29292732ybm.428.1648593600139; Tue, 29 Mar 2022 15:40:00 -0700 (PDT) Date: Tue, 29 Mar 2022 15:39:56 -0700 In-Reply-To: Message-Id: <20220329223956.486608-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=lvO/pmg+aaCb6dPhyGC1GyOCvPueDrrc8Zeso5CaGKE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1648593596; l=4543; s=20211004; h=from:subject; bh=5slE50Y/sReDbpFV50LnX2HSeC48C/EwsulabxEX2AY=; b=qrVKmwgB+c+z+CeXQOhS6rjRIAZu/2Wrsrlcq7EKGqSdZjeyWxrfJNKXWI3wHnZmJLb/M85Dploc 41bx/78uD5Tx5oHMxesWB1z9dYo+509XZkUz0pdnf8rnJ9/hmR+r X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2] net, uapi: remove inclusion of arpa/inet.h From: Nick Desaulniers To: Jon Maloy , Ying Xue Cc: Arnd Bergmann , Masahiro Yamada , David Howells , Nick Desaulniers , Nathan Chancellor , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Testing out CONFIG_UAPI_HEADER_TEST=3Dy with a prebuilt Bionic sysroot from Android's SDK, I encountered an error: HDRTEST usr/include/linux/fsi.h In file included from :1: In file included from ./usr/include/linux/tipc_config.h:46: prebuilts/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arp= a/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 --- 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_con= fig.h index 4dfc05651c98..2c494b7ae008 100644 --- a/include/uapi/linux/tipc_config.h +++ b/include/uapi/linux/tipc_config.h @@ -43,10 +43,6 @@ #include #include =20 -#ifndef __KERNEL__ -#include /* 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))) =20 +#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) */ =20 return (space >=3D TLV_SPACE(0)) && - (ntohs(((struct tlv_desc *)tlv)->tlv_len) <=3D space); + (__ntohs(((struct tlv_desc *)tlv)->tlv_len) <=3D space); } =20 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) =3D=3D exp_type); + (__ntohs(((struct tlv_desc *)tlv)->tlv_type) =3D=3D exp_type); } =20 static inline int TLV_GET_LEN(struct tlv_desc *tlv) { - return ntohs(tlv->tlv_len); + return __ntohs(tlv->tlv_len); } =20 static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len) { - tlv->tlv_len =3D htons(len); + tlv->tlv_len =3D __htons(len); } =20 static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type) { - return (ntohs(tlv->tlv_type) =3D=3D type); + return (__ntohs(tlv->tlv_type) =3D=3D type); } =20 static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type) { - tlv->tlv_type =3D htons(type); + tlv->tlv_type =3D __htons(type); } =20 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) =20 tlv_len =3D TLV_LENGTH(len); tlv_ptr =3D (struct tlv_desc *)tlv; - tlv_ptr->tlv_type =3D htons(type); - tlv_ptr->tlv_len =3D htons(tlv_len); + tlv_ptr->tlv_type =3D __htons(type); + tlv_ptr->tlv_len =3D __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) =20 static inline void TLV_LIST_STEP(struct tlv_list_desc *list) { - __u16 tlv_space =3D TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len)); + __u16 tlv_space =3D TLV_ALIGN(__ntohs(list->tlv_ptr->tlv_len)); =20 list->tlv_ptr =3D (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space); list->tlv_space -=3D tlv_space; @@ -404,9 +404,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 f= lags, =20 msg_len =3D TCM_LENGTH(data_len); tcm_hdr =3D (struct tipc_cfg_msg_hdr *)msg; - tcm_hdr->tcm_len =3D htonl(msg_len); - tcm_hdr->tcm_type =3D htons(cmd); - tcm_hdr->tcm_flags =3D htons(flags); + tcm_hdr->tcm_len =3D __htonl(msg_len); + tcm_hdr->tcm_type =3D __htons(cmd); + tcm_hdr->tcm_flags =3D __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_le= n); base-commit: 5efabdadcf4a5b9a37847ecc85ba71cf2eff0fcf --=20 2.35.1.1021.g381101b075-goog