From nobody Mon Feb 24 16:01:01 2025 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Z1lp80jMxz5pNk4 for ; Mon, 24 Feb 2025 16:01:04 +0000 (UTC) (envelope-from ianfreislich@gmail.com) Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z1lp74tSJz43Bd; Mon, 24 Feb 2025 16:01:03 +0000 (UTC) (envelope-from ianfreislich@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-6fbaf4cf2b5so32563097b3.3; Mon, 24 Feb 2025 08:01:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740412863; x=1741017663; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CPJGdzZidjCH+rNFyB9dpQUjpGWZwm9vpE/w01jUkBA=; b=jnwHtyRIiGA5nkkIctV2QVRyR6rAgmyiHAoVwSxaevvrI8wb+SedbIdJpvPhyR1Q2F neTHzClRyiuyZTr5FZybn+TVdaoisn4OYQ6UZRbA74bJSg04UonvH6L6Io9HA6Z6rrMV 7g2txwe0dXVP3oTVAE8xvf0p06x2N/8//CESHGdkBG98G1BSUGRBBFyVgLvR2S4hrH13 lfiYnDogZMAyNPgkFbyZGkHb3bJqvqDim6HaeHoDqDbE2B0DJULY1HGvRxJrgwl/N54i wb7eOLxetL9JvoJMZFUuhIriQBHMKRz6nF2Tfs10SjtROokuvknnHdvcuxMtA7gr0/Dv 99Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740412863; x=1741017663; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CPJGdzZidjCH+rNFyB9dpQUjpGWZwm9vpE/w01jUkBA=; b=LWOHBdcqvikl5H7o6UrwPj64/ucSWvJcIcNnDOCobSeZDaJVyJo5JzPUHXMe4HsIDQ 9y3B92Ni+K1CvThs3gg5AQRz96YJhC4ronJaRYZLjbOm9LDlNxhjx2NkG6EukK3U+G/6 /v/Q7cYYi+M3py8WKjS9g0ep7XMo0CF2zA0M8BAzFTyGcE1MvnOLDmO/3COqDR5cI3No xrkvGdPZm4ADx+6/UPTUnP4OrB+tJ/9B7psOgFHWCt+NK5x00Q68+AK2BdaAsNwCdf3p g0P+jLpTQ7v9Pku/zPVknFrah+tI/dC1IatUbmiWVAw+iZnHuBv66CZD6pbmAApiDs5D eqgw== X-Forwarded-Encrypted: i=1; AJvYcCVP2NnMb/ARqZoA0sC3JVrbYIsQz+FenhVcNLmNjiHmLxAYNDRKu+7A5IsEJyI4gmPsUkD//A==@freebsd.org, AJvYcCVyS4rig+RA6aN6vUvRy8qBuZ8dSAftK7gmaQdp16LNhzdDOac92TFwDs95ucVX4cJjEhUn2IFr@freebsd.org X-Gm-Message-State: AOJu0Ywd1D0+HIyGKwQ9ZoeKBeuiJtNmzdgbYkSyWAV8aYYsDtoORFbl 8Ty0877Wsnflux9E/6HM14rs04reGf3rO+3QeNunL+jya+sDxNw7EAtCN0mS X-Gm-Gg: ASbGncsQfpReEbGCA4RnD7hO/vxXZRKB/s0xTnzFMBMqtVGTw7rDW6IgfMUn4bTZ48f CfCwAXNLHhAj0n3q3Tr6Yt1EjM2eAyttvdaPKpuCla0XDm15jJx3hkBw14fy5kOSjSJ95Y/fSKk JkChZQqtNfb7OjifrxyULcnr0SRHahhBc6M8xKFCVqLs7g83Rzu8rksBW2L/L85Lt08tNIyttoh b8biPSD+so0k42DVB96Ve3cnP2XC0PyB7dZf5+kjEuQiPfrGpojmb1Bni0l0LKLxFATH3UqEKJD 6A72G/MeDZHdHImWTRGZOpNKsZWAj7pCSOUmyTJZxeyzBcMeY1weSs3VfECnXGBOixWv/pxEAyt NyDLg5A== X-Google-Smtp-Source: AGHT+IE0wE/jpW2cQ1Uu3ZMiZg/wVvWLdPSCzaU6SnLWkjUqPOTKHdbVM5JC4T7WQE2DBSCREvbo9w== X-Received: by 2002:a05:690c:61c6:b0:6fb:9474:7b5f with SMTP id 00721157ae682-6fbcc23a926mr117619467b3.14.1740412862321; Mon, 24 Feb 2025 08:01:02 -0800 (PST) Received: from [10.0.0.5] (107-128-20-168.lightspeed.tukrga.sbcglobal.net. [107.128.20.168]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6fbb4e77ad5sm25335577b3.26.2025.02.24.08.01.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Feb 2025 08:01:02 -0800 (PST) Message-ID: <3cbb3d88-0a0d-4063-81df-f2d440d4b163@gmail.com> Date: Mon, 24 Feb 2025 11:01:01 -0500 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 User-Agent: Thunderbird Daily Subject: Re: buildkernel failure in net/toeplitz.c (commit 3b281d1421a78b588c5fc4182009ce62d8823d95) To: Mark Johnston , Zhenlei Huang Cc: FreeBSD Current , Gleb Smirnoff References: <4858aa49-f102-49fc-90c7-9bd7480306c9@gmail.com> Content-Language: en-US From: Ian FREISLICH In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4Z1lp74tSJz43Bd X-Spamd-Bar: ---- On 2025-02-24 09:54, Mark Johnston wrote: > On Mon, Feb 24, 2025 at 03:52:14PM +0800, Zhenlei Huang wrote: >> >> >>> On Feb 24, 2025, at 12:42 PM, Ian FREISLICH wrote: >>> >>> Hi >>> >>> Building a kernel today failed with: >>> >>> -Werror /usr/src/sys/net/toeplitz.c >>> In file included from /usr/src/sys/net/toeplitz.c:29: >>> In file included from /usr/src/sys/net/rss_config.h:33: >>> /usr/src/sys/netinet/in.h:692:23: error: call to undeclared function 'htonl'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] >>> 692 | return (in.s_addr == htonl(INADDR_BROADCAST) || >>> | ^ >>> In file included from /usr/src/sys/net/toeplitz.c:32: >>> In file included from /usr/src/sys/sys/systm.h:98: >>> /usr/src/sys/sys/param.h:343:13: error: conflicting types for 'htonl' >>> 343 | __uint32_t htonl(__uint32_t); >>> | ^ >>> /usr/src/sys/netinet/in.h:692:23: note: previous implicit declaration is here >>> 692 | return (in.s_addr == htonl(INADDR_BROADCAST) || >>> >>> I think this is a result of changes to netinet/in.h (3b281d1421a78) which added a static inline function using ntohl() which is not defined in kernel use. >>> >>> Ian >>> >> >> >> May you please have a try with this patch ? >> >> ``` >> diff --git a/sys/netinet/in.h b/sys/netinet/in.h >> index 0925e3aa7669..4dad4e4fed4d 100644 >> --- a/sys/netinet/in.h >> +++ b/sys/netinet/in.h >> @@ -689,8 +689,8 @@ void in_ifdetach(struct ifnet *); >> static inline bool >> in_broadcast(struct in_addr in) >> { >> - return (in.s_addr == htonl(INADDR_BROADCAST) || >> - in.s_addr == htonl(INADDR_ANY)); >> + return (in.s_addr == INADDR_BROADCAST || >> + in.s_addr == INADDR_ANY); >> } >> ``` >> >> The `htonl` is pointless here, as INADDR_BROADCAST is all 1s, and INADDR_ANY is all 0s. > > See the review: it's formally unneeded, as you say, but I think the > conversions should be there in case this function is ever augmented > someday. I think this patch would also work: > > diff --git a/sys/netinet/in.h b/sys/netinet/in.h > index fa710af7cd58..e42422341ada 100644 > --- a/sys/netinet/in.h > +++ b/sys/netinet/in.h > @@ -689,8 +689,8 @@ void in_ifdetach(struct ifnet *); > static inline bool > in_broadcast(struct in_addr in) > { > - return (in.s_addr == htonl(INADDR_BROADCAST) || > - in.s_addr == htonl(INADDR_ANY)); > + return (in.s_addr == __htonl(INADDR_BROADCAST) || > + in.s_addr == __htonl(INADDR_ANY)); > } > > #define in_hosteq(s, t) ((s).s_addr == (t).s_addr) I was going to start a bikeshed: I prefer the style of the original because it shows that the author understands the importance of byte order. Perhaps the root issue is that htonl is define in both arpa/inet.h and netinet/in.h with conditional compilation in and out of the kernel. The reason existing uses of htonl work in this header file is that they're #defines and not functions and so they're not compiled unless they're used. Ian