krpc: Get rid of KRPC_VNET macros
When the krpc was vnet'd, the VNET macros were hidden behind macros that had the KRPC_ prefix on them. This was done because, at the time, it was thought that something other than vnet might be used for this. That has not happened and probably will not happen, so this patch replaces these obscuring macros with the regular vnet ones. There should be no semantics change caused by this commit. Discussed with: bz, glebius MFC after: 1 month
This commit is contained in:
@@ -65,21 +65,6 @@ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run,
|
||||
/* String for AUTH_TLS reply verifier. */
|
||||
#define RPCTLS_START_STRING "STARTTLS"
|
||||
|
||||
/* Macros for VIMAGE. */
|
||||
/* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */
|
||||
#define KRPC_VNET_NAME(n) VNET_NAME(n)
|
||||
#define KRPC_VNET_DECLARE(t, n) VNET_DECLARE(t, n)
|
||||
#define KRPC_VNET_DEFINE(t, n) VNET_DEFINE(t, n)
|
||||
#define KRPC_VNET_DEFINE_STATIC(t, n) VNET_DEFINE_STATIC(t, n)
|
||||
#define KRPC_VNET(n) VNET(n)
|
||||
|
||||
#define CTLFLAG_KRPC_VNET CTLFLAG_VNET
|
||||
|
||||
#define KRPC_CURVNET_SET(n) CURVNET_SET(n)
|
||||
#define KRPC_CURVNET_SET_QUIET(n) CURVNET_SET_QUIET(n)
|
||||
#define KRPC_CURVNET_RESTORE() CURVNET_RESTORE()
|
||||
#define KRPC_TD_TO_VNET(n) TD_TO_VNET(n)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _RPC_RPCSEC_TLS_H_ */
|
||||
|
||||
@@ -75,8 +75,8 @@ static struct syscall_helper_data rpctls_syscalls[] = {
|
||||
|
||||
static struct opaque_auth rpctls_null_verf;
|
||||
|
||||
KRPC_VNET_DECLARE(uint64_t, svc_vc_tls_handshake_success);
|
||||
KRPC_VNET_DECLARE(uint64_t, svc_vc_tls_handshake_failed);
|
||||
VNET_DECLARE(uint64_t, svc_vc_tls_handshake_success);
|
||||
VNET_DECLARE(uint64_t, svc_vc_tls_handshake_failed);
|
||||
|
||||
static CLIENT *rpctls_connect_handle;
|
||||
static CLIENT *rpctls_server_handle;
|
||||
@@ -159,7 +159,7 @@ sys_rpctls_syscall(struct thread *td, struct rpctls_syscall_args *uap)
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
KRPC_CURVNET_SET(KRPC_TD_TO_VNET(td));
|
||||
CURVNET_SET(TD_TO_VNET(td));
|
||||
mtx_lock(&rpctls_lock);
|
||||
upsp = RB_FIND(upsock_t, &upcall_sockets,
|
||||
&(struct upsock){
|
||||
@@ -176,7 +176,7 @@ sys_rpctls_syscall(struct thread *td, struct rpctls_syscall_args *uap)
|
||||
}
|
||||
mtx_unlock(&rpctls_lock);
|
||||
if (upsp == NULL) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
printf("%s: socket lookup failed\n", __func__);
|
||||
return (EPERM);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ sys_rpctls_syscall(struct thread *td, struct rpctls_syscall_args *uap)
|
||||
* As such, it needs to be closed here.
|
||||
*/
|
||||
soclose(ups.so);
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
return (error);
|
||||
}
|
||||
soref(ups.so);
|
||||
@@ -211,7 +211,7 @@ sys_rpctls_syscall(struct thread *td, struct rpctls_syscall_args *uap)
|
||||
finit(fp, FREAD | FWRITE, DTYPE_SOCKET, ups.so, &socketops);
|
||||
fdrop(fp, td); /* Drop fp reference. */
|
||||
td->td_retval[0] = fd;
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
|
||||
return (error);
|
||||
}
|
||||
@@ -441,8 +441,8 @@ _svcauth_rpcsec_tls(struct svc_req *rqst, struct rpc_msg *msg)
|
||||
u_int maxlen;
|
||||
#endif
|
||||
|
||||
KRPC_CURVNET_SET_QUIET(KRPC_TD_TO_VNET(curthread));
|
||||
KRPC_VNET(svc_vc_tls_handshake_failed)++;
|
||||
CURVNET_SET_QUIET(TD_TO_VNET(curthread));
|
||||
VNET(svc_vc_tls_handshake_failed)++;
|
||||
/* Initialize reply. */
|
||||
rqst->rq_verf = rpctls_null_verf;
|
||||
|
||||
@@ -450,12 +450,12 @@ _svcauth_rpcsec_tls(struct svc_req *rqst, struct rpc_msg *msg)
|
||||
if (rqst->rq_cred.oa_length != 0 ||
|
||||
msg->rm_call.cb_verf.oa_length != 0 ||
|
||||
msg->rm_call.cb_verf.oa_flavor != AUTH_NULL) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
return (AUTH_BADCRED);
|
||||
}
|
||||
|
||||
if (rqst->rq_proc != NULLPROC) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
return (AUTH_REJECTEDCRED);
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ _svcauth_rpcsec_tls(struct svc_req *rqst, struct rpc_msg *msg)
|
||||
call_stat = TRUE;
|
||||
#endif
|
||||
if (!call_stat) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
return (AUTH_REJECTEDCRED);
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ _svcauth_rpcsec_tls(struct svc_req *rqst, struct rpc_msg *msg)
|
||||
xprt->xp_dontrcv = FALSE;
|
||||
sx_xunlock(&xprt->xp_lock);
|
||||
xprt_active(xprt); /* Harmless if already active. */
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
return (AUTH_REJECTEDCRED);
|
||||
}
|
||||
|
||||
@@ -506,12 +506,12 @@ _svcauth_rpcsec_tls(struct svc_req *rqst, struct rpc_msg *msg)
|
||||
xprt->xp_uid = uid;
|
||||
xprt->xp_gidp = gidp;
|
||||
}
|
||||
KRPC_VNET(svc_vc_tls_handshake_failed)--;
|
||||
KRPC_VNET(svc_vc_tls_handshake_success)++;
|
||||
VNET(svc_vc_tls_handshake_failed)--;
|
||||
VNET(svc_vc_tls_handshake_success)++;
|
||||
}
|
||||
sx_xunlock(&xprt->xp_lock);
|
||||
xprt_active(xprt); /* Harmless if already active. */
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
|
||||
return (RPCSEC_GSS_NODISPATCH);
|
||||
}
|
||||
|
||||
+45
-45
@@ -77,57 +77,57 @@ SYSCTL_NODE(_kern_rpc, OID_AUTO, tls, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
|
||||
SYSCTL_NODE(_kern_rpc, OID_AUTO, unenc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
|
||||
"unencrypted");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_rx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, rx_msgbytes, CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_rx_msgbytes), 0, "Count of non-TLS rx bytes");
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_rx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, rx_msgbytes, CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_rx_msgbytes), 0, "Count of non-TLS rx bytes");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_rx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, rx_msgcnt, CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_rx_msgcnt), 0, "Count of non-TLS rx messages");
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_rx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, rx_msgcnt, CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_rx_msgcnt), 0, "Count of non-TLS rx messages");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, tx_msgbytes, CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_tx_msgbytes), 0, "Count of non-TLS tx bytes");
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, tx_msgbytes, CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_tx_msgbytes), 0, "Count of non-TLS tx bytes");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, tx_msgcnt, CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_tx_msgcnt), 0, "Count of non-TLS tx messages");
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_unenc, OID_AUTO, tx_msgcnt, CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_tx_msgcnt), 0, "Count of non-TLS tx messages");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_alerts) = 0;
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_alerts) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, alerts,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW, &KRPC_VNET_NAME(svc_vc_tls_alerts), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(svc_vc_tls_alerts), 0,
|
||||
"Count of TLS alert messages");
|
||||
|
||||
KRPC_VNET_DEFINE(uint64_t, svc_vc_tls_handshake_failed) = 0;
|
||||
VNET_DEFINE(uint64_t, svc_vc_tls_handshake_failed) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, handshake_failed,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_tls_handshake_failed), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_tls_handshake_failed), 0,
|
||||
"Count of TLS failed handshakes");
|
||||
|
||||
KRPC_VNET_DEFINE(uint64_t, svc_vc_tls_handshake_success) = 0;
|
||||
VNET_DEFINE(uint64_t, svc_vc_tls_handshake_success) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, handshake_success,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW,
|
||||
&KRPC_VNET_NAME(svc_vc_tls_handshake_success), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW,
|
||||
&VNET_NAME(svc_vc_tls_handshake_success), 0,
|
||||
"Count of TLS successful handshakes");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_rx_msgbytes) = 0;
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_rx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, rx_msgbytes,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW, &KRPC_VNET_NAME(svc_vc_tls_rx_msgbytes), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(svc_vc_tls_rx_msgbytes), 0,
|
||||
"Count of TLS rx bytes");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_rx_msgcnt) = 0;
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_rx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, rx_msgcnt,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW, &KRPC_VNET_NAME(svc_vc_tls_rx_msgcnt), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(svc_vc_tls_rx_msgcnt), 0,
|
||||
"Count of TLS rx messages");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_tx_msgbytes) = 0;
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_tx_msgbytes) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, tx_msgbytes,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW, &KRPC_VNET_NAME(svc_vc_tls_tx_msgbytes), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(svc_vc_tls_tx_msgbytes), 0,
|
||||
"Count of TLS tx bytes");
|
||||
|
||||
KRPC_VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_tx_msgcnt) = 0;
|
||||
VNET_DEFINE_STATIC(uint64_t, svc_vc_tls_tx_msgcnt) = 0;
|
||||
SYSCTL_U64(_kern_rpc_tls, OID_AUTO, tx_msgcnt,
|
||||
CTLFLAG_KRPC_VNET | CTLFLAG_RW, &KRPC_VNET_NAME(svc_vc_tls_tx_msgcnt), 0,
|
||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(svc_vc_tls_tx_msgcnt), 0,
|
||||
"Count of TLS tx messages");
|
||||
|
||||
static bool_t svc_vc_rendezvous_recv(SVCXPRT *, struct rpc_msg *,
|
||||
@@ -850,15 +850,15 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
* This record needs to be handled in userland
|
||||
* via an SSL_read() call, so do an upcall to the daemon.
|
||||
*/
|
||||
KRPC_CURVNET_SET(so->so_vnet);
|
||||
CURVNET_SET(so->so_vnet);
|
||||
if ((xprt->xp_tls & RPCTLS_FLAGS_HANDSHAKE) != 0 &&
|
||||
error == ENXIO) {
|
||||
KRPC_VNET(svc_vc_tls_alerts)++;
|
||||
VNET(svc_vc_tls_alerts)++;
|
||||
/* Disable reception. */
|
||||
xprt->xp_dontrcv = TRUE;
|
||||
sx_xunlock(&xprt->xp_lock);
|
||||
ret = rpctls_srv_handlerecord(so, &reterr);
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
sx_xlock(&xprt->xp_lock);
|
||||
xprt->xp_dontrcv = FALSE;
|
||||
if (ret != RPC_SUCCESS || reterr != RPCTLSERR_OK) {
|
||||
@@ -875,7 +875,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
}
|
||||
|
||||
if (error) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
SOCK_RECVBUF_LOCK(so);
|
||||
if (xprt->xp_upcallset) {
|
||||
xprt->xp_upcallset = 0;
|
||||
@@ -889,7 +889,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
}
|
||||
|
||||
if (!m) {
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
/*
|
||||
* EOF - the other end has closed the socket.
|
||||
*/
|
||||
@@ -915,20 +915,20 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
m_freem(m);
|
||||
m_free(ctrl);
|
||||
rcvflag = MSG_DONTWAIT | MSG_TLSAPPDATA;
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
goto tryagain;
|
||||
}
|
||||
KRPC_VNET(svc_vc_tls_rx_msgcnt)++;
|
||||
KRPC_VNET(svc_vc_tls_rx_msgbytes) +=
|
||||
VNET(svc_vc_tls_rx_msgcnt)++;
|
||||
VNET(svc_vc_tls_rx_msgbytes) +=
|
||||
1000000000 - uio.uio_resid;
|
||||
}
|
||||
m_free(ctrl);
|
||||
} else {
|
||||
KRPC_VNET(svc_vc_rx_msgcnt)++;
|
||||
KRPC_VNET(svc_vc_rx_msgbytes) += 1000000000 -
|
||||
VNET(svc_vc_rx_msgcnt)++;
|
||||
VNET(svc_vc_rx_msgbytes) += 1000000000 -
|
||||
uio.uio_resid;
|
||||
}
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
|
||||
if (cd->mpending)
|
||||
m_last(cd->mpending)->m_next = m;
|
||||
@@ -1017,7 +1017,7 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
htonl(0x80000000 | (len - sizeof(uint32_t)));
|
||||
|
||||
/* For RPC-over-TLS, copy mrep to a chain of ext_pgs. */
|
||||
KRPC_CURVNET_SET(xprt->xp_socket->so_vnet);
|
||||
CURVNET_SET(xprt->xp_socket->so_vnet);
|
||||
if ((xprt->xp_tls & RPCTLS_FLAGS_HANDSHAKE) != 0) {
|
||||
/*
|
||||
* Copy the mbuf chain to a chain of
|
||||
@@ -1029,13 +1029,13 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg,
|
||||
maxextsiz = min(maxextsiz, maxlen);
|
||||
#endif
|
||||
mrep = _rpc_copym_into_ext_pgs(mrep, maxextsiz);
|
||||
KRPC_VNET(svc_vc_tls_tx_msgcnt)++;
|
||||
KRPC_VNET(svc_vc_tls_tx_msgbytes) += len;
|
||||
VNET(svc_vc_tls_tx_msgcnt)++;
|
||||
VNET(svc_vc_tls_tx_msgbytes) += len;
|
||||
} else {
|
||||
KRPC_VNET(svc_vc_tx_msgcnt)++;
|
||||
KRPC_VNET(svc_vc_tx_msgbytes) += len;
|
||||
VNET(svc_vc_tx_msgcnt)++;
|
||||
VNET(svc_vc_tx_msgbytes) += len;
|
||||
}
|
||||
KRPC_CURVNET_RESTORE();
|
||||
CURVNET_RESTORE();
|
||||
atomic_add_32(&xprt->xp_snd_cnt, len);
|
||||
/*
|
||||
* sosend consumes mreq.
|
||||
|
||||
Reference in New Issue
Block a user