diff mbox

packet: fix second argument of sock_tx_timestamp()

Message ID 1468905320-8132-1-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Yoshihiro Shimoda July 19, 2016, 5:15 a.m. UTC
This patch fixes an issue that a syscall (e.g. sendto syscall) cannot
work correctly. Since the sendto syscall doesn't have msg_control buffer,
the sock_tx_timestamp() in packet_snd() cannot work correctly because
the socks.tsflags is set to 0.
So, this patch sets the socks.tsflags to sk->sk_tsflags as default.

Fixes: c14ac9451c34 ("sock: enable timestamping using control messages")
Cc: <stable@vger.kernel.org>
Reported-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Reported-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 Changes from v1:
  - Set socks.tsflags to sk->sk_tsflags as default instead of a condition.
  - Fix other socks.tsflags values in the af_packet.c.
  - Revise the commit log.

 About v1 (as RFC):
  - http://thread.gmane.org/gmane.linux.kernel.renesas-soc/5646


 net/packet/af_packet.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Yoshihiro Shimoda July 19, 2016, 5:24 a.m. UTC | #1
> -----Original Message-----
> From: Yoshihiro Shimoda
> Sent: Tuesday, July 19, 2016 2:15 PM
> 
> This patch fixes an issue that a syscall (e.g. sendto syscall) cannot
> work correctly. Since the sendto syscall doesn't have msg_control buffer,
> the sock_tx_timestamp() in packet_snd() cannot work correctly because
> the socks.tsflags is set to 0.
> So, this patch sets the socks.tsflags to sk->sk_tsflags as default.
> 
> Fixes: c14ac9451c34 ("sock: enable timestamping using control messages")
> Cc: <stable@vger.kernel.org>
> Reported-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
> Reported-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  Changes from v1:
>   - Set socks.tsflags to sk->sk_tsflags as default instead of a condition.
>   - Fix other socks.tsflags values in the af_packet.c.
>   - Revise the commit log.
> 
>  About v1 (as RFC):
>   - http://thread.gmane.org/gmane.linux.kernel.renesas-soc/5646
> 
> 
>  net/packet/af_packet.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 9f0983f..50ea97e 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -1927,7 +1927,7 @@ retry:
>  		goto out_unlock;
>  	}
> 
> -	sockc.tsflags = 0;
> +	sockc.tsflags = sk->sk_tsflags;
>  	if (msg->msg_controllen) {
>  		err = sock_cmsg_send(sk, msg, &sockc);
>  		if (unlikely(err)) {
> @@ -2678,7 +2678,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
>  		dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
>  	}
> 
> -	sockc.tsflags = 0;
> +	sockc.tsflags = sk->sk_tsflags;

Oops! I mistook this. I will resubmit a fixed patch

Best regards,
Yoshihiro Shimoda
kernel test robot July 19, 2016, 4:01 p.m. UTC | #2
Hi,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.7-rc7 next-20160719]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yoshihiro-Shimoda/packet-fix-second-argument-of-sock_tx_timestamp/20160719-194240
config: i386-defconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   net/packet/af_packet.c: In function 'tpacket_snd':
>> net/packet/af_packet.c:2645:18: error: 'sk' undeclared (first use in this function)
     sockc.tsflags = sk->sk_tsflags;
                     ^~
   net/packet/af_packet.c:2645:18: note: each undeclared identifier is reported only once for each function it appears in

vim +/sk +2645 net/packet/af_packet.c

  2639				goto out;
  2640			proto	= saddr->sll_protocol;
  2641			addr	= saddr->sll_addr;
  2642			dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
  2643		}
  2644	
> 2645		sockc.tsflags = sk->sk_tsflags;
  2646		if (msg->msg_controllen) {
  2647			err = sock_cmsg_send(&po->sk, msg, &sockc);
  2648			if (unlikely(err))

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 9f0983f..50ea97e 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1927,7 +1927,7 @@  retry:
 		goto out_unlock;
 	}
 
-	sockc.tsflags = 0;
+	sockc.tsflags = sk->sk_tsflags;
 	if (msg->msg_controllen) {
 		err = sock_cmsg_send(sk, msg, &sockc);
 		if (unlikely(err)) {
@@ -2678,7 +2678,7 @@  static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
 		dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
 	}
 
-	sockc.tsflags = 0;
+	sockc.tsflags = sk->sk_tsflags;
 	if (msg->msg_controllen) {
 		err = sock_cmsg_send(&po->sk, msg, &sockc);
 		if (unlikely(err))
@@ -2881,7 +2881,7 @@  static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
 	if (unlikely(!(dev->flags & IFF_UP)))
 		goto out_unlock;
 
-	sockc.tsflags = 0;
+	sockc.tsflags = sk->sk_tsflags;
 	sockc.mark = sk->sk_mark;
 	if (msg->msg_controllen) {
 		err = sock_cmsg_send(sk, msg, &sockc);