Re: git: c93db4abf454 - main - udp: call UDP methods from UDP over IPv6 directly
- In reply to: John Baldwin : "Re: git: c93db4abf454 - main - udp: call UDP methods from UDP over IPv6 directly"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 17 Aug 2022 16:57:22 UTC
On Wed, Aug 17, 2022 at 09:37:44AM -0700, John Baldwin wrote: J> On 8/17/22 9:19 AM, Gleb Smirnoff wrote: J> > John, J> > J> > On Wed, Aug 17, 2022 at 09:04:08AM -0700, John Baldwin wrote: J> > J> > diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c J> > J> > index a7bdfce97707..6a3ac2abd90b 100644 J> > J> > --- a/sys/netinet6/udp6_usrreq.c J> > J> > +++ b/sys/netinet6/udp6_usrreq.c J> > J> > @@ -131,12 +131,18 @@ VNET_DEFINE(int, zero_checksum_port) = 0; J> > J> > SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW, J> > J> > &VNET_NAME(zero_checksum_port), 0, J> > J> > "Zero UDP checksum allowed for traffic to/from this port."); J> > J> > + J> > J> > + J> > J> > +/* netinet/udp_usrreqs.c */ J> > J> > +pr_abort_t udp_abort; J> > J> > +pr_disconnect_t udp_disconnect; J> > J> > +pr_send_t udp_send; J> > J> > + J> > J> J> > J> Oof, can you please put these in a header instead? <netinet/udp_var.h> would seem to be J> > J> a good candidate. J> > J> > I actually don't want to share these functions to anybody. Sometimes we are J> > in a situation when two compilation units are historically separated, J> > while they need to call into each other functions, which by design are private. J> J> Putting them in a header doesn't really change that. Anyone can add a local J> prototype and call it. Even better, they can add a _wrong_ prototype and J> call it with the wrong arguments. Or more likely, if the original function changes J> then previously working code breaks and the compiler won't catch this. In this J> specific case you mostly sidestep that due to using a typedef, but in general the J> wrong prototype problem is the reason to store prototypes in headers. J> J> I'm not sure that "I don't trust other developers" is a valid reason to avoid the J> use of headers, or at least I'm not sure it outweighs "code breaks without J> the compiler noticing in the future". I'd rather signpost it in the header J> clarifying when it is allowed to be used (e.g. /* Shared between udp*_usrreq.c. */ J> or the like) I'm already working on the change you suggested and I'm already in dependency hell. Since the typedefs are declared in protosw.h that would require anybody who included udp_var.h also include protosw.h. And we have lots of files that include udp_var.h for good or for no reason. Of course I don't want to sprinkle protosw.h include all around. Suggestion by Jessica about udp_usrreq_private.h seems to be more viable, but is it worth to create yet another include to share a function between 2 files, when we are sure that there would never be a 3 file to include it? -- Gleb Smirnoff