aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h81
1 files changed, 72 insertions, 9 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index b3b75419eafe..433f45fc2d68 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -139,6 +139,7 @@ typedef __u64 __bitwise __addrpair;
139 * @skc_node: main hash linkage for various protocol lookup tables 139 * @skc_node: main hash linkage for various protocol lookup tables
140 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol 140 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol
141 * @skc_tx_queue_mapping: tx queue number for this connection 141 * @skc_tx_queue_mapping: tx queue number for this connection
142 * @skc_rx_queue_mapping: rx queue number for this connection
142 * @skc_flags: place holder for sk_flags 143 * @skc_flags: place holder for sk_flags
143 * %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, 144 * %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
144 * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings 145 * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings
@@ -214,7 +215,10 @@ struct sock_common {
214 struct hlist_node skc_node; 215 struct hlist_node skc_node;
215 struct hlist_nulls_node skc_nulls_node; 216 struct hlist_nulls_node skc_nulls_node;
216 }; 217 };
217 int skc_tx_queue_mapping; 218 unsigned short skc_tx_queue_mapping;
219#ifdef CONFIG_XPS
220 unsigned short skc_rx_queue_mapping;
221#endif
218 union { 222 union {
219 int skc_incoming_cpu; 223 int skc_incoming_cpu;
220 u32 skc_rcv_wnd; 224 u32 skc_rcv_wnd;
@@ -315,6 +319,9 @@ struct sock_common {
315 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0 319 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
316 * @sk_reuseport_cb: reuseport group container 320 * @sk_reuseport_cb: reuseport group container
317 * @sk_rcu: used during RCU grace period 321 * @sk_rcu: used during RCU grace period
322 * @sk_clockid: clockid used by time-based scheduling (SO_TXTIME)
323 * @sk_txtime_deadline_mode: set deadline mode for SO_TXTIME
324 * @sk_txtime_unused: unused txtime flags
318 */ 325 */
319struct sock { 326struct sock {
320 /* 327 /*
@@ -326,6 +333,9 @@ struct sock {
326#define sk_nulls_node __sk_common.skc_nulls_node 333#define sk_nulls_node __sk_common.skc_nulls_node
327#define sk_refcnt __sk_common.skc_refcnt 334#define sk_refcnt __sk_common.skc_refcnt
328#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping 335#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
336#ifdef CONFIG_XPS
337#define sk_rx_queue_mapping __sk_common.skc_rx_queue_mapping
338#endif
329 339
330#define sk_dontcopy_begin __sk_common.skc_dontcopy_begin 340#define sk_dontcopy_begin __sk_common.skc_dontcopy_begin
331#define sk_dontcopy_end __sk_common.skc_dontcopy_end 341#define sk_dontcopy_end __sk_common.skc_dontcopy_end
@@ -468,6 +478,12 @@ struct sock {
468 u8 sk_shutdown; 478 u8 sk_shutdown;
469 u32 sk_tskey; 479 u32 sk_tskey;
470 atomic_t sk_zckey; 480 atomic_t sk_zckey;
481
482 u8 sk_clockid;
483 u8 sk_txtime_deadline_mode : 1,
484 sk_txtime_report_errors : 1,
485 sk_txtime_unused : 6;
486
471 struct socket *sk_socket; 487 struct socket *sk_socket;
472 void *sk_user_data; 488 void *sk_user_data;
473#ifdef CONFIG_SECURITY 489#ifdef CONFIG_SECURITY
@@ -783,6 +799,7 @@ enum sock_flags {
783 SOCK_FILTER_LOCKED, /* Filter cannot be changed anymore */ 799 SOCK_FILTER_LOCKED, /* Filter cannot be changed anymore */
784 SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */ 800 SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
785 SOCK_RCU_FREE, /* wait rcu grace period in sk_destruct() */ 801 SOCK_RCU_FREE, /* wait rcu grace period in sk_destruct() */
802 SOCK_TXTIME,
786}; 803};
787 804
788#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)) 805#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
@@ -1578,10 +1595,17 @@ void sock_kzfree_s(struct sock *sk, void *mem, int size);
1578void sk_send_sigurg(struct sock *sk); 1595void sk_send_sigurg(struct sock *sk);
1579 1596
1580struct sockcm_cookie { 1597struct sockcm_cookie {
1598 u64 transmit_time;
1581 u32 mark; 1599 u32 mark;
1582 u16 tsflags; 1600 u16 tsflags;
1583}; 1601};
1584 1602
1603static inline void sockcm_init(struct sockcm_cookie *sockc,
1604 const struct sock *sk)
1605{
1606 *sockc = (struct sockcm_cookie) { .tsflags = sk->sk_tsflags };
1607}
1608
1585int __sock_cmsg_send(struct sock *sk, struct msghdr *msg, struct cmsghdr *cmsg, 1609int __sock_cmsg_send(struct sock *sk, struct msghdr *msg, struct cmsghdr *cmsg,
1586 struct sockcm_cookie *sockc); 1610 struct sockcm_cookie *sockc);
1587int sock_cmsg_send(struct sock *sk, struct msghdr *msg, 1611int sock_cmsg_send(struct sock *sk, struct msghdr *msg,
@@ -1681,19 +1705,58 @@ static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
1681 1705
1682static inline void sk_tx_queue_set(struct sock *sk, int tx_queue) 1706static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
1683{ 1707{
1708 /* sk_tx_queue_mapping accept only upto a 16-bit value */
1709 if (WARN_ON_ONCE((unsigned short)tx_queue >= USHRT_MAX))
1710 return;
1684 sk->sk_tx_queue_mapping = tx_queue; 1711 sk->sk_tx_queue_mapping = tx_queue;
1685} 1712}
1686 1713
1714#define NO_QUEUE_MAPPING USHRT_MAX
1715
1687static inline void sk_tx_queue_clear(struct sock *sk) 1716static inline void sk_tx_queue_clear(struct sock *sk)
1688{ 1717{
1689 sk->sk_tx_queue_mapping = -1; 1718 sk->sk_tx_queue_mapping = NO_QUEUE_MAPPING;
1690} 1719}
1691 1720
1692static inline int sk_tx_queue_get(const struct sock *sk) 1721static inline int sk_tx_queue_get(const struct sock *sk)
1693{ 1722{
1694 return sk ? sk->sk_tx_queue_mapping : -1; 1723 if (sk && sk->sk_tx_queue_mapping != NO_QUEUE_MAPPING)
1724 return sk->sk_tx_queue_mapping;
1725
1726 return -1;
1695} 1727}
1696 1728
1729static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
1730{
1731#ifdef CONFIG_XPS
1732 if (skb_rx_queue_recorded(skb)) {
1733 u16 rx_queue = skb_get_rx_queue(skb);
1734
1735 if (WARN_ON_ONCE(rx_queue == NO_QUEUE_MAPPING))
1736 return;
1737
1738 sk->sk_rx_queue_mapping = rx_queue;
1739 }
1740#endif
1741}
1742
1743static inline void sk_rx_queue_clear(struct sock *sk)
1744{
1745#ifdef CONFIG_XPS
1746 sk->sk_rx_queue_mapping = NO_QUEUE_MAPPING;
1747#endif
1748}
1749
1750#ifdef CONFIG_XPS
1751static inline int sk_rx_queue_get(const struct sock *sk)
1752{
1753 if (sk && sk->sk_rx_queue_mapping != NO_QUEUE_MAPPING)
1754 return sk->sk_rx_queue_mapping;
1755
1756 return -1;
1757}
1758#endif
1759
1697static inline void sk_set_socket(struct sock *sk, struct socket *sock) 1760static inline void sk_set_socket(struct sock *sk, struct socket *sock)
1698{ 1761{
1699 sk_tx_queue_clear(sk); 1762 sk_tx_queue_clear(sk);
@@ -1725,7 +1788,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
1725{ 1788{
1726 WARN_ON(parent->sk); 1789 WARN_ON(parent->sk);
1727 write_lock_bh(&sk->sk_callback_lock); 1790 write_lock_bh(&sk->sk_callback_lock);
1728 sk->sk_wq = parent->wq; 1791 rcu_assign_pointer(sk->sk_wq, parent->wq);
1729 parent->sk = sk; 1792 parent->sk = sk;
1730 sk_set_socket(sk, parent); 1793 sk_set_socket(sk, parent);
1731 sk->sk_uid = SOCK_INODE(parent)->i_uid; 1794 sk->sk_uid = SOCK_INODE(parent)->i_uid;
@@ -1994,16 +2057,16 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq)
1994/** 2057/**
1995 * sock_poll_wait - place memory barrier behind the poll_wait call. 2058 * sock_poll_wait - place memory barrier behind the poll_wait call.
1996 * @filp: file 2059 * @filp: file
1997 * @wait_address: socket wait queue
1998 * @p: poll_table 2060 * @p: poll_table
1999 * 2061 *
2000 * See the comments in the wq_has_sleeper function. 2062 * See the comments in the wq_has_sleeper function.
2001 */ 2063 */
2002static inline void sock_poll_wait(struct file *filp, 2064static inline void sock_poll_wait(struct file *filp, poll_table *p)
2003 wait_queue_head_t *wait_address, poll_table *p)
2004{ 2065{
2005 if (!poll_does_not_wait(p) && wait_address) { 2066 struct socket *sock = filp->private_data;
2006 poll_wait(filp, wait_address, p); 2067
2068 if (!poll_does_not_wait(p)) {
2069 poll_wait(filp, &sock->wq->wait, p);
2007 /* We need to be sure we are in sync with the 2070 /* We need to be sure we are in sync with the
2008 * socket flags modification. 2071 * socket flags modification.
2009 * 2072 *