Page MenuHomeFreeBSD

divert: declare PF_DIVERT domain and stop abusing PF_INET
ClosedPublic

Authored by glebius on Aug 28 2022, 7:01 AM.
Tags
None
Referenced Files
F102149004: D36379.diff
Fri, Nov 8, 5:44 AM
Unknown Object (File)
Thu, Oct 17, 4:31 PM
Unknown Object (File)
Wed, Oct 16, 8:55 PM
Unknown Object (File)
Wed, Oct 16, 2:15 PM
Unknown Object (File)
Tue, Oct 15, 10:13 AM
Unknown Object (File)
Tue, Oct 15, 7:24 AM
Unknown Object (File)
Sun, Oct 13, 5:21 PM
Unknown Object (File)
Sun, Oct 13, 4:41 AM

Details

Summary

The divert(4) is not a protocol of IPv4. It is a socket to
intercept packets from ipfw(4) to userland and re-inject them
back. It can divert and re-inject IPv4 and IPv6 packets today,
but potentially it is not limited to these two protocols. The
IPPROTO_DIVERT does not belong to known IP protocols, it
doesn't even fit into u_char. I guess, the implementation of
divert(4) was done the way it is done basically because it was
easier to do it this way, back when protocols for sockets were
intertwined with IP protocols and domains were statically
compiled in.

Moving divert(4) out of inetsw accomplished two important things:

  1. IPDIVERT is getting much closer to be not dependent on INET. This will be finalized in following changes.
  2. Now divert socket no longer aliases with raw IPv4 socket. Domain/proto selection code won't need a hack for SOCK_RAW and multiple entries in inetsw implementing different flavors of raw socket can merge into one without requirement of raw IPv4 being the last member of dom_protosw.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable