On Fri, 11 Dec 2020 10:44:19 -0800 Arjun Roy wrote:
> From: Arjun Roy <arjun...@google.com>
> 
> tcp_recvmsg() uses the CMSG mechanism to receive control information
> like packet receive timestamps. This patch adds CMSG fields to
> struct tcp_zerocopy_receive, and provides receive timestamps
> if available to the user.
> 
> Signed-off-by: Arjun Roy <arjun...@google.com>
> Signed-off-by: Eric Dumazet <eduma...@google.com>
> Signed-off-by: Soheil Hassas Yeganeh <soh...@google.com>

>                             struct scm_timestamping_internal *tss,
>                             int *cmsg_flags);
>  static int receive_fallback_to_copy(struct sock *sk,
> -                                 struct tcp_zerocopy_receive *zc, int inq)
> +                                 struct tcp_zerocopy_receive *zc, int inq,
> +                                 struct scm_timestamping_internal *tss)
>  {
>       unsigned long copy_address = (unsigned long)zc->copybuf_address;
> -     struct scm_timestamping_internal tss_unused;
> -     int err, cmsg_flags_unused;
> +     int err;
>       struct msghdr msg = {};
>       struct iovec iov;
>  

rev xmas tree

> @@ -1913,17 +1927,24 @@ static int tcp_zerocopy_handle_leftover_data(struct 
> tcp_zerocopy_receive *zc,
>                                            struct sock *sk,
>                                            struct sk_buff *skb,
>                                            u32 *seq,
> -                                          s32 copybuf_len)
> +                                          s32 copybuf_len,
> +                                          struct scm_timestamping_internal
> +                                             *tss)

I appreciate the attempt to make the code fit 80 chars, but this
particular wrapping does more harm than good.

> @@ -4116,6 +4138,30 @@ static int do_tcp_getsockopt(struct sock *sk, int 
> level,
>               default:
>                       goto zerocopy_rcv_out;
>               }
> +zerocopy_rcv_cmsg:
> +             if (zc.msg_flags & TCP_CMSG_TS) {
> +                     unsigned long msg_control_addr;
> +                     struct msghdr cmsg_dummy;
> +
> +                     msg_control_addr = (unsigned long)zc.msg_control;
> +                     cmsg_dummy.msg_control = (void *)msg_control_addr;
> +                     cmsg_dummy.msg_controllen =
> +                             (__kernel_size_t)zc.msg_controllen;
> +                     cmsg_dummy.msg_flags = in_compat_syscall()
> +                             ? MSG_CMSG_COMPAT : 0;
> +                     zc.msg_flags = 0;
> +                     if (zc.msg_control == msg_control_addr &&
> +                         zc.msg_controllen == cmsg_dummy.msg_controllen) {
> +                             tcp_recv_timestamp(&cmsg_dummy, sk, &tss);
> +                             zc.msg_control = (__u64)
> +                                     ((uintptr_t)cmsg_dummy.msg_control);
> +                             zc.msg_controllen =
> +                                     (__u64)cmsg_dummy.msg_controllen;
> +                             zc.msg_flags = (__u32)cmsg_dummy.msg_flags;

This is indented by 4 levels. Time to create a helper?

Do we really need to cast each of these assignments explicitly?

Reply via email to