aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h48
1 files changed, 41 insertions, 7 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 101b9623e85a..159f12270085 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -472,8 +472,14 @@ struct sock {
472 u32 sk_ack_backlog; 472 u32 sk_ack_backlog;
473 u32 sk_max_ack_backlog; 473 u32 sk_max_ack_backlog;
474 kuid_t sk_uid; 474 kuid_t sk_uid;
475#if IS_ENABLED(CONFIG_DEBUG_SPINLOCK) || IS_ENABLED(CONFIG_DEBUG_LOCK_ALLOC)
476 spinlock_t sk_peer_lock;
477#else
478 /* sk_peer_lock is in the ANDROID_KABI_RESERVE(1) field below */
479#endif
475 struct pid *sk_peer_pid; 480 struct pid *sk_peer_pid;
476 const struct cred *sk_peer_cred; 481 const struct cred *sk_peer_cred;
482
477 long sk_rcvtimeo; 483 long sk_rcvtimeo;
478 ktime_t sk_stamp; 484 ktime_t sk_stamp;
479#if BITS_PER_LONG==32 485#if BITS_PER_LONG==32
@@ -511,7 +517,11 @@ struct sock {
511 struct sock_reuseport __rcu *sk_reuseport_cb; 517 struct sock_reuseport __rcu *sk_reuseport_cb;
512 struct rcu_head sk_rcu; 518 struct rcu_head sk_rcu;
513 519
520#if IS_ENABLED(CONFIG_DEBUG_SPINLOCK) || IS_ENABLED(CONFIG_DEBUG_LOCK_ALLOC)
514 ANDROID_KABI_RESERVE(1); 521 ANDROID_KABI_RESERVE(1);
522#else
523 ANDROID_KABI_USE(1, spinlock_t sk_peer_lock);
524#endif
515 ANDROID_KABI_RESERVE(2); 525 ANDROID_KABI_RESERVE(2);
516 ANDROID_KABI_RESERVE(3); 526 ANDROID_KABI_RESERVE(3);
517 ANDROID_KABI_RESERVE(4); 527 ANDROID_KABI_RESERVE(4);
@@ -1842,7 +1852,8 @@ static inline u32 net_tx_rndhash(void)
1842 1852
1843static inline void sk_set_txhash(struct sock *sk) 1853static inline void sk_set_txhash(struct sock *sk)
1844{ 1854{
1845 sk->sk_txhash = net_tx_rndhash(); 1855 /* This pairs with READ_ONCE() in skb_set_hash_from_sk() */
1856 WRITE_ONCE(sk->sk_txhash, net_tx_rndhash());
1846} 1857}
1847 1858
1848static inline void sk_rethink_txhash(struct sock *sk) 1859static inline void sk_rethink_txhash(struct sock *sk)
@@ -2113,9 +2124,12 @@ static inline void sock_poll_wait(struct file *filp, struct socket *sock,
2113 2124
2114static inline void skb_set_hash_from_sk(struct sk_buff *skb, struct sock *sk) 2125static inline void skb_set_hash_from_sk(struct sk_buff *skb, struct sock *sk)
2115{ 2126{
2116 if (sk->sk_txhash) { 2127 /* This pairs with WRITE_ONCE() in sk_set_txhash() */
2128 u32 txhash = READ_ONCE(sk->sk_txhash);
2129
2130 if (txhash) {
2117 skb->l4_hash = 1; 2131 skb->l4_hash = 1;
2118 skb->hash = sk->sk_txhash; 2132 skb->hash = txhash;
2119 } 2133 }
2120} 2134}
2121 2135
@@ -2404,22 +2418,39 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
2404void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); 2418void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags);
2405 2419
2406/** 2420/**
2407 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped 2421 * _sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
2408 * @sk: socket sending this packet 2422 * @sk: socket sending this packet
2409 * @tsflags: timestamping flags to use 2423 * @tsflags: timestamping flags to use
2410 * @tx_flags: completed with instructions for time stamping 2424 * @tx_flags: completed with instructions for time stamping
2425 * @tskey: filled in with next sk_tskey (not for TCP, which uses seqno)
2411 * 2426 *
2412 * Note: callers should take care of initial ``*tx_flags`` value (usually 0) 2427 * Note: callers should take care of initial ``*tx_flags`` value (usually 0)
2413 */ 2428 */
2414static inline void sock_tx_timestamp(const struct sock *sk, __u16 tsflags, 2429static inline void _sock_tx_timestamp(struct sock *sk, __u16 tsflags,
2415 __u8 *tx_flags) 2430 __u8 *tx_flags, __u32 *tskey)
2416{ 2431{
2417 if (unlikely(tsflags)) 2432 if (unlikely(tsflags)) {
2418 __sock_tx_timestamp(tsflags, tx_flags); 2433 __sock_tx_timestamp(tsflags, tx_flags);
2434 if (tsflags & SOF_TIMESTAMPING_OPT_ID && tskey &&
2435 tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)
2436 *tskey = sk->sk_tskey++;
2437 }
2419 if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS))) 2438 if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS)))
2420 *tx_flags |= SKBTX_WIFI_STATUS; 2439 *tx_flags |= SKBTX_WIFI_STATUS;
2421} 2440}
2422 2441
2442static inline void sock_tx_timestamp(struct sock *sk, __u16 tsflags,
2443 __u8 *tx_flags)
2444{
2445 _sock_tx_timestamp(sk, tsflags, tx_flags, NULL);
2446}
2447
2448static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags)
2449{
2450 _sock_tx_timestamp(skb->sk, tsflags, &skb_shinfo(skb)->tx_flags,
2451 &skb_shinfo(skb)->tskey);
2452}
2453
2423/** 2454/**
2424 * sk_eat_skb - Release a skb if it is no longer needed 2455 * sk_eat_skb - Release a skb if it is no longer needed
2425 * @sk: socket to eat this skb from 2456 * @sk: socket to eat this skb from
@@ -2522,6 +2553,9 @@ extern int sysctl_optmem_max;
2522extern __u32 sysctl_wmem_default; 2553extern __u32 sysctl_wmem_default;
2523extern __u32 sysctl_rmem_default; 2554extern __u32 sysctl_rmem_default;
2524 2555
2556/* On 32bit arches, an skb frag is limited to 2^15 */
2557#define SKB_FRAG_PAGE_ORDER get_order(32768)
2558
2525static inline int sk_get_wmem0(const struct sock *sk, const struct proto *proto) 2559static inline int sk_get_wmem0(const struct sock *sk, const struct proto *proto)
2526{ 2560{
2527 /* Does this proto have per netns sysctl_wmem ? */ 2561 /* Does this proto have per netns sysctl_wmem ? */