Re: git: c93db4abf454 - main - udp: call UDP methods from UDP over IPv6 directly

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Wed, 17 Aug 2022 16:19:29 UTC
  John,

On Wed, Aug 17, 2022 at 09:04:08AM -0700, John Baldwin wrote:
J> > diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
J> > index a7bdfce97707..6a3ac2abd90b 100644
J> > --- a/sys/netinet6/udp6_usrreq.c
J> > +++ b/sys/netinet6/udp6_usrreq.c
J> > @@ -131,12 +131,18 @@ VNET_DEFINE(int, zero_checksum_port) = 0;
J> >   SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW,
J> >       &VNET_NAME(zero_checksum_port), 0,
J> >       "Zero UDP checksum allowed for traffic to/from this port.");
J> > +
J> > +
J> > +/* netinet/udp_usrreqs.c */
J> > +pr_abort_t	udp_abort;
J> > +pr_disconnect_t	udp_disconnect;
J> > +pr_send_t	udp_send;
J> > +
J> 
J> Oof, can you please put these in a header instead?  <netinet/udp_var.h> would seem to be
J> a good candidate.

I actually don't want to share these functions to anybody.  Sometimes we are
in a situation when two compilation units are historically separated,
while they need to call into each other functions, which by design are private.

With declaration in the caller unit I emphasize that nobody except udp6_usrreq.c
may call functions from udp_usrreq.c. I find this self-documenting and better than
exposing it in udp_var.h or anywhere else.

We got many examples of this problem in the network stack. A good example is tcp_init()
calling into various sub-inits, all of which are never ever supposed to be called by
anybody else.  They should have been just static, but historically are separated into
separate files.

-- 
Gleb Smirnoff