aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/ip_divert.c
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2022-08-17 18:50:31 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2022-08-17 18:50:31 +0000
commit78b1fc05b20504ed13aeeb4a5b47443246cabaeb (patch)
tree9508c47a91e5db3c5de822e8dc43c3d4e841e156 /sys/netinet/ip_divert.c
parentef8b872301c5fbeeea3b0410b369b8f36584cd65 (diff)
downloadsrc-78b1fc05b20504ed13aeeb4a5b47443246cabaeb.tar.gz
src-78b1fc05b20504ed13aeeb4a5b47443246cabaeb.zip
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
Diffstat (limited to 'sys/netinet/ip_divert.c')
-rw-r--r--sys/netinet/ip_divert.c20
1 files changed, 0 insertions, 20 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index c149a2a2c416..c8a2ad7b4c94 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -147,20 +147,6 @@ div_destroy(void *unused __unused)
}
VNET_SYSUNINIT(divert, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, div_destroy, NULL);
-/*
- * IPPROTO_DIVERT is not in the real IP protocol number space; this
- * function should never be called. Just in case, drop any packets.
- */
-static int
-div_input(struct mbuf **mp, int *offp, int proto)
-{
- struct mbuf *m = *mp;
-
- KMOD_IPSTAT_INC(ips_noproto);
- m_freem(m);
- return (IPPROTO_DONE);
-}
-
static bool
div_port_match(const struct inpcb *inp, void *v)
{
@@ -171,9 +157,6 @@ div_port_match(const struct inpcb *inp, void *v)
/*
* Divert a packet by passing it up to the divert socket at port 'port'.
- *
- * Setup generic address and protocol structures for div_input routine,
- * then pass them along with mbuf chain.
*/
static void
divert_packet(struct mbuf *m, bool incoming)
@@ -759,7 +742,6 @@ struct protosw div_protosw = {
.pr_type = SOCK_RAW,
.pr_protocol = IPPROTO_DIVERT,
.pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = div_input,
.pr_usrreqs = &div_usrreqs
};
@@ -772,8 +754,6 @@ div_modevent(module_t mod, int type, void *unused)
case MOD_LOAD:
/*
* Protocol will be initialized by pf_proto_register().
- * We don't have to register ip_protox because we are not
- * a true IP protocol that goes over the wire.
*/
err = pf_proto_register(PF_INET, &div_protosw);
if (err != 0)