[PATCHv2] msghdr: print SCM_TIMESTAMP* control messages

Dmitry V. Levin ldv at altlinux.org
Fri Jun 16 01:09:39 UTC 2017


On Thu, Jun 15, 2017 at 04:02:40PM +0200, Miroslav Lichvar wrote:
> Add support for printing control messages containing software and/or
> hardware timestamps, which are typically enabled by NTP and PTP
> implementations.
> 
> * print_timeval.c (print_struct_timeval_data_size): New function.
> * print_timespec.c (print_struct_timespec_data_size,
>   print_struct_timespec_array_data_size): New functions.
> * msghdr.c (print_scm_timestamp, print_scm_timestampns,
>   print_scm_timestamping): New functions.
>   (cmsg_socket_printers): Add them.
> * tests/msg_control.c: Include "xlat.h", "xlat/scmvals.h".
>   (test_scm_timestamp, test_scm_timestampns, test_scm_timestamping):
>   New functions.
>   (test_sol_socket): Use them.
> 
> Signed-off-by: Miroslav Lichvar <mlichvar at redhat.com>
> ---
>  msghdr.c            | 26 +++++++++++++-
>  print_timespec.c    | 36 ++++++++++++++++++++
>  print_timeval.c     | 12 +++++++
>  tests/msg_control.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 170 insertions(+), 1 deletion(-)
> 
> diff --git a/msghdr.c b/msghdr.c
> index 56ba549..1df2d26 100644
> --- a/msghdr.c
> +++ b/msghdr.c
> @@ -96,6 +96,27 @@ print_scm_security(struct tcb *tcp, const void *cmsg_data,
>  }
>  
>  static void
> +print_scm_timestamp(struct tcb *tcp, const void *cmsg_data,
> +		    const unsigned int data_len)
> +{
> +	print_struct_timeval_data_size(cmsg_data, data_len);
> +}
> +
> +static void
> +print_scm_timestampns(struct tcb *tcp, const void *cmsg_data,
> +		      const unsigned int data_len)
> +{
> +	print_struct_timespec_data_size(cmsg_data, data_len);
> +}
> +
> +static void
> +print_scm_timestamping(struct tcb *tcp, const void *cmsg_data,
> +		       const unsigned int data_len)
> +{
> +	print_struct_timespec_array_data_size(cmsg_data, 3, data_len);
> +}
> +
> +static void
>  print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
>  		      const unsigned int data_len)
>  {
> @@ -191,7 +212,10 @@ static const struct {
>  } cmsg_socket_printers[] = {
>  	[SCM_RIGHTS] = { print_scm_rights, sizeof(int) },
>  	[SCM_CREDENTIALS] = { print_scm_creds, sizeof(struct ucred) },
> -	[SCM_SECURITY] = { print_scm_security, 1 }
> +	[SCM_SECURITY] = { print_scm_security, 1 },
> +	[SCM_TIMESTAMP] = { print_scm_timestamp, 0 },
> +	[SCM_TIMESTAMPNS] = { print_scm_timestampns, 0 },
> +	[SCM_TIMESTAMPING] = { print_scm_timestamping, 0 }

The minimal length for these printers is 1, not 0.
Applied with this small correction, thanks!


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170616/98a791d0/attachment.bin>


More information about the Strace-devel mailing list