[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH hurd 26/30] utils/rpctrace: make `trace_and_forward' payload-awar
From: |
Justus Winter |
Subject: |
[PATCH hurd 26/30] utils/rpctrace: make `trace_and_forward' payload-aware |
Date: |
Thu, 27 Nov 2014 14:19:06 +0100 |
As the protected payloads were retrofitted into the Mach message
format, the local port type is lost.
* utils/rpctrace.c (is_notification): New function
(trace_and_forward): Recover the original local port type.
---
utils/rpctrace.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index c954e51..62d3c87 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -1195,6 +1195,16 @@ wrap_new_task (mach_msg_header_t *inp, struct req_info
*req)
ports_port_deref (task_wrapper1);
}
+/* Returns true if the given message is a Mach notification. */
+static inline int
+is_notification (const mach_msg_header_t *InHeadP)
+{
+ int msgh_id = InHeadP->msgh_id - 64;
+ if ((msgh_id > 8) || (msgh_id < 0))
+ return 0;
+ return 1;
+}
+
int
trace_and_forward (mach_msg_header_t *inp, mach_msg_header_t *outp)
{
@@ -1219,7 +1229,24 @@ trace_and_forward (mach_msg_header_t *inp,
mach_msg_header_t *outp)
/* Look up our record for the receiving port. There is no need to check
the class, because our port bucket only ever contains one class of
ports (traced_class). */
- info = ports_lookup_port (traced_bucket, inp->msgh_local_port, 0);
+
+ if (MACH_MSGH_BITS_LOCAL (inp->msgh_bits) == MACH_MSG_TYPE_PROTECTED_PAYLOAD)
+ {
+ info = ports_lookup_payload (traced_bucket, inp->msgh_protected_payload,
+ NULL);
+ if (info)
+ {
+ /* Undo the protected payload optimization. */
+ inp->msgh_bits = MACH_MSGH_BITS (
+ MACH_MSGH_BITS_REMOTE (inp->msgh_bits),
+ is_notification (inp)? MACH_MSG_TYPE_MOVE_SEND_ONCE: info->type)
+ | MACH_MSGH_BITS_OTHER (inp->msgh_bits);
+ inp->msgh_local_port = ports_payload_get_name (info);
+ }
+ }
+ else
+ info = ports_lookup_port (traced_bucket, inp->msgh_local_port, NULL);
+
assert (info);
/* A notification message from the kernel appears to have been sent
--
2.1.3
- [PATCH hurd 19/30] startup: disable default payload to port mapping, (continued)
- [PATCH hurd 19/30] startup: disable default payload to port mapping, Justus Winter, 2014/11/27
- [PATCH hurd 18/30] proc: add payload-aware intrans functions, Justus Winter, 2014/11/27
- [PATCH hurd 23/30] trans/password: add a payload-aware intrans function, Justus Winter, 2014/11/27
- [PATCH hurd 21/30] trans/fakeroot: make the demuxer payload-aware, Justus Winter, 2014/11/27
- [PATCH hurd 22/30] trans/ifsock: add a payload-aware intrans function, Justus Winter, 2014/11/27
- [PATCH hurd 20/30] term: add a payload-aware intrans function, Justus Winter, 2014/11/27
- [PATCH hurd 24/30] trans/streamio: make the translator payload-aware, Justus Winter, 2014/11/27
- [PATCH hurd 29/30] libports: Fix build, Justus Winter, 2014/11/27
- [PATCH hurd 25/30] trans/symlink: disable default payload to port mapping, Justus Winter, 2014/11/27
- [PATCH hurd 27/30] hurd: add intranpayload functions to all hurd types, Justus Winter, 2014/11/27
- [PATCH hurd 26/30] utils/rpctrace: make `trace_and_forward' payload-aware,
Justus Winter <=
- [PATCH hurd 30/30] mach-defpager: fix build, Justus Winter, 2014/11/27
- [PATCH hurd 28/30] libports: use protected payloads to optimize the object lookup, Justus Winter, 2014/11/27
- [PATCH hurd 07/30] libnetfs: add a payload-aware intrans function, Justus Winter, 2014/11/27
- Re: [PATCH hurd 01/30] proc: fix NULL dereference, Samuel Thibault, 2014/11/27
- [PATCH hurd-dde 1/4] devnode: add a payload-aware intrans function, Justus Winter, 2014/11/27