tcp: annotate tp->write_seq lockless reads
[linux-2.6-block.git] / include / net / tcp.h
index 81e8ade1e6e415779e1a18b39bd2695c9b871152..8e7c3f6801a935c2ef4c76e7e3790ce39adcf5cb 100644 (file)
@@ -64,7 +64,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
 /* Minimal accepted MSS. It is (60+60+8) - (20+20). */
 #define TCP_MIN_MSS            88U
 
-/* The least MTU to use for probing */
+/* The initial MTU to use for probing */
 #define TCP_BASE_MSS           1024
 
 /* probing interval, default to 10 minutes as per RFC4821 */
@@ -258,7 +258,7 @@ static inline bool tcp_under_memory_pressure(const struct sock *sk)
            mem_cgroup_under_socket_pressure(sk->sk_memcg))
                return true;
 
-       return tcp_memory_pressure;
+       return READ_ONCE(tcp_memory_pressure);
 }
 /*
  * The next routines deal with comparing 32 bit unsigned ints
@@ -414,6 +414,16 @@ void tcp_parse_options(const struct net *net, const struct sk_buff *skb,
                       int estab, struct tcp_fastopen_cookie *foc);
 const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
 
+/*
+ *     BPF SKB-less helpers
+ */
+u16 tcp_v4_get_syncookie(struct sock *sk, struct iphdr *iph,
+                        struct tcphdr *th, u32 *cookie);
+u16 tcp_v6_get_syncookie(struct sock *sk, struct ipv6hdr *iph,
+                        struct tcphdr *th, u32 *cookie);
+u16 tcp_get_syncookie_mss(struct request_sock_ops *rsk_ops,
+                         const struct tcp_request_sock_ops *af_ops,
+                         struct sock *sk, struct tcphdr *th);
 /*
  *     TCP v4 functions exported for the inet6 API
  */
@@ -1370,7 +1380,8 @@ static inline int tcp_win_from_space(const struct sock *sk, int space)
 /* Note: caller must be prepared to deal with negative returns */
 static inline int tcp_space(const struct sock *sk)
 {
-       return tcp_win_from_space(sk, sk->sk_rcvbuf - sk->sk_backlog.len -
+       return tcp_win_from_space(sk, sk->sk_rcvbuf -
+                                 READ_ONCE(sk->sk_backlog.len) -
                                  atomic_read(&sk->sk_rmem_alloc));
 }
 
@@ -1906,7 +1917,7 @@ static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
 static inline bool tcp_stream_memory_free(const struct sock *sk, int wake)
 {
        const struct tcp_sock *tp = tcp_sk(sk);
-       u32 notsent_bytes = tp->write_seq - tp->snd_nxt;
+       u32 notsent_bytes = READ_ONCE(tp->write_seq) - tp->snd_nxt;
 
        return (notsent_bytes << wake) < tcp_notsent_lowat(tp);
 }
@@ -2112,6 +2123,9 @@ struct tcp_ulp_ops {
        void (*update)(struct sock *sk, struct proto *p);
        /* cleanup ulp */
        void (*release)(struct sock *sk);
+       /* diagnostic */
+       int (*get_info)(const struct sock *sk, struct sk_buff *skb);
+       size_t (*get_info_size)(const struct sock *sk);
 
        char            name[TCP_ULP_NAME_MAX];
        struct module   *owner;