diff options
author | Steve French <sfrench@us.ibm.com> | 2005-06-20 14:12:51 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2005-06-20 14:12:51 -0400 |
commit | 58aab753de605c14b9878a897e7349c3063afeff (patch) | |
tree | c9339c8cbcaae4dfe2232618fe6de1398d05455e /net/ipv4 | |
parent | 5893a65711164e42fea4a58bb8adf47c2fac8a4b (diff) | |
parent | 8b22c249e7de453961e4d253b19fc2a0bdd65d53 (diff) |
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 1 | ||||
-rw-r--r-- | net/ipv4/devinet.c | 9 | ||||
-rw-r--r-- | net/ipv4/fib_hash.c | 3 | ||||
-rw-r--r-- | net/ipv4/fib_lookup.h | 3 | ||||
-rw-r--r-- | net/ipv4/fib_rules.c | 7 | ||||
-rw-r--r-- | net/ipv4/fib_semantics.c | 10 | ||||
-rw-r--r-- | net/ipv4/icmp.c | 9 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 6 | ||||
-rw-r--r-- | net/ipv4/multipath_drr.c | 2 | ||||
-rw-r--r-- | net/ipv4/multipath_random.c | 2 | ||||
-rw-r--r-- | net/ipv4/multipath_rr.c | 2 | ||||
-rw-r--r-- | net/ipv4/multipath_wrandom.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_conntrack_standalone.c | 1 | ||||
-rw-r--r-- | net/ipv4/netfilter/ipt_recent.c | 10 | ||||
-rw-r--r-- | net/ipv4/raw.c | 22 | ||||
-rw-r--r-- | net/ipv4/route.c | 11 | ||||
-rw-r--r-- | net/ipv4/syncookies.c | 49 | ||||
-rw-r--r-- | net/ipv4/sysctl_net_ipv4.c | 9 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 86 | ||||
-rw-r--r-- | net/ipv4/tcp_diag.c | 37 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 172 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 68 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 27 | ||||
-rw-r--r-- | net/ipv4/tcp_timer.c | 18 |
24 files changed, 275 insertions, 291 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index b3cb49ce5fad..03942f133944 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1181,6 +1181,7 @@ EXPORT_SYMBOL(inet_stream_connect); | |||
1181 | EXPORT_SYMBOL(inet_stream_ops); | 1181 | EXPORT_SYMBOL(inet_stream_ops); |
1182 | EXPORT_SYMBOL(inet_unregister_protosw); | 1182 | EXPORT_SYMBOL(inet_unregister_protosw); |
1183 | EXPORT_SYMBOL(net_statistics); | 1183 | EXPORT_SYMBOL(net_statistics); |
1184 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); | ||
1184 | 1185 | ||
1185 | #ifdef INET_REFCNT_DEBUG | 1186 | #ifdef INET_REFCNT_DEBUG |
1186 | EXPORT_SYMBOL(inet_sock_nr); | 1187 | EXPORT_SYMBOL(inet_sock_nr); |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 478a30179a52..650dcb12d9a1 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1030,14 +1030,13 @@ static struct notifier_block ip_netdev_notifier = { | |||
1030 | }; | 1030 | }; |
1031 | 1031 | ||
1032 | static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa, | 1032 | static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa, |
1033 | u32 pid, u32 seq, int event) | 1033 | u32 pid, u32 seq, int event, unsigned int flags) |
1034 | { | 1034 | { |
1035 | struct ifaddrmsg *ifm; | 1035 | struct ifaddrmsg *ifm; |
1036 | struct nlmsghdr *nlh; | 1036 | struct nlmsghdr *nlh; |
1037 | unsigned char *b = skb->tail; | 1037 | unsigned char *b = skb->tail; |
1038 | 1038 | ||
1039 | nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*ifm)); | 1039 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*ifm), flags); |
1040 | if (pid) nlh->nlmsg_flags |= NLM_F_MULTI; | ||
1041 | ifm = NLMSG_DATA(nlh); | 1040 | ifm = NLMSG_DATA(nlh); |
1042 | ifm->ifa_family = AF_INET; | 1041 | ifm->ifa_family = AF_INET; |
1043 | ifm->ifa_prefixlen = ifa->ifa_prefixlen; | 1042 | ifm->ifa_prefixlen = ifa->ifa_prefixlen; |
@@ -1090,7 +1089,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | |||
1090 | continue; | 1089 | continue; |
1091 | if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, | 1090 | if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, |
1092 | cb->nlh->nlmsg_seq, | 1091 | cb->nlh->nlmsg_seq, |
1093 | RTM_NEWADDR) <= 0) { | 1092 | RTM_NEWADDR, NLM_F_MULTI) <= 0) { |
1094 | rcu_read_unlock(); | 1093 | rcu_read_unlock(); |
1095 | goto done; | 1094 | goto done; |
1096 | } | 1095 | } |
@@ -1113,7 +1112,7 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa) | |||
1113 | 1112 | ||
1114 | if (!skb) | 1113 | if (!skb) |
1115 | netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS); | 1114 | netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS); |
1116 | else if (inet_fill_ifaddr(skb, ifa, 0, 0, event) < 0) { | 1115 | else if (inet_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) { |
1117 | kfree_skb(skb); | 1116 | kfree_skb(skb); |
1118 | netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL); | 1117 | netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL); |
1119 | } else { | 1118 | } else { |
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c index 6506dcc01b46..b10d6bb5ef3d 100644 --- a/net/ipv4/fib_hash.c +++ b/net/ipv4/fib_hash.c | |||
@@ -703,7 +703,8 @@ fn_hash_dump_bucket(struct sk_buff *skb, struct netlink_callback *cb, | |||
703 | &f->fn_key, | 703 | &f->fn_key, |
704 | fz->fz_order, | 704 | fz->fz_order, |
705 | fa->fa_tos, | 705 | fa->fa_tos, |
706 | fa->fa_info) < 0) { | 706 | fa->fa_info, |
707 | NLM_F_MULTI) < 0) { | ||
707 | cb->args[3] = i; | 708 | cb->args[3] = i; |
708 | return -1; | 709 | return -1; |
709 | } | 710 | } |
diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h index ac4485f75e97..b729d97cfa93 100644 --- a/net/ipv4/fib_lookup.h +++ b/net/ipv4/fib_lookup.h | |||
@@ -30,7 +30,8 @@ extern int fib_nh_match(struct rtmsg *r, struct nlmsghdr *, | |||
30 | struct kern_rta *rta, struct fib_info *fi); | 30 | struct kern_rta *rta, struct fib_info *fi); |
31 | extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, | 31 | extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, |
32 | u8 tb_id, u8 type, u8 scope, void *dst, | 32 | u8 tb_id, u8 type, u8 scope, void *dst, |
33 | int dst_len, u8 tos, struct fib_info *fi); | 33 | int dst_len, u8 tos, struct fib_info *fi, |
34 | unsigned int); | ||
34 | extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, | 35 | extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, |
35 | int z, int tb_id, | 36 | int z, int tb_id, |
36 | struct nlmsghdr *n, struct netlink_skb_parms *req); | 37 | struct nlmsghdr *n, struct netlink_skb_parms *req); |
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index 39d0aadb9a2a..0b298bbc1518 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -367,13 +367,14 @@ static struct notifier_block fib_rules_notifier = { | |||
367 | 367 | ||
368 | static __inline__ int inet_fill_rule(struct sk_buff *skb, | 368 | static __inline__ int inet_fill_rule(struct sk_buff *skb, |
369 | struct fib_rule *r, | 369 | struct fib_rule *r, |
370 | struct netlink_callback *cb) | 370 | struct netlink_callback *cb, |
371 | unsigned int flags) | ||
371 | { | 372 | { |
372 | struct rtmsg *rtm; | 373 | struct rtmsg *rtm; |
373 | struct nlmsghdr *nlh; | 374 | struct nlmsghdr *nlh; |
374 | unsigned char *b = skb->tail; | 375 | unsigned char *b = skb->tail; |
375 | 376 | ||
376 | nlh = NLMSG_PUT(skb, NETLINK_CREDS(cb->skb)->pid, cb->nlh->nlmsg_seq, RTM_NEWRULE, sizeof(*rtm)); | 377 | nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWRULE, sizeof(*rtm), flags); |
377 | rtm = NLMSG_DATA(nlh); | 378 | rtm = NLMSG_DATA(nlh); |
378 | rtm->rtm_family = AF_INET; | 379 | rtm->rtm_family = AF_INET; |
379 | rtm->rtm_dst_len = r->r_dst_len; | 380 | rtm->rtm_dst_len = r->r_dst_len; |
@@ -422,7 +423,7 @@ int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb) | |||
422 | for (r=fib_rules, idx=0; r; r = r->r_next, idx++) { | 423 | for (r=fib_rules, idx=0; r; r = r->r_next, idx++) { |
423 | if (idx < s_idx) | 424 | if (idx < s_idx) |
424 | continue; | 425 | continue; |
425 | if (inet_fill_rule(skb, r, cb) < 0) | 426 | if (inet_fill_rule(skb, r, cb, NLM_F_MULTI) < 0) |
426 | break; | 427 | break; |
427 | } | 428 | } |
428 | read_unlock(&fib_rules_lock); | 429 | read_unlock(&fib_rules_lock); |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 029362d66135..c886b28ba9f5 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -276,7 +276,7 @@ void rtmsg_fib(int event, u32 key, struct fib_alias *fa, | |||
276 | struct nlmsghdr *n, struct netlink_skb_parms *req) | 276 | struct nlmsghdr *n, struct netlink_skb_parms *req) |
277 | { | 277 | { |
278 | struct sk_buff *skb; | 278 | struct sk_buff *skb; |
279 | u32 pid = req ? req->pid : 0; | 279 | u32 pid = req ? req->pid : n->nlmsg_pid; |
280 | int size = NLMSG_SPACE(sizeof(struct rtmsg)+256); | 280 | int size = NLMSG_SPACE(sizeof(struct rtmsg)+256); |
281 | 281 | ||
282 | skb = alloc_skb(size, GFP_KERNEL); | 282 | skb = alloc_skb(size, GFP_KERNEL); |
@@ -286,7 +286,7 @@ void rtmsg_fib(int event, u32 key, struct fib_alias *fa, | |||
286 | if (fib_dump_info(skb, pid, n->nlmsg_seq, event, tb_id, | 286 | if (fib_dump_info(skb, pid, n->nlmsg_seq, event, tb_id, |
287 | fa->fa_type, fa->fa_scope, &key, z, | 287 | fa->fa_type, fa->fa_scope, &key, z, |
288 | fa->fa_tos, | 288 | fa->fa_tos, |
289 | fa->fa_info) < 0) { | 289 | fa->fa_info, 0) < 0) { |
290 | kfree_skb(skb); | 290 | kfree_skb(skb); |
291 | return; | 291 | return; |
292 | } | 292 | } |
@@ -932,13 +932,13 @@ u32 __fib_res_prefsrc(struct fib_result *res) | |||
932 | int | 932 | int |
933 | fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, | 933 | fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, |
934 | u8 tb_id, u8 type, u8 scope, void *dst, int dst_len, u8 tos, | 934 | u8 tb_id, u8 type, u8 scope, void *dst, int dst_len, u8 tos, |
935 | struct fib_info *fi) | 935 | struct fib_info *fi, unsigned int flags) |
936 | { | 936 | { |
937 | struct rtmsg *rtm; | 937 | struct rtmsg *rtm; |
938 | struct nlmsghdr *nlh; | 938 | struct nlmsghdr *nlh; |
939 | unsigned char *b = skb->tail; | 939 | unsigned char *b = skb->tail; |
940 | 940 | ||
941 | nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*rtm)); | 941 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags); |
942 | rtm = NLMSG_DATA(nlh); | 942 | rtm = NLMSG_DATA(nlh); |
943 | rtm->rtm_family = AF_INET; | 943 | rtm->rtm_family = AF_INET; |
944 | rtm->rtm_dst_len = dst_len; | 944 | rtm->rtm_dst_len = dst_len; |
@@ -1035,7 +1035,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm, | |||
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | nl->nlmsg_flags = NLM_F_REQUEST; | 1037 | nl->nlmsg_flags = NLM_F_REQUEST; |
1038 | nl->nlmsg_pid = 0; | 1038 | nl->nlmsg_pid = current->pid; |
1039 | nl->nlmsg_seq = 0; | 1039 | nl->nlmsg_seq = 0; |
1040 | nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm)); | 1040 | nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm)); |
1041 | if (cmd == SIOCDELRT) { | 1041 | if (cmd == SIOCDELRT) { |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 85bf0d3e294b..cb759484979d 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -207,6 +207,7 @@ int sysctl_icmp_ignore_bogus_error_responses; | |||
207 | 207 | ||
208 | int sysctl_icmp_ratelimit = 1 * HZ; | 208 | int sysctl_icmp_ratelimit = 1 * HZ; |
209 | int sysctl_icmp_ratemask = 0x1818; | 209 | int sysctl_icmp_ratemask = 0x1818; |
210 | int sysctl_icmp_errors_use_inbound_ifaddr; | ||
210 | 211 | ||
211 | /* | 212 | /* |
212 | * ICMP control array. This specifies what to do with each ICMP. | 213 | * ICMP control array. This specifies what to do with each ICMP. |
@@ -511,8 +512,12 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info) | |||
511 | */ | 512 | */ |
512 | 513 | ||
513 | saddr = iph->daddr; | 514 | saddr = iph->daddr; |
514 | if (!(rt->rt_flags & RTCF_LOCAL)) | 515 | if (!(rt->rt_flags & RTCF_LOCAL)) { |
515 | saddr = 0; | 516 | if (sysctl_icmp_errors_use_inbound_ifaddr) |
517 | saddr = inet_select_addr(skb_in->dev, 0, RT_SCOPE_LINK); | ||
518 | else | ||
519 | saddr = 0; | ||
520 | } | ||
516 | 521 | ||
517 | tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | | 522 | tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | |
518 | IPTOS_PREC_INTERNETCONTROL) : | 523 | IPTOS_PREC_INTERNETCONTROL) : |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 47012b93cad2..f8b172f89811 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -360,14 +360,14 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len) | |||
360 | err = copied; | 360 | err = copied; |
361 | 361 | ||
362 | /* Reset and regenerate socket error */ | 362 | /* Reset and regenerate socket error */ |
363 | spin_lock_irq(&sk->sk_error_queue.lock); | 363 | spin_lock_bh(&sk->sk_error_queue.lock); |
364 | sk->sk_err = 0; | 364 | sk->sk_err = 0; |
365 | if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) { | 365 | if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) { |
366 | sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno; | 366 | sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno; |
367 | spin_unlock_irq(&sk->sk_error_queue.lock); | 367 | spin_unlock_bh(&sk->sk_error_queue.lock); |
368 | sk->sk_error_report(sk); | 368 | sk->sk_error_report(sk); |
369 | } else | 369 | } else |
370 | spin_unlock_irq(&sk->sk_error_queue.lock); | 370 | spin_unlock_bh(&sk->sk_error_queue.lock); |
371 | 371 | ||
372 | out_free_skb: | 372 | out_free_skb: |
373 | kfree_skb(skb); | 373 | kfree_skb(skb); |
diff --git a/net/ipv4/multipath_drr.c b/net/ipv4/multipath_drr.c index cf2e6bcf7973..c9cf8726051d 100644 --- a/net/ipv4/multipath_drr.c +++ b/net/ipv4/multipath_drr.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/igmp.h> | 31 | #include <linux/igmp.h> |
32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/module.h> | ||
34 | #include <linux/mroute.h> | 35 | #include <linux/mroute.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <net/ip.h> | 37 | #include <net/ip.h> |
@@ -247,3 +248,4 @@ static void __exit drr_exit(void) | |||
247 | 248 | ||
248 | module_init(drr_init); | 249 | module_init(drr_init); |
249 | module_exit(drr_exit); | 250 | module_exit(drr_exit); |
251 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/ipv4/multipath_random.c b/net/ipv4/multipath_random.c index 805a16e47de5..5249dbe7c559 100644 --- a/net/ipv4/multipath_random.c +++ b/net/ipv4/multipath_random.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/igmp.h> | 31 | #include <linux/igmp.h> |
32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/module.h> | ||
34 | #include <linux/mroute.h> | 35 | #include <linux/mroute.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <net/ip.h> | 37 | #include <net/ip.h> |
@@ -126,3 +127,4 @@ static void __exit random_exit(void) | |||
126 | 127 | ||
127 | module_init(random_init); | 128 | module_init(random_init); |
128 | module_exit(random_exit); | 129 | module_exit(random_exit); |
130 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/ipv4/multipath_rr.c b/net/ipv4/multipath_rr.c index 061b6b253982..b6cd2870478f 100644 --- a/net/ipv4/multipath_rr.c +++ b/net/ipv4/multipath_rr.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/igmp.h> | 31 | #include <linux/igmp.h> |
32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/module.h> | ||
34 | #include <linux/mroute.h> | 35 | #include <linux/mroute.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <net/ip.h> | 37 | #include <net/ip.h> |
@@ -93,3 +94,4 @@ static void __exit rr_exit(void) | |||
93 | 94 | ||
94 | module_init(rr_init); | 95 | module_init(rr_init); |
95 | module_exit(rr_exit); | 96 | module_exit(rr_exit); |
97 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c index c3d2ca1a6781..bd7d75b6abe0 100644 --- a/net/ipv4/multipath_wrandom.c +++ b/net/ipv4/multipath_wrandom.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/igmp.h> | 31 | #include <linux/igmp.h> |
32 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/module.h> | ||
34 | #include <linux/mroute.h> | 35 | #include <linux/mroute.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <net/ip.h> | 37 | #include <net/ip.h> |
@@ -342,3 +343,4 @@ static void __exit wrandom_exit(void) | |||
342 | 343 | ||
343 | module_init(wrandom_init); | 344 | module_init(wrandom_init); |
344 | module_exit(wrandom_exit); | 345 | module_exit(wrandom_exit); |
346 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c index 46ca45f74d85..bc59f7b39805 100644 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c | |||
@@ -256,6 +256,7 @@ static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos) | |||
256 | { | 256 | { |
257 | struct list_head *e = v; | 257 | struct list_head *e = v; |
258 | 258 | ||
259 | ++*pos; | ||
259 | e = e->next; | 260 | e = e->next; |
260 | 261 | ||
261 | if (e == &ip_conntrack_expect_list) | 262 | if (e == &ip_conntrack_expect_list) |
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 25ab9fabdcba..2d44b07688af 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c | |||
@@ -223,7 +223,7 @@ static int ip_recent_ctrl(struct file *file, const char __user *input, unsigned | |||
223 | curr_table->table[count].last_seen = 0; | 223 | curr_table->table[count].last_seen = 0; |
224 | curr_table->table[count].addr = 0; | 224 | curr_table->table[count].addr = 0; |
225 | curr_table->table[count].ttl = 0; | 225 | curr_table->table[count].ttl = 0; |
226 | memset(curr_table->table[count].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t)); | 226 | memset(curr_table->table[count].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long)); |
227 | curr_table->table[count].oldest_pkt = 0; | 227 | curr_table->table[count].oldest_pkt = 0; |
228 | curr_table->table[count].time_pos = 0; | 228 | curr_table->table[count].time_pos = 0; |
229 | curr_table->time_info[count].position = count; | 229 | curr_table->time_info[count].position = count; |
@@ -502,7 +502,7 @@ match(const struct sk_buff *skb, | |||
502 | location = time_info[curr_table->time_pos].position; | 502 | location = time_info[curr_table->time_pos].position; |
503 | hash_table[r_list[location].hash_entry] = -1; | 503 | hash_table[r_list[location].hash_entry] = -1; |
504 | hash_table[hash_result] = location; | 504 | hash_table[hash_result] = location; |
505 | memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t)); | 505 | memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long)); |
506 | r_list[location].time_pos = curr_table->time_pos; | 506 | r_list[location].time_pos = curr_table->time_pos; |
507 | r_list[location].addr = addr; | 507 | r_list[location].addr = addr; |
508 | r_list[location].ttl = ttl; | 508 | r_list[location].ttl = ttl; |
@@ -631,7 +631,7 @@ match(const struct sk_buff *skb, | |||
631 | r_list[location].last_seen = 0; | 631 | r_list[location].last_seen = 0; |
632 | r_list[location].addr = 0; | 632 | r_list[location].addr = 0; |
633 | r_list[location].ttl = 0; | 633 | r_list[location].ttl = 0; |
634 | memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(u_int32_t)); | 634 | memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long)); |
635 | r_list[location].oldest_pkt = 0; | 635 | r_list[location].oldest_pkt = 0; |
636 | ans = !info->invert; | 636 | ans = !info->invert; |
637 | } | 637 | } |
@@ -734,10 +734,10 @@ checkentry(const char *tablename, | |||
734 | memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot); | 734 | memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot); |
735 | #ifdef DEBUG | 735 | #ifdef DEBUG |
736 | if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n", | 736 | if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n", |
737 | sizeof(u_int32_t)*ip_pkt_list_tot*ip_list_tot); | 737 | sizeof(unsigned long)*ip_pkt_list_tot*ip_list_tot); |
738 | #endif | 738 | #endif |
739 | 739 | ||
740 | hold = vmalloc(sizeof(u_int32_t)*ip_pkt_list_tot*ip_list_tot); | 740 | hold = vmalloc(sizeof(unsigned long)*ip_pkt_list_tot*ip_list_tot); |
741 | #ifdef DEBUG | 741 | #ifdef DEBUG |
742 | if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: After pkt_list allocation.\n"); | 742 | if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: After pkt_list allocation.\n"); |
743 | #endif | 743 | #endif |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 5b1ec586bae6..d1835b1bc8c4 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -259,7 +259,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb) | |||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | static int raw_send_hdrinc(struct sock *sk, void *from, int length, | 262 | static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, |
263 | struct rtable *rt, | 263 | struct rtable *rt, |
264 | unsigned int flags) | 264 | unsigned int flags) |
265 | { | 265 | { |
@@ -298,7 +298,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length, | |||
298 | goto error_fault; | 298 | goto error_fault; |
299 | 299 | ||
300 | /* We don't modify invalid header */ | 300 | /* We don't modify invalid header */ |
301 | if (length >= sizeof(*iph) && iph->ihl * 4 <= length) { | 301 | if (length >= sizeof(*iph) && iph->ihl * 4U <= length) { |
302 | if (!iph->saddr) | 302 | if (!iph->saddr) |
303 | iph->saddr = rt->rt_src; | 303 | iph->saddr = rt->rt_src; |
304 | iph->check = 0; | 304 | iph->check = 0; |
@@ -332,7 +332,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg) | |||
332 | u8 __user *type = NULL; | 332 | u8 __user *type = NULL; |
333 | u8 __user *code = NULL; | 333 | u8 __user *code = NULL; |
334 | int probed = 0; | 334 | int probed = 0; |
335 | int i; | 335 | unsigned int i; |
336 | 336 | ||
337 | if (!msg->msg_iov) | 337 | if (!msg->msg_iov) |
338 | return; | 338 | return; |
@@ -384,7 +384,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
384 | int err; | 384 | int err; |
385 | 385 | ||
386 | err = -EMSGSIZE; | 386 | err = -EMSGSIZE; |
387 | if (len < 0 || len > 0xFFFF) | 387 | if (len > 0xFFFF) |
388 | goto out; | 388 | goto out; |
389 | 389 | ||
390 | /* | 390 | /* |
@@ -514,7 +514,10 @@ done: | |||
514 | kfree(ipc.opt); | 514 | kfree(ipc.opt); |
515 | ip_rt_put(rt); | 515 | ip_rt_put(rt); |
516 | 516 | ||
517 | out: return err < 0 ? err : len; | 517 | out: |
518 | if (err < 0) | ||
519 | return err; | ||
520 | return len; | ||
518 | 521 | ||
519 | do_confirm: | 522 | do_confirm: |
520 | dst_confirm(&rt->u.dst); | 523 | dst_confirm(&rt->u.dst); |
@@ -610,7 +613,10 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
610 | copied = skb->len; | 613 | copied = skb->len; |
611 | done: | 614 | done: |
612 | skb_free_datagram(sk, skb); | 615 | skb_free_datagram(sk, skb); |
613 | out: return err ? err : copied; | 616 | out: |
617 | if (err) | ||
618 | return err; | ||
619 | return copied; | ||
614 | } | 620 | } |
615 | 621 | ||
616 | static int raw_init(struct sock *sk) | 622 | static int raw_init(struct sock *sk) |
@@ -691,11 +697,11 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
691 | struct sk_buff *skb; | 697 | struct sk_buff *skb; |
692 | int amount = 0; | 698 | int amount = 0; |
693 | 699 | ||
694 | spin_lock_irq(&sk->sk_receive_queue.lock); | 700 | spin_lock_bh(&sk->sk_receive_queue.lock); |
695 | skb = skb_peek(&sk->sk_receive_queue); | 701 | skb = skb_peek(&sk->sk_receive_queue); |
696 | if (skb != NULL) | 702 | if (skb != NULL) |
697 | amount = skb->len; | 703 | amount = skb->len; |
698 | spin_unlock_irq(&sk->sk_receive_queue.lock); | 704 | spin_unlock_bh(&sk->sk_receive_queue.lock); |
699 | return put_user(amount, (int __user *)arg); | 705 | return put_user(amount, (int __user *)arg); |
700 | } | 706 | } |
701 | 707 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a682d28e247b..f4d53c919869 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2581,7 +2581,7 @@ int ip_route_output_key(struct rtable **rp, struct flowi *flp) | |||
2581 | } | 2581 | } |
2582 | 2582 | ||
2583 | static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, | 2583 | static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, |
2584 | int nowait) | 2584 | int nowait, unsigned int flags) |
2585 | { | 2585 | { |
2586 | struct rtable *rt = (struct rtable*)skb->dst; | 2586 | struct rtable *rt = (struct rtable*)skb->dst; |
2587 | struct rtmsg *r; | 2587 | struct rtmsg *r; |
@@ -2591,9 +2591,8 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, | |||
2591 | #ifdef CONFIG_IP_MROUTE | 2591 | #ifdef CONFIG_IP_MROUTE |
2592 | struct rtattr *eptr; | 2592 | struct rtattr *eptr; |
2593 | #endif | 2593 | #endif |
2594 | nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*r)); | 2594 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags); |
2595 | r = NLMSG_DATA(nlh); | 2595 | r = NLMSG_DATA(nlh); |
2596 | nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0; | ||
2597 | r->rtm_family = AF_INET; | 2596 | r->rtm_family = AF_INET; |
2598 | r->rtm_dst_len = 32; | 2597 | r->rtm_dst_len = 32; |
2599 | r->rtm_src_len = 0; | 2598 | r->rtm_src_len = 0; |
@@ -2744,7 +2743,7 @@ int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg) | |||
2744 | NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid; | 2743 | NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid; |
2745 | 2744 | ||
2746 | err = rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, | 2745 | err = rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, |
2747 | RTM_NEWROUTE, 0); | 2746 | RTM_NEWROUTE, 0, 0); |
2748 | if (!err) | 2747 | if (!err) |
2749 | goto out_free; | 2748 | goto out_free; |
2750 | if (err < 0) { | 2749 | if (err < 0) { |
@@ -2781,8 +2780,8 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2781 | continue; | 2780 | continue; |
2782 | skb->dst = dst_clone(&rt->u.dst); | 2781 | skb->dst = dst_clone(&rt->u.dst); |
2783 | if (rt_fill_info(skb, NETLINK_CB(cb->skb).pid, | 2782 | if (rt_fill_info(skb, NETLINK_CB(cb->skb).pid, |
2784 | cb->nlh->nlmsg_seq, | 2783 | cb->nlh->nlmsg_seq, RTM_NEWROUTE, |
2785 | RTM_NEWROUTE, 1) <= 0) { | 2784 | 1, NLM_F_MULTI) <= 0) { |
2786 | dst_release(xchg(&skb->dst, NULL)); | 2785 | dst_release(xchg(&skb->dst, NULL)); |
2787 | rcu_read_unlock_bh(); | 2786 | rcu_read_unlock_bh(); |
2788 | goto done; | 2787 | goto done; |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index e923d2f021aa..72d014442185 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -169,10 +169,10 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie) | |||
169 | return mssind < NUM_MSS ? msstab[mssind] + 1 : 0; | 169 | return mssind < NUM_MSS ? msstab[mssind] + 1 : 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | extern struct or_calltable or_ipv4; | 172 | extern struct request_sock_ops tcp_request_sock_ops; |
173 | 173 | ||
174 | static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | 174 | static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, |
175 | struct open_request *req, | 175 | struct request_sock *req, |
176 | struct dst_entry *dst) | 176 | struct dst_entry *dst) |
177 | { | 177 | { |
178 | struct tcp_sock *tp = tcp_sk(sk); | 178 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -182,7 +182,7 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | |||
182 | if (child) | 182 | if (child) |
183 | tcp_acceptq_queue(sk, req, child); | 183 | tcp_acceptq_queue(sk, req, child); |
184 | else | 184 | else |
185 | tcp_openreq_free(req); | 185 | reqsk_free(req); |
186 | 186 | ||
187 | return child; | 187 | return child; |
188 | } | 188 | } |
@@ -190,10 +190,12 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | |||
190 | struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | 190 | struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, |
191 | struct ip_options *opt) | 191 | struct ip_options *opt) |
192 | { | 192 | { |
193 | struct inet_request_sock *ireq; | ||
194 | struct tcp_request_sock *treq; | ||
193 | struct tcp_sock *tp = tcp_sk(sk); | 195 | struct tcp_sock *tp = tcp_sk(sk); |
194 | __u32 cookie = ntohl(skb->h.th->ack_seq) - 1; | 196 | __u32 cookie = ntohl(skb->h.th->ack_seq) - 1; |
195 | struct sock *ret = sk; | 197 | struct sock *ret = sk; |
196 | struct open_request *req; | 198 | struct request_sock *req; |
197 | int mss; | 199 | int mss; |
198 | struct rtable *rt; | 200 | struct rtable *rt; |
199 | __u8 rcv_wscale; | 201 | __u8 rcv_wscale; |
@@ -209,19 +211,20 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
209 | 211 | ||
210 | NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESRECV); | 212 | NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESRECV); |
211 | 213 | ||
212 | req = tcp_openreq_alloc(); | ||
213 | ret = NULL; | 214 | ret = NULL; |
215 | req = reqsk_alloc(&tcp_request_sock_ops); /* for safety */ | ||
214 | if (!req) | 216 | if (!req) |
215 | goto out; | 217 | goto out; |
216 | 218 | ||
217 | req->rcv_isn = htonl(skb->h.th->seq) - 1; | 219 | ireq = inet_rsk(req); |
218 | req->snt_isn = cookie; | 220 | treq = tcp_rsk(req); |
221 | treq->rcv_isn = htonl(skb->h.th->seq) - 1; | ||
222 | treq->snt_isn = cookie; | ||
219 | req->mss = mss; | 223 | req->mss = mss; |
220 | req->rmt_port = skb->h.th->source; | 224 | ireq->rmt_port = skb->h.th->source; |
221 | req->af.v4_req.loc_addr = skb->nh.iph->daddr; | 225 | ireq->loc_addr = skb->nh.iph->daddr; |
222 | req->af.v4_req.rmt_addr = skb->nh.iph->saddr; | 226 | ireq->rmt_addr = skb->nh.iph->saddr; |
223 | req->class = &or_ipv4; /* for savety */ | 227 | ireq->opt = NULL; |
224 | req->af.v4_req.opt = NULL; | ||
225 | 228 | ||
226 | /* We throwed the options of the initial SYN away, so we hope | 229 | /* We throwed the options of the initial SYN away, so we hope |
227 | * the ACK carries the same options again (see RFC1122 4.2.3.8) | 230 | * the ACK carries the same options again (see RFC1122 4.2.3.8) |
@@ -229,17 +232,15 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
229 | if (opt && opt->optlen) { | 232 | if (opt && opt->optlen) { |
230 | int opt_size = sizeof(struct ip_options) + opt->optlen; | 233 | int opt_size = sizeof(struct ip_options) + opt->optlen; |
231 | 234 | ||
232 | req->af.v4_req.opt = kmalloc(opt_size, GFP_ATOMIC); | 235 | ireq->opt = kmalloc(opt_size, GFP_ATOMIC); |
233 | if (req->af.v4_req.opt) { | 236 | if (ireq->opt != NULL && ip_options_echo(ireq->opt, skb)) { |
234 | if (ip_options_echo(req->af.v4_req.opt, skb)) { | 237 | kfree(ireq->opt); |
235 | kfree(req->af.v4_req.opt); | 238 | ireq->opt = NULL; |
236 | req->af.v4_req.opt = NULL; | ||
237 | } | ||
238 | } | 239 | } |
239 | } | 240 | } |
240 | 241 | ||
241 | req->snd_wscale = req->rcv_wscale = req->tstamp_ok = 0; | 242 | ireq->snd_wscale = ireq->rcv_wscale = ireq->tstamp_ok = 0; |
242 | req->wscale_ok = req->sack_ok = 0; | 243 | ireq->wscale_ok = ireq->sack_ok = 0; |
243 | req->expires = 0UL; | 244 | req->expires = 0UL; |
244 | req->retrans = 0; | 245 | req->retrans = 0; |
245 | 246 | ||
@@ -253,15 +254,15 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
253 | struct flowi fl = { .nl_u = { .ip4_u = | 254 | struct flowi fl = { .nl_u = { .ip4_u = |
254 | { .daddr = ((opt && opt->srr) ? | 255 | { .daddr = ((opt && opt->srr) ? |
255 | opt->faddr : | 256 | opt->faddr : |
256 | req->af.v4_req.rmt_addr), | 257 | ireq->rmt_addr), |
257 | .saddr = req->af.v4_req.loc_addr, | 258 | .saddr = ireq->loc_addr, |
258 | .tos = RT_CONN_FLAGS(sk) } }, | 259 | .tos = RT_CONN_FLAGS(sk) } }, |
259 | .proto = IPPROTO_TCP, | 260 | .proto = IPPROTO_TCP, |
260 | .uli_u = { .ports = | 261 | .uli_u = { .ports = |
261 | { .sport = skb->h.th->dest, | 262 | { .sport = skb->h.th->dest, |
262 | .dport = skb->h.th->source } } }; | 263 | .dport = skb->h.th->source } } }; |
263 | if (ip_route_output_key(&rt, &fl)) { | 264 | if (ip_route_output_key(&rt, &fl)) { |
264 | tcp_openreq_free(req); | 265 | reqsk_free(req); |
265 | goto out; | 266 | goto out; |
266 | } | 267 | } |
267 | } | 268 | } |
@@ -272,7 +273,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
272 | &req->rcv_wnd, &req->window_clamp, | 273 | &req->rcv_wnd, &req->window_clamp, |
273 | 0, &rcv_wscale); | 274 | 0, &rcv_wscale); |
274 | /* BTW win scale with syncookies is 0 by definition */ | 275 | /* BTW win scale with syncookies is 0 by definition */ |
275 | req->rcv_wscale = rcv_wscale; | 276 | ireq->rcv_wscale = rcv_wscale; |
276 | 277 | ||
277 | ret = get_cookie_sock(sk, skb, req, &rt->u.dst); | 278 | ret = get_cookie_sock(sk, skb, req, &rt->u.dst); |
278 | out: return ret; | 279 | out: return ret; |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 3aafb298c1c1..23068bddbf0b 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -23,6 +23,7 @@ extern int sysctl_ip_nonlocal_bind; | |||
23 | extern int sysctl_icmp_echo_ignore_all; | 23 | extern int sysctl_icmp_echo_ignore_all; |
24 | extern int sysctl_icmp_echo_ignore_broadcasts; | 24 | extern int sysctl_icmp_echo_ignore_broadcasts; |
25 | extern int sysctl_icmp_ignore_bogus_error_responses; | 25 | extern int sysctl_icmp_ignore_bogus_error_responses; |
26 | extern int sysctl_icmp_errors_use_inbound_ifaddr; | ||
26 | 27 | ||
27 | /* From ip_fragment.c */ | 28 | /* From ip_fragment.c */ |
28 | extern int sysctl_ipfrag_low_thresh; | 29 | extern int sysctl_ipfrag_low_thresh; |
@@ -396,6 +397,14 @@ ctl_table ipv4_table[] = { | |||
396 | .proc_handler = &proc_dointvec | 397 | .proc_handler = &proc_dointvec |
397 | }, | 398 | }, |
398 | { | 399 | { |
400 | .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR, | ||
401 | .procname = "icmp_errors_use_inbound_ifaddr", | ||
402 | .data = &sysctl_icmp_errors_use_inbound_ifaddr, | ||
403 | .maxlen = sizeof(int), | ||
404 | .mode = 0644, | ||
405 | .proc_handler = &proc_dointvec | ||
406 | }, | ||
407 | { | ||
399 | .ctl_name = NET_IPV4_ROUTE, | 408 | .ctl_name = NET_IPV4_ROUTE, |
400 | .procname = "route", | 409 | .procname = "route", |
401 | .maxlen = 0, | 410 | .maxlen = 0, |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a037bafcba3c..674bbd8cfd36 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -271,7 +271,6 @@ int sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT; | |||
271 | 271 | ||
272 | DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); | 272 | DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); |
273 | 273 | ||
274 | kmem_cache_t *tcp_openreq_cachep; | ||
275 | kmem_cache_t *tcp_bucket_cachep; | 274 | kmem_cache_t *tcp_bucket_cachep; |
276 | kmem_cache_t *tcp_timewait_cachep; | 275 | kmem_cache_t *tcp_timewait_cachep; |
277 | 276 | ||
@@ -317,7 +316,7 @@ EXPORT_SYMBOL(tcp_enter_memory_pressure); | |||
317 | static __inline__ unsigned int tcp_listen_poll(struct sock *sk, | 316 | static __inline__ unsigned int tcp_listen_poll(struct sock *sk, |
318 | poll_table *wait) | 317 | poll_table *wait) |
319 | { | 318 | { |
320 | return tcp_sk(sk)->accept_queue ? (POLLIN | POLLRDNORM) : 0; | 319 | return !reqsk_queue_empty(&tcp_sk(sk)->accept_queue) ? (POLLIN | POLLRDNORM) : 0; |
321 | } | 320 | } |
322 | 321 | ||
323 | /* | 322 | /* |
@@ -463,28 +462,15 @@ int tcp_listen_start(struct sock *sk) | |||
463 | { | 462 | { |
464 | struct inet_sock *inet = inet_sk(sk); | 463 | struct inet_sock *inet = inet_sk(sk); |
465 | struct tcp_sock *tp = tcp_sk(sk); | 464 | struct tcp_sock *tp = tcp_sk(sk); |
466 | struct tcp_listen_opt *lopt; | 465 | int rc = reqsk_queue_alloc(&tp->accept_queue, TCP_SYNQ_HSIZE); |
466 | |||
467 | if (rc != 0) | ||
468 | return rc; | ||
467 | 469 | ||
468 | sk->sk_max_ack_backlog = 0; | 470 | sk->sk_max_ack_backlog = 0; |
469 | sk->sk_ack_backlog = 0; | 471 | sk->sk_ack_backlog = 0; |
470 | tp->accept_queue = tp->accept_queue_tail = NULL; | ||
471 | rwlock_init(&tp->syn_wait_lock); | ||
472 | tcp_delack_init(tp); | 472 | tcp_delack_init(tp); |
473 | 473 | ||
474 | lopt = kmalloc(sizeof(struct tcp_listen_opt), GFP_KERNEL); | ||
475 | if (!lopt) | ||
476 | return -ENOMEM; | ||
477 | |||
478 | memset(lopt, 0, sizeof(struct tcp_listen_opt)); | ||
479 | for (lopt->max_qlen_log = 6; ; lopt->max_qlen_log++) | ||
480 | if ((1 << lopt->max_qlen_log) >= sysctl_max_syn_backlog) | ||
481 | break; | ||
482 | get_random_bytes(&lopt->hash_rnd, 4); | ||
483 | |||
484 | write_lock_bh(&tp->syn_wait_lock); | ||
485 | tp->listen_opt = lopt; | ||
486 | write_unlock_bh(&tp->syn_wait_lock); | ||
487 | |||
488 | /* There is race window here: we announce ourselves listening, | 474 | /* There is race window here: we announce ourselves listening, |
489 | * but this transition is still not validated by get_port(). | 475 | * but this transition is still not validated by get_port(). |
490 | * It is OK, because this socket enters to hash table only | 476 | * It is OK, because this socket enters to hash table only |
@@ -501,10 +487,7 @@ int tcp_listen_start(struct sock *sk) | |||
501 | } | 487 | } |
502 | 488 | ||
503 | sk->sk_state = TCP_CLOSE; | 489 | sk->sk_state = TCP_CLOSE; |
504 | write_lock_bh(&tp->syn_wait_lock); | 490 | reqsk_queue_destroy(&tp->accept_queue); |
505 | tp->listen_opt = NULL; | ||
506 | write_unlock_bh(&tp->syn_wait_lock); | ||
507 | kfree(lopt); | ||
508 | return -EADDRINUSE; | 491 | return -EADDRINUSE; |
509 | } | 492 | } |
510 | 493 | ||
@@ -516,25 +499,23 @@ int tcp_listen_start(struct sock *sk) | |||
516 | static void tcp_listen_stop (struct sock *sk) | 499 | static void tcp_listen_stop (struct sock *sk) |
517 | { | 500 | { |
518 | struct tcp_sock *tp = tcp_sk(sk); | 501 | struct tcp_sock *tp = tcp_sk(sk); |
519 | struct tcp_listen_opt *lopt = tp->listen_opt; | 502 | struct listen_sock *lopt; |
520 | struct open_request *acc_req = tp->accept_queue; | 503 | struct request_sock *acc_req; |
521 | struct open_request *req; | 504 | struct request_sock *req; |
522 | int i; | 505 | int i; |
523 | 506 | ||
524 | tcp_delete_keepalive_timer(sk); | 507 | tcp_delete_keepalive_timer(sk); |
525 | 508 | ||
526 | /* make all the listen_opt local to us */ | 509 | /* make all the listen_opt local to us */ |
527 | write_lock_bh(&tp->syn_wait_lock); | 510 | lopt = reqsk_queue_yank_listen_sk(&tp->accept_queue); |
528 | tp->listen_opt = NULL; | 511 | acc_req = reqsk_queue_yank_acceptq(&tp->accept_queue); |
529 | write_unlock_bh(&tp->syn_wait_lock); | ||
530 | tp->accept_queue = tp->accept_queue_tail = NULL; | ||
531 | 512 | ||
532 | if (lopt->qlen) { | 513 | if (lopt->qlen) { |
533 | for (i = 0; i < TCP_SYNQ_HSIZE; i++) { | 514 | for (i = 0; i < TCP_SYNQ_HSIZE; i++) { |
534 | while ((req = lopt->syn_table[i]) != NULL) { | 515 | while ((req = lopt->syn_table[i]) != NULL) { |
535 | lopt->syn_table[i] = req->dl_next; | 516 | lopt->syn_table[i] = req->dl_next; |
536 | lopt->qlen--; | 517 | lopt->qlen--; |
537 | tcp_openreq_free(req); | 518 | reqsk_free(req); |
538 | 519 | ||
539 | /* Following specs, it would be better either to send FIN | 520 | /* Following specs, it would be better either to send FIN |
540 | * (and enter FIN-WAIT-1, it is normal close) | 521 | * (and enter FIN-WAIT-1, it is normal close) |
@@ -574,7 +555,7 @@ static void tcp_listen_stop (struct sock *sk) | |||
574 | sock_put(child); | 555 | sock_put(child); |
575 | 556 | ||
576 | sk_acceptq_removed(sk); | 557 | sk_acceptq_removed(sk); |
577 | tcp_openreq_fastfree(req); | 558 | __reqsk_free(req); |
578 | } | 559 | } |
579 | BUG_TRAP(!sk->sk_ack_backlog); | 560 | BUG_TRAP(!sk->sk_ack_backlog); |
580 | } | 561 | } |
@@ -1345,7 +1326,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
1345 | 1326 | ||
1346 | cleanup_rbuf(sk, copied); | 1327 | cleanup_rbuf(sk, copied); |
1347 | 1328 | ||
1348 | if (tp->ucopy.task == user_recv) { | 1329 | if (!sysctl_tcp_low_latency && tp->ucopy.task == user_recv) { |
1349 | /* Install new reader */ | 1330 | /* Install new reader */ |
1350 | if (!user_recv && !(flags & (MSG_TRUNC | MSG_PEEK))) { | 1331 | if (!user_recv && !(flags & (MSG_TRUNC | MSG_PEEK))) { |
1351 | user_recv = current; | 1332 | user_recv = current; |
@@ -1868,11 +1849,11 @@ static int wait_for_connect(struct sock *sk, long timeo) | |||
1868 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, | 1849 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, |
1869 | TASK_INTERRUPTIBLE); | 1850 | TASK_INTERRUPTIBLE); |
1870 | release_sock(sk); | 1851 | release_sock(sk); |
1871 | if (!tp->accept_queue) | 1852 | if (reqsk_queue_empty(&tp->accept_queue)) |
1872 | timeo = schedule_timeout(timeo); | 1853 | timeo = schedule_timeout(timeo); |
1873 | lock_sock(sk); | 1854 | lock_sock(sk); |
1874 | err = 0; | 1855 | err = 0; |
1875 | if (tp->accept_queue) | 1856 | if (!reqsk_queue_empty(&tp->accept_queue)) |
1876 | break; | 1857 | break; |
1877 | err = -EINVAL; | 1858 | err = -EINVAL; |
1878 | if (sk->sk_state != TCP_LISTEN) | 1859 | if (sk->sk_state != TCP_LISTEN) |
@@ -1895,7 +1876,6 @@ static int wait_for_connect(struct sock *sk, long timeo) | |||
1895 | struct sock *tcp_accept(struct sock *sk, int flags, int *err) | 1876 | struct sock *tcp_accept(struct sock *sk, int flags, int *err) |
1896 | { | 1877 | { |
1897 | struct tcp_sock *tp = tcp_sk(sk); | 1878 | struct tcp_sock *tp = tcp_sk(sk); |
1898 | struct open_request *req; | ||
1899 | struct sock *newsk; | 1879 | struct sock *newsk; |
1900 | int error; | 1880 | int error; |
1901 | 1881 | ||
@@ -1906,37 +1886,31 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err) | |||
1906 | */ | 1886 | */ |
1907 | error = -EINVAL; | 1887 | error = -EINVAL; |
1908 | if (sk->sk_state != TCP_LISTEN) | 1888 | if (sk->sk_state != TCP_LISTEN) |
1909 | goto out; | 1889 | goto out_err; |
1910 | 1890 | ||
1911 | /* Find already established connection */ | 1891 | /* Find already established connection */ |
1912 | if (!tp->accept_queue) { | 1892 | if (reqsk_queue_empty(&tp->accept_queue)) { |
1913 | long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); | 1893 | long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); |
1914 | 1894 | ||
1915 | /* If this is a non blocking socket don't sleep */ | 1895 | /* If this is a non blocking socket don't sleep */ |
1916 | error = -EAGAIN; | 1896 | error = -EAGAIN; |
1917 | if (!timeo) | 1897 | if (!timeo) |
1918 | goto out; | 1898 | goto out_err; |
1919 | 1899 | ||
1920 | error = wait_for_connect(sk, timeo); | 1900 | error = wait_for_connect(sk, timeo); |
1921 | if (error) | 1901 | if (error) |
1922 | goto out; | 1902 | goto out_err; |
1923 | } | 1903 | } |
1924 | 1904 | ||
1925 | req = tp->accept_queue; | 1905 | newsk = reqsk_queue_get_child(&tp->accept_queue, sk); |
1926 | if ((tp->accept_queue = req->dl_next) == NULL) | ||
1927 | tp->accept_queue_tail = NULL; | ||
1928 | |||
1929 | newsk = req->sk; | ||
1930 | sk_acceptq_removed(sk); | ||
1931 | tcp_openreq_fastfree(req); | ||
1932 | BUG_TRAP(newsk->sk_state != TCP_SYN_RECV); | 1906 | BUG_TRAP(newsk->sk_state != TCP_SYN_RECV); |
1933 | release_sock(sk); | ||
1934 | return newsk; | ||
1935 | |||
1936 | out: | 1907 | out: |
1937 | release_sock(sk); | 1908 | release_sock(sk); |
1909 | return newsk; | ||
1910 | out_err: | ||
1911 | newsk = NULL; | ||
1938 | *err = error; | 1912 | *err = error; |
1939 | return NULL; | 1913 | goto out; |
1940 | } | 1914 | } |
1941 | 1915 | ||
1942 | /* | 1916 | /* |
@@ -2271,13 +2245,6 @@ void __init tcp_init(void) | |||
2271 | __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb), | 2245 | __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb), |
2272 | sizeof(skb->cb)); | 2246 | sizeof(skb->cb)); |
2273 | 2247 | ||
2274 | tcp_openreq_cachep = kmem_cache_create("tcp_open_request", | ||
2275 | sizeof(struct open_request), | ||
2276 | 0, SLAB_HWCACHE_ALIGN, | ||
2277 | NULL, NULL); | ||
2278 | if (!tcp_openreq_cachep) | ||
2279 | panic("tcp_init: Cannot alloc open_request cache."); | ||
2280 | |||
2281 | tcp_bucket_cachep = kmem_cache_create("tcp_bind_bucket", | 2248 | tcp_bucket_cachep = kmem_cache_create("tcp_bind_bucket", |
2282 | sizeof(struct tcp_bind_bucket), | 2249 | sizeof(struct tcp_bind_bucket), |
2283 | 0, SLAB_HWCACHE_ALIGN, | 2250 | 0, SLAB_HWCACHE_ALIGN, |
@@ -2338,7 +2305,7 @@ void __init tcp_init(void) | |||
2338 | (tcp_bhash_size * sizeof(struct tcp_bind_hashbucket)); | 2305 | (tcp_bhash_size * sizeof(struct tcp_bind_hashbucket)); |
2339 | order++) | 2306 | order++) |
2340 | ; | 2307 | ; |
2341 | if (order > 4) { | 2308 | if (order >= 4) { |
2342 | sysctl_local_port_range[0] = 32768; | 2309 | sysctl_local_port_range[0] = 32768; |
2343 | sysctl_local_port_range[1] = 61000; | 2310 | sysctl_local_port_range[1] = 61000; |
2344 | sysctl_tcp_max_tw_buckets = 180000; | 2311 | sysctl_tcp_max_tw_buckets = 180000; |
@@ -2374,7 +2341,6 @@ EXPORT_SYMBOL(tcp_destroy_sock); | |||
2374 | EXPORT_SYMBOL(tcp_disconnect); | 2341 | EXPORT_SYMBOL(tcp_disconnect); |
2375 | EXPORT_SYMBOL(tcp_getsockopt); | 2342 | EXPORT_SYMBOL(tcp_getsockopt); |
2376 | EXPORT_SYMBOL(tcp_ioctl); | 2343 | EXPORT_SYMBOL(tcp_ioctl); |
2377 | EXPORT_SYMBOL(tcp_openreq_cachep); | ||
2378 | EXPORT_SYMBOL(tcp_poll); | 2344 | EXPORT_SYMBOL(tcp_poll); |
2379 | EXPORT_SYMBOL(tcp_read_sock); | 2345 | EXPORT_SYMBOL(tcp_read_sock); |
2380 | EXPORT_SYMBOL(tcp_recvmsg); | 2346 | EXPORT_SYMBOL(tcp_recvmsg); |
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c index 8faa8948f75c..634befc07921 100644 --- a/net/ipv4/tcp_diag.c +++ b/net/ipv4/tcp_diag.c | |||
@@ -455,9 +455,10 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk, | |||
455 | } | 455 | } |
456 | 456 | ||
457 | static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | 457 | static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, |
458 | struct open_request *req, | 458 | struct request_sock *req, |
459 | u32 pid, u32 seq) | 459 | u32 pid, u32 seq) |
460 | { | 460 | { |
461 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
461 | struct inet_sock *inet = inet_sk(sk); | 462 | struct inet_sock *inet = inet_sk(sk); |
462 | unsigned char *b = skb->tail; | 463 | unsigned char *b = skb->tail; |
463 | struct tcpdiagmsg *r; | 464 | struct tcpdiagmsg *r; |
@@ -482,9 +483,9 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
482 | tmo = 0; | 483 | tmo = 0; |
483 | 484 | ||
484 | r->id.tcpdiag_sport = inet->sport; | 485 | r->id.tcpdiag_sport = inet->sport; |
485 | r->id.tcpdiag_dport = req->rmt_port; | 486 | r->id.tcpdiag_dport = ireq->rmt_port; |
486 | r->id.tcpdiag_src[0] = req->af.v4_req.loc_addr; | 487 | r->id.tcpdiag_src[0] = ireq->loc_addr; |
487 | r->id.tcpdiag_dst[0] = req->af.v4_req.rmt_addr; | 488 | r->id.tcpdiag_dst[0] = ireq->rmt_addr; |
488 | r->tcpdiag_expires = jiffies_to_msecs(tmo), | 489 | r->tcpdiag_expires = jiffies_to_msecs(tmo), |
489 | r->tcpdiag_rqueue = 0; | 490 | r->tcpdiag_rqueue = 0; |
490 | r->tcpdiag_wqueue = 0; | 491 | r->tcpdiag_wqueue = 0; |
@@ -493,9 +494,9 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
493 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 494 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
494 | if (r->tcpdiag_family == AF_INET6) { | 495 | if (r->tcpdiag_family == AF_INET6) { |
495 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, | 496 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, |
496 | &req->af.v6_req.loc_addr); | 497 | &tcp6_rsk(req)->loc_addr); |
497 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, | 498 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, |
498 | &req->af.v6_req.rmt_addr); | 499 | &tcp6_rsk(req)->rmt_addr); |
499 | } | 500 | } |
500 | #endif | 501 | #endif |
501 | nlh->nlmsg_len = skb->tail - b; | 502 | nlh->nlmsg_len = skb->tail - b; |
@@ -513,7 +514,7 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
513 | struct tcpdiag_entry entry; | 514 | struct tcpdiag_entry entry; |
514 | struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); | 515 | struct tcpdiagreq *r = NLMSG_DATA(cb->nlh); |
515 | struct tcp_sock *tp = tcp_sk(sk); | 516 | struct tcp_sock *tp = tcp_sk(sk); |
516 | struct tcp_listen_opt *lopt; | 517 | struct listen_sock *lopt; |
517 | struct rtattr *bc = NULL; | 518 | struct rtattr *bc = NULL; |
518 | struct inet_sock *inet = inet_sk(sk); | 519 | struct inet_sock *inet = inet_sk(sk); |
519 | int j, s_j; | 520 | int j, s_j; |
@@ -528,9 +529,9 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
528 | 529 | ||
529 | entry.family = sk->sk_family; | 530 | entry.family = sk->sk_family; |
530 | 531 | ||
531 | read_lock_bh(&tp->syn_wait_lock); | 532 | read_lock_bh(&tp->accept_queue.syn_wait_lock); |
532 | 533 | ||
533 | lopt = tp->listen_opt; | 534 | lopt = tp->accept_queue.listen_opt; |
534 | if (!lopt || !lopt->qlen) | 535 | if (!lopt || !lopt->qlen) |
535 | goto out; | 536 | goto out; |
536 | 537 | ||
@@ -541,13 +542,15 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
541 | } | 542 | } |
542 | 543 | ||
543 | for (j = s_j; j < TCP_SYNQ_HSIZE; j++) { | 544 | for (j = s_j; j < TCP_SYNQ_HSIZE; j++) { |
544 | struct open_request *req, *head = lopt->syn_table[j]; | 545 | struct request_sock *req, *head = lopt->syn_table[j]; |
545 | 546 | ||
546 | reqnum = 0; | 547 | reqnum = 0; |
547 | for (req = head; req; reqnum++, req = req->dl_next) { | 548 | for (req = head; req; reqnum++, req = req->dl_next) { |
549 | struct inet_request_sock *ireq = inet_rsk(req); | ||
550 | |||
548 | if (reqnum < s_reqnum) | 551 | if (reqnum < s_reqnum) |
549 | continue; | 552 | continue; |
550 | if (r->id.tcpdiag_dport != req->rmt_port && | 553 | if (r->id.tcpdiag_dport != ireq->rmt_port && |
551 | r->id.tcpdiag_dport) | 554 | r->id.tcpdiag_dport) |
552 | continue; | 555 | continue; |
553 | 556 | ||
@@ -555,16 +558,16 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
555 | entry.saddr = | 558 | entry.saddr = |
556 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 559 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
557 | (entry.family == AF_INET6) ? | 560 | (entry.family == AF_INET6) ? |
558 | req->af.v6_req.loc_addr.s6_addr32 : | 561 | tcp6_rsk(req)->loc_addr.s6_addr32 : |
559 | #endif | 562 | #endif |
560 | &req->af.v4_req.loc_addr; | 563 | &ireq->loc_addr; |
561 | entry.daddr = | 564 | entry.daddr = |
562 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 565 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
563 | (entry.family == AF_INET6) ? | 566 | (entry.family == AF_INET6) ? |
564 | req->af.v6_req.rmt_addr.s6_addr32 : | 567 | tcp6_rsk(req)->rmt_addr.s6_addr32 : |
565 | #endif | 568 | #endif |
566 | &req->af.v4_req.rmt_addr; | 569 | &ireq->rmt_addr; |
567 | entry.dport = ntohs(req->rmt_port); | 570 | entry.dport = ntohs(ireq->rmt_port); |
568 | 571 | ||
569 | if (!tcpdiag_bc_run(RTA_DATA(bc), | 572 | if (!tcpdiag_bc_run(RTA_DATA(bc), |
570 | RTA_PAYLOAD(bc), &entry)) | 573 | RTA_PAYLOAD(bc), &entry)) |
@@ -585,7 +588,7 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
585 | } | 588 | } |
586 | 589 | ||
587 | out: | 590 | out: |
588 | read_unlock_bh(&tp->syn_wait_lock); | 591 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
589 | 592 | ||
590 | return err; | 593 | return err; |
591 | } | 594 | } |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index dad98e4a5043..2d41d5d6ad19 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -36,7 +36,7 @@ | |||
36 | * ACK bit. | 36 | * ACK bit. |
37 | * Andi Kleen : Implemented fast path mtu discovery. | 37 | * Andi Kleen : Implemented fast path mtu discovery. |
38 | * Fixed many serious bugs in the | 38 | * Fixed many serious bugs in the |
39 | * open_request handling and moved | 39 | * request_sock handling and moved |
40 | * most of it into the af independent code. | 40 | * most of it into the af independent code. |
41 | * Added tail drop and some other bugfixes. | 41 | * Added tail drop and some other bugfixes. |
42 | * Added new listen sematics. | 42 | * Added new listen sematics. |
@@ -869,21 +869,23 @@ static __inline__ u32 tcp_v4_synq_hash(u32 raddr, u16 rport, u32 rnd) | |||
869 | return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); | 869 | return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); |
870 | } | 870 | } |
871 | 871 | ||
872 | static struct open_request *tcp_v4_search_req(struct tcp_sock *tp, | 872 | static struct request_sock *tcp_v4_search_req(struct tcp_sock *tp, |
873 | struct open_request ***prevp, | 873 | struct request_sock ***prevp, |
874 | __u16 rport, | 874 | __u16 rport, |
875 | __u32 raddr, __u32 laddr) | 875 | __u32 raddr, __u32 laddr) |
876 | { | 876 | { |
877 | struct tcp_listen_opt *lopt = tp->listen_opt; | 877 | struct listen_sock *lopt = tp->accept_queue.listen_opt; |
878 | struct open_request *req, **prev; | 878 | struct request_sock *req, **prev; |
879 | 879 | ||
880 | for (prev = &lopt->syn_table[tcp_v4_synq_hash(raddr, rport, lopt->hash_rnd)]; | 880 | for (prev = &lopt->syn_table[tcp_v4_synq_hash(raddr, rport, lopt->hash_rnd)]; |
881 | (req = *prev) != NULL; | 881 | (req = *prev) != NULL; |
882 | prev = &req->dl_next) { | 882 | prev = &req->dl_next) { |
883 | if (req->rmt_port == rport && | 883 | const struct inet_request_sock *ireq = inet_rsk(req); |
884 | req->af.v4_req.rmt_addr == raddr && | 884 | |
885 | req->af.v4_req.loc_addr == laddr && | 885 | if (ireq->rmt_port == rport && |
886 | TCP_INET_FAMILY(req->class->family)) { | 886 | ireq->rmt_addr == raddr && |
887 | ireq->loc_addr == laddr && | ||
888 | TCP_INET_FAMILY(req->rsk_ops->family)) { | ||
887 | BUG_TRAP(!req->sk); | 889 | BUG_TRAP(!req->sk); |
888 | *prevp = prev; | 890 | *prevp = prev; |
889 | break; | 891 | break; |
@@ -893,21 +895,13 @@ static struct open_request *tcp_v4_search_req(struct tcp_sock *tp, | |||
893 | return req; | 895 | return req; |
894 | } | 896 | } |
895 | 897 | ||
896 | static void tcp_v4_synq_add(struct sock *sk, struct open_request *req) | 898 | static void tcp_v4_synq_add(struct sock *sk, struct request_sock *req) |
897 | { | 899 | { |
898 | struct tcp_sock *tp = tcp_sk(sk); | 900 | struct tcp_sock *tp = tcp_sk(sk); |
899 | struct tcp_listen_opt *lopt = tp->listen_opt; | 901 | struct listen_sock *lopt = tp->accept_queue.listen_opt; |
900 | u32 h = tcp_v4_synq_hash(req->af.v4_req.rmt_addr, req->rmt_port, lopt->hash_rnd); | 902 | u32 h = tcp_v4_synq_hash(inet_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd); |
901 | |||
902 | req->expires = jiffies + TCP_TIMEOUT_INIT; | ||
903 | req->retrans = 0; | ||
904 | req->sk = NULL; | ||
905 | req->dl_next = lopt->syn_table[h]; | ||
906 | |||
907 | write_lock(&tp->syn_wait_lock); | ||
908 | lopt->syn_table[h] = req; | ||
909 | write_unlock(&tp->syn_wait_lock); | ||
910 | 903 | ||
904 | reqsk_queue_hash_req(&tp->accept_queue, h, req, TCP_TIMEOUT_INIT); | ||
911 | tcp_synq_added(sk); | 905 | tcp_synq_added(sk); |
912 | } | 906 | } |
913 | 907 | ||
@@ -1050,7 +1044,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) | |||
1050 | } | 1044 | } |
1051 | 1045 | ||
1052 | switch (sk->sk_state) { | 1046 | switch (sk->sk_state) { |
1053 | struct open_request *req, **prev; | 1047 | struct request_sock *req, **prev; |
1054 | case TCP_LISTEN: | 1048 | case TCP_LISTEN: |
1055 | if (sock_owned_by_user(sk)) | 1049 | if (sock_owned_by_user(sk)) |
1056 | goto out; | 1050 | goto out; |
@@ -1065,7 +1059,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) | |||
1065 | */ | 1059 | */ |
1066 | BUG_TRAP(!req->sk); | 1060 | BUG_TRAP(!req->sk); |
1067 | 1061 | ||
1068 | if (seq != req->snt_isn) { | 1062 | if (seq != tcp_rsk(req)->snt_isn) { |
1069 | NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); | 1063 | NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); |
1070 | goto out; | 1064 | goto out; |
1071 | } | 1065 | } |
@@ -1254,28 +1248,29 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
1254 | tcp_tw_put(tw); | 1248 | tcp_tw_put(tw); |
1255 | } | 1249 | } |
1256 | 1250 | ||
1257 | static void tcp_v4_or_send_ack(struct sk_buff *skb, struct open_request *req) | 1251 | static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) |
1258 | { | 1252 | { |
1259 | tcp_v4_send_ack(skb, req->snt_isn + 1, req->rcv_isn + 1, req->rcv_wnd, | 1253 | tcp_v4_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, |
1260 | req->ts_recent); | 1254 | req->ts_recent); |
1261 | } | 1255 | } |
1262 | 1256 | ||
1263 | static struct dst_entry* tcp_v4_route_req(struct sock *sk, | 1257 | static struct dst_entry* tcp_v4_route_req(struct sock *sk, |
1264 | struct open_request *req) | 1258 | struct request_sock *req) |
1265 | { | 1259 | { |
1266 | struct rtable *rt; | 1260 | struct rtable *rt; |
1267 | struct ip_options *opt = req->af.v4_req.opt; | 1261 | const struct inet_request_sock *ireq = inet_rsk(req); |
1262 | struct ip_options *opt = inet_rsk(req)->opt; | ||
1268 | struct flowi fl = { .oif = sk->sk_bound_dev_if, | 1263 | struct flowi fl = { .oif = sk->sk_bound_dev_if, |
1269 | .nl_u = { .ip4_u = | 1264 | .nl_u = { .ip4_u = |
1270 | { .daddr = ((opt && opt->srr) ? | 1265 | { .daddr = ((opt && opt->srr) ? |
1271 | opt->faddr : | 1266 | opt->faddr : |
1272 | req->af.v4_req.rmt_addr), | 1267 | ireq->rmt_addr), |
1273 | .saddr = req->af.v4_req.loc_addr, | 1268 | .saddr = ireq->loc_addr, |
1274 | .tos = RT_CONN_FLAGS(sk) } }, | 1269 | .tos = RT_CONN_FLAGS(sk) } }, |
1275 | .proto = IPPROTO_TCP, | 1270 | .proto = IPPROTO_TCP, |
1276 | .uli_u = { .ports = | 1271 | .uli_u = { .ports = |
1277 | { .sport = inet_sk(sk)->sport, | 1272 | { .sport = inet_sk(sk)->sport, |
1278 | .dport = req->rmt_port } } }; | 1273 | .dport = ireq->rmt_port } } }; |
1279 | 1274 | ||
1280 | if (ip_route_output_flow(&rt, &fl, sk, 0)) { | 1275 | if (ip_route_output_flow(&rt, &fl, sk, 0)) { |
1281 | IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); | 1276 | IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); |
@@ -1291,12 +1286,13 @@ static struct dst_entry* tcp_v4_route_req(struct sock *sk, | |||
1291 | 1286 | ||
1292 | /* | 1287 | /* |
1293 | * Send a SYN-ACK after having received an ACK. | 1288 | * Send a SYN-ACK after having received an ACK. |
1294 | * This still operates on a open_request only, not on a big | 1289 | * This still operates on a request_sock only, not on a big |
1295 | * socket. | 1290 | * socket. |
1296 | */ | 1291 | */ |
1297 | static int tcp_v4_send_synack(struct sock *sk, struct open_request *req, | 1292 | static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req, |
1298 | struct dst_entry *dst) | 1293 | struct dst_entry *dst) |
1299 | { | 1294 | { |
1295 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
1300 | int err = -1; | 1296 | int err = -1; |
1301 | struct sk_buff * skb; | 1297 | struct sk_buff * skb; |
1302 | 1298 | ||
@@ -1310,14 +1306,14 @@ static int tcp_v4_send_synack(struct sock *sk, struct open_request *req, | |||
1310 | struct tcphdr *th = skb->h.th; | 1306 | struct tcphdr *th = skb->h.th; |
1311 | 1307 | ||
1312 | th->check = tcp_v4_check(th, skb->len, | 1308 | th->check = tcp_v4_check(th, skb->len, |
1313 | req->af.v4_req.loc_addr, | 1309 | ireq->loc_addr, |
1314 | req->af.v4_req.rmt_addr, | 1310 | ireq->rmt_addr, |
1315 | csum_partial((char *)th, skb->len, | 1311 | csum_partial((char *)th, skb->len, |
1316 | skb->csum)); | 1312 | skb->csum)); |
1317 | 1313 | ||
1318 | err = ip_build_and_send_pkt(skb, sk, req->af.v4_req.loc_addr, | 1314 | err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, |
1319 | req->af.v4_req.rmt_addr, | 1315 | ireq->rmt_addr, |
1320 | req->af.v4_req.opt); | 1316 | ireq->opt); |
1321 | if (err == NET_XMIT_CN) | 1317 | if (err == NET_XMIT_CN) |
1322 | err = 0; | 1318 | err = 0; |
1323 | } | 1319 | } |
@@ -1328,12 +1324,12 @@ out: | |||
1328 | } | 1324 | } |
1329 | 1325 | ||
1330 | /* | 1326 | /* |
1331 | * IPv4 open_request destructor. | 1327 | * IPv4 request_sock destructor. |
1332 | */ | 1328 | */ |
1333 | static void tcp_v4_or_free(struct open_request *req) | 1329 | static void tcp_v4_reqsk_destructor(struct request_sock *req) |
1334 | { | 1330 | { |
1335 | if (req->af.v4_req.opt) | 1331 | if (inet_rsk(req)->opt) |
1336 | kfree(req->af.v4_req.opt); | 1332 | kfree(inet_rsk(req)->opt); |
1337 | } | 1333 | } |
1338 | 1334 | ||
1339 | static inline void syn_flood_warning(struct sk_buff *skb) | 1335 | static inline void syn_flood_warning(struct sk_buff *skb) |
@@ -1349,7 +1345,7 @@ static inline void syn_flood_warning(struct sk_buff *skb) | |||
1349 | } | 1345 | } |
1350 | 1346 | ||
1351 | /* | 1347 | /* |
1352 | * Save and compile IPv4 options into the open_request if needed. | 1348 | * Save and compile IPv4 options into the request_sock if needed. |
1353 | */ | 1349 | */ |
1354 | static inline struct ip_options *tcp_v4_save_options(struct sock *sk, | 1350 | static inline struct ip_options *tcp_v4_save_options(struct sock *sk, |
1355 | struct sk_buff *skb) | 1351 | struct sk_buff *skb) |
@@ -1370,33 +1366,20 @@ static inline struct ip_options *tcp_v4_save_options(struct sock *sk, | |||
1370 | return dopt; | 1366 | return dopt; |
1371 | } | 1367 | } |
1372 | 1368 | ||
1373 | /* | 1369 | struct request_sock_ops tcp_request_sock_ops = { |
1374 | * Maximum number of SYN_RECV sockets in queue per LISTEN socket. | ||
1375 | * One SYN_RECV socket costs about 80bytes on a 32bit machine. | ||
1376 | * It would be better to replace it with a global counter for all sockets | ||
1377 | * but then some measure against one socket starving all other sockets | ||
1378 | * would be needed. | ||
1379 | * | ||
1380 | * It was 128 by default. Experiments with real servers show, that | ||
1381 | * it is absolutely not enough even at 100conn/sec. 256 cures most | ||
1382 | * of problems. This value is adjusted to 128 for very small machines | ||
1383 | * (<=32Mb of memory) and to 1024 on normal or better ones (>=256Mb). | ||
1384 | * Further increasing requires to change hash table size. | ||
1385 | */ | ||
1386 | int sysctl_max_syn_backlog = 256; | ||
1387 | |||
1388 | struct or_calltable or_ipv4 = { | ||
1389 | .family = PF_INET, | 1370 | .family = PF_INET, |
1371 | .obj_size = sizeof(struct tcp_request_sock), | ||
1390 | .rtx_syn_ack = tcp_v4_send_synack, | 1372 | .rtx_syn_ack = tcp_v4_send_synack, |
1391 | .send_ack = tcp_v4_or_send_ack, | 1373 | .send_ack = tcp_v4_reqsk_send_ack, |
1392 | .destructor = tcp_v4_or_free, | 1374 | .destructor = tcp_v4_reqsk_destructor, |
1393 | .send_reset = tcp_v4_send_reset, | 1375 | .send_reset = tcp_v4_send_reset, |
1394 | }; | 1376 | }; |
1395 | 1377 | ||
1396 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | 1378 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) |
1397 | { | 1379 | { |
1380 | struct inet_request_sock *ireq; | ||
1398 | struct tcp_options_received tmp_opt; | 1381 | struct tcp_options_received tmp_opt; |
1399 | struct open_request *req; | 1382 | struct request_sock *req; |
1400 | __u32 saddr = skb->nh.iph->saddr; | 1383 | __u32 saddr = skb->nh.iph->saddr; |
1401 | __u32 daddr = skb->nh.iph->daddr; | 1384 | __u32 daddr = skb->nh.iph->daddr; |
1402 | __u32 isn = TCP_SKB_CB(skb)->when; | 1385 | __u32 isn = TCP_SKB_CB(skb)->when; |
@@ -1433,7 +1416,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1433 | if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1) | 1416 | if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1) |
1434 | goto drop; | 1417 | goto drop; |
1435 | 1418 | ||
1436 | req = tcp_openreq_alloc(); | 1419 | req = reqsk_alloc(&tcp_request_sock_ops); |
1437 | if (!req) | 1420 | if (!req) |
1438 | goto drop; | 1421 | goto drop; |
1439 | 1422 | ||
@@ -1461,10 +1444,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1461 | 1444 | ||
1462 | tcp_openreq_init(req, &tmp_opt, skb); | 1445 | tcp_openreq_init(req, &tmp_opt, skb); |
1463 | 1446 | ||
1464 | req->af.v4_req.loc_addr = daddr; | 1447 | ireq = inet_rsk(req); |
1465 | req->af.v4_req.rmt_addr = saddr; | 1448 | ireq->loc_addr = daddr; |
1466 | req->af.v4_req.opt = tcp_v4_save_options(sk, skb); | 1449 | ireq->rmt_addr = saddr; |
1467 | req->class = &or_ipv4; | 1450 | ireq->opt = tcp_v4_save_options(sk, skb); |
1468 | if (!want_cookie) | 1451 | if (!want_cookie) |
1469 | TCP_ECN_create_request(req, skb->h.th); | 1452 | TCP_ECN_create_request(req, skb->h.th); |
1470 | 1453 | ||
@@ -1523,20 +1506,20 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1523 | 1506 | ||
1524 | isn = tcp_v4_init_sequence(sk, skb); | 1507 | isn = tcp_v4_init_sequence(sk, skb); |
1525 | } | 1508 | } |
1526 | req->snt_isn = isn; | 1509 | tcp_rsk(req)->snt_isn = isn; |
1527 | 1510 | ||
1528 | if (tcp_v4_send_synack(sk, req, dst)) | 1511 | if (tcp_v4_send_synack(sk, req, dst)) |
1529 | goto drop_and_free; | 1512 | goto drop_and_free; |
1530 | 1513 | ||
1531 | if (want_cookie) { | 1514 | if (want_cookie) { |
1532 | tcp_openreq_free(req); | 1515 | reqsk_free(req); |
1533 | } else { | 1516 | } else { |
1534 | tcp_v4_synq_add(sk, req); | 1517 | tcp_v4_synq_add(sk, req); |
1535 | } | 1518 | } |
1536 | return 0; | 1519 | return 0; |
1537 | 1520 | ||
1538 | drop_and_free: | 1521 | drop_and_free: |
1539 | tcp_openreq_free(req); | 1522 | reqsk_free(req); |
1540 | drop: | 1523 | drop: |
1541 | TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS); | 1524 | TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS); |
1542 | return 0; | 1525 | return 0; |
@@ -1548,9 +1531,10 @@ drop: | |||
1548 | * now create the new socket. | 1531 | * now create the new socket. |
1549 | */ | 1532 | */ |
1550 | struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | 1533 | struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, |
1551 | struct open_request *req, | 1534 | struct request_sock *req, |
1552 | struct dst_entry *dst) | 1535 | struct dst_entry *dst) |
1553 | { | 1536 | { |
1537 | struct inet_request_sock *ireq; | ||
1554 | struct inet_sock *newinet; | 1538 | struct inet_sock *newinet; |
1555 | struct tcp_sock *newtp; | 1539 | struct tcp_sock *newtp; |
1556 | struct sock *newsk; | 1540 | struct sock *newsk; |
@@ -1570,11 +1554,12 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1570 | 1554 | ||
1571 | newtp = tcp_sk(newsk); | 1555 | newtp = tcp_sk(newsk); |
1572 | newinet = inet_sk(newsk); | 1556 | newinet = inet_sk(newsk); |
1573 | newinet->daddr = req->af.v4_req.rmt_addr; | 1557 | ireq = inet_rsk(req); |
1574 | newinet->rcv_saddr = req->af.v4_req.loc_addr; | 1558 | newinet->daddr = ireq->rmt_addr; |
1575 | newinet->saddr = req->af.v4_req.loc_addr; | 1559 | newinet->rcv_saddr = ireq->loc_addr; |
1576 | newinet->opt = req->af.v4_req.opt; | 1560 | newinet->saddr = ireq->loc_addr; |
1577 | req->af.v4_req.opt = NULL; | 1561 | newinet->opt = ireq->opt; |
1562 | ireq->opt = NULL; | ||
1578 | newinet->mc_index = tcp_v4_iif(skb); | 1563 | newinet->mc_index = tcp_v4_iif(skb); |
1579 | newinet->mc_ttl = skb->nh.iph->ttl; | 1564 | newinet->mc_ttl = skb->nh.iph->ttl; |
1580 | newtp->ext_header_len = 0; | 1565 | newtp->ext_header_len = 0; |
@@ -1605,9 +1590,9 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) | |||
1605 | struct iphdr *iph = skb->nh.iph; | 1590 | struct iphdr *iph = skb->nh.iph; |
1606 | struct tcp_sock *tp = tcp_sk(sk); | 1591 | struct tcp_sock *tp = tcp_sk(sk); |
1607 | struct sock *nsk; | 1592 | struct sock *nsk; |
1608 | struct open_request **prev; | 1593 | struct request_sock **prev; |
1609 | /* Find possible connection requests. */ | 1594 | /* Find possible connection requests. */ |
1610 | struct open_request *req = tcp_v4_search_req(tp, &prev, th->source, | 1595 | struct request_sock *req = tcp_v4_search_req(tp, &prev, th->source, |
1611 | iph->saddr, iph->daddr); | 1596 | iph->saddr, iph->daddr); |
1612 | if (req) | 1597 | if (req) |
1613 | return tcp_check_req(sk, skb, req, prev); | 1598 | return tcp_check_req(sk, skb, req, prev); |
@@ -2144,13 +2129,13 @@ static void *listening_get_next(struct seq_file *seq, void *cur) | |||
2144 | ++st->num; | 2129 | ++st->num; |
2145 | 2130 | ||
2146 | if (st->state == TCP_SEQ_STATE_OPENREQ) { | 2131 | if (st->state == TCP_SEQ_STATE_OPENREQ) { |
2147 | struct open_request *req = cur; | 2132 | struct request_sock *req = cur; |
2148 | 2133 | ||
2149 | tp = tcp_sk(st->syn_wait_sk); | 2134 | tp = tcp_sk(st->syn_wait_sk); |
2150 | req = req->dl_next; | 2135 | req = req->dl_next; |
2151 | while (1) { | 2136 | while (1) { |
2152 | while (req) { | 2137 | while (req) { |
2153 | if (req->class->family == st->family) { | 2138 | if (req->rsk_ops->family == st->family) { |
2154 | cur = req; | 2139 | cur = req; |
2155 | goto out; | 2140 | goto out; |
2156 | } | 2141 | } |
@@ -2159,17 +2144,17 @@ static void *listening_get_next(struct seq_file *seq, void *cur) | |||
2159 | if (++st->sbucket >= TCP_SYNQ_HSIZE) | 2144 | if (++st->sbucket >= TCP_SYNQ_HSIZE) |
2160 | break; | 2145 | break; |
2161 | get_req: | 2146 | get_req: |
2162 | req = tp->listen_opt->syn_table[st->sbucket]; | 2147 | req = tp->accept_queue.listen_opt->syn_table[st->sbucket]; |
2163 | } | 2148 | } |
2164 | sk = sk_next(st->syn_wait_sk); | 2149 | sk = sk_next(st->syn_wait_sk); |
2165 | st->state = TCP_SEQ_STATE_LISTENING; | 2150 | st->state = TCP_SEQ_STATE_LISTENING; |
2166 | read_unlock_bh(&tp->syn_wait_lock); | 2151 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
2167 | } else { | 2152 | } else { |
2168 | tp = tcp_sk(sk); | 2153 | tp = tcp_sk(sk); |
2169 | read_lock_bh(&tp->syn_wait_lock); | 2154 | read_lock_bh(&tp->accept_queue.syn_wait_lock); |
2170 | if (tp->listen_opt && tp->listen_opt->qlen) | 2155 | if (reqsk_queue_len(&tp->accept_queue)) |
2171 | goto start_req; | 2156 | goto start_req; |
2172 | read_unlock_bh(&tp->syn_wait_lock); | 2157 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
2173 | sk = sk_next(sk); | 2158 | sk = sk_next(sk); |
2174 | } | 2159 | } |
2175 | get_sk: | 2160 | get_sk: |
@@ -2179,8 +2164,8 @@ get_sk: | |||
2179 | goto out; | 2164 | goto out; |
2180 | } | 2165 | } |
2181 | tp = tcp_sk(sk); | 2166 | tp = tcp_sk(sk); |
2182 | read_lock_bh(&tp->syn_wait_lock); | 2167 | read_lock_bh(&tp->accept_queue.syn_wait_lock); |
2183 | if (tp->listen_opt && tp->listen_opt->qlen) { | 2168 | if (reqsk_queue_len(&tp->accept_queue)) { |
2184 | start_req: | 2169 | start_req: |
2185 | st->uid = sock_i_uid(sk); | 2170 | st->uid = sock_i_uid(sk); |
2186 | st->syn_wait_sk = sk; | 2171 | st->syn_wait_sk = sk; |
@@ -2188,7 +2173,7 @@ start_req: | |||
2188 | st->sbucket = 0; | 2173 | st->sbucket = 0; |
2189 | goto get_req; | 2174 | goto get_req; |
2190 | } | 2175 | } |
2191 | read_unlock_bh(&tp->syn_wait_lock); | 2176 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
2192 | } | 2177 | } |
2193 | if (++st->bucket < TCP_LHTABLE_SIZE) { | 2178 | if (++st->bucket < TCP_LHTABLE_SIZE) { |
2194 | sk = sk_head(&tcp_listening_hash[st->bucket]); | 2179 | sk = sk_head(&tcp_listening_hash[st->bucket]); |
@@ -2375,7 +2360,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v) | |||
2375 | case TCP_SEQ_STATE_OPENREQ: | 2360 | case TCP_SEQ_STATE_OPENREQ: |
2376 | if (v) { | 2361 | if (v) { |
2377 | struct tcp_sock *tp = tcp_sk(st->syn_wait_sk); | 2362 | struct tcp_sock *tp = tcp_sk(st->syn_wait_sk); |
2378 | read_unlock_bh(&tp->syn_wait_lock); | 2363 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
2379 | } | 2364 | } |
2380 | case TCP_SEQ_STATE_LISTENING: | 2365 | case TCP_SEQ_STATE_LISTENING: |
2381 | if (v != SEQ_START_TOKEN) | 2366 | if (v != SEQ_START_TOKEN) |
@@ -2451,18 +2436,19 @@ void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo) | |||
2451 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); | 2436 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); |
2452 | } | 2437 | } |
2453 | 2438 | ||
2454 | static void get_openreq4(struct sock *sk, struct open_request *req, | 2439 | static void get_openreq4(struct sock *sk, struct request_sock *req, |
2455 | char *tmpbuf, int i, int uid) | 2440 | char *tmpbuf, int i, int uid) |
2456 | { | 2441 | { |
2442 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
2457 | int ttd = req->expires - jiffies; | 2443 | int ttd = req->expires - jiffies; |
2458 | 2444 | ||
2459 | sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" | 2445 | sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" |
2460 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p", | 2446 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p", |
2461 | i, | 2447 | i, |
2462 | req->af.v4_req.loc_addr, | 2448 | ireq->loc_addr, |
2463 | ntohs(inet_sk(sk)->sport), | 2449 | ntohs(inet_sk(sk)->sport), |
2464 | req->af.v4_req.rmt_addr, | 2450 | ireq->rmt_addr, |
2465 | ntohs(req->rmt_port), | 2451 | ntohs(ireq->rmt_port), |
2466 | TCP_SYN_RECV, | 2452 | TCP_SYN_RECV, |
2467 | 0, 0, /* could print option size, but that is af dependent. */ | 2453 | 0, 0, /* could print option size, but that is af dependent. */ |
2468 | 1, /* timers active (only the expire timer) */ | 2454 | 1, /* timers active (only the expire timer) */ |
@@ -2618,6 +2604,7 @@ struct proto tcp_prot = { | |||
2618 | .sysctl_rmem = sysctl_tcp_rmem, | 2604 | .sysctl_rmem = sysctl_tcp_rmem, |
2619 | .max_header = MAX_TCP_HEADER, | 2605 | .max_header = MAX_TCP_HEADER, |
2620 | .obj_size = sizeof(struct tcp_sock), | 2606 | .obj_size = sizeof(struct tcp_sock), |
2607 | .rsk_prot = &tcp_request_sock_ops, | ||
2621 | }; | 2608 | }; |
2622 | 2609 | ||
2623 | 2610 | ||
@@ -2660,7 +2647,6 @@ EXPORT_SYMBOL(tcp_proc_register); | |||
2660 | EXPORT_SYMBOL(tcp_proc_unregister); | 2647 | EXPORT_SYMBOL(tcp_proc_unregister); |
2661 | #endif | 2648 | #endif |
2662 | EXPORT_SYMBOL(sysctl_local_port_range); | 2649 | EXPORT_SYMBOL(sysctl_local_port_range); |
2663 | EXPORT_SYMBOL(sysctl_max_syn_backlog); | ||
2664 | EXPORT_SYMBOL(sysctl_tcp_low_latency); | 2650 | EXPORT_SYMBOL(sysctl_tcp_low_latency); |
2665 | EXPORT_SYMBOL(sysctl_tcp_tw_reuse); | 2651 | EXPORT_SYMBOL(sysctl_tcp_tw_reuse); |
2666 | 2652 | ||
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index eea1a17a9ac2..b3943e7562f3 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -684,7 +684,7 @@ out: | |||
684 | * Actually, we could lots of memory writes here. tp of listening | 684 | * Actually, we could lots of memory writes here. tp of listening |
685 | * socket contains all necessary default parameters. | 685 | * socket contains all necessary default parameters. |
686 | */ | 686 | */ |
687 | struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, struct sk_buff *skb) | 687 | struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb) |
688 | { | 688 | { |
689 | /* allocate the newsk from the same slab of the master sock, | 689 | /* allocate the newsk from the same slab of the master sock, |
690 | * if not, at sk_free time we'll try to free it from the wrong | 690 | * if not, at sk_free time we'll try to free it from the wrong |
@@ -692,6 +692,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
692 | struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, sk->sk_prot, 0); | 692 | struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, sk->sk_prot, 0); |
693 | 693 | ||
694 | if(newsk != NULL) { | 694 | if(newsk != NULL) { |
695 | struct inet_request_sock *ireq = inet_rsk(req); | ||
696 | struct tcp_request_sock *treq = tcp_rsk(req); | ||
695 | struct tcp_sock *newtp; | 697 | struct tcp_sock *newtp; |
696 | struct sk_filter *filter; | 698 | struct sk_filter *filter; |
697 | 699 | ||
@@ -703,7 +705,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
703 | tcp_sk(newsk)->bind_hash = NULL; | 705 | tcp_sk(newsk)->bind_hash = NULL; |
704 | 706 | ||
705 | /* Clone the TCP header template */ | 707 | /* Clone the TCP header template */ |
706 | inet_sk(newsk)->dport = req->rmt_port; | 708 | inet_sk(newsk)->dport = ireq->rmt_port; |
707 | 709 | ||
708 | sock_lock_init(newsk); | 710 | sock_lock_init(newsk); |
709 | bh_lock_sock(newsk); | 711 | bh_lock_sock(newsk); |
@@ -739,14 +741,14 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
739 | /* Now setup tcp_sock */ | 741 | /* Now setup tcp_sock */ |
740 | newtp = tcp_sk(newsk); | 742 | newtp = tcp_sk(newsk); |
741 | newtp->pred_flags = 0; | 743 | newtp->pred_flags = 0; |
742 | newtp->rcv_nxt = req->rcv_isn + 1; | 744 | newtp->rcv_nxt = treq->rcv_isn + 1; |
743 | newtp->snd_nxt = req->snt_isn + 1; | 745 | newtp->snd_nxt = treq->snt_isn + 1; |
744 | newtp->snd_una = req->snt_isn + 1; | 746 | newtp->snd_una = treq->snt_isn + 1; |
745 | newtp->snd_sml = req->snt_isn + 1; | 747 | newtp->snd_sml = treq->snt_isn + 1; |
746 | 748 | ||
747 | tcp_prequeue_init(newtp); | 749 | tcp_prequeue_init(newtp); |
748 | 750 | ||
749 | tcp_init_wl(newtp, req->snt_isn, req->rcv_isn); | 751 | tcp_init_wl(newtp, treq->snt_isn, treq->rcv_isn); |
750 | 752 | ||
751 | newtp->retransmits = 0; | 753 | newtp->retransmits = 0; |
752 | newtp->backoff = 0; | 754 | newtp->backoff = 0; |
@@ -775,10 +777,10 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
775 | tcp_set_ca_state(newtp, TCP_CA_Open); | 777 | tcp_set_ca_state(newtp, TCP_CA_Open); |
776 | tcp_init_xmit_timers(newsk); | 778 | tcp_init_xmit_timers(newsk); |
777 | skb_queue_head_init(&newtp->out_of_order_queue); | 779 | skb_queue_head_init(&newtp->out_of_order_queue); |
778 | newtp->rcv_wup = req->rcv_isn + 1; | 780 | newtp->rcv_wup = treq->rcv_isn + 1; |
779 | newtp->write_seq = req->snt_isn + 1; | 781 | newtp->write_seq = treq->snt_isn + 1; |
780 | newtp->pushed_seq = newtp->write_seq; | 782 | newtp->pushed_seq = newtp->write_seq; |
781 | newtp->copied_seq = req->rcv_isn + 1; | 783 | newtp->copied_seq = treq->rcv_isn + 1; |
782 | 784 | ||
783 | newtp->rx_opt.saw_tstamp = 0; | 785 | newtp->rx_opt.saw_tstamp = 0; |
784 | 786 | ||
@@ -788,10 +790,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
788 | newtp->probes_out = 0; | 790 | newtp->probes_out = 0; |
789 | newtp->rx_opt.num_sacks = 0; | 791 | newtp->rx_opt.num_sacks = 0; |
790 | newtp->urg_data = 0; | 792 | newtp->urg_data = 0; |
791 | newtp->listen_opt = NULL; | 793 | /* Deinitialize accept_queue to trap illegal accesses. */ |
792 | newtp->accept_queue = newtp->accept_queue_tail = NULL; | 794 | memset(&newtp->accept_queue, 0, sizeof(newtp->accept_queue)); |
793 | /* Deinitialize syn_wait_lock to trap illegal accesses. */ | ||
794 | memset(&newtp->syn_wait_lock, 0, sizeof(newtp->syn_wait_lock)); | ||
795 | 795 | ||
796 | /* Back to base struct sock members. */ | 796 | /* Back to base struct sock members. */ |
797 | newsk->sk_err = 0; | 797 | newsk->sk_err = 0; |
@@ -808,18 +808,18 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
808 | newsk->sk_socket = NULL; | 808 | newsk->sk_socket = NULL; |
809 | newsk->sk_sleep = NULL; | 809 | newsk->sk_sleep = NULL; |
810 | 810 | ||
811 | newtp->rx_opt.tstamp_ok = req->tstamp_ok; | 811 | newtp->rx_opt.tstamp_ok = ireq->tstamp_ok; |
812 | if((newtp->rx_opt.sack_ok = req->sack_ok) != 0) { | 812 | if((newtp->rx_opt.sack_ok = ireq->sack_ok) != 0) { |
813 | if (sysctl_tcp_fack) | 813 | if (sysctl_tcp_fack) |
814 | newtp->rx_opt.sack_ok |= 2; | 814 | newtp->rx_opt.sack_ok |= 2; |
815 | } | 815 | } |
816 | newtp->window_clamp = req->window_clamp; | 816 | newtp->window_clamp = req->window_clamp; |
817 | newtp->rcv_ssthresh = req->rcv_wnd; | 817 | newtp->rcv_ssthresh = req->rcv_wnd; |
818 | newtp->rcv_wnd = req->rcv_wnd; | 818 | newtp->rcv_wnd = req->rcv_wnd; |
819 | newtp->rx_opt.wscale_ok = req->wscale_ok; | 819 | newtp->rx_opt.wscale_ok = ireq->wscale_ok; |
820 | if (newtp->rx_opt.wscale_ok) { | 820 | if (newtp->rx_opt.wscale_ok) { |
821 | newtp->rx_opt.snd_wscale = req->snd_wscale; | 821 | newtp->rx_opt.snd_wscale = ireq->snd_wscale; |
822 | newtp->rx_opt.rcv_wscale = req->rcv_wscale; | 822 | newtp->rx_opt.rcv_wscale = ireq->rcv_wscale; |
823 | } else { | 823 | } else { |
824 | newtp->rx_opt.snd_wscale = newtp->rx_opt.rcv_wscale = 0; | 824 | newtp->rx_opt.snd_wscale = newtp->rx_opt.rcv_wscale = 0; |
825 | newtp->window_clamp = min(newtp->window_clamp, 65535U); | 825 | newtp->window_clamp = min(newtp->window_clamp, 65535U); |
@@ -851,12 +851,12 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
851 | 851 | ||
852 | /* | 852 | /* |
853 | * Process an incoming packet for SYN_RECV sockets represented | 853 | * Process an incoming packet for SYN_RECV sockets represented |
854 | * as an open_request. | 854 | * as a request_sock. |
855 | */ | 855 | */ |
856 | 856 | ||
857 | struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | 857 | struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, |
858 | struct open_request *req, | 858 | struct request_sock *req, |
859 | struct open_request **prev) | 859 | struct request_sock **prev) |
860 | { | 860 | { |
861 | struct tcphdr *th = skb->h.th; | 861 | struct tcphdr *th = skb->h.th; |
862 | struct tcp_sock *tp = tcp_sk(sk); | 862 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -881,7 +881,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
881 | } | 881 | } |
882 | 882 | ||
883 | /* Check for pure retransmitted SYN. */ | 883 | /* Check for pure retransmitted SYN. */ |
884 | if (TCP_SKB_CB(skb)->seq == req->rcv_isn && | 884 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn && |
885 | flg == TCP_FLAG_SYN && | 885 | flg == TCP_FLAG_SYN && |
886 | !paws_reject) { | 886 | !paws_reject) { |
887 | /* | 887 | /* |
@@ -901,7 +901,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
901 | * Enforce "SYN-ACK" according to figure 8, figure 6 | 901 | * Enforce "SYN-ACK" according to figure 8, figure 6 |
902 | * of RFC793, fixed by RFC1122. | 902 | * of RFC793, fixed by RFC1122. |
903 | */ | 903 | */ |
904 | req->class->rtx_syn_ack(sk, req, NULL); | 904 | req->rsk_ops->rtx_syn_ack(sk, req, NULL); |
905 | return NULL; | 905 | return NULL; |
906 | } | 906 | } |
907 | 907 | ||
@@ -959,7 +959,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
959 | * Invalid ACK: reset will be sent by listening socket | 959 | * Invalid ACK: reset will be sent by listening socket |
960 | */ | 960 | */ |
961 | if ((flg & TCP_FLAG_ACK) && | 961 | if ((flg & TCP_FLAG_ACK) && |
962 | (TCP_SKB_CB(skb)->ack_seq != req->snt_isn+1)) | 962 | (TCP_SKB_CB(skb)->ack_seq != tcp_rsk(req)->snt_isn + 1)) |
963 | return sk; | 963 | return sk; |
964 | 964 | ||
965 | /* Also, it would be not so bad idea to check rcv_tsecr, which | 965 | /* Also, it would be not so bad idea to check rcv_tsecr, which |
@@ -970,10 +970,10 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
970 | /* RFC793: "first check sequence number". */ | 970 | /* RFC793: "first check sequence number". */ |
971 | 971 | ||
972 | if (paws_reject || !tcp_in_window(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, | 972 | if (paws_reject || !tcp_in_window(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, |
973 | req->rcv_isn+1, req->rcv_isn+1+req->rcv_wnd)) { | 973 | tcp_rsk(req)->rcv_isn + 1, tcp_rsk(req)->rcv_isn + 1 + req->rcv_wnd)) { |
974 | /* Out of window: send ACK and drop. */ | 974 | /* Out of window: send ACK and drop. */ |
975 | if (!(flg & TCP_FLAG_RST)) | 975 | if (!(flg & TCP_FLAG_RST)) |
976 | req->class->send_ack(skb, req); | 976 | req->rsk_ops->send_ack(skb, req); |
977 | if (paws_reject) | 977 | if (paws_reject) |
978 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); | 978 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); |
979 | return NULL; | 979 | return NULL; |
@@ -981,12 +981,12 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
981 | 981 | ||
982 | /* In sequence, PAWS is OK. */ | 982 | /* In sequence, PAWS is OK. */ |
983 | 983 | ||
984 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, req->rcv_isn+1)) | 984 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_isn + 1)) |
985 | req->ts_recent = tmp_opt.rcv_tsval; | 985 | req->ts_recent = tmp_opt.rcv_tsval; |
986 | 986 | ||
987 | if (TCP_SKB_CB(skb)->seq == req->rcv_isn) { | 987 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) { |
988 | /* Truncate SYN, it is out of window starting | 988 | /* Truncate SYN, it is out of window starting |
989 | at req->rcv_isn+1. */ | 989 | at tcp_rsk(req)->rcv_isn + 1. */ |
990 | flg &= ~TCP_FLAG_SYN; | 990 | flg &= ~TCP_FLAG_SYN; |
991 | } | 991 | } |
992 | 992 | ||
@@ -1003,8 +1003,8 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
1003 | return NULL; | 1003 | return NULL; |
1004 | 1004 | ||
1005 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ | 1005 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ |
1006 | if (tp->defer_accept && TCP_SKB_CB(skb)->end_seq == req->rcv_isn+1) { | 1006 | if (tp->defer_accept && TCP_SKB_CB(skb)->end_seq == tcp_rsk(req)->rcv_isn + 1) { |
1007 | req->acked = 1; | 1007 | inet_rsk(req)->acked = 1; |
1008 | return NULL; | 1008 | return NULL; |
1009 | } | 1009 | } |
1010 | 1010 | ||
@@ -1026,14 +1026,14 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
1026 | 1026 | ||
1027 | listen_overflow: | 1027 | listen_overflow: |
1028 | if (!sysctl_tcp_abort_on_overflow) { | 1028 | if (!sysctl_tcp_abort_on_overflow) { |
1029 | req->acked = 1; | 1029 | inet_rsk(req)->acked = 1; |
1030 | return NULL; | 1030 | return NULL; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | embryonic_reset: | 1033 | embryonic_reset: |
1034 | NET_INC_STATS_BH(LINUX_MIB_EMBRYONICRSTS); | 1034 | NET_INC_STATS_BH(LINUX_MIB_EMBRYONICRSTS); |
1035 | if (!(flg & TCP_FLAG_RST)) | 1035 | if (!(flg & TCP_FLAG_RST)) |
1036 | req->class->send_reset(skb); | 1036 | req->rsk_ops->send_reset(skb); |
1037 | 1037 | ||
1038 | tcp_synq_drop(sk, req, prev); | 1038 | tcp_synq_drop(sk, req, prev); |
1039 | return NULL; | 1039 | return NULL; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index fa24e7ae1f40..f17c6577e337 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -1356,8 +1356,9 @@ int tcp_send_synack(struct sock *sk) | |||
1356 | * Prepare a SYN-ACK. | 1356 | * Prepare a SYN-ACK. |
1357 | */ | 1357 | */ |
1358 | struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, | 1358 | struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, |
1359 | struct open_request *req) | 1359 | struct request_sock *req) |
1360 | { | 1360 | { |
1361 | struct inet_request_sock *ireq = inet_rsk(req); | ||
1361 | struct tcp_sock *tp = tcp_sk(sk); | 1362 | struct tcp_sock *tp = tcp_sk(sk); |
1362 | struct tcphdr *th; | 1363 | struct tcphdr *th; |
1363 | int tcp_header_size; | 1364 | int tcp_header_size; |
@@ -1373,47 +1374,47 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
1373 | skb->dst = dst_clone(dst); | 1374 | skb->dst = dst_clone(dst); |
1374 | 1375 | ||
1375 | tcp_header_size = (sizeof(struct tcphdr) + TCPOLEN_MSS + | 1376 | tcp_header_size = (sizeof(struct tcphdr) + TCPOLEN_MSS + |
1376 | (req->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0) + | 1377 | (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0) + |
1377 | (req->wscale_ok ? TCPOLEN_WSCALE_ALIGNED : 0) + | 1378 | (ireq->wscale_ok ? TCPOLEN_WSCALE_ALIGNED : 0) + |
1378 | /* SACK_PERM is in the place of NOP NOP of TS */ | 1379 | /* SACK_PERM is in the place of NOP NOP of TS */ |
1379 | ((req->sack_ok && !req->tstamp_ok) ? TCPOLEN_SACKPERM_ALIGNED : 0)); | 1380 | ((ireq->sack_ok && !ireq->tstamp_ok) ? TCPOLEN_SACKPERM_ALIGNED : 0)); |
1380 | skb->h.th = th = (struct tcphdr *) skb_push(skb, tcp_header_size); | 1381 | skb->h.th = th = (struct tcphdr *) skb_push(skb, tcp_header_size); |
1381 | 1382 | ||
1382 | memset(th, 0, sizeof(struct tcphdr)); | 1383 | memset(th, 0, sizeof(struct tcphdr)); |
1383 | th->syn = 1; | 1384 | th->syn = 1; |
1384 | th->ack = 1; | 1385 | th->ack = 1; |
1385 | if (dst->dev->features&NETIF_F_TSO) | 1386 | if (dst->dev->features&NETIF_F_TSO) |
1386 | req->ecn_ok = 0; | 1387 | ireq->ecn_ok = 0; |
1387 | TCP_ECN_make_synack(req, th); | 1388 | TCP_ECN_make_synack(req, th); |
1388 | th->source = inet_sk(sk)->sport; | 1389 | th->source = inet_sk(sk)->sport; |
1389 | th->dest = req->rmt_port; | 1390 | th->dest = ireq->rmt_port; |
1390 | TCP_SKB_CB(skb)->seq = req->snt_isn; | 1391 | TCP_SKB_CB(skb)->seq = tcp_rsk(req)->snt_isn; |
1391 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + 1; | 1392 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + 1; |
1392 | TCP_SKB_CB(skb)->sacked = 0; | 1393 | TCP_SKB_CB(skb)->sacked = 0; |
1393 | skb_shinfo(skb)->tso_segs = 1; | 1394 | skb_shinfo(skb)->tso_segs = 1; |
1394 | skb_shinfo(skb)->tso_size = 0; | 1395 | skb_shinfo(skb)->tso_size = 0; |
1395 | th->seq = htonl(TCP_SKB_CB(skb)->seq); | 1396 | th->seq = htonl(TCP_SKB_CB(skb)->seq); |
1396 | th->ack_seq = htonl(req->rcv_isn + 1); | 1397 | th->ack_seq = htonl(tcp_rsk(req)->rcv_isn + 1); |
1397 | if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */ | 1398 | if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */ |
1398 | __u8 rcv_wscale; | 1399 | __u8 rcv_wscale; |
1399 | /* Set this up on the first call only */ | 1400 | /* Set this up on the first call only */ |
1400 | req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW); | 1401 | req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW); |
1401 | /* tcp_full_space because it is guaranteed to be the first packet */ | 1402 | /* tcp_full_space because it is guaranteed to be the first packet */ |
1402 | tcp_select_initial_window(tcp_full_space(sk), | 1403 | tcp_select_initial_window(tcp_full_space(sk), |
1403 | dst_metric(dst, RTAX_ADVMSS) - (req->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0), | 1404 | dst_metric(dst, RTAX_ADVMSS) - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0), |
1404 | &req->rcv_wnd, | 1405 | &req->rcv_wnd, |
1405 | &req->window_clamp, | 1406 | &req->window_clamp, |
1406 | req->wscale_ok, | 1407 | ireq->wscale_ok, |
1407 | &rcv_wscale); | 1408 | &rcv_wscale); |
1408 | req->rcv_wscale = rcv_wscale; | 1409 | ireq->rcv_wscale = rcv_wscale; |
1409 | } | 1410 | } |
1410 | 1411 | ||
1411 | /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */ | 1412 | /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */ |
1412 | th->window = htons(req->rcv_wnd); | 1413 | th->window = htons(req->rcv_wnd); |
1413 | 1414 | ||
1414 | TCP_SKB_CB(skb)->when = tcp_time_stamp; | 1415 | TCP_SKB_CB(skb)->when = tcp_time_stamp; |
1415 | tcp_syn_build_options((__u32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), req->tstamp_ok, | 1416 | tcp_syn_build_options((__u32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, |
1416 | req->sack_ok, req->wscale_ok, req->rcv_wscale, | 1417 | ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale, |
1417 | TCP_SKB_CB(skb)->when, | 1418 | TCP_SKB_CB(skb)->when, |
1418 | req->ts_recent); | 1419 | req->ts_recent); |
1419 | 1420 | ||
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 799ebe061e2c..b127b4498565 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -464,11 +464,11 @@ out_unlock: | |||
464 | static void tcp_synack_timer(struct sock *sk) | 464 | static void tcp_synack_timer(struct sock *sk) |
465 | { | 465 | { |
466 | struct tcp_sock *tp = tcp_sk(sk); | 466 | struct tcp_sock *tp = tcp_sk(sk); |
467 | struct tcp_listen_opt *lopt = tp->listen_opt; | 467 | struct listen_sock *lopt = tp->accept_queue.listen_opt; |
468 | int max_retries = tp->syn_retries ? : sysctl_tcp_synack_retries; | 468 | int max_retries = tp->syn_retries ? : sysctl_tcp_synack_retries; |
469 | int thresh = max_retries; | 469 | int thresh = max_retries; |
470 | unsigned long now = jiffies; | 470 | unsigned long now = jiffies; |
471 | struct open_request **reqp, *req; | 471 | struct request_sock **reqp, *req; |
472 | int i, budget; | 472 | int i, budget; |
473 | 473 | ||
474 | if (lopt == NULL || lopt->qlen == 0) | 474 | if (lopt == NULL || lopt->qlen == 0) |
@@ -513,8 +513,8 @@ static void tcp_synack_timer(struct sock *sk) | |||
513 | while ((req = *reqp) != NULL) { | 513 | while ((req = *reqp) != NULL) { |
514 | if (time_after_eq(now, req->expires)) { | 514 | if (time_after_eq(now, req->expires)) { |
515 | if ((req->retrans < thresh || | 515 | if ((req->retrans < thresh || |
516 | (req->acked && req->retrans < max_retries)) | 516 | (inet_rsk(req)->acked && req->retrans < max_retries)) |
517 | && !req->class->rtx_syn_ack(sk, req, NULL)) { | 517 | && !req->rsk_ops->rtx_syn_ack(sk, req, NULL)) { |
518 | unsigned long timeo; | 518 | unsigned long timeo; |
519 | 519 | ||
520 | if (req->retrans++ == 0) | 520 | if (req->retrans++ == 0) |
@@ -527,13 +527,9 @@ static void tcp_synack_timer(struct sock *sk) | |||
527 | } | 527 | } |
528 | 528 | ||
529 | /* Drop this request */ | 529 | /* Drop this request */ |
530 | write_lock(&tp->syn_wait_lock); | 530 | tcp_synq_unlink(tp, req, reqp); |
531 | *reqp = req->dl_next; | 531 | reqsk_queue_removed(&tp->accept_queue, req); |
532 | write_unlock(&tp->syn_wait_lock); | 532 | reqsk_free(req); |
533 | lopt->qlen--; | ||
534 | if (req->retrans == 0) | ||
535 | lopt->qlen_young--; | ||
536 | tcp_openreq_free(req); | ||
537 | continue; | 533 | continue; |
538 | } | 534 | } |
539 | reqp = &req->dl_next; | 535 | reqp = &req->dl_next; |