Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_divert.c
Show First 20 Lines • Show All 555 Lines • ▼ Show 20 Lines | #endif | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
div_attach(struct socket *so, int proto, struct thread *td) | div_attach(struct socket *so, int proto, struct thread *td) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
int error; | int error; | ||||
u_long sendspace, recvspace; | |||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp == NULL, ("div_attach: inp != NULL")); | KASSERT(inp == NULL, ("div_attach: inp != NULL")); | ||||
if (td != NULL) { | if (td != NULL) { | ||||
error = priv_check(td, PRIV_NETINET_DIVERT); | error = priv_check(td, PRIV_NETINET_DIVERT); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
error = soreserve(so, div_sendspace, div_recvspace); | sendspace = so->divsendspace ? so->divsendspace : div_sendspace; | ||||
recvspace = so->divrecvspace ? so->divrecvspace : div_recvspace; | |||||
error = soreserve(so, sendspace, recvspace); | |||||
donner: Here is the only point where the values are used. | |||||
if (error) | if (error) | ||||
return error; | return error; | ||||
INP_INFO_WLOCK(&V_divcbinfo); | INP_INFO_WLOCK(&V_divcbinfo); | ||||
error = in_pcballoc(so, &V_divcbinfo); | error = in_pcballoc(so, &V_divcbinfo); | ||||
if (error) { | if (error) { | ||||
INP_INFO_WUNLOCK(&V_divcbinfo); | INP_INFO_WUNLOCK(&V_divcbinfo); | ||||
return error; | return error; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | div_pcblist(SYSCTL_HANDLER_ARGS) | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef SYSCTL_NODE | #ifdef SYSCTL_NODE | ||||
static SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, divert, CTLFLAG_RW, 0, | static SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, divert, CTLFLAG_RW, 0, | ||||
"IPDIVERT"); | "IPDIVERT"); | ||||
SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLTYPE_OPAQUE | CTLFLAG_RD, | SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLTYPE_OPAQUE | CTLFLAG_RD, | ||||
NULL, 0, div_pcblist, "S,xinpcb", "List of active divert sockets"); | NULL, 0, div_pcblist, "S,xinpcb", "List of active divert sockets"); | ||||
#endif | #endif | ||||
Not Done Inline ActionsDue to the usage, a tunable_ro seems to be more appropriate. donner: Due to the usage, a tunable_ro seems to be more appropriate.
| |||||
Not Done Inline ActionsThe variables div_sendspace and div_recvspace are used when creating a socket. Because of this, the changed values are applied to the newly created socket. And this is a good feature that allows you to change these variables at runtime. afedorov: The variables div_sendspace and div_recvspace are used when creating a socket. Because of this… | |||||
Not Done Inline ActionsAfter reading through sys/kern/uipc_socket.c I understand, that this is evaluated every time, the user space process handling the divert (natd in this example) is (re)started. So I'm fine with the CTLFLAG_RW. donner: After reading through sys/kern/uipc_socket.c I understand, that this is evaluated every time… | |||||
struct pr_usrreqs div_usrreqs = { | struct pr_usrreqs div_usrreqs = { | ||||
.pru_attach = div_attach, | .pru_attach = div_attach, | ||||
.pru_bind = div_bind, | .pru_bind = div_bind, | ||||
.pru_control = in_control, | .pru_control = in_control, | ||||
.pru_detach = div_detach, | .pru_detach = div_detach, | ||||
.pru_peeraddr = in_getpeeraddr, | .pru_peeraddr = in_getpeeraddr, | ||||
.pru_send = div_send, | .pru_send = div_send, | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
Here is the only point where the values are used.