HomeFreeBSD

divert: declare PF_DIVERT domain and stop abusing PF_INET

Description

divert: declare PF_DIVERT domain and stop abusing PF_INET

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.

Differential revision: https://reviews.freebsd.org/D36379

Details

Provenance
glebiusAuthored on Aug 30 2022, 10:09 PM
Differential Revision
D36379: divert: declare PF_DIVERT domain and stop abusing PF_INET
Parents
rG603677334a64: mount_nfs.8: Note that NFSv4 requires unique /etc/hostid's
Branches
Unknown
Tags
Unknown