]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blobdiff - include/net/sock.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[mirror_ubuntu-kernels.git] / include / net / sock.h
index 341f8bafa0cf585fc72e5819054f1b2f15a8e338..e9d769c04637a3c0b967c9bfa6def724834796b9 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * INET                An implementation of the TCP/IP protocol suite for the LINUX
  *             operating system.  INET is implemented using the  BSD Socket
  *                                     respective headers and ipv4/v6, etc now
  *                                     use private slabcaches for its socks
  *              Pedro Hortas   :       New flags field for socket options
- *
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
  */
 #ifndef _SOCK_H
 #define _SOCK_H
@@ -236,6 +231,8 @@ struct sock_common {
        /* public: */
 };
 
+struct bpf_sk_storage;
+
 /**
   *    struct sock - network layer representation of sockets
   *    @__sk_common: shared layout with inet_timewait_sock
@@ -368,6 +365,7 @@ struct sock {
        atomic_t                sk_drops;
        int                     sk_rcvlowat;
        struct sk_buff_head     sk_error_queue;
+       struct sk_buff          *sk_rx_skb_cache;
        struct sk_buff_head     sk_receive_queue;
        /*
         * The backlog queue is special, it is always used with
@@ -414,6 +412,7 @@ struct sock {
                struct sk_buff  *sk_send_head;
                struct rb_root  tcp_rtx_queue;
        };
+       struct sk_buff          *sk_tx_skb_cache;
        struct sk_buff_head     sk_write_queue;
        __s32                   sk_peek_off;
        int                     sk_write_pending;
@@ -508,6 +507,9 @@ struct sock {
 #endif
        void                    (*sk_destruct)(struct sock *sk);
        struct sock_reuseport __rcu     *sk_reuseport_cb;
+#ifdef CONFIG_BPF_SYSCALL
+       struct bpf_sk_storage __rcu     *sk_bpf_storage;
+#endif
        struct rcu_head         sk_rcu;
 };
 
@@ -966,7 +968,7 @@ static inline void sock_rps_record_flow_hash(__u32 hash)
 static inline void sock_rps_record_flow(const struct sock *sk)
 {
 #ifdef CONFIG_RPS
-       if (static_key_false(&rfs_needed)) {
+       if (static_branch_unlikely(&rfs_needed)) {
                /* Reading sk->sk_rxhash might incur an expensive cache line
                 * miss.
                 *
@@ -1466,6 +1468,11 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
        sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
        sk->sk_wmem_queued -= skb->truesize;
        sk_mem_uncharge(sk, skb->truesize);
+       if (!sk->sk_tx_skb_cache && !skb_cloned(skb)) {
+               skb_zcopy_clear(skb, true);
+               sk->sk_tx_skb_cache = skb;
+               return;
+       }
        __kfree_skb(skb);
 }
 
@@ -1607,6 +1614,8 @@ int sock_setsockopt(struct socket *sock, int level, int op,
 
 int sock_getsockopt(struct socket *sock, int level, int op,
                    char __user *optval, int __user *optlen);
+int sock_gettstamp(struct socket *sock, void __user *userstamp,
+                  bool timeval, bool time32);
 struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
                                    int noblock, int *errcode);
 struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
@@ -2427,6 +2436,15 @@ static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags)
 static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
 {
        __skb_unlink(skb, &sk->sk_receive_queue);
+       if (
+#ifdef CONFIG_RPS
+           !static_branch_unlikely(&rps_needed) &&
+#endif
+           !sk->sk_rx_skb_cache) {
+               sk->sk_rx_skb_cache = skb;
+               skb_orphan(skb);
+               return;
+       }
        __kfree_skb(skb);
 }
 
@@ -2487,8 +2505,6 @@ static inline bool sk_listener(const struct sock *sk)
 }
 
 void sock_enable_timestamp(struct sock *sk, int flag);
-int sock_get_timestamp(struct sock *, struct timeval __user *);
-int sock_get_timestampns(struct sock *, struct timespec __user *);
 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len, int level,
                       int type);