aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h292
1 files changed, 116 insertions, 176 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 75be5a28815d..df6a2eb20193 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -294,46 +294,32 @@ extern struct proto tcp_prot;
294#define TCP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.tcp_statistics, field) 294#define TCP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.tcp_statistics, field)
295#define TCP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field) 295#define TCP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field)
296#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) 296#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
297 297#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
298extern void tcp_v4_err(struct sk_buff *skb, u32); 298
299 299extern void tcp_v4_err(struct sk_buff *skb, u32);
300extern void tcp_shutdown (struct sock *sk, int how); 300
301 301extern void tcp_shutdown (struct sock *sk, int how);
302extern int tcp_v4_rcv(struct sk_buff *skb); 302
303 303extern int tcp_v4_rcv(struct sk_buff *skb);
304extern int tcp_v4_remember_stamp(struct sock *sk); 304
305 305extern int tcp_v4_remember_stamp(struct sock *sk);
306extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); 306extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw);
307 307extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
308extern int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, 308 size_t size);
309 struct msghdr *msg, size_t size); 309extern int tcp_sendpage(struct sock *sk, struct page *page, int offset,
310extern ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags); 310 size_t size, int flags);
311 311extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg);
312extern int tcp_ioctl(struct sock *sk, 312extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
313 int cmd, 313 struct tcphdr *th, unsigned len);
314 unsigned long arg); 314extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
315 315 struct tcphdr *th, unsigned len);
316extern int tcp_rcv_state_process(struct sock *sk, 316extern void tcp_rcv_space_adjust(struct sock *sk);
317 struct sk_buff *skb, 317extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
318 struct tcphdr *th, 318extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp);
319 unsigned len); 319extern void tcp_twsk_destructor(struct sock *sk);
320 320extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
321extern int tcp_rcv_established(struct sock *sk, 321 struct pipe_inode_info *pipe, size_t len,
322 struct sk_buff *skb, 322 unsigned int flags);
323 struct tcphdr *th,
324 unsigned len);
325
326extern void tcp_rcv_space_adjust(struct sock *sk);
327
328extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
329
330extern int tcp_twsk_unique(struct sock *sk,
331 struct sock *sktw, void *twp);
332
333extern void tcp_twsk_destructor(struct sock *sk);
334
335extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
336 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
337 323
338static inline void tcp_dec_quickack_mode(struct sock *sk, 324static inline void tcp_dec_quickack_mode(struct sock *sk,
339 const unsigned int pkts) 325 const unsigned int pkts)
@@ -371,88 +357,59 @@ enum tcp_tw_status {
371}; 357};
372 358
373 359
374extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw, 360extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw,
375 struct sk_buff *skb, 361 struct sk_buff *skb,
376 const struct tcphdr *th); 362 const struct tcphdr *th);
377 363extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb,
378extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, 364 struct request_sock *req,
379 struct request_sock *req, 365 struct request_sock **prev);
380 struct request_sock **prev); 366extern int tcp_child_process(struct sock *parent, struct sock *child,
381extern int tcp_child_process(struct sock *parent, 367 struct sk_buff *skb);
382 struct sock *child, 368extern int tcp_use_frto(struct sock *sk);
383 struct sk_buff *skb); 369extern void tcp_enter_frto(struct sock *sk);
384extern int tcp_use_frto(struct sock *sk); 370extern void tcp_enter_loss(struct sock *sk, int how);
385extern void tcp_enter_frto(struct sock *sk); 371extern void tcp_clear_retrans(struct tcp_sock *tp);
386extern void tcp_enter_loss(struct sock *sk, int how); 372extern void tcp_update_metrics(struct sock *sk);
387extern void tcp_clear_retrans(struct tcp_sock *tp); 373extern void tcp_close(struct sock *sk, long timeout);
388extern void tcp_update_metrics(struct sock *sk); 374extern unsigned int tcp_poll(struct file * file, struct socket *sock,
389 375 struct poll_table_struct *wait);
390extern void tcp_close(struct sock *sk, 376extern int tcp_getsockopt(struct sock *sk, int level, int optname,
391 long timeout); 377 char __user *optval, int __user *optlen);
392extern unsigned int tcp_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); 378extern int tcp_setsockopt(struct sock *sk, int level, int optname,
393 379 char __user *optval, unsigned int optlen);
394extern int tcp_getsockopt(struct sock *sk, int level, 380extern int compat_tcp_getsockopt(struct sock *sk, int level, int optname,
395 int optname, 381 char __user *optval, int __user *optlen);
396 char __user *optval, 382extern int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
397 int __user *optlen); 383 char __user *optval, unsigned int optlen);
398extern int tcp_setsockopt(struct sock *sk, int level, 384extern void tcp_set_keepalive(struct sock *sk, int val);
399 int optname, char __user *optval, 385extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req);
400 unsigned int optlen); 386extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
401extern int compat_tcp_getsockopt(struct sock *sk, 387 size_t len, int nonblock, int flags, int *addr_len);
402 int level, int optname, 388extern void tcp_parse_options(struct sk_buff *skb,
403 char __user *optval, int __user *optlen); 389 struct tcp_options_received *opt_rx, u8 **hvpp,
404extern int compat_tcp_setsockopt(struct sock *sk, 390 int estab);
405 int level, int optname, 391extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);
406 char __user *optval, unsigned int optlen);
407extern void tcp_set_keepalive(struct sock *sk, int val);
408extern void tcp_syn_ack_timeout(struct sock *sk,
409 struct request_sock *req);
410extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
411 struct msghdr *msg,
412 size_t len, int nonblock,
413 int flags, int *addr_len);
414
415extern void tcp_parse_options(struct sk_buff *skb,
416 struct tcp_options_received *opt_rx,
417 u8 **hvpp,
418 int estab);
419
420extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);
421 392
422/* 393/*
423 * TCP v4 functions exported for the inet6 API 394 * TCP v4 functions exported for the inet6 API
424 */ 395 */
425 396
426extern void tcp_v4_send_check(struct sock *sk, int len, 397extern void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
427 struct sk_buff *skb); 398extern int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
428 399extern struct sock * tcp_create_openreq_child(struct sock *sk,
429extern int tcp_v4_conn_request(struct sock *sk, 400 struct request_sock *req,
430 struct sk_buff *skb);
431
432extern struct sock * tcp_create_openreq_child(struct sock *sk,
433 struct request_sock *req,
434 struct sk_buff *skb);
435
436extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk,
437 struct sk_buff *skb,
438 struct request_sock *req,
439 struct dst_entry *dst);
440
441extern int tcp_v4_do_rcv(struct sock *sk,
442 struct sk_buff *skb); 401 struct sk_buff *skb);
443 402extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
444extern int tcp_v4_connect(struct sock *sk, 403 struct request_sock *req,
445 struct sockaddr *uaddr, 404 struct dst_entry *dst);
446 int addr_len); 405extern int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb);
447 406extern int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
448extern int tcp_connect(struct sock *sk); 407 int addr_len);
449 408extern int tcp_connect(struct sock *sk);
450extern struct sk_buff * tcp_make_synack(struct sock *sk, 409extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
451 struct dst_entry *dst, 410 struct request_sock *req,
452 struct request_sock *req, 411 struct request_values *rvp);
453 struct request_values *rvp); 412extern int tcp_disconnect(struct sock *sk, int flags);
454
455extern int tcp_disconnect(struct sock *sk, int flags);
456 413
457 414
458/* From syncookies.c */ 415/* From syncookies.c */
@@ -463,7 +420,7 @@ extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb,
463 __u16 *mss); 420 __u16 *mss);
464 421
465extern __u32 cookie_init_timestamp(struct request_sock *req); 422extern __u32 cookie_init_timestamp(struct request_sock *req);
466extern void cookie_check_timestamp(struct tcp_options_received *tcp_opt); 423extern bool cookie_check_timestamp(struct tcp_options_received *opt, bool *);
467 424
468/* From net/ipv6/syncookies.c */ 425/* From net/ipv6/syncookies.c */
469extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); 426extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
@@ -484,10 +441,10 @@ extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
484 441
485extern void tcp_send_probe0(struct sock *); 442extern void tcp_send_probe0(struct sock *);
486extern void tcp_send_partial(struct sock *); 443extern void tcp_send_partial(struct sock *);
487extern int tcp_write_wakeup(struct sock *); 444extern int tcp_write_wakeup(struct sock *);
488extern void tcp_send_fin(struct sock *sk); 445extern void tcp_send_fin(struct sock *sk);
489extern void tcp_send_active_reset(struct sock *sk, gfp_t priority); 446extern void tcp_send_active_reset(struct sock *sk, gfp_t priority);
490extern int tcp_send_synack(struct sock *); 447extern int tcp_send_synack(struct sock *);
491extern void tcp_push_one(struct sock *, unsigned int mss_now); 448extern void tcp_push_one(struct sock *, unsigned int mss_now);
492extern void tcp_send_ack(struct sock *sk); 449extern void tcp_send_ack(struct sock *sk);
493extern void tcp_send_delayed_ack(struct sock *sk); 450extern void tcp_send_delayed_ack(struct sock *sk);
@@ -591,7 +548,7 @@ static inline u32 tcp_receive_window(const struct tcp_sock *tp)
591 * scaling applied to the result. The caller does these things 548 * scaling applied to the result. The caller does these things
592 * if necessary. This is a "raw" window selection. 549 * if necessary. This is a "raw" window selection.
593 */ 550 */
594extern u32 __tcp_select_window(struct sock *sk); 551extern u32 __tcp_select_window(struct sock *sk);
595 552
596/* TCP timestamps are only 32-bits, this causes a slight 553/* TCP timestamps are only 32-bits, this causes a slight
597 * complication on 64-bit systems since we store a snapshot 554 * complication on 64-bit systems since we store a snapshot
@@ -601,12 +558,22 @@ extern u32 __tcp_select_window(struct sock *sk);
601 */ 558 */
602#define tcp_time_stamp ((__u32)(jiffies)) 559#define tcp_time_stamp ((__u32)(jiffies))
603 560
561#define tcp_flag_byte(th) (((u_int8_t *)th)[13])
562
563#define TCPHDR_FIN 0x01
564#define TCPHDR_SYN 0x02
565#define TCPHDR_RST 0x04
566#define TCPHDR_PSH 0x08
567#define TCPHDR_ACK 0x10
568#define TCPHDR_URG 0x20
569#define TCPHDR_ECE 0x40
570#define TCPHDR_CWR 0x80
571
604/* This is what the send packet queuing engine uses to pass 572/* This is what the send packet queuing engine uses to pass
605 * TCP per-packet control information to the transmission 573 * TCP per-packet control information to the transmission code.
606 * code. We also store the host-order sequence numbers in 574 * We also store the host-order sequence numbers in here too.
607 * here too. This is 36 bytes on 32-bit architectures, 575 * This is 44 bytes if IPV6 is enabled.
608 * 40 bytes on 64-bit machines, if this grows please adjust 576 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
609 * skbuff.h:skbuff->cb[xxx] size appropriately.
610 */ 577 */
611struct tcp_skb_cb { 578struct tcp_skb_cb {
612 union { 579 union {
@@ -619,19 +586,6 @@ struct tcp_skb_cb {
619 __u32 end_seq; /* SEQ + FIN + SYN + datalen */ 586 __u32 end_seq; /* SEQ + FIN + SYN + datalen */
620 __u32 when; /* used to compute rtt's */ 587 __u32 when; /* used to compute rtt's */
621 __u8 flags; /* TCP header flags. */ 588 __u8 flags; /* TCP header flags. */
622
623 /* NOTE: These must match up to the flags byte in a
624 * real TCP header.
625 */
626#define TCPCB_FLAG_FIN 0x01
627#define TCPCB_FLAG_SYN 0x02
628#define TCPCB_FLAG_RST 0x04
629#define TCPCB_FLAG_PSH 0x08
630#define TCPCB_FLAG_ACK 0x10
631#define TCPCB_FLAG_URG 0x20
632#define TCPCB_FLAG_ECE 0x40
633#define TCPCB_FLAG_CWR 0x80
634
635 __u8 sacked; /* State flags for SACK/FACK. */ 589 __u8 sacked; /* State flags for SACK/FACK. */
636#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ 590#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */
637#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ 591#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */
@@ -939,7 +893,7 @@ static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb)
939 893
940 tp->ucopy.memory = 0; 894 tp->ucopy.memory = 0;
941 } else if (skb_queue_len(&tp->ucopy.prequeue) == 1) { 895 } else if (skb_queue_len(&tp->ucopy.prequeue) == 1) {
942 wake_up_interruptible_sync_poll(sk->sk_sleep, 896 wake_up_interruptible_sync_poll(sk_sleep(sk),
943 POLLIN | POLLRDNORM | POLLRDBAND); 897 POLLIN | POLLRDNORM | POLLRDBAND);
944 if (!inet_csk_ack_scheduled(sk)) 898 if (!inet_csk_ack_scheduled(sk))
945 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 899 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
@@ -1032,6 +986,14 @@ static inline int keepalive_probes(const struct tcp_sock *tp)
1032 return tp->keepalive_probes ? : sysctl_tcp_keepalive_probes; 986 return tp->keepalive_probes ? : sysctl_tcp_keepalive_probes;
1033} 987}
1034 988
989static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp)
990{
991 const struct inet_connection_sock *icsk = &tp->inet_conn;
992
993 return min_t(u32, tcp_time_stamp - icsk->icsk_ack.lrcvtime,
994 tcp_time_stamp - tp->rcv_tstamp);
995}
996
1035static inline int tcp_fin_time(const struct sock *sk) 997static inline int tcp_fin_time(const struct sock *sk)
1036{ 998{
1037 int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout; 999 int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout;
@@ -1167,22 +1129,14 @@ struct tcp_md5sig_pool {
1167#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */ 1129#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */
1168 1130
1169/* - functions */ 1131/* - functions */
1170extern int tcp_v4_md5_hash_skb(char *md5_hash, 1132extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1171 struct tcp_md5sig_key *key, 1133 struct sock *sk, struct request_sock *req,
1172 struct sock *sk, 1134 struct sk_buff *skb);
1173 struct request_sock *req, 1135extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk,
1174 struct sk_buff *skb); 1136 struct sock *addr_sk);
1175 1137extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey,
1176extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 1138 u8 newkeylen);
1177 struct sock *addr_sk); 1139extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr);
1178
1179extern int tcp_v4_md5_do_add(struct sock *sk,
1180 __be32 addr,
1181 u8 *newkey,
1182 u8 newkeylen);
1183
1184extern int tcp_v4_md5_do_del(struct sock *sk,
1185 __be32 addr);
1186 1140
1187#ifdef CONFIG_TCP_MD5SIG 1141#ifdef CONFIG_TCP_MD5SIG
1188#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ 1142#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \
@@ -1195,32 +1149,17 @@ extern int tcp_v4_md5_do_del(struct sock *sk,
1195#endif 1149#endif
1196 1150
1197extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *); 1151extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *);
1198extern void tcp_free_md5sig_pool(void); 1152extern void tcp_free_md5sig_pool(void);
1153
1154extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void);
1155extern void tcp_put_md5sig_pool(void);
1199 1156
1200extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu);
1201extern void __tcp_put_md5sig_pool(void);
1202extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *); 1157extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *);
1203extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *, 1158extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *,
1204 unsigned header_len); 1159 unsigned header_len);
1205extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, 1160extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp,
1206 struct tcp_md5sig_key *key); 1161 struct tcp_md5sig_key *key);
1207 1162
1208static inline
1209struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
1210{
1211 int cpu = get_cpu();
1212 struct tcp_md5sig_pool *ret = __tcp_get_md5sig_pool(cpu);
1213 if (!ret)
1214 put_cpu();
1215 return ret;
1216}
1217
1218static inline void tcp_put_md5sig_pool(void)
1219{
1220 __tcp_put_md5sig_pool();
1221 put_cpu();
1222}
1223
1224/* write queue abstraction */ 1163/* write queue abstraction */
1225static inline void tcp_write_queue_purge(struct sock *sk) 1164static inline void tcp_write_queue_purge(struct sock *sk)
1226{ 1165{
@@ -1419,7 +1358,8 @@ struct tcp_iter_state {
1419 sa_family_t family; 1358 sa_family_t family;
1420 enum tcp_seq_states state; 1359 enum tcp_seq_states state;
1421 struct sock *syn_wait_sk; 1360 struct sock *syn_wait_sk;
1422 int bucket, sbucket, num, uid; 1361 int bucket, offset, sbucket, num, uid;
1362 loff_t last_pos;
1423}; 1363};
1424 1364
1425extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo); 1365extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo);
@@ -1440,7 +1380,7 @@ extern int tcp_gro_complete(struct sk_buff *skb);
1440extern int tcp4_gro_complete(struct sk_buff *skb); 1380extern int tcp4_gro_complete(struct sk_buff *skb);
1441 1381
1442#ifdef CONFIG_PROC_FS 1382#ifdef CONFIG_PROC_FS
1443extern int tcp4_proc_init(void); 1383extern int tcp4_proc_init(void);
1444extern void tcp4_proc_exit(void); 1384extern void tcp4_proc_exit(void);
1445#endif 1385#endif
1446 1386