protosw: separate pr_input and pr_ctlinput out of protosw
authorGleb Smirnoff <glebius@FreeBSD.org>
Wed, 17 Aug 2022 18:50:31 +0000 (11:50 -0700)
committerGleb Smirnoff <glebius@FreeBSD.org>
Wed, 17 Aug 2022 18:50:31 +0000 (11:50 -0700)
commit78b1fc05b20504ed13aeeb4a5b47443246cabaeb
tree9508c47a91e5db3c5de822e8dc43c3d4e841e156
parentef8b872301c5fbeeea3b0410b369b8f36584cd65
protosw: separate pr_input and pr_ctlinput out of protosw

The protosw KPI historically has implemented two quite orthogonal
things: protocols that implement a certain kind of socket, and
protocols that are IPv4/IPv6 protocol.  These two things do not
make one-to-one correspondence. The pr_input and pr_ctlinput methods
were utilized only in IP protocols.  This strange duality required
IP protocols that doesn't have a socket to declare protosw, e.g.
carp(4).  On the other hand developers of socket protocols thought
that they need to define pr_input/pr_ctlinput always, which lead to
strange dead code, e.g. div_input() or sdp_ctlinput().

With this change pr_input and pr_ctlinput as part of protosw disappear
and IPv4/IPv6 get their private single level protocol switch table
ip_protox[] and ip6_protox[] respectively, pointing at array of
ipproto_input_t functions.  The pr_ctlinput that was used for
control input coming from the network (ICMP, ICMPv6) is now represented
by ip_ctlprotox[] and ip6_ctlprotox[].

ipproto_register() becomes the only official way to register in the
table.  Those protocols that were always static and unlikely anybody
is interested in making them loadable, are now registered by ip_init(),
ip6_init().  An IP protocol that considers itself unloadable shall
register itself within its own private SYSINIT().

Reviewed by: tuexen, melifaro
Differential revision: https://reviews.freebsd.org/D36157
26 files changed:
sys/kern/uipc_debug.c
sys/kern/uipc_domain.c
sys/netinet/in.h
sys/netinet/in_proto.c
sys/netinet/ip_carp.c
sys/netinet/ip_carp.h
sys/netinet/ip_divert.c
sys/netinet/ip_icmp.c
sys/netinet/ip_input.c
sys/netinet/ip_var.h
sys/netinet/raw_ip.c
sys/netinet/sctp_module.c
sys/netinet/sctp_var.h
sys/netinet/tcp_subr.c
sys/netinet/udp_usrreq.c
sys/netinet/udp_var.h
sys/netinet6/icmp6.c
sys/netinet6/in6.h
sys/netinet6/in6_proto.c
sys/netinet6/ip6_input.c
sys/netinet6/ip6_var.h
sys/netinet6/tcp6_var.h
sys/netinet6/udp6_usrreq.c
sys/netipsec/ipsec_input.c
sys/netpfil/pf/if_pfsync.c
sys/sys/protosw.h