From: Jérémie Galarneau Date: Mon, 29 Aug 2016 20:02:09 +0000 (-0400) Subject: Add x86-64 override for accept4 syscall X-Git-Tag: v2.8.1~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2365a428baad529291f3c5cfb30b694a4e31375a;p=lttng-modules.git Add x86-64 override for accept4 syscall This patch adds an instrumentation override for the accept4() syscall which is almost identical to accept(), except for an additional "flags" parameter. A follow-up patch refactors both overrides to minimize code duplication as is done for the select/pselect6 overrides. Signed-off-by: Jérémie Galarneau Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h index 40fa930a..6c59790a 100644 --- a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h +++ b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h @@ -108,6 +108,63 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(accept, TP_code_post() ) +#define OVERRIDE_64_accept4 +SC_LTTNG_TRACEPOINT_EVENT_CODE(accept4, + TP_PROTO(sc_exit(long ret,) int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen, int flags), + TP_ARGS(sc_exit(ret,) fd, upeer_sockaddr, upeer_addrlen, flags), + TP_locvar( + __typeof__(upeer_sockaddr->sa_family) sa_family; + uint16_t sport; + uint32_t v4addr; + uint16_t v6addr[8]; + int v4addr_len, v6addr_len; + int uaddr_len; + ), + TP_code_pre( + sc_inout( + memset(tp_locvar, 0, sizeof(*tp_locvar)); + (void) get_user(tp_locvar->uaddr_len, upeer_addrlen); + ) + sc_out( + if (tp_locvar->uaddr_len < sizeof(struct sockaddr)) + goto skip_code; + (void) get_user(tp_locvar->sa_family, &upeer_sockaddr->sa_family); + switch (tp_locvar->sa_family) { + case AF_INET: + if (tp_locvar->uaddr_len < sizeof(struct sockaddr_in)) + goto skip_code; + (void) get_user(tp_locvar->sport, &((struct sockaddr_in *) upeer_sockaddr)->sin_port); + (void) get_user(tp_locvar->v4addr, &((struct sockaddr_in *) upeer_sockaddr)->sin_addr.s_addr); + tp_locvar->v4addr_len = 4; + break; + case AF_INET6: + if (tp_locvar->uaddr_len < sizeof(struct sockaddr_in6)) + goto skip_code; + (void) get_user(tp_locvar->sport, &((struct sockaddr_in6 *) upeer_sockaddr)->sin6_port); + if (copy_from_user(tp_locvar->v6addr, + &((struct sockaddr_in6 *) upeer_sockaddr)->sin6_addr.in6_u.u6_addr8, + sizeof(tp_locvar->v6addr))) + memset(tp_locvar->v6addr, 0, sizeof(tp_locvar->v6addr)); + tp_locvar->v6addr_len = 8; + break; + } + skip_code: + ) + ), + TP_FIELDS( + sc_exit(ctf_integer(long, ret, ret)) + sc_in(ctf_integer(int, fd, fd)) + sc_in(ctf_integer_hex(struct sockaddr *, upeer_sockaddr, upeer_sockaddr)) + sc_inout(ctf_integer(int, upeer_addrlen, tp_locvar->uaddr_len)) + sc_in(ctf_integer_hex(int, flags, flags)) + sc_out(ctf_integer(int, family, tp_locvar->sa_family)) + sc_out(ctf_integer_network(uint16_t, sport, tp_locvar->sport)) + sc_out(ctf_sequence_network(uint8_t, v4addr, &tp_locvar->v4addr, unsigned int, tp_locvar->v4addr_len)) + sc_out(ctf_sequence_network(uint16_t, v6addr, &tp_locvar->v6addr, unsigned int, tp_locvar->v6addr_len)) + ), + TP_code_post() +) + #define OVERRIDE_64_pipe SC_LTTNG_TRACEPOINT_EVENT(pipe, TP_PROTO(sc_exit(long ret,) int * fildes),