diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-02 09:39:42 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-02 09:39:42 +0000 |
commit | c09e53aa358d111e83f83163e97cc6e772f552c1 (patch) | |
tree | cd79c1271008bba543cfbbc43ab98da8cbcbddd1 | |
parent | c733ff88cfce3223384aaeab606325623cf80c21 (diff) |
Add back the "peerid" to the proc_compose*() functions: in relayd, I
initially left it out because I didn't have a need for it. But it is
actually quite useful to carry a reference to the imsg data context
across processes.
-rw-r--r-- | usr.sbin/vmd/proc.c | 12 | ||||
-rw-r--r-- | usr.sbin/vmd/proc.h | 6 | ||||
-rw-r--r-- | usr.sbin/vmd/vmm.c | 8 |
3 files changed, 13 insertions, 13 deletions
diff --git a/usr.sbin/vmd/proc.c b/usr.sbin/vmd/proc.c index 56f8d720d8a..4ec159a4a10 100644 --- a/usr.sbin/vmd/proc.c +++ b/usr.sbin/vmd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.1 2015/12/02 09:14:25 reyk Exp $ */ +/* $OpenBSD: proc.c,v 1.2 2015/12/02 09:39:41 reyk Exp $ */ /* * Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -576,14 +576,14 @@ proc_range(struct privsep *ps, enum privsep_procid id, int *n, int *m) int proc_compose_imsg(struct privsep *ps, enum privsep_procid id, int n, - uint16_t type, int fd, void *data, uint16_t datalen) + uint16_t type, uint32_t peerid, int fd, void *data, uint16_t datalen) { int m; proc_range(ps, id, &n, &m); for (; n < m; n++) { if (imsg_compose_event(&ps->ps_ievs[id][n], - type, -1, 0, fd, data, datalen) == -1) + type, peerid, 0, fd, data, datalen) == -1) return (-1); } @@ -592,14 +592,14 @@ proc_compose_imsg(struct privsep *ps, enum privsep_procid id, int n, int proc_composev_imsg(struct privsep *ps, enum privsep_procid id, int n, - uint16_t type, int fd, const struct iovec *iov, int iovcnt) + uint16_t type, uint32_t peerid, int fd, const struct iovec *iov, int iovcnt) { int m; proc_range(ps, id, &n, &m); for (; n < m; n++) if (imsg_composev_event(&ps->ps_ievs[id][n], - type, -1, 0, fd, iov, iovcnt) == -1) + type, peerid, 0, fd, iov, iovcnt) == -1) return (-1); return (0); @@ -610,7 +610,7 @@ proc_forward_imsg(struct privsep *ps, struct imsg *imsg, enum privsep_procid id, int n) { return (proc_compose_imsg(ps, id, n, imsg->hdr.type, - imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg))); + imsg->hdr.peerid, imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg))); } struct imsgbuf * diff --git a/usr.sbin/vmd/proc.h b/usr.sbin/vmd/proc.h index 2c192551ef4..2fc2f5e2bc5 100644 --- a/usr.sbin/vmd/proc.h +++ b/usr.sbin/vmd/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.1 2015/12/02 09:14:25 reyk Exp $ */ +/* $OpenBSD: proc.h,v 1.2 2015/12/02 09:39:41 reyk Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org> @@ -147,9 +147,9 @@ int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, int imsg_composev_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, const struct iovec *, int); int proc_compose_imsg(struct privsep *, enum privsep_procid, int, - uint16_t, int, void *, uint16_t); + uint16_t, uint32_t, int, void *, uint16_t); int proc_composev_imsg(struct privsep *, enum privsep_procid, int, - uint16_t, int, const struct iovec *, int); + uint16_t, uint32_t, int, const struct iovec *, int); int proc_forward_imsg(struct privsep *, struct imsg *, enum privsep_procid, int); struct imsgbuf * diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index 32c10397e86..e8d0e648428 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.1 2015/12/02 09:14:25 reyk Exp $ */ +/* $OpenBSD: vmm.c,v 1.2 2015/12/02 09:39:41 reyk Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -159,8 +159,8 @@ vmm_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) } if (cmd && - imsg_compose_event(&ps->ps_ievs[PROC_CONTROL][0], - cmd, imsg->hdr.peerid, 0, -1, &res, sizeof(res)) == -1) + proc_compose_imsg(ps, PROC_CONTROL, cmd, imsg->hdr.peerid, + 0, -1, &res, sizeof(res)) == -1) return (-1); return (0); @@ -455,7 +455,7 @@ get_info_vm(struct privsep *ps, struct imsg *imsg) /* Return info to vmmctl(4) */ ct = vip.vip_size / sizeof(struct vm_info_result); for (i = 0; i < ct; i++) { - if (imsg_compose_event(&ps->ps_ievs[PROC_CONTROL][0], + if (proc_compose_imsg(ps, PROC_CONTROL, IMSG_VMDOP_GET_INFO_VM_DATA, imsg->hdr.peerid, 0, -1, &info[i], sizeof(struct vm_info_result)) == -1) return (EIO); |