aboutsummaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2014-11-19 05:32:12 -0500
committerJames Morris <james.l.morris@oracle.com>2014-11-19 05:32:12 -0500
commitb10778a00d40b3d9fdaaf5891e802794781ff71c (patch)
tree6ba4cbac86eecedc3f30650e7f764ecf00c83898 /net/socket.c
parent594081ee7145cc30a3977cb4e218f81213b63dc5 (diff)
parentbfe01a5ba2490f299e1d2d5508cbbbadd897bbe9 (diff)
Merge commit 'v3.17' into next
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/net/socket.c b/net/socket.c
index abf56b2a14f9..4cdbc107606f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -106,6 +106,7 @@
106#include <linux/sockios.h> 106#include <linux/sockios.h>
107#include <linux/atalk.h> 107#include <linux/atalk.h>
108#include <net/busy_poll.h> 108#include <net/busy_poll.h>
109#include <linux/errqueue.h>
109 110
110#ifdef CONFIG_NET_RX_BUSY_POLL 111#ifdef CONFIG_NET_RX_BUSY_POLL
111unsigned int sysctl_net_busy_read __read_mostly; 112unsigned int sysctl_net_busy_read __read_mostly;
@@ -609,15 +610,26 @@ void sock_release(struct socket *sock)
609} 610}
610EXPORT_SYMBOL(sock_release); 611EXPORT_SYMBOL(sock_release);
611 612
612void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags) 613void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
613{ 614{
614 *tx_flags = 0; 615 u8 flags = *tx_flags;
615 if (sock_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE)) 616
616 *tx_flags |= SKBTX_HW_TSTAMP; 617 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_HARDWARE)
617 if (sock_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE)) 618 flags |= SKBTX_HW_TSTAMP;
618 *tx_flags |= SKBTX_SW_TSTAMP; 619
620 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_SOFTWARE)
621 flags |= SKBTX_SW_TSTAMP;
622
623 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)
624 flags |= SKBTX_SCHED_TSTAMP;
625
626 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)
627 flags |= SKBTX_ACK_TSTAMP;
628
619 if (sock_flag(sk, SOCK_WIFI_STATUS)) 629 if (sock_flag(sk, SOCK_WIFI_STATUS))
620 *tx_flags |= SKBTX_WIFI_STATUS; 630 flags |= SKBTX_WIFI_STATUS;
631
632 *tx_flags = flags;
621} 633}
622EXPORT_SYMBOL(sock_tx_timestamp); 634EXPORT_SYMBOL(sock_tx_timestamp);
623 635
@@ -697,7 +709,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
697 struct sk_buff *skb) 709 struct sk_buff *skb)
698{ 710{
699 int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP); 711 int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP);
700 struct timespec ts[3]; 712 struct scm_timestamping tss;
701 int empty = 1; 713 int empty = 1;
702 struct skb_shared_hwtstamps *shhwtstamps = 714 struct skb_shared_hwtstamps *shhwtstamps =
703 skb_hwtstamps(skb); 715 skb_hwtstamps(skb);
@@ -714,28 +726,24 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
714 put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP, 726 put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP,
715 sizeof(tv), &tv); 727 sizeof(tv), &tv);
716 } else { 728 } else {
717 skb_get_timestampns(skb, &ts[0]); 729 struct timespec ts;
730 skb_get_timestampns(skb, &ts);
718 put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPNS, 731 put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPNS,
719 sizeof(ts[0]), &ts[0]); 732 sizeof(ts), &ts);
720 } 733 }
721 } 734 }
722 735
723 736 memset(&tss, 0, sizeof(tss));
724 memset(ts, 0, sizeof(ts)); 737 if ((sk->sk_tsflags & SOF_TIMESTAMPING_SOFTWARE) &&
725 if (sock_flag(sk, SOCK_TIMESTAMPING_SOFTWARE) && 738 ktime_to_timespec_cond(skb->tstamp, tss.ts + 0))
726 ktime_to_timespec_cond(skb->tstamp, ts + 0)) 739 empty = 0;
740 if (shhwtstamps &&
741 (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
742 ktime_to_timespec_cond(shhwtstamps->hwtstamp, tss.ts + 2))
727 empty = 0; 743 empty = 0;
728 if (shhwtstamps) {
729 if (sock_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE) &&
730 ktime_to_timespec_cond(shhwtstamps->syststamp, ts + 1))
731 empty = 0;
732 if (sock_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE) &&
733 ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts + 2))
734 empty = 0;
735 }
736 if (!empty) 744 if (!empty)
737 put_cmsg(msg, SOL_SOCKET, 745 put_cmsg(msg, SOL_SOCKET,
738 SCM_TIMESTAMPING, sizeof(ts), &ts); 746 SCM_TIMESTAMPING, sizeof(tss), &tss);
739} 747}
740EXPORT_SYMBOL_GPL(__sock_recv_timestamp); 748EXPORT_SYMBOL_GPL(__sock_recv_timestamp);
741 749
@@ -1988,6 +1996,9 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
1988 if (copy_from_user(kmsg, umsg, sizeof(struct msghdr))) 1996 if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
1989 return -EFAULT; 1997 return -EFAULT;
1990 1998
1999 if (kmsg->msg_name == NULL)
2000 kmsg->msg_namelen = 0;
2001
1991 if (kmsg->msg_namelen < 0) 2002 if (kmsg->msg_namelen < 0)
1992 return -EINVAL; 2003 return -EINVAL;
1993 2004
@@ -2593,7 +2604,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
2593 * 2604 *
2594 * This function is called by a protocol handler that wants to 2605 * This function is called by a protocol handler that wants to
2595 * advertise its address family, and have it linked into the 2606 * advertise its address family, and have it linked into the
2596 * socket interface. The value ops->family coresponds to the 2607 * socket interface. The value ops->family corresponds to the
2597 * socket system call protocol family. 2608 * socket system call protocol family.
2598 */ 2609 */
2599int sock_register(const struct net_proto_family *ops) 2610int sock_register(const struct net_proto_family *ops)