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
Unknown Object (File)
Tue, Nov 12, 8:19 PM
Unknown Object (File)
Sun, Nov 10, 12:20 PM
Unknown Object (File)
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)
Oct 15 2024, 10:13 AM
Unknown Object (File)
Oct 15 2024, 7:24 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