Skip to content
Snippets Groups Projects
tcp.h 32.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • Linus Torvalds's avatar
    Linus Torvalds committed
    static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int rst)
    {
    	if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0)
    		return 0;
    	if (xtime.tv_sec >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)
    		return 0;
    
    	/* RST segments are not recommended to carry timestamp,
    	   and, if they do, it is recommended to ignore PAWS because
    	   "their cleanup function should take precedence over timestamps."
    	   Certainly, it is mistake. It is necessary to understand the reasons
    	   of this constraint to relax it: if peer reboots, clock may go
    	   out-of-sync and half-open connections will not be reset.
    	   Actually, the problem would be not existing if all
    	   the implementations followed draft about maintaining clock
    	   via reboots. Linux-2.2 DOES NOT!
    
    	   However, we can relax time bounds for RST segments to MSL.
    	 */
    	if (rst && xtime.tv_sec >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL)
    		return 0;
    	return 1;
    }
    
    #define TCP_CHECK_TIMER(sk) do { } while (0)
    
    static inline int tcp_use_frto(const struct sock *sk)
    {
    	const struct tcp_sock *tp = tcp_sk(sk);
    	
    	/* F-RTO must be activated in sysctl and there must be some
    	 * unsent new data, and the advertised window should allow
    	 * sending it.
    	 */
    	return (sysctl_tcp_frto && sk->sk_send_head &&
    		!after(TCP_SKB_CB(sk->sk_send_head)->end_seq,
    		       tp->snd_una + tp->snd_wnd));
    }
    
    static inline void tcp_mib_init(void)
    {
    	/* See RFC 2012 */
    	TCP_ADD_STATS_USER(TCP_MIB_RTOALGORITHM, 1);
    	TCP_ADD_STATS_USER(TCP_MIB_RTOMIN, TCP_RTO_MIN*1000/HZ);
    	TCP_ADD_STATS_USER(TCP_MIB_RTOMAX, TCP_RTO_MAX*1000/HZ);
    	TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1);
    }
    
    
    /*from STCP */
    static inline void clear_all_retrans_hints(struct tcp_sock *tp){
    	tp->lost_skb_hint = NULL;
    	tp->scoreboard_skb_hint = NULL;
    	tp->retransmit_skb_hint = NULL;
    	tp->forward_skb_hint = NULL;
    	tp->fastpath_skb_hint = NULL;
    }
    
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    /* /proc */
    enum tcp_seq_states {
    	TCP_SEQ_STATE_LISTENING,
    	TCP_SEQ_STATE_OPENREQ,
    	TCP_SEQ_STATE_ESTABLISHED,
    	TCP_SEQ_STATE_TIME_WAIT,
    };
    
    struct tcp_seq_afinfo {
    	struct module		*owner;
    	char			*name;
    	sa_family_t		family;
    	int			(*seq_show) (struct seq_file *m, void *v);
    	struct file_operations	*seq_fops;
    };
    
    struct tcp_iter_state {
    	sa_family_t		family;
    	enum tcp_seq_states	state;
    	struct sock		*syn_wait_sk;
    	int			bucket, sbucket, num, uid;
    	struct seq_operations	seq_ops;
    };
    
    extern int tcp_proc_register(struct tcp_seq_afinfo *afinfo);
    extern void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo);
    
    
    extern struct request_sock_ops tcp_request_sock_ops;
    
    extern int tcp_v4_destroy_sock(struct sock *sk);
    
    
    extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features);
    
    #ifdef CONFIG_PROC_FS
    extern int  tcp4_proc_init(void);
    extern void tcp4_proc_exit(void);
    #endif
    
    extern void tcp_v4_init(struct net_proto_family *ops);
    extern void tcp_init(void);
    
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    #endif	/* _TCP_H */