Re: git: e72c522858cb - main - divert(4): make it compilable and working without INET

From: Bjoern A. Zeeb <bz_at_freebsd.org>
Date: Wed, 07 Sep 2022 09:54:49 UTC
On Tue, 6 Sep 2022, Gleb Smirnoff wrote:

> On Sun, Sep 04, 2022 at 06:39:53AM +0000, Bjoern A. Zeeb wrote:
> B> > B> > Author:     Gleb Smirnoff <glebius@FreeBSD.org>
> B> > B> > AuthorDate: 2022-08-30 22:09:21 +0000
> B> > B> > Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
> B> > B> > CommitDate: 2022-08-30 22:09:21 +0000
> B> > B> >
> B> > B> >    divert(4): make it compilable and working without INET
> B> > B> >
> B> > B> >    Differential revision:  https://reviews.freebsd.org/D36383
> B> > B>
> B> > B> Well, almost at least....
> B> >
> B> > I wonder why LINT-NOINET builds without this??
> B>
> B> I wondered the same last night.. I would be good to find out?
>
> Ok, I think that assumption that sysctl parts of divert require
> INET were just wrong, that's why LINT-NOINET builds.

Not entirely.  It's because sys/netinet/in_proto.c uncodonitionally
currently provides _net_inet for the sysctl.
The reason for that is that a lot of AF independent sysctls were initially
put under inet but are equally used for inet6 or neither in the network stack.

You will need at least #if defined(INET6) || defined(INET)  around the sysctls
in divert.c then.

A LINT-NOIP kernel will complain about the missing symbol if we keep compiling
divert without INET or INET6 in the kernel:

       1 make[4]: "/tank/users/bz/git/FreeBSD/freebsd-src/Makefile.inc1" line 334: SYSTEM_LINKER: Determined that LD=ld matches the source tree.  Not bootstrapping a cross-linker.
       2
       3 --------------------------------------------------------------
       4 >>> Kernel build for LINT-NOIP started on Mon Sep  5 20:26:47 UTC 2022
       5 --------------------------------------------------------------
       6 ===> LINT-NOIP
       7         0.09 real         0.03 user         0.06 sys
       8
       9 --------------------------------------------------------------
      10 >>> stage 2.3: build tools
      11 --------------------------------------------------------------
      12         0.12 real         0.03 user         0.09 sys
      13 --------------------------------------------------------------
      14 >>> stage 3.1: building everything
      15 --------------------------------------------------------------
      16 linking kernel
      17 ld: error: undefined symbol: ip_divert_ptr
      18 >>> referenced by ip_divert.c
      19 >>>               ip_divert.o:(div_modevent)
      20 >>> referenced by ip_divert.c
      21 >>>               ip_divert.o:(div_modevent)
      22
      23 ld: error: undefined symbol: sctp_delayed_cksum
      24 >>> referenced by ip_divert.c
      25 >>>               ip_divert.o:(divert_packet)
      26
      27 ld: error: undefined symbol: sysctl___net_inet
      28 >>> referenced by ip_divert.c
      29 >>>               ip_divert.o:(sysctl___net_inet_divert)
      30 --- kernel ---
      31 *** [kernel] Error code 1
      32
      33 make[5]: stopped in /tank/users/bz/obj/tank/users/bz/git/FreeBSD/freebsd-src/amd64.amd64/sys/LINT-NOIP
      34 1 error
      35
      36 make[5]: stopped in /tank/users/bz/obj/tank/users/bz/git/FreeBSD/freebsd-src/amd64.amd64/sys/LINT-NOIP
      37      1224.73 real      2829.68 user       196.38 sys
      38 --- buildkernel ---
      39
      40 make[4]: stopped in /tank/users/bz/git/FreeBSD/freebsd-src
      41 --- buildkernel ---
      42
      43 make[3]: stopped in /tank/users/bz/git/FreeBSD/freebsd-src

-- 
Bjoern A. Zeeb                                                     r15:7