Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_divert.c
Show First 20 Lines • Show All 720 Lines • ▼ Show 20 Lines | static SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, divert, | ||||
CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | ||||
"IPDIVERT"); | "IPDIVERT"); | ||||
SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, | SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, | ||||
CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, | CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, | ||||
NULL, 0, div_pcblist, "S,xinpcb", | NULL, 0, div_pcblist, "S,xinpcb", | ||||
"List of active divert sockets"); | "List of active divert sockets"); | ||||
#endif | #endif | ||||
struct pr_usrreqs div_usrreqs = { | static struct protosw div_protosw = { | ||||
.pru_attach = div_attach, | |||||
.pru_bind = div_bind, | |||||
.pru_control = in_control, | |||||
.pru_detach = div_detach, | |||||
.pru_peeraddr = in_getpeeraddr, | |||||
.pru_send = div_send, | |||||
.pru_shutdown = div_shutdown, | |||||
.pru_sockaddr = in_getsockaddr, | |||||
.pru_sosetlabel = in_pcbsosetlabel | |||||
}; | |||||
struct protosw div_protosw = { | |||||
.pr_type = SOCK_RAW, | .pr_type = SOCK_RAW, | ||||
.pr_protocol = IPPROTO_DIVERT, | .pr_protocol = IPPROTO_DIVERT, | ||||
.pr_flags = PR_ATOMIC|PR_ADDR, | .pr_flags = PR_ATOMIC|PR_ADDR, | ||||
.pr_usrreqs = &div_usrreqs | .pr_attach = div_attach, | ||||
.pr_bind = div_bind, | |||||
.pr_control = in_control, | |||||
.pr_detach = div_detach, | |||||
.pr_peeraddr = in_getpeeraddr, | |||||
.pr_send = div_send, | |||||
.pr_shutdown = div_shutdown, | |||||
.pr_sockaddr = in_getsockaddr, | |||||
.pr_sosetlabel = in_pcbsosetlabel | |||||
}; | }; | ||||
static int | static int | ||||
div_modevent(module_t mod, int type, void *unused) | div_modevent(module_t mod, int type, void *unused) | ||||
{ | { | ||||
int err = 0; | int err = 0; | ||||
switch (type) { | switch (type) { | ||||
case MOD_LOAD: | case MOD_LOAD: | ||||
/* | /* | ||||
* Protocol will be initialized by pf_proto_register(). | * Protocol will be initialized by pf_proto_register(). | ||||
*/ | */ | ||||
err = pf_proto_register(PF_INET, &div_protosw); | err = protosw_register(&inetdomain, &div_protosw); | ||||
if (err != 0) | if (err != 0) | ||||
return (err); | return (err); | ||||
ip_divert_ptr = divert_packet; | ip_divert_ptr = divert_packet; | ||||
break; | break; | ||||
case MOD_QUIESCE: | case MOD_QUIESCE: | ||||
/* | /* | ||||
* IPDIVERT may normally not be unloaded because of the | * IPDIVERT may normally not be unloaded because of the | ||||
* potential race conditions. Tell kldunload we can't be | * potential race conditions. Tell kldunload we can't be | ||||
Show All 15 Lines | case MOD_UNLOAD: | ||||
*/ | */ | ||||
INP_INFO_WLOCK(&V_divcbinfo); | INP_INFO_WLOCK(&V_divcbinfo); | ||||
if (V_divcbinfo.ipi_count != 0) { | if (V_divcbinfo.ipi_count != 0) { | ||||
err = EBUSY; | err = EBUSY; | ||||
INP_INFO_WUNLOCK(&V_divcbinfo); | INP_INFO_WUNLOCK(&V_divcbinfo); | ||||
break; | break; | ||||
} | } | ||||
ip_divert_ptr = NULL; | ip_divert_ptr = NULL; | ||||
err = pf_proto_unregister(PF_INET, IPPROTO_DIVERT, SOCK_RAW); | err = protosw_unregister(&div_protosw); | ||||
INP_INFO_WUNLOCK(&V_divcbinfo); | INP_INFO_WUNLOCK(&V_divcbinfo); | ||||
#ifndef VIMAGE | #ifndef VIMAGE | ||||
div_destroy(NULL); | div_destroy(NULL); | ||||
#endif | #endif | ||||
break; | break; | ||||
default: | default: | ||||
err = EOPNOTSUPP; | err = EOPNOTSUPP; | ||||
break; | break; | ||||
Show All 13 Lines |