diff options
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 159 |
1 files changed, 154 insertions, 5 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 7a093d0aa0fe..c99774f15eba 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/percpu.h> | 28 | #include <linux/percpu.h> |
29 | #include <linux/skbuff.h> | 29 | #include <linux/skbuff.h> |
30 | #include <linux/dmaengine.h> | 30 | #include <linux/dmaengine.h> |
31 | #include <linux/crypto.h> | ||
31 | 32 | ||
32 | #include <net/inet_connection_sock.h> | 33 | #include <net/inet_connection_sock.h> |
33 | #include <net/inet_timewait_sock.h> | 34 | #include <net/inet_timewait_sock.h> |
@@ -138,7 +139,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
138 | #define MAX_TCP_SYNCNT 127 | 139 | #define MAX_TCP_SYNCNT 127 |
139 | 140 | ||
140 | #define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */ | 141 | #define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */ |
141 | #define TCP_SYNQ_HSIZE 512 /* Size of SYNACK hash table */ | ||
142 | 142 | ||
143 | #define TCP_PAWS_24DAYS (60 * 60 * 24 * 24) | 143 | #define TCP_PAWS_24DAYS (60 * 60 * 24 * 24) |
144 | #define TCP_PAWS_MSL 60 /* Per-host timestamps are invalidated | 144 | #define TCP_PAWS_MSL 60 /* Per-host timestamps are invalidated |
@@ -162,6 +162,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
162 | #define TCPOPT_SACK_PERM 4 /* SACK Permitted */ | 162 | #define TCPOPT_SACK_PERM 4 /* SACK Permitted */ |
163 | #define TCPOPT_SACK 5 /* SACK Block */ | 163 | #define TCPOPT_SACK 5 /* SACK Block */ |
164 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ | 164 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ |
165 | #define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ | ||
165 | 166 | ||
166 | /* | 167 | /* |
167 | * TCP option lengths | 168 | * TCP option lengths |
@@ -171,6 +172,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
171 | #define TCPOLEN_WINDOW 3 | 172 | #define TCPOLEN_WINDOW 3 |
172 | #define TCPOLEN_SACK_PERM 2 | 173 | #define TCPOLEN_SACK_PERM 2 |
173 | #define TCPOLEN_TIMESTAMP 10 | 174 | #define TCPOLEN_TIMESTAMP 10 |
175 | #define TCPOLEN_MD5SIG 18 | ||
174 | 176 | ||
175 | /* But this is what stacks really send out. */ | 177 | /* But this is what stacks really send out. */ |
176 | #define TCPOLEN_TSTAMP_ALIGNED 12 | 178 | #define TCPOLEN_TSTAMP_ALIGNED 12 |
@@ -179,6 +181,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
179 | #define TCPOLEN_SACK_BASE 2 | 181 | #define TCPOLEN_SACK_BASE 2 |
180 | #define TCPOLEN_SACK_BASE_ALIGNED 4 | 182 | #define TCPOLEN_SACK_BASE_ALIGNED 4 |
181 | #define TCPOLEN_SACK_PERBLOCK 8 | 183 | #define TCPOLEN_SACK_PERBLOCK 8 |
184 | #define TCPOLEN_MD5SIG_ALIGNED 20 | ||
182 | 185 | ||
183 | /* Flags in tp->nonagle */ | 186 | /* Flags in tp->nonagle */ |
184 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ | 187 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ |
@@ -300,6 +303,8 @@ extern void tcp_cleanup_rbuf(struct sock *sk, int copied); | |||
300 | extern int tcp_twsk_unique(struct sock *sk, | 303 | extern int tcp_twsk_unique(struct sock *sk, |
301 | struct sock *sktw, void *twp); | 304 | struct sock *sktw, void *twp); |
302 | 305 | ||
306 | extern void tcp_twsk_destructor(struct sock *sk); | ||
307 | |||
303 | static inline void tcp_dec_quickack_mode(struct sock *sk, | 308 | static inline void tcp_dec_quickack_mode(struct sock *sk, |
304 | const unsigned int pkts) | 309 | const unsigned int pkts) |
305 | { | 310 | { |
@@ -621,8 +626,12 @@ enum tcp_ca_event { | |||
621 | * Interface for adding new TCP congestion control handlers | 626 | * Interface for adding new TCP congestion control handlers |
622 | */ | 627 | */ |
623 | #define TCP_CA_NAME_MAX 16 | 628 | #define TCP_CA_NAME_MAX 16 |
629 | #define TCP_CA_MAX 128 | ||
630 | #define TCP_CA_BUF_MAX (TCP_CA_NAME_MAX*TCP_CA_MAX) | ||
631 | |||
624 | struct tcp_congestion_ops { | 632 | struct tcp_congestion_ops { |
625 | struct list_head list; | 633 | struct list_head list; |
634 | int non_restricted; | ||
626 | 635 | ||
627 | /* initialize private data (optional) */ | 636 | /* initialize private data (optional) */ |
628 | void (*init)(struct sock *sk); | 637 | void (*init)(struct sock *sk); |
@@ -660,6 +669,9 @@ extern void tcp_init_congestion_control(struct sock *sk); | |||
660 | extern void tcp_cleanup_congestion_control(struct sock *sk); | 669 | extern void tcp_cleanup_congestion_control(struct sock *sk); |
661 | extern int tcp_set_default_congestion_control(const char *name); | 670 | extern int tcp_set_default_congestion_control(const char *name); |
662 | extern void tcp_get_default_congestion_control(char *name); | 671 | extern void tcp_get_default_congestion_control(char *name); |
672 | extern void tcp_get_available_congestion_control(char *buf, size_t len); | ||
673 | extern void tcp_get_allowed_congestion_control(char *buf, size_t len); | ||
674 | extern int tcp_set_allowed_congestion_control(char *allowed); | ||
663 | extern int tcp_set_congestion_control(struct sock *sk, const char *name); | 675 | extern int tcp_set_congestion_control(struct sock *sk, const char *name); |
664 | extern void tcp_slow_start(struct tcp_sock *tp); | 676 | extern void tcp_slow_start(struct tcp_sock *tp); |
665 | 677 | ||
@@ -795,14 +807,14 @@ static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq) | |||
795 | /* | 807 | /* |
796 | * Calculate(/check) TCP checksum | 808 | * Calculate(/check) TCP checksum |
797 | */ | 809 | */ |
798 | static inline u16 tcp_v4_check(struct tcphdr *th, int len, | 810 | static inline __sum16 tcp_v4_check(struct tcphdr *th, int len, |
799 | unsigned long saddr, unsigned long daddr, | 811 | __be32 saddr, __be32 daddr, |
800 | unsigned long base) | 812 | __wsum base) |
801 | { | 813 | { |
802 | return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); | 814 | return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); |
803 | } | 815 | } |
804 | 816 | ||
805 | static inline int __tcp_checksum_complete(struct sk_buff *skb) | 817 | static inline __sum16 __tcp_checksum_complete(struct sk_buff *skb) |
806 | { | 818 | { |
807 | return __skb_checksum_complete(skb); | 819 | return __skb_checksum_complete(skb); |
808 | } | 820 | } |
@@ -1058,6 +1070,114 @@ static inline void clear_all_retrans_hints(struct tcp_sock *tp){ | |||
1058 | tp->fastpath_skb_hint = NULL; | 1070 | tp->fastpath_skb_hint = NULL; |
1059 | } | 1071 | } |
1060 | 1072 | ||
1073 | /* MD5 Signature */ | ||
1074 | struct crypto_hash; | ||
1075 | |||
1076 | /* - key database */ | ||
1077 | struct tcp_md5sig_key { | ||
1078 | u8 *key; | ||
1079 | u8 keylen; | ||
1080 | }; | ||
1081 | |||
1082 | struct tcp4_md5sig_key { | ||
1083 | u8 *key; | ||
1084 | u16 keylen; | ||
1085 | __be32 addr; | ||
1086 | }; | ||
1087 | |||
1088 | struct tcp6_md5sig_key { | ||
1089 | u8 *key; | ||
1090 | u16 keylen; | ||
1091 | #if 0 | ||
1092 | u32 scope_id; /* XXX */ | ||
1093 | #endif | ||
1094 | struct in6_addr addr; | ||
1095 | }; | ||
1096 | |||
1097 | /* - sock block */ | ||
1098 | struct tcp_md5sig_info { | ||
1099 | struct tcp4_md5sig_key *keys4; | ||
1100 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
1101 | struct tcp6_md5sig_key *keys6; | ||
1102 | u32 entries6; | ||
1103 | u32 alloced6; | ||
1104 | #endif | ||
1105 | u32 entries4; | ||
1106 | u32 alloced4; | ||
1107 | }; | ||
1108 | |||
1109 | /* - pseudo header */ | ||
1110 | struct tcp4_pseudohdr { | ||
1111 | __be32 saddr; | ||
1112 | __be32 daddr; | ||
1113 | __u8 pad; | ||
1114 | __u8 protocol; | ||
1115 | __be16 len; | ||
1116 | }; | ||
1117 | |||
1118 | struct tcp6_pseudohdr { | ||
1119 | struct in6_addr saddr; | ||
1120 | struct in6_addr daddr; | ||
1121 | __be32 len; | ||
1122 | __be32 protocol; /* including padding */ | ||
1123 | }; | ||
1124 | |||
1125 | union tcp_md5sum_block { | ||
1126 | struct tcp4_pseudohdr ip4; | ||
1127 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
1128 | struct tcp6_pseudohdr ip6; | ||
1129 | #endif | ||
1130 | }; | ||
1131 | |||
1132 | /* - pool: digest algorithm, hash description and scratch buffer */ | ||
1133 | struct tcp_md5sig_pool { | ||
1134 | struct hash_desc md5_desc; | ||
1135 | union tcp_md5sum_block md5_blk; | ||
1136 | }; | ||
1137 | |||
1138 | #define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */ | ||
1139 | |||
1140 | /* - functions */ | ||
1141 | extern int tcp_v4_calc_md5_hash(char *md5_hash, | ||
1142 | struct tcp_md5sig_key *key, | ||
1143 | struct sock *sk, | ||
1144 | struct dst_entry *dst, | ||
1145 | struct request_sock *req, | ||
1146 | struct tcphdr *th, | ||
1147 | int protocol, int tcplen); | ||
1148 | extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | ||
1149 | struct sock *addr_sk); | ||
1150 | |||
1151 | extern int tcp_v4_md5_do_add(struct sock *sk, | ||
1152 | __be32 addr, | ||
1153 | u8 *newkey, | ||
1154 | u8 newkeylen); | ||
1155 | |||
1156 | extern int tcp_v4_md5_do_del(struct sock *sk, | ||
1157 | __be32 addr); | ||
1158 | |||
1159 | extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void); | ||
1160 | extern void tcp_free_md5sig_pool(void); | ||
1161 | |||
1162 | extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu); | ||
1163 | extern void __tcp_put_md5sig_pool(void); | ||
1164 | |||
1165 | static inline | ||
1166 | struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) | ||
1167 | { | ||
1168 | int cpu = get_cpu(); | ||
1169 | struct tcp_md5sig_pool *ret = __tcp_get_md5sig_pool(cpu); | ||
1170 | if (!ret) | ||
1171 | put_cpu(); | ||
1172 | return ret; | ||
1173 | } | ||
1174 | |||
1175 | static inline void tcp_put_md5sig_pool(void) | ||
1176 | { | ||
1177 | __tcp_put_md5sig_pool(); | ||
1178 | put_cpu(); | ||
1179 | } | ||
1180 | |||
1061 | /* /proc */ | 1181 | /* /proc */ |
1062 | enum tcp_seq_states { | 1182 | enum tcp_seq_states { |
1063 | TCP_SEQ_STATE_LISTENING, | 1183 | TCP_SEQ_STATE_LISTENING, |
@@ -1097,6 +1217,35 @@ extern int tcp4_proc_init(void); | |||
1097 | extern void tcp4_proc_exit(void); | 1217 | extern void tcp4_proc_exit(void); |
1098 | #endif | 1218 | #endif |
1099 | 1219 | ||
1220 | /* TCP af-specific functions */ | ||
1221 | struct tcp_sock_af_ops { | ||
1222 | #ifdef CONFIG_TCP_MD5SIG | ||
1223 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, | ||
1224 | struct sock *addr_sk); | ||
1225 | int (*calc_md5_hash) (char *location, | ||
1226 | struct tcp_md5sig_key *md5, | ||
1227 | struct sock *sk, | ||
1228 | struct dst_entry *dst, | ||
1229 | struct request_sock *req, | ||
1230 | struct tcphdr *th, | ||
1231 | int protocol, int len); | ||
1232 | int (*md5_add) (struct sock *sk, | ||
1233 | struct sock *addr_sk, | ||
1234 | u8 *newkey, | ||
1235 | u8 len); | ||
1236 | int (*md5_parse) (struct sock *sk, | ||
1237 | char __user *optval, | ||
1238 | int optlen); | ||
1239 | #endif | ||
1240 | }; | ||
1241 | |||
1242 | struct tcp_request_sock_ops { | ||
1243 | #ifdef CONFIG_TCP_MD5SIG | ||
1244 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, | ||
1245 | struct request_sock *req); | ||
1246 | #endif | ||
1247 | }; | ||
1248 | |||
1100 | extern void tcp_v4_init(struct net_proto_family *ops); | 1249 | extern void tcp_v4_init(struct net_proto_family *ops); |
1101 | extern void tcp_init(void); | 1250 | extern void tcp_init(void); |
1102 | 1251 | ||