diff options
Diffstat (limited to 'net/ipv4')
44 files changed, 416 insertions, 464 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 621b128897d7..d2f22e74b267 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -323,7 +323,7 @@ lookup_protocol: | |||
323 | BUG_TRAP(answer_prot->slab != NULL); | 323 | BUG_TRAP(answer_prot->slab != NULL); |
324 | 324 | ||
325 | err = -ENOBUFS; | 325 | err = -ENOBUFS; |
326 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot, 1); | 326 | sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot); |
327 | if (sk == NULL) | 327 | if (sk == NULL) |
328 | goto out; | 328 | goto out; |
329 | 329 | ||
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 4e8e3b079f5b..5fc346d8b566 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <linux/spinlock.h> | 8 | #include <linux/spinlock.h> |
9 | #include <net/icmp.h> | 9 | #include <net/icmp.h> |
10 | #include <net/protocol.h> | 10 | #include <net/protocol.h> |
11 | #include <asm/scatterlist.h> | ||
12 | 11 | ||
13 | 12 | ||
14 | /* Clear mutable options and find final destination to substitute | 13 | /* Clear mutable options and find final destination to substitute |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 36d6798947b5..b3f366a33a5c 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -111,12 +111,8 @@ | |||
111 | #include <net/tcp.h> | 111 | #include <net/tcp.h> |
112 | #include <net/sock.h> | 112 | #include <net/sock.h> |
113 | #include <net/arp.h> | 113 | #include <net/arp.h> |
114 | #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | ||
115 | #include <net/ax25.h> | 114 | #include <net/ax25.h> |
116 | #if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) | ||
117 | #include <net/netrom.h> | 115 | #include <net/netrom.h> |
118 | #endif | ||
119 | #endif | ||
120 | #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) | 116 | #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) |
121 | #include <net/atmclip.h> | 117 | #include <net/atmclip.h> |
122 | struct neigh_table *clip_tbl_hook; | 118 | struct neigh_table *clip_tbl_hook; |
@@ -731,20 +727,10 @@ static int arp_process(struct sk_buff *skb) | |||
731 | htons(dev_type) != arp->ar_hrd) | 727 | htons(dev_type) != arp->ar_hrd) |
732 | goto out; | 728 | goto out; |
733 | break; | 729 | break; |
734 | #ifdef CONFIG_NET_ETHERNET | ||
735 | case ARPHRD_ETHER: | 730 | case ARPHRD_ETHER: |
736 | #endif | ||
737 | #ifdef CONFIG_TR | ||
738 | case ARPHRD_IEEE802_TR: | 731 | case ARPHRD_IEEE802_TR: |
739 | #endif | ||
740 | #ifdef CONFIG_FDDI | ||
741 | case ARPHRD_FDDI: | 732 | case ARPHRD_FDDI: |
742 | #endif | ||
743 | #ifdef CONFIG_NET_FC | ||
744 | case ARPHRD_IEEE802: | 733 | case ARPHRD_IEEE802: |
745 | #endif | ||
746 | #if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_TR) || \ | ||
747 | defined(CONFIG_FDDI) || defined(CONFIG_NET_FC) | ||
748 | /* | 734 | /* |
749 | * ETHERNET, Token Ring and Fibre Channel (which are IEEE 802 | 735 | * ETHERNET, Token Ring and Fibre Channel (which are IEEE 802 |
750 | * devices, according to RFC 2625) devices will accept ARP | 736 | * devices, according to RFC 2625) devices will accept ARP |
@@ -759,21 +745,16 @@ static int arp_process(struct sk_buff *skb) | |||
759 | arp->ar_pro != htons(ETH_P_IP)) | 745 | arp->ar_pro != htons(ETH_P_IP)) |
760 | goto out; | 746 | goto out; |
761 | break; | 747 | break; |
762 | #endif | ||
763 | #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | ||
764 | case ARPHRD_AX25: | 748 | case ARPHRD_AX25: |
765 | if (arp->ar_pro != htons(AX25_P_IP) || | 749 | if (arp->ar_pro != htons(AX25_P_IP) || |
766 | arp->ar_hrd != htons(ARPHRD_AX25)) | 750 | arp->ar_hrd != htons(ARPHRD_AX25)) |
767 | goto out; | 751 | goto out; |
768 | break; | 752 | break; |
769 | #if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) | ||
770 | case ARPHRD_NETROM: | 753 | case ARPHRD_NETROM: |
771 | if (arp->ar_pro != htons(AX25_P_IP) || | 754 | if (arp->ar_pro != htons(AX25_P_IP) || |
772 | arp->ar_hrd != htons(ARPHRD_NETROM)) | 755 | arp->ar_hrd != htons(ARPHRD_NETROM)) |
773 | goto out; | 756 | goto out; |
774 | break; | 757 | break; |
775 | #endif | ||
776 | #endif | ||
777 | } | 758 | } |
778 | 759 | ||
779 | /* Understand only these message types */ | 760 | /* Understand only these message types */ |
@@ -828,7 +809,8 @@ static int arp_process(struct sk_buff *skb) | |||
828 | if (arp->ar_op == htons(ARPOP_REQUEST) && | 809 | if (arp->ar_op == htons(ARPOP_REQUEST) && |
829 | inet_addr_type(tip) == RTN_LOCAL && | 810 | inet_addr_type(tip) == RTN_LOCAL && |
830 | !arp_ignore(in_dev,dev,sip,tip)) | 811 | !arp_ignore(in_dev,dev,sip,tip)) |
831 | arp_send(ARPOP_REPLY,ETH_P_ARP,tip,dev,tip,sha,dev->dev_addr,dev->dev_addr); | 812 | arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha, |
813 | dev->dev_addr, sha); | ||
832 | goto out; | 814 | goto out; |
833 | } | 815 | } |
834 | 816 | ||
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index cad4278025ad..c31bccb9b526 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -111,9 +111,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) | |||
111 | goto unlock; | 111 | goto unlock; |
112 | } | 112 | } |
113 | sg_init_table(sg, nfrags); | 113 | sg_init_table(sg, nfrags); |
114 | sg_mark_end(sg, skb_to_sgvec(skb, sg, esph->enc_data + | 114 | skb_to_sgvec(skb, sg, |
115 | esp->conf.ivlen - | 115 | esph->enc_data + |
116 | skb->data, clen)); | 116 | esp->conf.ivlen - |
117 | skb->data, clen); | ||
117 | err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); | 118 | err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); |
118 | if (unlikely(sg != &esp->sgbuf[0])) | 119 | if (unlikely(sg != &esp->sgbuf[0])) |
119 | kfree(sg); | 120 | kfree(sg); |
@@ -205,8 +206,9 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) | |||
205 | goto out; | 206 | goto out; |
206 | } | 207 | } |
207 | sg_init_table(sg, nfrags); | 208 | sg_init_table(sg, nfrags); |
208 | sg_mark_end(sg, skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, | 209 | skb_to_sgvec(skb, sg, |
209 | elen)); | 210 | sizeof(*esph) + esp->conf.ivlen, |
211 | elen); | ||
210 | err = crypto_blkcipher_decrypt(&desc, sg, sg, elen); | 212 | err = crypto_blkcipher_decrypt(&desc, sg, sg, elen); |
211 | if (unlikely(sg != &esp->sgbuf[0])) | 213 | if (unlikely(sg != &esp->sgbuf[0])) |
212 | kfree(sg); | 214 | kfree(sg); |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 60123905dbbf..732d8f088b13 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -59,6 +59,13 @@ struct fib_table *ip_fib_main_table; | |||
59 | #define FIB_TABLE_HASHSZ 1 | 59 | #define FIB_TABLE_HASHSZ 1 |
60 | static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; | 60 | static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; |
61 | 61 | ||
62 | static void __init fib4_rules_init(void) | ||
63 | { | ||
64 | ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL); | ||
65 | hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]); | ||
66 | ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN); | ||
67 | hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]); | ||
68 | } | ||
62 | #else | 69 | #else |
63 | 70 | ||
64 | #define FIB_TABLE_HASHSZ 256 | 71 | #define FIB_TABLE_HASHSZ 256 |
@@ -905,14 +912,8 @@ void __init ip_fib_init(void) | |||
905 | 912 | ||
906 | for (i = 0; i < FIB_TABLE_HASHSZ; i++) | 913 | for (i = 0; i < FIB_TABLE_HASHSZ; i++) |
907 | INIT_HLIST_HEAD(&fib_table_hash[i]); | 914 | INIT_HLIST_HEAD(&fib_table_hash[i]); |
908 | #ifndef CONFIG_IP_MULTIPLE_TABLES | 915 | |
909 | ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL); | ||
910 | hlist_add_head_rcu(&ip_fib_local_table->tb_hlist, &fib_table_hash[0]); | ||
911 | ip_fib_main_table = fib_hash_init(RT_TABLE_MAIN); | ||
912 | hlist_add_head_rcu(&ip_fib_main_table->tb_hlist, &fib_table_hash[0]); | ||
913 | #else | ||
914 | fib4_rules_init(); | 916 | fib4_rules_init(); |
915 | #endif | ||
916 | 917 | ||
917 | register_netdevice_notifier(&fib_netdev_notifier); | 918 | register_netdevice_notifier(&fib_netdev_notifier); |
918 | register_inetaddr_notifier(&fib_inetaddr_notifier); | 919 | register_inetaddr_notifier(&fib_inetaddr_notifier); |
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index f16839c6a721..a0ada3a8d8dd 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -49,33 +49,6 @@ struct fib4_rule | |||
49 | #endif | 49 | #endif |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static struct fib4_rule default_rule = { | ||
53 | .common = { | ||
54 | .refcnt = ATOMIC_INIT(2), | ||
55 | .pref = 0x7FFF, | ||
56 | .table = RT_TABLE_DEFAULT, | ||
57 | .action = FR_ACT_TO_TBL, | ||
58 | }, | ||
59 | }; | ||
60 | |||
61 | static struct fib4_rule main_rule = { | ||
62 | .common = { | ||
63 | .refcnt = ATOMIC_INIT(2), | ||
64 | .pref = 0x7FFE, | ||
65 | .table = RT_TABLE_MAIN, | ||
66 | .action = FR_ACT_TO_TBL, | ||
67 | }, | ||
68 | }; | ||
69 | |||
70 | static struct fib4_rule local_rule = { | ||
71 | .common = { | ||
72 | .refcnt = ATOMIC_INIT(2), | ||
73 | .table = RT_TABLE_LOCAL, | ||
74 | .action = FR_ACT_TO_TBL, | ||
75 | .flags = FIB_RULE_PERMANENT, | ||
76 | }, | ||
77 | }; | ||
78 | |||
79 | #ifdef CONFIG_NET_CLS_ROUTE | 52 | #ifdef CONFIG_NET_CLS_ROUTE |
80 | u32 fib_rules_tclass(struct fib_result *res) | 53 | u32 fib_rules_tclass(struct fib_result *res) |
81 | { | 54 | { |
@@ -319,11 +292,27 @@ static struct fib_rules_ops fib4_rules_ops = { | |||
319 | .owner = THIS_MODULE, | 292 | .owner = THIS_MODULE, |
320 | }; | 293 | }; |
321 | 294 | ||
322 | void __init fib4_rules_init(void) | 295 | static int __init fib_default_rules_init(void) |
323 | { | 296 | { |
324 | list_add_tail(&local_rule.common.list, &fib4_rules_ops.rules_list); | 297 | int err; |
325 | list_add_tail(&main_rule.common.list, &fib4_rules_ops.rules_list); | 298 | |
326 | list_add_tail(&default_rule.common.list, &fib4_rules_ops.rules_list); | 299 | err = fib_default_rule_add(&fib4_rules_ops, 0, |
300 | RT_TABLE_LOCAL, FIB_RULE_PERMANENT); | ||
301 | if (err < 0) | ||
302 | return err; | ||
303 | err = fib_default_rule_add(&fib4_rules_ops, 0x7FFE, | ||
304 | RT_TABLE_MAIN, 0); | ||
305 | if (err < 0) | ||
306 | return err; | ||
307 | err = fib_default_rule_add(&fib4_rules_ops, 0x7FFF, | ||
308 | RT_TABLE_DEFAULT, 0); | ||
309 | if (err < 0) | ||
310 | return err; | ||
311 | return 0; | ||
312 | } | ||
327 | 313 | ||
314 | void __init fib4_rules_init(void) | ||
315 | { | ||
316 | BUG_ON(fib_default_rules_init()); | ||
328 | fib_rules_register(&fib4_rules_ops); | 317 | fib_rules_register(&fib4_rules_ops); |
329 | } | 318 | } |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index dc429b6b0ba6..b0170732b5e9 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -747,13 +747,14 @@ skip_listen_ht: | |||
747 | 747 | ||
748 | for (i = s_i; i < hashinfo->ehash_size; i++) { | 748 | for (i = s_i; i < hashinfo->ehash_size; i++) { |
749 | struct inet_ehash_bucket *head = &hashinfo->ehash[i]; | 749 | struct inet_ehash_bucket *head = &hashinfo->ehash[i]; |
750 | rwlock_t *lock = inet_ehash_lockp(hashinfo, i); | ||
750 | struct sock *sk; | 751 | struct sock *sk; |
751 | struct hlist_node *node; | 752 | struct hlist_node *node; |
752 | 753 | ||
753 | if (i > s_i) | 754 | if (i > s_i) |
754 | s_num = 0; | 755 | s_num = 0; |
755 | 756 | ||
756 | read_lock_bh(&head->lock); | 757 | read_lock_bh(lock); |
757 | num = 0; | 758 | num = 0; |
758 | sk_for_each(sk, node, &head->chain) { | 759 | sk_for_each(sk, node, &head->chain) { |
759 | struct inet_sock *inet = inet_sk(sk); | 760 | struct inet_sock *inet = inet_sk(sk); |
@@ -769,7 +770,7 @@ skip_listen_ht: | |||
769 | r->id.idiag_dport) | 770 | r->id.idiag_dport) |
770 | goto next_normal; | 771 | goto next_normal; |
771 | if (inet_csk_diag_dump(sk, skb, cb) < 0) { | 772 | if (inet_csk_diag_dump(sk, skb, cb) < 0) { |
772 | read_unlock_bh(&head->lock); | 773 | read_unlock_bh(lock); |
773 | goto done; | 774 | goto done; |
774 | } | 775 | } |
775 | next_normal: | 776 | next_normal: |
@@ -791,14 +792,14 @@ next_normal: | |||
791 | r->id.idiag_dport) | 792 | r->id.idiag_dport) |
792 | goto next_dying; | 793 | goto next_dying; |
793 | if (inet_twsk_diag_dump(tw, skb, cb) < 0) { | 794 | if (inet_twsk_diag_dump(tw, skb, cb) < 0) { |
794 | read_unlock_bh(&head->lock); | 795 | read_unlock_bh(lock); |
795 | goto done; | 796 | goto done; |
796 | } | 797 | } |
797 | next_dying: | 798 | next_dying: |
798 | ++num; | 799 | ++num; |
799 | } | 800 | } |
800 | } | 801 | } |
801 | read_unlock_bh(&head->lock); | 802 | read_unlock_bh(lock); |
802 | } | 803 | } |
803 | 804 | ||
804 | done: | 805 | done: |
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 16eecc7046a3..67704da04fc4 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
@@ -204,12 +204,13 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row, | |||
204 | const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); | 204 | const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); |
205 | unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); | 205 | unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); |
206 | struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); | 206 | struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
207 | rwlock_t *lock = inet_ehash_lockp(hinfo, hash); | ||
207 | struct sock *sk2; | 208 | struct sock *sk2; |
208 | const struct hlist_node *node; | 209 | const struct hlist_node *node; |
209 | struct inet_timewait_sock *tw; | 210 | struct inet_timewait_sock *tw; |
210 | 211 | ||
211 | prefetch(head->chain.first); | 212 | prefetch(head->chain.first); |
212 | write_lock(&head->lock); | 213 | write_lock(lock); |
213 | 214 | ||
214 | /* Check TIME-WAIT sockets first. */ | 215 | /* Check TIME-WAIT sockets first. */ |
215 | sk_for_each(sk2, node, &head->twchain) { | 216 | sk_for_each(sk2, node, &head->twchain) { |
@@ -239,7 +240,7 @@ unique: | |||
239 | BUG_TRAP(sk_unhashed(sk)); | 240 | BUG_TRAP(sk_unhashed(sk)); |
240 | __sk_add_node(sk, &head->chain); | 241 | __sk_add_node(sk, &head->chain); |
241 | sock_prot_inc_use(sk->sk_prot); | 242 | sock_prot_inc_use(sk->sk_prot); |
242 | write_unlock(&head->lock); | 243 | write_unlock(lock); |
243 | 244 | ||
244 | if (twp) { | 245 | if (twp) { |
245 | *twp = tw; | 246 | *twp = tw; |
@@ -255,7 +256,7 @@ unique: | |||
255 | return 0; | 256 | return 0; |
256 | 257 | ||
257 | not_unique: | 258 | not_unique: |
258 | write_unlock(&head->lock); | 259 | write_unlock(lock); |
259 | return -EADDRNOTAVAIL; | 260 | return -EADDRNOTAVAIL; |
260 | } | 261 | } |
261 | 262 | ||
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 4e189e28f306..a60b99e0ebdc 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -20,16 +20,16 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw, | |||
20 | struct inet_bind_hashbucket *bhead; | 20 | struct inet_bind_hashbucket *bhead; |
21 | struct inet_bind_bucket *tb; | 21 | struct inet_bind_bucket *tb; |
22 | /* Unlink from established hashes. */ | 22 | /* Unlink from established hashes. */ |
23 | struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, tw->tw_hash); | 23 | rwlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); |
24 | 24 | ||
25 | write_lock(&ehead->lock); | 25 | write_lock(lock); |
26 | if (hlist_unhashed(&tw->tw_node)) { | 26 | if (hlist_unhashed(&tw->tw_node)) { |
27 | write_unlock(&ehead->lock); | 27 | write_unlock(lock); |
28 | return; | 28 | return; |
29 | } | 29 | } |
30 | __hlist_del(&tw->tw_node); | 30 | __hlist_del(&tw->tw_node); |
31 | sk_node_init(&tw->tw_node); | 31 | sk_node_init(&tw->tw_node); |
32 | write_unlock(&ehead->lock); | 32 | write_unlock(lock); |
33 | 33 | ||
34 | /* Disassociate with bind bucket. */ | 34 | /* Disassociate with bind bucket. */ |
35 | bhead = &hashinfo->bhash[inet_bhashfn(tw->tw_num, hashinfo->bhash_size)]; | 35 | bhead = &hashinfo->bhash[inet_bhashfn(tw->tw_num, hashinfo->bhash_size)]; |
@@ -59,6 +59,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
59 | const struct inet_sock *inet = inet_sk(sk); | 59 | const struct inet_sock *inet = inet_sk(sk); |
60 | const struct inet_connection_sock *icsk = inet_csk(sk); | 60 | const struct inet_connection_sock *icsk = inet_csk(sk); |
61 | struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); | 61 | struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); |
62 | rwlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash); | ||
62 | struct inet_bind_hashbucket *bhead; | 63 | struct inet_bind_hashbucket *bhead; |
63 | /* Step 1: Put TW into bind hash. Original socket stays there too. | 64 | /* Step 1: Put TW into bind hash. Original socket stays there too. |
64 | Note, that any socket with inet->num != 0 MUST be bound in | 65 | Note, that any socket with inet->num != 0 MUST be bound in |
@@ -71,7 +72,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
71 | inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); | 72 | inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); |
72 | spin_unlock(&bhead->lock); | 73 | spin_unlock(&bhead->lock); |
73 | 74 | ||
74 | write_lock(&ehead->lock); | 75 | write_lock(lock); |
75 | 76 | ||
76 | /* Step 2: Remove SK from established hash. */ | 77 | /* Step 2: Remove SK from established hash. */ |
77 | if (__sk_del_node_init(sk)) | 78 | if (__sk_del_node_init(sk)) |
@@ -81,7 +82,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
81 | inet_twsk_add_node(tw, &ehead->twchain); | 82 | inet_twsk_add_node(tw, &ehead->twchain); |
82 | atomic_inc(&tw->tw_refcnt); | 83 | atomic_inc(&tw->tw_refcnt); |
83 | 84 | ||
84 | write_unlock(&ehead->lock); | 85 | write_unlock(lock); |
85 | } | 86 | } |
86 | 87 | ||
87 | EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); | 88 | EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); |
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index 771031dfbd0f..af995198f643 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c | |||
@@ -61,7 +61,7 @@ | |||
61 | * 4. Global variable peer_total is modified under the pool lock. | 61 | * 4. Global variable peer_total is modified under the pool lock. |
62 | * 5. struct inet_peer fields modification: | 62 | * 5. struct inet_peer fields modification: |
63 | * avl_left, avl_right, avl_parent, avl_height: pool lock | 63 | * avl_left, avl_right, avl_parent, avl_height: pool lock |
64 | * unused_next, unused_prevp: unused node list lock | 64 | * unused: unused node list lock |
65 | * refcnt: atomically against modifications on other CPU; | 65 | * refcnt: atomically against modifications on other CPU; |
66 | * usually under some other lock to prevent node disappearing | 66 | * usually under some other lock to prevent node disappearing |
67 | * dtime: unused node list lock | 67 | * dtime: unused node list lock |
@@ -94,8 +94,7 @@ int inet_peer_maxttl __read_mostly = 10 * 60 * HZ; /* usual time to live: 10 min | |||
94 | int inet_peer_gc_mintime __read_mostly = 10 * HZ; | 94 | int inet_peer_gc_mintime __read_mostly = 10 * HZ; |
95 | int inet_peer_gc_maxtime __read_mostly = 120 * HZ; | 95 | int inet_peer_gc_maxtime __read_mostly = 120 * HZ; |
96 | 96 | ||
97 | static struct inet_peer *inet_peer_unused_head; | 97 | static LIST_HEAD(unused_peers); |
98 | static struct inet_peer **inet_peer_unused_tailp = &inet_peer_unused_head; | ||
99 | static DEFINE_SPINLOCK(inet_peer_unused_lock); | 98 | static DEFINE_SPINLOCK(inet_peer_unused_lock); |
100 | 99 | ||
101 | static void peer_check_expire(unsigned long dummy); | 100 | static void peer_check_expire(unsigned long dummy); |
@@ -138,15 +137,7 @@ void __init inet_initpeers(void) | |||
138 | static void unlink_from_unused(struct inet_peer *p) | 137 | static void unlink_from_unused(struct inet_peer *p) |
139 | { | 138 | { |
140 | spin_lock_bh(&inet_peer_unused_lock); | 139 | spin_lock_bh(&inet_peer_unused_lock); |
141 | if (p->unused_prevp != NULL) { | 140 | list_del_init(&p->unused); |
142 | /* On unused list. */ | ||
143 | *p->unused_prevp = p->unused_next; | ||
144 | if (p->unused_next != NULL) | ||
145 | p->unused_next->unused_prevp = p->unused_prevp; | ||
146 | else | ||
147 | inet_peer_unused_tailp = p->unused_prevp; | ||
148 | p->unused_prevp = NULL; /* mark it as removed */ | ||
149 | } | ||
150 | spin_unlock_bh(&inet_peer_unused_lock); | 141 | spin_unlock_bh(&inet_peer_unused_lock); |
151 | } | 142 | } |
152 | 143 | ||
@@ -337,24 +328,24 @@ static void unlink_from_pool(struct inet_peer *p) | |||
337 | /* May be called with local BH enabled. */ | 328 | /* May be called with local BH enabled. */ |
338 | static int cleanup_once(unsigned long ttl) | 329 | static int cleanup_once(unsigned long ttl) |
339 | { | 330 | { |
340 | struct inet_peer *p; | 331 | struct inet_peer *p = NULL; |
341 | 332 | ||
342 | /* Remove the first entry from the list of unused nodes. */ | 333 | /* Remove the first entry from the list of unused nodes. */ |
343 | spin_lock_bh(&inet_peer_unused_lock); | 334 | spin_lock_bh(&inet_peer_unused_lock); |
344 | p = inet_peer_unused_head; | 335 | if (!list_empty(&unused_peers)) { |
345 | if (p != NULL) { | 336 | __u32 delta; |
346 | __u32 delta = (__u32)jiffies - p->dtime; | 337 | |
338 | p = list_first_entry(&unused_peers, struct inet_peer, unused); | ||
339 | delta = (__u32)jiffies - p->dtime; | ||
340 | |||
347 | if (delta < ttl) { | 341 | if (delta < ttl) { |
348 | /* Do not prune fresh entries. */ | 342 | /* Do not prune fresh entries. */ |
349 | spin_unlock_bh(&inet_peer_unused_lock); | 343 | spin_unlock_bh(&inet_peer_unused_lock); |
350 | return -1; | 344 | return -1; |
351 | } | 345 | } |
352 | inet_peer_unused_head = p->unused_next; | 346 | |
353 | if (p->unused_next != NULL) | 347 | list_del_init(&p->unused); |
354 | p->unused_next->unused_prevp = p->unused_prevp; | 348 | |
355 | else | ||
356 | inet_peer_unused_tailp = p->unused_prevp; | ||
357 | p->unused_prevp = NULL; /* mark as not on the list */ | ||
358 | /* Grab an extra reference to prevent node disappearing | 349 | /* Grab an extra reference to prevent node disappearing |
359 | * before unlink_from_pool() call. */ | 350 | * before unlink_from_pool() call. */ |
360 | atomic_inc(&p->refcnt); | 351 | atomic_inc(&p->refcnt); |
@@ -412,7 +403,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create) | |||
412 | 403 | ||
413 | /* Link the node. */ | 404 | /* Link the node. */ |
414 | link_to_pool(n); | 405 | link_to_pool(n); |
415 | n->unused_prevp = NULL; /* not on the list */ | 406 | INIT_LIST_HEAD(&n->unused); |
416 | peer_total++; | 407 | peer_total++; |
417 | write_unlock_bh(&peer_pool_lock); | 408 | write_unlock_bh(&peer_pool_lock); |
418 | 409 | ||
@@ -467,10 +458,7 @@ void inet_putpeer(struct inet_peer *p) | |||
467 | { | 458 | { |
468 | spin_lock_bh(&inet_peer_unused_lock); | 459 | spin_lock_bh(&inet_peer_unused_lock); |
469 | if (atomic_dec_and_test(&p->refcnt)) { | 460 | if (atomic_dec_and_test(&p->refcnt)) { |
470 | p->unused_prevp = inet_peer_unused_tailp; | 461 | list_add_tail(&p->unused, &unused_peers); |
471 | p->unused_next = NULL; | ||
472 | *inet_peer_unused_tailp = p; | ||
473 | inet_peer_unused_tailp = &p->unused_next; | ||
474 | p->dtime = (__u32)jiffies; | 462 | p->dtime = (__u32)jiffies; |
475 | } | 463 | } |
476 | spin_unlock_bh(&inet_peer_unused_lock); | 464 | spin_unlock_bh(&inet_peer_unused_lock); |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index e5f7dc2de303..fd99fbd685ea 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -1183,6 +1183,17 @@ error: | |||
1183 | return err; | 1183 | return err; |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | static void ip_cork_release(struct inet_sock *inet) | ||
1187 | { | ||
1188 | inet->cork.flags &= ~IPCORK_OPT; | ||
1189 | kfree(inet->cork.opt); | ||
1190 | inet->cork.opt = NULL; | ||
1191 | if (inet->cork.rt) { | ||
1192 | ip_rt_put(inet->cork.rt); | ||
1193 | inet->cork.rt = NULL; | ||
1194 | } | ||
1195 | } | ||
1196 | |||
1186 | /* | 1197 | /* |
1187 | * Combined all pending IP fragments on the socket as one IP datagram | 1198 | * Combined all pending IP fragments on the socket as one IP datagram |
1188 | * and push them out. | 1199 | * and push them out. |
@@ -1276,13 +1287,7 @@ int ip_push_pending_frames(struct sock *sk) | |||
1276 | } | 1287 | } |
1277 | 1288 | ||
1278 | out: | 1289 | out: |
1279 | inet->cork.flags &= ~IPCORK_OPT; | 1290 | ip_cork_release(inet); |
1280 | kfree(inet->cork.opt); | ||
1281 | inet->cork.opt = NULL; | ||
1282 | if (inet->cork.rt) { | ||
1283 | ip_rt_put(inet->cork.rt); | ||
1284 | inet->cork.rt = NULL; | ||
1285 | } | ||
1286 | return err; | 1291 | return err; |
1287 | 1292 | ||
1288 | error: | 1293 | error: |
@@ -1295,19 +1300,12 @@ error: | |||
1295 | */ | 1300 | */ |
1296 | void ip_flush_pending_frames(struct sock *sk) | 1301 | void ip_flush_pending_frames(struct sock *sk) |
1297 | { | 1302 | { |
1298 | struct inet_sock *inet = inet_sk(sk); | ||
1299 | struct sk_buff *skb; | 1303 | struct sk_buff *skb; |
1300 | 1304 | ||
1301 | while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) | 1305 | while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) |
1302 | kfree_skb(skb); | 1306 | kfree_skb(skb); |
1303 | 1307 | ||
1304 | inet->cork.flags &= ~IPCORK_OPT; | 1308 | ip_cork_release(inet_sk(sk)); |
1305 | kfree(inet->cork.opt); | ||
1306 | inet->cork.opt = NULL; | ||
1307 | if (inet->cork.rt) { | ||
1308 | ip_rt_put(inet->cork.rt); | ||
1309 | inet->cork.rt = NULL; | ||
1310 | } | ||
1311 | } | 1309 | } |
1312 | 1310 | ||
1313 | 1311 | ||
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index f51f20e487c8..82817e554363 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -437,10 +437,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
437 | 437 | ||
438 | /* If optlen==0, it is equivalent to val == 0 */ | 438 | /* If optlen==0, it is equivalent to val == 0 */ |
439 | 439 | ||
440 | #ifdef CONFIG_IP_MROUTE | 440 | if (ip_mroute_opt(optname)) |
441 | if (optname >= MRT_BASE && optname <= (MRT_BASE + 10)) | ||
442 | return ip_mroute_setsockopt(sk,optname,optval,optlen); | 441 | return ip_mroute_setsockopt(sk,optname,optval,optlen); |
443 | #endif | ||
444 | 442 | ||
445 | err = 0; | 443 | err = 0; |
446 | lock_sock(sk); | 444 | lock_sock(sk); |
@@ -909,11 +907,9 @@ int ip_setsockopt(struct sock *sk, int level, | |||
909 | #ifdef CONFIG_NETFILTER | 907 | #ifdef CONFIG_NETFILTER |
910 | /* we need to exclude all possible ENOPROTOOPTs except default case */ | 908 | /* we need to exclude all possible ENOPROTOOPTs except default case */ |
911 | if (err == -ENOPROTOOPT && optname != IP_HDRINCL && | 909 | if (err == -ENOPROTOOPT && optname != IP_HDRINCL && |
912 | optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY | 910 | optname != IP_IPSEC_POLICY && |
913 | #ifdef CONFIG_IP_MROUTE | 911 | optname != IP_XFRM_POLICY && |
914 | && (optname < MRT_BASE || optname > (MRT_BASE + 10)) | 912 | !ip_mroute_opt(optname)) { |
915 | #endif | ||
916 | ) { | ||
917 | lock_sock(sk); | 913 | lock_sock(sk); |
918 | err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); | 914 | err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); |
919 | release_sock(sk); | 915 | release_sock(sk); |
@@ -935,11 +931,9 @@ int compat_ip_setsockopt(struct sock *sk, int level, int optname, | |||
935 | #ifdef CONFIG_NETFILTER | 931 | #ifdef CONFIG_NETFILTER |
936 | /* we need to exclude all possible ENOPROTOOPTs except default case */ | 932 | /* we need to exclude all possible ENOPROTOOPTs except default case */ |
937 | if (err == -ENOPROTOOPT && optname != IP_HDRINCL && | 933 | if (err == -ENOPROTOOPT && optname != IP_HDRINCL && |
938 | optname != IP_IPSEC_POLICY && optname != IP_XFRM_POLICY | 934 | optname != IP_IPSEC_POLICY && |
939 | #ifdef CONFIG_IP_MROUTE | 935 | optname != IP_XFRM_POLICY && |
940 | && (optname < MRT_BASE || optname > (MRT_BASE + 10)) | 936 | !ip_mroute_opt(optname)) { |
941 | #endif | ||
942 | ) { | ||
943 | lock_sock(sk); | 937 | lock_sock(sk); |
944 | err = compat_nf_setsockopt(sk, PF_INET, optname, | 938 | err = compat_nf_setsockopt(sk, PF_INET, optname, |
945 | optval, optlen); | 939 | optval, optlen); |
@@ -967,11 +961,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, | |||
967 | if (level != SOL_IP) | 961 | if (level != SOL_IP) |
968 | return -EOPNOTSUPP; | 962 | return -EOPNOTSUPP; |
969 | 963 | ||
970 | #ifdef CONFIG_IP_MROUTE | 964 | if (ip_mroute_opt(optname)) |
971 | if (optname >= MRT_BASE && optname <= MRT_BASE+10) { | ||
972 | return ip_mroute_getsockopt(sk,optname,optval,optlen); | 965 | return ip_mroute_getsockopt(sk,optname,optval,optlen); |
973 | } | ||
974 | #endif | ||
975 | 966 | ||
976 | if (get_user(len,optlen)) | 967 | if (get_user(len,optlen)) |
977 | return -EFAULT; | 968 | return -EFAULT; |
@@ -1171,11 +1162,8 @@ int ip_getsockopt(struct sock *sk, int level, | |||
1171 | err = do_ip_getsockopt(sk, level, optname, optval, optlen); | 1162 | err = do_ip_getsockopt(sk, level, optname, optval, optlen); |
1172 | #ifdef CONFIG_NETFILTER | 1163 | #ifdef CONFIG_NETFILTER |
1173 | /* we need to exclude all possible ENOPROTOOPTs except default case */ | 1164 | /* we need to exclude all possible ENOPROTOOPTs except default case */ |
1174 | if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS | 1165 | if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS && |
1175 | #ifdef CONFIG_IP_MROUTE | 1166 | !ip_mroute_opt(optname)) { |
1176 | && (optname < MRT_BASE || optname > MRT_BASE+10) | ||
1177 | #endif | ||
1178 | ) { | ||
1179 | int len; | 1167 | int len; |
1180 | 1168 | ||
1181 | if (get_user(len,optlen)) | 1169 | if (get_user(len,optlen)) |
@@ -1200,11 +1188,8 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, | |||
1200 | int err = do_ip_getsockopt(sk, level, optname, optval, optlen); | 1188 | int err = do_ip_getsockopt(sk, level, optname, optval, optlen); |
1201 | #ifdef CONFIG_NETFILTER | 1189 | #ifdef CONFIG_NETFILTER |
1202 | /* we need to exclude all possible ENOPROTOOPTs except default case */ | 1190 | /* we need to exclude all possible ENOPROTOOPTs except default case */ |
1203 | if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS | 1191 | if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS && |
1204 | #ifdef CONFIG_IP_MROUTE | 1192 | !ip_mroute_opt(optname)) { |
1205 | && (optname < MRT_BASE || optname > MRT_BASE+10) | ||
1206 | #endif | ||
1207 | ) { | ||
1208 | int len; | 1193 | int len; |
1209 | 1194 | ||
1210 | if (get_user(len, optlen)) | 1195 | if (get_user(len, optlen)) |
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 0bfeb02a5f87..2c44a94c2135 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -14,9 +14,9 @@ | |||
14 | * - Adaptive compression. | 14 | * - Adaptive compression. |
15 | */ | 15 | */ |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <asm/scatterlist.h> | ||
18 | #include <asm/semaphore.h> | 17 | #include <asm/semaphore.h> |
19 | #include <linux/crypto.h> | 18 | #include <linux/crypto.h> |
19 | #include <linux/err.h> | ||
20 | #include <linux/pfkeyv2.h> | 20 | #include <linux/pfkeyv2.h> |
21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
22 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
@@ -345,7 +345,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name) | |||
345 | for_each_possible_cpu(cpu) { | 345 | for_each_possible_cpu(cpu) { |
346 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, | 346 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, |
347 | CRYPTO_ALG_ASYNC); | 347 | CRYPTO_ALG_ASYNC); |
348 | if (!tfm) | 348 | if (IS_ERR(tfm)) |
349 | goto error; | 349 | goto error; |
350 | *per_cpu_ptr(tfms, cpu) = tfm; | 350 | *per_cpu_ptr(tfms, cpu) = tfm; |
351 | } | 351 | } |
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index 4b702f708d30..0a9f3c37e18d 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c | |||
@@ -426,6 +426,24 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) | |||
426 | 426 | ||
427 | 427 | ||
428 | /* | 428 | /* |
429 | * Check if there is a destination for the connection, if so | ||
430 | * bind the connection to the destination. | ||
431 | */ | ||
432 | struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp) | ||
433 | { | ||
434 | struct ip_vs_dest *dest; | ||
435 | |||
436 | if ((cp) && (!cp->dest)) { | ||
437 | dest = ip_vs_find_dest(cp->daddr, cp->dport, | ||
438 | cp->vaddr, cp->vport, cp->protocol); | ||
439 | ip_vs_bind_dest(cp, dest); | ||
440 | return dest; | ||
441 | } else | ||
442 | return NULL; | ||
443 | } | ||
444 | |||
445 | |||
446 | /* | ||
429 | * Unbind a connection entry with its VS destination | 447 | * Unbind a connection entry with its VS destination |
430 | * Called by the ip_vs_conn_expire function. | 448 | * Called by the ip_vs_conn_expire function. |
431 | */ | 449 | */ |
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index c6ed7654e839..8fba20256f52 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c | |||
@@ -637,7 +637,7 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *related) | |||
637 | verdict = NF_DROP; | 637 | verdict = NF_DROP; |
638 | 638 | ||
639 | if (IP_VS_FWD_METHOD(cp) != 0) { | 639 | if (IP_VS_FWD_METHOD(cp) != 0) { |
640 | IP_VS_ERR("shouldn't reach here, because the box is on the" | 640 | IP_VS_ERR("shouldn't reach here, because the box is on the " |
641 | "half connection in the tun/dr module.\n"); | 641 | "half connection in the tun/dr module.\n"); |
642 | } | 642 | } |
643 | 643 | ||
@@ -979,15 +979,23 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, | |||
979 | ret = NF_ACCEPT; | 979 | ret = NF_ACCEPT; |
980 | } | 980 | } |
981 | 981 | ||
982 | /* increase its packet counter and check if it is needed | 982 | /* Increase its packet counter and check if it is needed |
983 | to be synchronized */ | 983 | * to be synchronized |
984 | * | ||
985 | * Sync connection if it is about to close to | ||
986 | * encorage the standby servers to update the connections timeout | ||
987 | */ | ||
984 | atomic_inc(&cp->in_pkts); | 988 | atomic_inc(&cp->in_pkts); |
985 | if ((ip_vs_sync_state & IP_VS_STATE_MASTER) && | 989 | if ((ip_vs_sync_state & IP_VS_STATE_MASTER) && |
986 | (cp->protocol != IPPROTO_TCP || | 990 | (((cp->protocol != IPPROTO_TCP || |
987 | cp->state == IP_VS_TCP_S_ESTABLISHED) && | 991 | cp->state == IP_VS_TCP_S_ESTABLISHED) && |
988 | (atomic_read(&cp->in_pkts) % sysctl_ip_vs_sync_threshold[1] | 992 | (atomic_read(&cp->in_pkts) % sysctl_ip_vs_sync_threshold[1] |
989 | == sysctl_ip_vs_sync_threshold[0])) | 993 | == sysctl_ip_vs_sync_threshold[0])) || |
994 | ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) && | ||
995 | ((cp->state == IP_VS_TCP_S_FIN_WAIT) || | ||
996 | (cp->state == IP_VS_TCP_S_CLOSE))))) | ||
990 | ip_vs_sync_conn(cp); | 997 | ip_vs_sync_conn(cp); |
998 | cp->old_state = cp->state; | ||
991 | 999 | ||
992 | ip_vs_conn_put(cp); | 1000 | ip_vs_conn_put(cp); |
993 | return ret; | 1001 | return ret; |
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index 7345fc252a23..693d92490c11 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c | |||
@@ -579,6 +579,31 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport) | |||
579 | return NULL; | 579 | return NULL; |
580 | } | 580 | } |
581 | 581 | ||
582 | /* | ||
583 | * Find destination by {daddr,dport,vaddr,protocol} | ||
584 | * Cretaed to be used in ip_vs_process_message() in | ||
585 | * the backup synchronization daemon. It finds the | ||
586 | * destination to be bound to the received connection | ||
587 | * on the backup. | ||
588 | * | ||
589 | * ip_vs_lookup_real_service() looked promissing, but | ||
590 | * seems not working as expected. | ||
591 | */ | ||
592 | struct ip_vs_dest *ip_vs_find_dest(__be32 daddr, __be16 dport, | ||
593 | __be32 vaddr, __be16 vport, __u16 protocol) | ||
594 | { | ||
595 | struct ip_vs_dest *dest; | ||
596 | struct ip_vs_service *svc; | ||
597 | |||
598 | svc = ip_vs_service_get(0, protocol, vaddr, vport); | ||
599 | if (!svc) | ||
600 | return NULL; | ||
601 | dest = ip_vs_lookup_dest(svc, daddr, dport); | ||
602 | if (dest) | ||
603 | atomic_inc(&dest->refcnt); | ||
604 | ip_vs_service_put(svc); | ||
605 | return dest; | ||
606 | } | ||
582 | 607 | ||
583 | /* | 608 | /* |
584 | * Lookup dest by {svc,addr,port} in the destination trash. | 609 | * Lookup dest by {svc,addr,port} in the destination trash. |
@@ -1399,7 +1424,6 @@ proc_do_sync_threshold(ctl_table *table, int write, struct file *filp, | |||
1399 | 1424 | ||
1400 | static struct ctl_table vs_vars[] = { | 1425 | static struct ctl_table vs_vars[] = { |
1401 | { | 1426 | { |
1402 | .ctl_name = NET_IPV4_VS_AMEMTHRESH, | ||
1403 | .procname = "amemthresh", | 1427 | .procname = "amemthresh", |
1404 | .data = &sysctl_ip_vs_amemthresh, | 1428 | .data = &sysctl_ip_vs_amemthresh, |
1405 | .maxlen = sizeof(int), | 1429 | .maxlen = sizeof(int), |
@@ -1408,7 +1432,6 @@ static struct ctl_table vs_vars[] = { | |||
1408 | }, | 1432 | }, |
1409 | #ifdef CONFIG_IP_VS_DEBUG | 1433 | #ifdef CONFIG_IP_VS_DEBUG |
1410 | { | 1434 | { |
1411 | .ctl_name = NET_IPV4_VS_DEBUG_LEVEL, | ||
1412 | .procname = "debug_level", | 1435 | .procname = "debug_level", |
1413 | .data = &sysctl_ip_vs_debug_level, | 1436 | .data = &sysctl_ip_vs_debug_level, |
1414 | .maxlen = sizeof(int), | 1437 | .maxlen = sizeof(int), |
@@ -1417,7 +1440,6 @@ static struct ctl_table vs_vars[] = { | |||
1417 | }, | 1440 | }, |
1418 | #endif | 1441 | #endif |
1419 | { | 1442 | { |
1420 | .ctl_name = NET_IPV4_VS_AMDROPRATE, | ||
1421 | .procname = "am_droprate", | 1443 | .procname = "am_droprate", |
1422 | .data = &sysctl_ip_vs_am_droprate, | 1444 | .data = &sysctl_ip_vs_am_droprate, |
1423 | .maxlen = sizeof(int), | 1445 | .maxlen = sizeof(int), |
@@ -1425,7 +1447,6 @@ static struct ctl_table vs_vars[] = { | |||
1425 | .proc_handler = &proc_dointvec, | 1447 | .proc_handler = &proc_dointvec, |
1426 | }, | 1448 | }, |
1427 | { | 1449 | { |
1428 | .ctl_name = NET_IPV4_VS_DROP_ENTRY, | ||
1429 | .procname = "drop_entry", | 1450 | .procname = "drop_entry", |
1430 | .data = &sysctl_ip_vs_drop_entry, | 1451 | .data = &sysctl_ip_vs_drop_entry, |
1431 | .maxlen = sizeof(int), | 1452 | .maxlen = sizeof(int), |
@@ -1433,7 +1454,6 @@ static struct ctl_table vs_vars[] = { | |||
1433 | .proc_handler = &proc_do_defense_mode, | 1454 | .proc_handler = &proc_do_defense_mode, |
1434 | }, | 1455 | }, |
1435 | { | 1456 | { |
1436 | .ctl_name = NET_IPV4_VS_DROP_PACKET, | ||
1437 | .procname = "drop_packet", | 1457 | .procname = "drop_packet", |
1438 | .data = &sysctl_ip_vs_drop_packet, | 1458 | .data = &sysctl_ip_vs_drop_packet, |
1439 | .maxlen = sizeof(int), | 1459 | .maxlen = sizeof(int), |
@@ -1441,7 +1461,6 @@ static struct ctl_table vs_vars[] = { | |||
1441 | .proc_handler = &proc_do_defense_mode, | 1461 | .proc_handler = &proc_do_defense_mode, |
1442 | }, | 1462 | }, |
1443 | { | 1463 | { |
1444 | .ctl_name = NET_IPV4_VS_SECURE_TCP, | ||
1445 | .procname = "secure_tcp", | 1464 | .procname = "secure_tcp", |
1446 | .data = &sysctl_ip_vs_secure_tcp, | 1465 | .data = &sysctl_ip_vs_secure_tcp, |
1447 | .maxlen = sizeof(int), | 1466 | .maxlen = sizeof(int), |
@@ -1450,7 +1469,6 @@ static struct ctl_table vs_vars[] = { | |||
1450 | }, | 1469 | }, |
1451 | #if 0 | 1470 | #if 0 |
1452 | { | 1471 | { |
1453 | .ctl_name = NET_IPV4_VS_TO_ES, | ||
1454 | .procname = "timeout_established", | 1472 | .procname = "timeout_established", |
1455 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED], | 1473 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED], |
1456 | .maxlen = sizeof(int), | 1474 | .maxlen = sizeof(int), |
@@ -1458,7 +1476,6 @@ static struct ctl_table vs_vars[] = { | |||
1458 | .proc_handler = &proc_dointvec_jiffies, | 1476 | .proc_handler = &proc_dointvec_jiffies, |
1459 | }, | 1477 | }, |
1460 | { | 1478 | { |
1461 | .ctl_name = NET_IPV4_VS_TO_SS, | ||
1462 | .procname = "timeout_synsent", | 1479 | .procname = "timeout_synsent", |
1463 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT], | 1480 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT], |
1464 | .maxlen = sizeof(int), | 1481 | .maxlen = sizeof(int), |
@@ -1466,7 +1483,6 @@ static struct ctl_table vs_vars[] = { | |||
1466 | .proc_handler = &proc_dointvec_jiffies, | 1483 | .proc_handler = &proc_dointvec_jiffies, |
1467 | }, | 1484 | }, |
1468 | { | 1485 | { |
1469 | .ctl_name = NET_IPV4_VS_TO_SR, | ||
1470 | .procname = "timeout_synrecv", | 1486 | .procname = "timeout_synrecv", |
1471 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV], | 1487 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV], |
1472 | .maxlen = sizeof(int), | 1488 | .maxlen = sizeof(int), |
@@ -1474,7 +1490,6 @@ static struct ctl_table vs_vars[] = { | |||
1474 | .proc_handler = &proc_dointvec_jiffies, | 1490 | .proc_handler = &proc_dointvec_jiffies, |
1475 | }, | 1491 | }, |
1476 | { | 1492 | { |
1477 | .ctl_name = NET_IPV4_VS_TO_FW, | ||
1478 | .procname = "timeout_finwait", | 1493 | .procname = "timeout_finwait", |
1479 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT], | 1494 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT], |
1480 | .maxlen = sizeof(int), | 1495 | .maxlen = sizeof(int), |
@@ -1482,7 +1497,6 @@ static struct ctl_table vs_vars[] = { | |||
1482 | .proc_handler = &proc_dointvec_jiffies, | 1497 | .proc_handler = &proc_dointvec_jiffies, |
1483 | }, | 1498 | }, |
1484 | { | 1499 | { |
1485 | .ctl_name = NET_IPV4_VS_TO_TW, | ||
1486 | .procname = "timeout_timewait", | 1500 | .procname = "timeout_timewait", |
1487 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT], | 1501 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT], |
1488 | .maxlen = sizeof(int), | 1502 | .maxlen = sizeof(int), |
@@ -1490,7 +1504,6 @@ static struct ctl_table vs_vars[] = { | |||
1490 | .proc_handler = &proc_dointvec_jiffies, | 1504 | .proc_handler = &proc_dointvec_jiffies, |
1491 | }, | 1505 | }, |
1492 | { | 1506 | { |
1493 | .ctl_name = NET_IPV4_VS_TO_CL, | ||
1494 | .procname = "timeout_close", | 1507 | .procname = "timeout_close", |
1495 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE], | 1508 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE], |
1496 | .maxlen = sizeof(int), | 1509 | .maxlen = sizeof(int), |
@@ -1498,7 +1511,6 @@ static struct ctl_table vs_vars[] = { | |||
1498 | .proc_handler = &proc_dointvec_jiffies, | 1511 | .proc_handler = &proc_dointvec_jiffies, |
1499 | }, | 1512 | }, |
1500 | { | 1513 | { |
1501 | .ctl_name = NET_IPV4_VS_TO_CW, | ||
1502 | .procname = "timeout_closewait", | 1514 | .procname = "timeout_closewait", |
1503 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT], | 1515 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT], |
1504 | .maxlen = sizeof(int), | 1516 | .maxlen = sizeof(int), |
@@ -1506,7 +1518,6 @@ static struct ctl_table vs_vars[] = { | |||
1506 | .proc_handler = &proc_dointvec_jiffies, | 1518 | .proc_handler = &proc_dointvec_jiffies, |
1507 | }, | 1519 | }, |
1508 | { | 1520 | { |
1509 | .ctl_name = NET_IPV4_VS_TO_LA, | ||
1510 | .procname = "timeout_lastack", | 1521 | .procname = "timeout_lastack", |
1511 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK], | 1522 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK], |
1512 | .maxlen = sizeof(int), | 1523 | .maxlen = sizeof(int), |
@@ -1514,7 +1525,6 @@ static struct ctl_table vs_vars[] = { | |||
1514 | .proc_handler = &proc_dointvec_jiffies, | 1525 | .proc_handler = &proc_dointvec_jiffies, |
1515 | }, | 1526 | }, |
1516 | { | 1527 | { |
1517 | .ctl_name = NET_IPV4_VS_TO_LI, | ||
1518 | .procname = "timeout_listen", | 1528 | .procname = "timeout_listen", |
1519 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN], | 1529 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN], |
1520 | .maxlen = sizeof(int), | 1530 | .maxlen = sizeof(int), |
@@ -1522,7 +1532,6 @@ static struct ctl_table vs_vars[] = { | |||
1522 | .proc_handler = &proc_dointvec_jiffies, | 1532 | .proc_handler = &proc_dointvec_jiffies, |
1523 | }, | 1533 | }, |
1524 | { | 1534 | { |
1525 | .ctl_name = NET_IPV4_VS_TO_SA, | ||
1526 | .procname = "timeout_synack", | 1535 | .procname = "timeout_synack", |
1527 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK], | 1536 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK], |
1528 | .maxlen = sizeof(int), | 1537 | .maxlen = sizeof(int), |
@@ -1530,7 +1539,6 @@ static struct ctl_table vs_vars[] = { | |||
1530 | .proc_handler = &proc_dointvec_jiffies, | 1539 | .proc_handler = &proc_dointvec_jiffies, |
1531 | }, | 1540 | }, |
1532 | { | 1541 | { |
1533 | .ctl_name = NET_IPV4_VS_TO_UDP, | ||
1534 | .procname = "timeout_udp", | 1542 | .procname = "timeout_udp", |
1535 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP], | 1543 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP], |
1536 | .maxlen = sizeof(int), | 1544 | .maxlen = sizeof(int), |
@@ -1538,7 +1546,6 @@ static struct ctl_table vs_vars[] = { | |||
1538 | .proc_handler = &proc_dointvec_jiffies, | 1546 | .proc_handler = &proc_dointvec_jiffies, |
1539 | }, | 1547 | }, |
1540 | { | 1548 | { |
1541 | .ctl_name = NET_IPV4_VS_TO_ICMP, | ||
1542 | .procname = "timeout_icmp", | 1549 | .procname = "timeout_icmp", |
1543 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP], | 1550 | .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP], |
1544 | .maxlen = sizeof(int), | 1551 | .maxlen = sizeof(int), |
@@ -1547,7 +1554,6 @@ static struct ctl_table vs_vars[] = { | |||
1547 | }, | 1554 | }, |
1548 | #endif | 1555 | #endif |
1549 | { | 1556 | { |
1550 | .ctl_name = NET_IPV4_VS_CACHE_BYPASS, | ||
1551 | .procname = "cache_bypass", | 1557 | .procname = "cache_bypass", |
1552 | .data = &sysctl_ip_vs_cache_bypass, | 1558 | .data = &sysctl_ip_vs_cache_bypass, |
1553 | .maxlen = sizeof(int), | 1559 | .maxlen = sizeof(int), |
@@ -1555,7 +1561,6 @@ static struct ctl_table vs_vars[] = { | |||
1555 | .proc_handler = &proc_dointvec, | 1561 | .proc_handler = &proc_dointvec, |
1556 | }, | 1562 | }, |
1557 | { | 1563 | { |
1558 | .ctl_name = NET_IPV4_VS_EXPIRE_NODEST_CONN, | ||
1559 | .procname = "expire_nodest_conn", | 1564 | .procname = "expire_nodest_conn", |
1560 | .data = &sysctl_ip_vs_expire_nodest_conn, | 1565 | .data = &sysctl_ip_vs_expire_nodest_conn, |
1561 | .maxlen = sizeof(int), | 1566 | .maxlen = sizeof(int), |
@@ -1563,7 +1568,6 @@ static struct ctl_table vs_vars[] = { | |||
1563 | .proc_handler = &proc_dointvec, | 1568 | .proc_handler = &proc_dointvec, |
1564 | }, | 1569 | }, |
1565 | { | 1570 | { |
1566 | .ctl_name = NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE, | ||
1567 | .procname = "expire_quiescent_template", | 1571 | .procname = "expire_quiescent_template", |
1568 | .data = &sysctl_ip_vs_expire_quiescent_template, | 1572 | .data = &sysctl_ip_vs_expire_quiescent_template, |
1569 | .maxlen = sizeof(int), | 1573 | .maxlen = sizeof(int), |
@@ -1571,7 +1575,6 @@ static struct ctl_table vs_vars[] = { | |||
1571 | .proc_handler = &proc_dointvec, | 1575 | .proc_handler = &proc_dointvec, |
1572 | }, | 1576 | }, |
1573 | { | 1577 | { |
1574 | .ctl_name = NET_IPV4_VS_SYNC_THRESHOLD, | ||
1575 | .procname = "sync_threshold", | 1578 | .procname = "sync_threshold", |
1576 | .data = &sysctl_ip_vs_sync_threshold, | 1579 | .data = &sysctl_ip_vs_sync_threshold, |
1577 | .maxlen = sizeof(sysctl_ip_vs_sync_threshold), | 1580 | .maxlen = sizeof(sysctl_ip_vs_sync_threshold), |
@@ -1579,7 +1582,6 @@ static struct ctl_table vs_vars[] = { | |||
1579 | .proc_handler = &proc_do_sync_threshold, | 1582 | .proc_handler = &proc_do_sync_threshold, |
1580 | }, | 1583 | }, |
1581 | { | 1584 | { |
1582 | .ctl_name = NET_IPV4_VS_NAT_ICMP_SEND, | ||
1583 | .procname = "nat_icmp_send", | 1585 | .procname = "nat_icmp_send", |
1584 | .data = &sysctl_ip_vs_nat_icmp_send, | 1586 | .data = &sysctl_ip_vs_nat_icmp_send, |
1585 | .maxlen = sizeof(int), | 1587 | .maxlen = sizeof(int), |
@@ -1591,7 +1593,6 @@ static struct ctl_table vs_vars[] = { | |||
1591 | 1593 | ||
1592 | static ctl_table vs_table[] = { | 1594 | static ctl_table vs_table[] = { |
1593 | { | 1595 | { |
1594 | .ctl_name = NET_IPV4_VS, | ||
1595 | .procname = "vs", | 1596 | .procname = "vs", |
1596 | .mode = 0555, | 1597 | .mode = 0555, |
1597 | .child = vs_vars | 1598 | .child = vs_vars |
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c index 052f4ed59174..b843a11d7cf7 100644 --- a/net/ipv4/ipvs/ip_vs_lblc.c +++ b/net/ipv4/ipvs/ip_vs_lblc.c | |||
@@ -114,7 +114,6 @@ struct ip_vs_lblc_table { | |||
114 | 114 | ||
115 | static ctl_table vs_vars_table[] = { | 115 | static ctl_table vs_vars_table[] = { |
116 | { | 116 | { |
117 | .ctl_name = NET_IPV4_VS_LBLC_EXPIRE, | ||
118 | .procname = "lblc_expiration", | 117 | .procname = "lblc_expiration", |
119 | .data = &sysctl_ip_vs_lblc_expiration, | 118 | .data = &sysctl_ip_vs_lblc_expiration, |
120 | .maxlen = sizeof(int), | 119 | .maxlen = sizeof(int), |
@@ -126,7 +125,6 @@ static ctl_table vs_vars_table[] = { | |||
126 | 125 | ||
127 | static ctl_table vs_table[] = { | 126 | static ctl_table vs_table[] = { |
128 | { | 127 | { |
129 | .ctl_name = NET_IPV4_VS, | ||
130 | .procname = "vs", | 128 | .procname = "vs", |
131 | .mode = 0555, | 129 | .mode = 0555, |
132 | .child = vs_vars_table | 130 | .child = vs_vars_table |
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c index 6a1fec416eaf..e5b323a6b2f7 100644 --- a/net/ipv4/ipvs/ip_vs_lblcr.c +++ b/net/ipv4/ipvs/ip_vs_lblcr.c | |||
@@ -48,8 +48,6 @@ | |||
48 | /* for sysctl */ | 48 | /* for sysctl */ |
49 | #include <linux/fs.h> | 49 | #include <linux/fs.h> |
50 | #include <linux/sysctl.h> | 50 | #include <linux/sysctl.h> |
51 | /* for proc_net_create/proc_net_remove */ | ||
52 | #include <linux/proc_fs.h> | ||
53 | #include <net/net_namespace.h> | 51 | #include <net/net_namespace.h> |
54 | 52 | ||
55 | #include <net/ip_vs.h> | 53 | #include <net/ip_vs.h> |
@@ -304,7 +302,6 @@ struct ip_vs_lblcr_table { | |||
304 | 302 | ||
305 | static ctl_table vs_vars_table[] = { | 303 | static ctl_table vs_vars_table[] = { |
306 | { | 304 | { |
307 | .ctl_name = NET_IPV4_VS_LBLCR_EXPIRE, | ||
308 | .procname = "lblcr_expiration", | 305 | .procname = "lblcr_expiration", |
309 | .data = &sysctl_ip_vs_lblcr_expiration, | 306 | .data = &sysctl_ip_vs_lblcr_expiration, |
310 | .maxlen = sizeof(int), | 307 | .maxlen = sizeof(int), |
@@ -316,7 +313,6 @@ static ctl_table vs_vars_table[] = { | |||
316 | 313 | ||
317 | static ctl_table vs_table[] = { | 314 | static ctl_table vs_table[] = { |
318 | { | 315 | { |
319 | .ctl_name = NET_IPV4_VS, | ||
320 | .procname = "vs", | 316 | .procname = "vs", |
321 | .mode = 0555, | 317 | .mode = 0555, |
322 | .child = vs_vars_table | 318 | .child = vs_vars_table |
@@ -547,71 +543,6 @@ static void ip_vs_lblcr_check_expire(unsigned long data) | |||
547 | mod_timer(&tbl->periodic_timer, jiffies+CHECK_EXPIRE_INTERVAL); | 543 | mod_timer(&tbl->periodic_timer, jiffies+CHECK_EXPIRE_INTERVAL); |
548 | } | 544 | } |
549 | 545 | ||
550 | |||
551 | #ifdef CONFIG_IP_VS_LBLCR_DEBUG | ||
552 | static struct ip_vs_lblcr_table *lblcr_table_list; | ||
553 | |||
554 | /* | ||
555 | * /proc/net/ip_vs_lblcr to display the mappings of | ||
556 | * destination IP address <==> its serverSet | ||
557 | */ | ||
558 | static int | ||
559 | ip_vs_lblcr_getinfo(char *buffer, char **start, off_t offset, int length) | ||
560 | { | ||
561 | off_t pos=0, begin; | ||
562 | int len=0, size; | ||
563 | struct ip_vs_lblcr_table *tbl; | ||
564 | unsigned long now = jiffies; | ||
565 | int i; | ||
566 | struct ip_vs_lblcr_entry *en; | ||
567 | |||
568 | tbl = lblcr_table_list; | ||
569 | |||
570 | size = sprintf(buffer, "LastTime Dest IP address Server set\n"); | ||
571 | pos += size; | ||
572 | len += size; | ||
573 | |||
574 | for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) { | ||
575 | read_lock_bh(&tbl->lock); | ||
576 | list_for_each_entry(en, &tbl->bucket[i], list) { | ||
577 | char tbuf[16]; | ||
578 | struct ip_vs_dest_list *d; | ||
579 | |||
580 | sprintf(tbuf, "%u.%u.%u.%u", NIPQUAD(en->addr)); | ||
581 | size = sprintf(buffer+len, "%8lu %-16s ", | ||
582 | now-en->lastuse, tbuf); | ||
583 | |||
584 | read_lock(&en->set.lock); | ||
585 | for (d=en->set.list; d!=NULL; d=d->next) { | ||
586 | size += sprintf(buffer+len+size, | ||
587 | "%u.%u.%u.%u ", | ||
588 | NIPQUAD(d->dest->addr)); | ||
589 | } | ||
590 | read_unlock(&en->set.lock); | ||
591 | size += sprintf(buffer+len+size, "\n"); | ||
592 | len += size; | ||
593 | pos += size; | ||
594 | if (pos <= offset) | ||
595 | len=0; | ||
596 | if (pos >= offset+length) { | ||
597 | read_unlock_bh(&tbl->lock); | ||
598 | goto done; | ||
599 | } | ||
600 | } | ||
601 | read_unlock_bh(&tbl->lock); | ||
602 | } | ||
603 | |||
604 | done: | ||
605 | begin = len - (pos - offset); | ||
606 | *start = buffer + begin; | ||
607 | len -= begin; | ||
608 | if(len>length) | ||
609 | len = length; | ||
610 | return len; | ||
611 | } | ||
612 | #endif | ||
613 | |||
614 | |||
615 | static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc) | 546 | static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc) |
616 | { | 547 | { |
617 | int i; | 548 | int i; |
@@ -650,9 +581,6 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc) | |||
650 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; | 581 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; |
651 | add_timer(&tbl->periodic_timer); | 582 | add_timer(&tbl->periodic_timer); |
652 | 583 | ||
653 | #ifdef CONFIG_IP_VS_LBLCR_DEBUG | ||
654 | lblcr_table_list = tbl; | ||
655 | #endif | ||
656 | return 0; | 584 | return 0; |
657 | } | 585 | } |
658 | 586 | ||
@@ -843,18 +771,12 @@ static int __init ip_vs_lblcr_init(void) | |||
843 | { | 771 | { |
844 | INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); | 772 | INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); |
845 | sysctl_header = register_sysctl_table(lblcr_root_table); | 773 | sysctl_header = register_sysctl_table(lblcr_root_table); |
846 | #ifdef CONFIG_IP_VS_LBLCR_DEBUG | ||
847 | proc_net_create(&init_net, "ip_vs_lblcr", 0, ip_vs_lblcr_getinfo); | ||
848 | #endif | ||
849 | return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); | 774 | return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); |
850 | } | 775 | } |
851 | 776 | ||
852 | 777 | ||
853 | static void __exit ip_vs_lblcr_cleanup(void) | 778 | static void __exit ip_vs_lblcr_cleanup(void) |
854 | { | 779 | { |
855 | #ifdef CONFIG_IP_VS_LBLCR_DEBUG | ||
856 | proc_net_remove(&init_net, "ip_vs_lblcr"); | ||
857 | #endif | ||
858 | unregister_sysctl_table(sysctl_header); | 780 | unregister_sysctl_table(sysctl_header); |
859 | unregister_ip_vs_scheduler(&ip_vs_lblcr_scheduler); | 781 | unregister_ip_vs_scheduler(&ip_vs_lblcr_scheduler); |
860 | } | 782 | } |
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c index e844ddb82b9a..c0e11ec8f0f9 100644 --- a/net/ipv4/ipvs/ip_vs_proto.c +++ b/net/ipv4/ipvs/ip_vs_proto.c | |||
@@ -45,7 +45,7 @@ static struct ip_vs_protocol *ip_vs_proto_table[IP_VS_PROTO_TAB_SIZE]; | |||
45 | /* | 45 | /* |
46 | * register an ipvs protocol | 46 | * register an ipvs protocol |
47 | */ | 47 | */ |
48 | static int register_ip_vs_protocol(struct ip_vs_protocol *pp) | 48 | static int __used register_ip_vs_protocol(struct ip_vs_protocol *pp) |
49 | { | 49 | { |
50 | unsigned hash = IP_VS_PROTO_HASH(pp->protocol); | 50 | unsigned hash = IP_VS_PROTO_HASH(pp->protocol); |
51 | 51 | ||
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c index c99f2a33fb9e..bd930efc18da 100644 --- a/net/ipv4/ipvs/ip_vs_sync.c +++ b/net/ipv4/ipvs/ip_vs_sync.c | |||
@@ -72,7 +72,6 @@ struct ip_vs_sync_thread_data { | |||
72 | int state; | 72 | int state; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | #define IP_VS_SYNC_CONN_TIMEOUT (3*60*HZ) | ||
76 | #define SIMPLE_CONN_SIZE (sizeof(struct ip_vs_sync_conn)) | 75 | #define SIMPLE_CONN_SIZE (sizeof(struct ip_vs_sync_conn)) |
77 | #define FULL_CONN_SIZE \ | 76 | #define FULL_CONN_SIZE \ |
78 | (sizeof(struct ip_vs_sync_conn) + sizeof(struct ip_vs_sync_conn_options)) | 77 | (sizeof(struct ip_vs_sync_conn) + sizeof(struct ip_vs_sync_conn_options)) |
@@ -284,6 +283,8 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) | |||
284 | struct ip_vs_sync_conn *s; | 283 | struct ip_vs_sync_conn *s; |
285 | struct ip_vs_sync_conn_options *opt; | 284 | struct ip_vs_sync_conn_options *opt; |
286 | struct ip_vs_conn *cp; | 285 | struct ip_vs_conn *cp; |
286 | struct ip_vs_protocol *pp; | ||
287 | struct ip_vs_dest *dest; | ||
287 | char *p; | 288 | char *p; |
288 | int i; | 289 | int i; |
289 | 290 | ||
@@ -317,20 +318,34 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) | |||
317 | s->caddr, s->cport, | 318 | s->caddr, s->cport, |
318 | s->vaddr, s->vport); | 319 | s->vaddr, s->vport); |
319 | if (!cp) { | 320 | if (!cp) { |
321 | /* | ||
322 | * Find the appropriate destination for the connection. | ||
323 | * If it is not found the connection will remain unbound | ||
324 | * but still handled. | ||
325 | */ | ||
326 | dest = ip_vs_find_dest(s->daddr, s->dport, | ||
327 | s->vaddr, s->vport, | ||
328 | s->protocol); | ||
320 | cp = ip_vs_conn_new(s->protocol, | 329 | cp = ip_vs_conn_new(s->protocol, |
321 | s->caddr, s->cport, | 330 | s->caddr, s->cport, |
322 | s->vaddr, s->vport, | 331 | s->vaddr, s->vport, |
323 | s->daddr, s->dport, | 332 | s->daddr, s->dport, |
324 | flags, NULL); | 333 | flags, dest); |
334 | if (dest) | ||
335 | atomic_dec(&dest->refcnt); | ||
325 | if (!cp) { | 336 | if (!cp) { |
326 | IP_VS_ERR("ip_vs_conn_new failed\n"); | 337 | IP_VS_ERR("ip_vs_conn_new failed\n"); |
327 | return; | 338 | return; |
328 | } | 339 | } |
329 | cp->state = ntohs(s->state); | 340 | cp->state = ntohs(s->state); |
330 | } else if (!cp->dest) { | 341 | } else if (!cp->dest) { |
331 | /* it is an entry created by the synchronization */ | 342 | dest = ip_vs_try_bind_dest(cp); |
332 | cp->state = ntohs(s->state); | 343 | if (!dest) { |
333 | cp->flags = flags | IP_VS_CONN_F_HASHED; | 344 | /* it is an unbound entry created by |
345 | * synchronization */ | ||
346 | cp->flags = flags | IP_VS_CONN_F_HASHED; | ||
347 | } else | ||
348 | atomic_dec(&dest->refcnt); | ||
334 | } /* Note that we don't touch its state and flags | 349 | } /* Note that we don't touch its state and flags |
335 | if it is a normal entry. */ | 350 | if it is a normal entry. */ |
336 | 351 | ||
@@ -342,7 +357,9 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) | |||
342 | p += SIMPLE_CONN_SIZE; | 357 | p += SIMPLE_CONN_SIZE; |
343 | 358 | ||
344 | atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]); | 359 | atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]); |
345 | cp->timeout = IP_VS_SYNC_CONN_TIMEOUT; | 360 | cp->state = ntohs(s->state); |
361 | pp = ip_vs_proto_get(s->protocol); | ||
362 | cp->timeout = pp->timeout_table[cp->state]; | ||
346 | ip_vs_conn_put(cp); | 363 | ip_vs_conn_put(cp); |
347 | 364 | ||
348 | if (p > buffer+buflen) { | 365 | if (p > buffer+buflen) { |
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index fa97947c6ae1..9aca9c55687c 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
@@ -128,7 +128,7 @@ config IP_NF_MATCH_ADDRTYPE | |||
128 | eg. UNICAST, LOCAL, BROADCAST, ... | 128 | eg. UNICAST, LOCAL, BROADCAST, ... |
129 | 129 | ||
130 | If you want to compile it as a module, say M here and read | 130 | If you want to compile it as a module, say M here and read |
131 | <file:Documentation/modules.txt>. If unsure, say `N'. | 131 | <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. |
132 | 132 | ||
133 | # `filter', generic and specific targets | 133 | # `filter', generic and specific targets |
134 | config IP_NF_FILTER | 134 | config IP_NF_FILTER |
@@ -371,7 +371,7 @@ config IP_NF_RAW | |||
371 | and OUTPUT chains. | 371 | and OUTPUT chains. |
372 | 372 | ||
373 | If you want to compile it as a module, say M here and read | 373 | If you want to compile it as a module, say M here and read |
374 | <file:Documentation/modules.txt>. If unsure, say `N'. | 374 | <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. |
375 | 375 | ||
376 | # ARP tables | 376 | # ARP tables |
377 | config IP_NF_ARPTABLES | 377 | config IP_NF_ARPTABLES |
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile index 409d273f6f82..7456833d6ade 100644 --- a/net/ipv4/netfilter/Makefile +++ b/net/ipv4/netfilter/Makefile | |||
@@ -41,27 +41,27 @@ obj-$(CONFIG_NF_NAT) += iptable_nat.o | |||
41 | obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o | 41 | obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o |
42 | 42 | ||
43 | # matches | 43 | # matches |
44 | obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o | ||
45 | obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o | ||
46 | obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o | ||
44 | obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o | 47 | obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o |
45 | obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o | 48 | obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o |
46 | obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o | ||
47 | obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o | 49 | obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o |
48 | obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o | 50 | obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o |
49 | obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o | ||
50 | obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o | 51 | obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o |
51 | obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o | ||
52 | 52 | ||
53 | # targets | 53 | # targets |
54 | obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o | 54 | obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o |
55 | obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o | ||
56 | obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o | 55 | obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o |
56 | obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o | ||
57 | obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o | 57 | obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o |
58 | obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o | ||
59 | obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o | 58 | obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o |
59 | obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o | ||
60 | obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o | ||
60 | obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o | 61 | obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o |
61 | obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o | 62 | obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o |
62 | obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o | ||
63 | obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o | ||
64 | obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o | 63 | obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o |
64 | obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o | ||
65 | 65 | ||
66 | # generic ARP tables | 66 | # generic ARP tables |
67 | obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o | 67 | obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o |
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index 10a2ce09fd8e..14d64a383db1 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
23 | #include <linux/sysctl.h> | 23 | #include <linux/sysctl.h> |
24 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
25 | #include <linux/seq_file.h> | ||
25 | #include <linux/security.h> | 26 | #include <linux/security.h> |
26 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
27 | #include <net/net_namespace.h> | 28 | #include <net/net_namespace.h> |
@@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = { | |||
607 | { .ctl_name = 0 } | 608 | { .ctl_name = 0 } |
608 | }; | 609 | }; |
609 | 610 | ||
610 | #ifdef CONFIG_PROC_FS | 611 | static int ip_queue_show(struct seq_file *m, void *v) |
611 | static int | ||
612 | ipq_get_info(char *buffer, char **start, off_t offset, int length) | ||
613 | { | 612 | { |
614 | int len; | ||
615 | |||
616 | read_lock_bh(&queue_lock); | 613 | read_lock_bh(&queue_lock); |
617 | 614 | ||
618 | len = sprintf(buffer, | 615 | seq_printf(m, |
619 | "Peer PID : %d\n" | 616 | "Peer PID : %d\n" |
620 | "Copy mode : %hu\n" | 617 | "Copy mode : %hu\n" |
621 | "Copy range : %u\n" | 618 | "Copy range : %u\n" |
@@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length) | |||
632 | queue_user_dropped); | 629 | queue_user_dropped); |
633 | 630 | ||
634 | read_unlock_bh(&queue_lock); | 631 | read_unlock_bh(&queue_lock); |
632 | return 0; | ||
633 | } | ||
635 | 634 | ||
636 | *start = buffer + offset; | 635 | static int ip_queue_open(struct inode *inode, struct file *file) |
637 | len -= offset; | 636 | { |
638 | if (len > length) | 637 | return single_open(file, ip_queue_show, NULL); |
639 | len = length; | ||
640 | else if (len < 0) | ||
641 | len = 0; | ||
642 | return len; | ||
643 | } | 638 | } |
644 | #endif /* CONFIG_PROC_FS */ | 639 | |
640 | static const struct file_operations ip_queue_proc_fops = { | ||
641 | .open = ip_queue_open, | ||
642 | .read = seq_read, | ||
643 | .llseek = seq_lseek, | ||
644 | .release = single_release, | ||
645 | .owner = THIS_MODULE, | ||
646 | }; | ||
645 | 647 | ||
646 | static struct nf_queue_handler nfqh = { | 648 | static struct nf_queue_handler nfqh = { |
647 | .name = "ip_queue", | 649 | .name = "ip_queue", |
@@ -661,10 +663,11 @@ static int __init ip_queue_init(void) | |||
661 | goto cleanup_netlink_notifier; | 663 | goto cleanup_netlink_notifier; |
662 | } | 664 | } |
663 | 665 | ||
664 | proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); | 666 | proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); |
665 | if (proc) | 667 | if (proc) { |
666 | proc->owner = THIS_MODULE; | 668 | proc->owner = THIS_MODULE; |
667 | else { | 669 | proc->proc_fops = &ip_queue_proc_fops; |
670 | } else { | ||
668 | printk(KERN_ERR "ip_queue: failed to create proc entry\n"); | 671 | printk(KERN_ERR "ip_queue: failed to create proc entry\n"); |
669 | goto cleanup_ipqnl; | 672 | goto cleanup_ipqnl; |
670 | } | 673 | } |
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c index 5de6e57ac55c..f8678651250f 100644 --- a/net/ipv4/netfilter/iptable_raw.c +++ b/net/ipv4/netfilter/iptable_raw.c | |||
@@ -66,7 +66,7 @@ ipt_local_hook(unsigned int hook, | |||
66 | if (skb->len < sizeof(struct iphdr) || | 66 | if (skb->len < sizeof(struct iphdr) || |
67 | ip_hdrlen(skb) < sizeof(struct iphdr)) { | 67 | ip_hdrlen(skb) < sizeof(struct iphdr)) { |
68 | if (net_ratelimit()) | 68 | if (net_ratelimit()) |
69 | printk("iptable_raw: ignoring short SOCK_RAW" | 69 | printk("iptable_raw: ignoring short SOCK_RAW " |
70 | "packet.\n"); | 70 | "packet.\n"); |
71 | return NF_ACCEPT; | 71 | return NF_ACCEPT; |
72 | } | 72 | } |
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c index 35a5aa69cd92..c31b87668250 100644 --- a/net/ipv4/netfilter/nf_nat_amanda.c +++ b/net/ipv4/netfilter/nf_nat_amanda.c | |||
@@ -69,7 +69,7 @@ static void __exit nf_nat_amanda_fini(void) | |||
69 | 69 | ||
70 | static int __init nf_nat_amanda_init(void) | 70 | static int __init nf_nat_amanda_init(void) |
71 | { | 71 | { |
72 | BUG_ON(rcu_dereference(nf_nat_amanda_hook)); | 72 | BUG_ON(nf_nat_amanda_hook != NULL); |
73 | rcu_assign_pointer(nf_nat_amanda_hook, help); | 73 | rcu_assign_pointer(nf_nat_amanda_hook, help); |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index 56e93f692e82..86b465b176ba 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -607,13 +607,10 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) | |||
607 | struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); | 607 | struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); |
608 | struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old; | 608 | struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old; |
609 | struct nf_conn *ct = old_nat->ct; | 609 | struct nf_conn *ct = old_nat->ct; |
610 | unsigned int srchash; | ||
611 | 610 | ||
612 | if (!(ct->status & IPS_NAT_DONE_MASK)) | 611 | if (!ct || !(ct->status & IPS_NAT_DONE_MASK)) |
613 | return; | 612 | return; |
614 | 613 | ||
615 | srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | ||
616 | |||
617 | write_lock_bh(&nf_nat_lock); | 614 | write_lock_bh(&nf_nat_lock); |
618 | hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource); | 615 | hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource); |
619 | new_nat->ct = ct; | 616 | new_nat->ct = ct; |
@@ -681,7 +678,7 @@ static int clean_nat(struct nf_conn *i, void *data) | |||
681 | 678 | ||
682 | if (!nat) | 679 | if (!nat) |
683 | return 0; | 680 | return 0; |
684 | memset(nat, 0, sizeof(nat)); | 681 | memset(nat, 0, sizeof(*nat)); |
685 | i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST); | 682 | i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST); |
686 | return 0; | 683 | return 0; |
687 | } | 684 | } |
diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c index e1a16d3ea4cb..a1d5d58a58bf 100644 --- a/net/ipv4/netfilter/nf_nat_ftp.c +++ b/net/ipv4/netfilter/nf_nat_ftp.c | |||
@@ -147,7 +147,7 @@ static void __exit nf_nat_ftp_fini(void) | |||
147 | 147 | ||
148 | static int __init nf_nat_ftp_init(void) | 148 | static int __init nf_nat_ftp_init(void) |
149 | { | 149 | { |
150 | BUG_ON(rcu_dereference(nf_nat_ftp_hook)); | 150 | BUG_ON(nf_nat_ftp_hook != NULL); |
151 | rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp); | 151 | rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c index a868c8c41328..93e18ef114f2 100644 --- a/net/ipv4/netfilter/nf_nat_h323.c +++ b/net/ipv4/netfilter/nf_nat_h323.c | |||
@@ -544,15 +544,15 @@ static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct, | |||
544 | /****************************************************************************/ | 544 | /****************************************************************************/ |
545 | static int __init init(void) | 545 | static int __init init(void) |
546 | { | 546 | { |
547 | BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL); | 547 | BUG_ON(set_h245_addr_hook != NULL); |
548 | BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL); | 548 | BUG_ON(set_h225_addr_hook != NULL); |
549 | BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL); | 549 | BUG_ON(set_sig_addr_hook != NULL); |
550 | BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL); | 550 | BUG_ON(set_ras_addr_hook != NULL); |
551 | BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL); | 551 | BUG_ON(nat_rtp_rtcp_hook != NULL); |
552 | BUG_ON(rcu_dereference(nat_t120_hook) != NULL); | 552 | BUG_ON(nat_t120_hook != NULL); |
553 | BUG_ON(rcu_dereference(nat_h245_hook) != NULL); | 553 | BUG_ON(nat_h245_hook != NULL); |
554 | BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL); | 554 | BUG_ON(nat_callforwarding_hook != NULL); |
555 | BUG_ON(rcu_dereference(nat_q931_hook) != NULL); | 555 | BUG_ON(nat_q931_hook != NULL); |
556 | 556 | ||
557 | rcu_assign_pointer(set_h245_addr_hook, set_h245_addr); | 557 | rcu_assign_pointer(set_h245_addr_hook, set_h245_addr); |
558 | rcu_assign_pointer(set_h225_addr_hook, set_h225_addr); | 558 | rcu_assign_pointer(set_h225_addr_hook, set_h225_addr); |
diff --git a/net/ipv4/netfilter/nf_nat_irc.c b/net/ipv4/netfilter/nf_nat_irc.c index 766e2c16c6b9..fe6f9cef6c85 100644 --- a/net/ipv4/netfilter/nf_nat_irc.c +++ b/net/ipv4/netfilter/nf_nat_irc.c | |||
@@ -74,7 +74,7 @@ static void __exit nf_nat_irc_fini(void) | |||
74 | 74 | ||
75 | static int __init nf_nat_irc_init(void) | 75 | static int __init nf_nat_irc_init(void) |
76 | { | 76 | { |
77 | BUG_ON(rcu_dereference(nf_nat_irc_hook)); | 77 | BUG_ON(nf_nat_irc_hook != NULL); |
78 | rcu_assign_pointer(nf_nat_irc_hook, help); | 78 | rcu_assign_pointer(nf_nat_irc_hook, help); |
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
diff --git a/net/ipv4/netfilter/nf_nat_pptp.c b/net/ipv4/netfilter/nf_nat_pptp.c index e1385a099079..6817e7995f35 100644 --- a/net/ipv4/netfilter/nf_nat_pptp.c +++ b/net/ipv4/netfilter/nf_nat_pptp.c | |||
@@ -281,16 +281,16 @@ static int __init nf_nat_helper_pptp_init(void) | |||
281 | { | 281 | { |
282 | nf_nat_need_gre(); | 282 | nf_nat_need_gre(); |
283 | 283 | ||
284 | BUG_ON(rcu_dereference(nf_nat_pptp_hook_outbound)); | 284 | BUG_ON(nf_nat_pptp_hook_outbound != NULL); |
285 | rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt); | 285 | rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt); |
286 | 286 | ||
287 | BUG_ON(rcu_dereference(nf_nat_pptp_hook_inbound)); | 287 | BUG_ON(nf_nat_pptp_hook_inbound != NULL); |
288 | rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt); | 288 | rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt); |
289 | 289 | ||
290 | BUG_ON(rcu_dereference(nf_nat_pptp_hook_exp_gre)); | 290 | BUG_ON(nf_nat_pptp_hook_exp_gre != NULL); |
291 | rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre); | 291 | rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre); |
292 | 292 | ||
293 | BUG_ON(rcu_dereference(nf_nat_pptp_hook_expectfn)); | 293 | BUG_ON(nf_nat_pptp_hook_expectfn != NULL); |
294 | rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected); | 294 | rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c index ce9edbcc01e3..3ca98971a1e9 100644 --- a/net/ipv4/netfilter/nf_nat_sip.c +++ b/net/ipv4/netfilter/nf_nat_sip.c | |||
@@ -293,8 +293,8 @@ static void __exit nf_nat_sip_fini(void) | |||
293 | 293 | ||
294 | static int __init nf_nat_sip_init(void) | 294 | static int __init nf_nat_sip_init(void) |
295 | { | 295 | { |
296 | BUG_ON(rcu_dereference(nf_nat_sip_hook)); | 296 | BUG_ON(nf_nat_sip_hook != NULL); |
297 | BUG_ON(rcu_dereference(nf_nat_sdp_hook)); | 297 | BUG_ON(nf_nat_sdp_hook != NULL); |
298 | rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip); | 298 | rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip); |
299 | rcu_assign_pointer(nf_nat_sdp_hook, ip_nat_sdp); | 299 | rcu_assign_pointer(nf_nat_sdp_hook, ip_nat_sdp); |
300 | return 0; | 300 | return 0; |
diff --git a/net/ipv4/netfilter/nf_nat_tftp.c b/net/ipv4/netfilter/nf_nat_tftp.c index 0ecec701cb44..1360a94766dd 100644 --- a/net/ipv4/netfilter/nf_nat_tftp.c +++ b/net/ipv4/netfilter/nf_nat_tftp.c | |||
@@ -43,7 +43,7 @@ static void __exit nf_nat_tftp_fini(void) | |||
43 | 43 | ||
44 | static int __init nf_nat_tftp_init(void) | 44 | static int __init nf_nat_tftp_init(void) |
45 | { | 45 | { |
46 | BUG_ON(rcu_dereference(nf_nat_tftp_hook)); | 46 | BUG_ON(nf_nat_tftp_hook != NULL); |
47 | rcu_assign_pointer(nf_nat_tftp_hook, help); | 47 | rcu_assign_pointer(nf_nat_tftp_hook, help); |
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 9be0daa9c0ec..ce34b281803f 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -46,17 +46,6 @@ | |||
46 | #include <net/sock.h> | 46 | #include <net/sock.h> |
47 | #include <net/raw.h> | 47 | #include <net/raw.h> |
48 | 48 | ||
49 | static int fold_prot_inuse(struct proto *proto) | ||
50 | { | ||
51 | int res = 0; | ||
52 | int cpu; | ||
53 | |||
54 | for_each_possible_cpu(cpu) | ||
55 | res += proto->stats[cpu].inuse; | ||
56 | |||
57 | return res; | ||
58 | } | ||
59 | |||
60 | /* | 49 | /* |
61 | * Report socket allocation statistics [mea@utu.fi] | 50 | * Report socket allocation statistics [mea@utu.fi] |
62 | */ | 51 | */ |
@@ -64,12 +53,12 @@ static int sockstat_seq_show(struct seq_file *seq, void *v) | |||
64 | { | 53 | { |
65 | socket_seq_show(seq); | 54 | socket_seq_show(seq); |
66 | seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", | 55 | seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", |
67 | fold_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count), | 56 | sock_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count), |
68 | tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated), | 57 | tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated), |
69 | atomic_read(&tcp_memory_allocated)); | 58 | atomic_read(&tcp_memory_allocated)); |
70 | seq_printf(seq, "UDP: inuse %d\n", fold_prot_inuse(&udp_prot)); | 59 | seq_printf(seq, "UDP: inuse %d\n", sock_prot_inuse(&udp_prot)); |
71 | seq_printf(seq, "UDPLITE: inuse %d\n", fold_prot_inuse(&udplite_prot)); | 60 | seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse(&udplite_prot)); |
72 | seq_printf(seq, "RAW: inuse %d\n", fold_prot_inuse(&raw_prot)); | 61 | seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse(&raw_prot)); |
73 | seq_printf(seq, "FRAG: inuse %d memory %d\n", | 62 | seq_printf(seq, "FRAG: inuse %d memory %d\n", |
74 | ip_frag_nqueues(), ip_frag_mem()); | 63 | ip_frag_nqueues(), ip_frag_mem()); |
75 | return 0; | 64 | return 0; |
@@ -304,7 +293,7 @@ static void icmp_put(struct seq_file *seq) | |||
304 | for (i=0; icmpmibmap[i].name != NULL; i++) | 293 | for (i=0; icmpmibmap[i].name != NULL; i++) |
305 | seq_printf(seq, " %lu", | 294 | seq_printf(seq, " %lu", |
306 | snmp_fold_field((void **) icmpmsg_statistics, | 295 | snmp_fold_field((void **) icmpmsg_statistics, |
307 | icmpmibmap[i].index)); | 296 | icmpmibmap[i].index | 0x100)); |
308 | } | 297 | } |
309 | 298 | ||
310 | /* | 299 | /* |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 3916faca3afe..66b42f547bf9 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -760,6 +760,8 @@ static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
760 | } | 760 | } |
761 | } | 761 | } |
762 | 762 | ||
763 | DEFINE_PROTO_INUSE(raw) | ||
764 | |||
763 | struct proto raw_prot = { | 765 | struct proto raw_prot = { |
764 | .name = "RAW", | 766 | .name = "RAW", |
765 | .owner = THIS_MODULE, | 767 | .owner = THIS_MODULE, |
@@ -781,6 +783,7 @@ struct proto raw_prot = { | |||
781 | .compat_setsockopt = compat_raw_setsockopt, | 783 | .compat_setsockopt = compat_raw_setsockopt, |
782 | .compat_getsockopt = compat_raw_getsockopt, | 784 | .compat_getsockopt = compat_raw_getsockopt, |
783 | #endif | 785 | #endif |
786 | REF_PROTO_INUSE(raw) | ||
784 | }; | 787 | }; |
785 | 788 | ||
786 | #ifdef CONFIG_PROC_FS | 789 | #ifdef CONFIG_PROC_FS |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 21b12de9e653..c426dec6d579 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -578,6 +578,9 @@ static void rt_check_expire(struct work_struct *work) | |||
578 | i = (i + 1) & rt_hash_mask; | 578 | i = (i + 1) & rt_hash_mask; |
579 | rthp = &rt_hash_table[i].chain; | 579 | rthp = &rt_hash_table[i].chain; |
580 | 580 | ||
581 | if (need_resched()) | ||
582 | cond_resched(); | ||
583 | |||
581 | if (*rthp == NULL) | 584 | if (*rthp == NULL) |
582 | continue; | 585 | continue; |
583 | spin_lock_bh(rt_hash_lock_addr(i)); | 586 | spin_lock_bh(rt_hash_lock_addr(i)); |
@@ -851,9 +854,7 @@ restart: | |||
851 | */ | 854 | */ |
852 | rcu_assign_pointer(rt_hash_table[hash].chain, rth); | 855 | rcu_assign_pointer(rt_hash_table[hash].chain, rth); |
853 | 856 | ||
854 | rth->u.dst.__use++; | 857 | dst_use(&rth->u.dst, now); |
855 | dst_hold(&rth->u.dst); | ||
856 | rth->u.dst.lastuse = now; | ||
857 | spin_unlock_bh(rt_hash_lock_addr(hash)); | 858 | spin_unlock_bh(rt_hash_lock_addr(hash)); |
858 | 859 | ||
859 | rt_drop(rt); | 860 | rt_drop(rt); |
@@ -1813,11 +1814,6 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1813 | goto martian_destination; | 1814 | goto martian_destination; |
1814 | 1815 | ||
1815 | err = ip_mkroute_input(skb, &res, &fl, in_dev, daddr, saddr, tos); | 1816 | err = ip_mkroute_input(skb, &res, &fl, in_dev, daddr, saddr, tos); |
1816 | if (err == -ENOBUFS) | ||
1817 | goto e_nobufs; | ||
1818 | if (err == -EINVAL) | ||
1819 | goto e_inval; | ||
1820 | |||
1821 | done: | 1817 | done: |
1822 | in_dev_put(in_dev); | 1818 | in_dev_put(in_dev); |
1823 | if (free_res) | 1819 | if (free_res) |
@@ -1935,9 +1931,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1935 | rth->fl.oif == 0 && | 1931 | rth->fl.oif == 0 && |
1936 | rth->fl.mark == skb->mark && | 1932 | rth->fl.mark == skb->mark && |
1937 | rth->fl.fl4_tos == tos) { | 1933 | rth->fl.fl4_tos == tos) { |
1938 | rth->u.dst.lastuse = jiffies; | 1934 | dst_use(&rth->u.dst, jiffies); |
1939 | dst_hold(&rth->u.dst); | ||
1940 | rth->u.dst.__use++; | ||
1941 | RT_CACHE_STAT_INC(in_hit); | 1935 | RT_CACHE_STAT_INC(in_hit); |
1942 | rcu_read_unlock(); | 1936 | rcu_read_unlock(); |
1943 | skb->dst = (struct dst_entry*)rth; | 1937 | skb->dst = (struct dst_entry*)rth; |
@@ -2331,9 +2325,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp) | |||
2331 | rth->fl.mark == flp->mark && | 2325 | rth->fl.mark == flp->mark && |
2332 | !((rth->fl.fl4_tos ^ flp->fl4_tos) & | 2326 | !((rth->fl.fl4_tos ^ flp->fl4_tos) & |
2333 | (IPTOS_RT_MASK | RTO_ONLINK))) { | 2327 | (IPTOS_RT_MASK | RTO_ONLINK))) { |
2334 | rth->u.dst.lastuse = jiffies; | 2328 | dst_use(&rth->u.dst, jiffies); |
2335 | dst_hold(&rth->u.dst); | ||
2336 | rth->u.dst.__use++; | ||
2337 | RT_CACHE_STAT_INC(out_hit); | 2329 | RT_CACHE_STAT_INC(out_hit); |
2338 | rcu_read_unlock_bh(); | 2330 | rcu_read_unlock_bh(); |
2339 | *rp = rth; | 2331 | *rp = rth; |
@@ -2896,18 +2888,14 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset, | |||
2896 | offset /= sizeof(u32); | 2888 | offset /= sizeof(u32); |
2897 | 2889 | ||
2898 | if (length > 0) { | 2890 | if (length > 0) { |
2899 | u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset; | ||
2900 | u32 *dst = (u32 *) buffer; | 2891 | u32 *dst = (u32 *) buffer; |
2901 | 2892 | ||
2902 | /* Copy first cpu. */ | ||
2903 | *start = buffer; | 2893 | *start = buffer; |
2904 | memcpy(dst, src, length); | 2894 | memset(dst, 0, length); |
2905 | 2895 | ||
2906 | /* Add the other cpus in, one int at a time */ | ||
2907 | for_each_possible_cpu(i) { | 2896 | for_each_possible_cpu(i) { |
2908 | unsigned int j; | 2897 | unsigned int j; |
2909 | 2898 | u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset; | |
2910 | src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset; | ||
2911 | 2899 | ||
2912 | for (j = 0; j < length/4; j++) | 2900 | for (j = 0; j < length/4; j++) |
2913 | dst[j] += src[j]; | 2901 | dst[j] += src[j]; |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index ffddd2b45352..bec6fe880657 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -191,7 +191,7 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name, | |||
191 | 191 | ||
192 | tcp_get_default_congestion_control(val); | 192 | tcp_get_default_congestion_control(val); |
193 | ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); | 193 | ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen); |
194 | if (ret == 0 && newval && newlen) | 194 | if (ret == 1 && newval && newlen) |
195 | ret = tcp_set_default_congestion_control(val); | 195 | ret = tcp_set_default_congestion_control(val); |
196 | return ret; | 196 | return ret; |
197 | } | 197 | } |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 2e6ad6dbba6c..8e65182f7af1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2453,14 +2453,14 @@ void __init tcp_init(void) | |||
2453 | 0, | 2453 | 0, |
2454 | &tcp_hashinfo.ehash_size, | 2454 | &tcp_hashinfo.ehash_size, |
2455 | NULL, | 2455 | NULL, |
2456 | 0); | 2456 | thash_entries ? 0 : 512 * 1024); |
2457 | tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size; | 2457 | tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size; |
2458 | for (i = 0; i < tcp_hashinfo.ehash_size; i++) { | 2458 | for (i = 0; i < tcp_hashinfo.ehash_size; i++) { |
2459 | rwlock_init(&tcp_hashinfo.ehash[i].lock); | ||
2460 | INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain); | 2459 | INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].chain); |
2461 | INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain); | 2460 | INIT_HLIST_HEAD(&tcp_hashinfo.ehash[i].twchain); |
2462 | } | 2461 | } |
2463 | 2462 | if (inet_ehash_locks_alloc(&tcp_hashinfo)) | |
2463 | panic("TCP: failed to alloc ehash_locks"); | ||
2464 | tcp_hashinfo.bhash = | 2464 | tcp_hashinfo.bhash = |
2465 | alloc_large_system_hash("TCP bind", | 2465 | alloc_large_system_hash("TCP bind", |
2466 | sizeof(struct inet_bind_hashbucket), | 2466 | sizeof(struct inet_bind_hashbucket), |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 69d8c38ccd39..0f0c1c9829a1 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1269,6 +1269,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1269 | if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) | 1269 | if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) |
1270 | return 0; | 1270 | return 0; |
1271 | 1271 | ||
1272 | if (!tp->packets_out) | ||
1273 | goto out; | ||
1274 | |||
1272 | /* SACK fastpath: | 1275 | /* SACK fastpath: |
1273 | * if the only SACK change is the increase of the end_seq of | 1276 | * if the only SACK change is the increase of the end_seq of |
1274 | * the first block then only apply that SACK block | 1277 | * the first block then only apply that SACK block |
@@ -1330,12 +1333,15 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1330 | cached_fack_count = 0; | 1333 | cached_fack_count = 0; |
1331 | } | 1334 | } |
1332 | 1335 | ||
1333 | for (i=0; i<num_sacks; i++, sp++) { | 1336 | for (i = 0; i < num_sacks; i++) { |
1334 | struct sk_buff *skb; | 1337 | struct sk_buff *skb; |
1335 | __u32 start_seq = ntohl(sp->start_seq); | 1338 | __u32 start_seq = ntohl(sp->start_seq); |
1336 | __u32 end_seq = ntohl(sp->end_seq); | 1339 | __u32 end_seq = ntohl(sp->end_seq); |
1337 | int fack_count; | 1340 | int fack_count; |
1338 | int dup_sack = (found_dup_sack && (i == first_sack_index)); | 1341 | int dup_sack = (found_dup_sack && (i == first_sack_index)); |
1342 | int next_dup = (found_dup_sack && (i+1 == first_sack_index)); | ||
1343 | |||
1344 | sp++; | ||
1339 | 1345 | ||
1340 | if (!tcp_is_sackblock_valid(tp, dup_sack, start_seq, end_seq)) { | 1346 | if (!tcp_is_sackblock_valid(tp, dup_sack, start_seq, end_seq)) { |
1341 | if (dup_sack) { | 1347 | if (dup_sack) { |
@@ -1361,7 +1367,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1361 | flag |= FLAG_DATA_LOST; | 1367 | flag |= FLAG_DATA_LOST; |
1362 | 1368 | ||
1363 | tcp_for_write_queue_from(skb, sk) { | 1369 | tcp_for_write_queue_from(skb, sk) { |
1364 | int in_sack; | 1370 | int in_sack = 0; |
1365 | u8 sacked; | 1371 | u8 sacked; |
1366 | 1372 | ||
1367 | if (skb == tcp_send_head(sk)) | 1373 | if (skb == tcp_send_head(sk)) |
@@ -1380,11 +1386,25 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1380 | if (!before(TCP_SKB_CB(skb)->seq, end_seq)) | 1386 | if (!before(TCP_SKB_CB(skb)->seq, end_seq)) |
1381 | break; | 1387 | break; |
1382 | 1388 | ||
1383 | in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq); | 1389 | dup_sack = (found_dup_sack && (i == first_sack_index)); |
1384 | if (in_sack < 0) | 1390 | |
1385 | break; | 1391 | /* Due to sorting DSACK may reside within this SACK block! */ |
1392 | if (next_dup) { | ||
1393 | u32 dup_start = ntohl(sp->start_seq); | ||
1394 | u32 dup_end = ntohl(sp->end_seq); | ||
1386 | 1395 | ||
1387 | fack_count += tcp_skb_pcount(skb); | 1396 | if (before(TCP_SKB_CB(skb)->seq, dup_end)) { |
1397 | in_sack = tcp_match_skb_to_sack(sk, skb, dup_start, dup_end); | ||
1398 | if (in_sack > 0) | ||
1399 | dup_sack = 1; | ||
1400 | } | ||
1401 | } | ||
1402 | |||
1403 | /* DSACK info lost if out-of-mem, try SACK still */ | ||
1404 | if (in_sack <= 0) | ||
1405 | in_sack = tcp_match_skb_to_sack(sk, skb, start_seq, end_seq); | ||
1406 | if (unlikely(in_sack < 0)) | ||
1407 | break; | ||
1388 | 1408 | ||
1389 | sacked = TCP_SKB_CB(skb)->sacked; | 1409 | sacked = TCP_SKB_CB(skb)->sacked; |
1390 | 1410 | ||
@@ -1400,19 +1420,17 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1400 | if ((dup_sack && in_sack) && | 1420 | if ((dup_sack && in_sack) && |
1401 | (sacked&TCPCB_SACKED_ACKED)) | 1421 | (sacked&TCPCB_SACKED_ACKED)) |
1402 | reord = min(fack_count, reord); | 1422 | reord = min(fack_count, reord); |
1403 | } else { | ||
1404 | /* If it was in a hole, we detected reordering. */ | ||
1405 | if (fack_count < prior_fackets && | ||
1406 | !(sacked&TCPCB_SACKED_ACKED)) | ||
1407 | reord = min(fack_count, reord); | ||
1408 | } | 1423 | } |
1409 | 1424 | ||
1410 | /* Nothing to do; acked frame is about to be dropped. */ | 1425 | /* Nothing to do; acked frame is about to be dropped. */ |
1426 | fack_count += tcp_skb_pcount(skb); | ||
1411 | continue; | 1427 | continue; |
1412 | } | 1428 | } |
1413 | 1429 | ||
1414 | if (!in_sack) | 1430 | if (!in_sack) { |
1431 | fack_count += tcp_skb_pcount(skb); | ||
1415 | continue; | 1432 | continue; |
1433 | } | ||
1416 | 1434 | ||
1417 | if (!(sacked&TCPCB_SACKED_ACKED)) { | 1435 | if (!(sacked&TCPCB_SACKED_ACKED)) { |
1418 | if (sacked & TCPCB_SACKED_RETRANS) { | 1436 | if (sacked & TCPCB_SACKED_RETRANS) { |
@@ -1429,12 +1447,17 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1429 | tp->retransmit_skb_hint = NULL; | 1447 | tp->retransmit_skb_hint = NULL; |
1430 | } | 1448 | } |
1431 | } else { | 1449 | } else { |
1432 | /* New sack for not retransmitted frame, | 1450 | if (!(sacked & TCPCB_RETRANS)) { |
1433 | * which was in hole. It is reordering. | 1451 | /* New sack for not retransmitted frame, |
1434 | */ | 1452 | * which was in hole. It is reordering. |
1435 | if (!(sacked & TCPCB_RETRANS) && | 1453 | */ |
1436 | fack_count < prior_fackets) | 1454 | if (fack_count < prior_fackets) |
1437 | reord = min(fack_count, reord); | 1455 | reord = min(fack_count, reord); |
1456 | |||
1457 | /* SACK enhanced F-RTO (RFC4138; Appendix B) */ | ||
1458 | if (!after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark)) | ||
1459 | flag |= FLAG_ONLY_ORIG_SACKED; | ||
1460 | } | ||
1438 | 1461 | ||
1439 | if (sacked & TCPCB_LOST) { | 1462 | if (sacked & TCPCB_LOST) { |
1440 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST; | 1463 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST; |
@@ -1443,24 +1466,13 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1443 | /* clear lost hint */ | 1466 | /* clear lost hint */ |
1444 | tp->retransmit_skb_hint = NULL; | 1467 | tp->retransmit_skb_hint = NULL; |
1445 | } | 1468 | } |
1446 | /* SACK enhanced F-RTO detection. | ||
1447 | * Set flag if and only if non-rexmitted | ||
1448 | * segments below frto_highmark are | ||
1449 | * SACKed (RFC4138; Appendix B). | ||
1450 | * Clearing correct due to in-order walk | ||
1451 | */ | ||
1452 | if (after(end_seq, tp->frto_highmark)) { | ||
1453 | flag &= ~FLAG_ONLY_ORIG_SACKED; | ||
1454 | } else { | ||
1455 | if (!(sacked & TCPCB_RETRANS)) | ||
1456 | flag |= FLAG_ONLY_ORIG_SACKED; | ||
1457 | } | ||
1458 | } | 1469 | } |
1459 | 1470 | ||
1460 | TCP_SKB_CB(skb)->sacked |= TCPCB_SACKED_ACKED; | 1471 | TCP_SKB_CB(skb)->sacked |= TCPCB_SACKED_ACKED; |
1461 | flag |= FLAG_DATA_SACKED; | 1472 | flag |= FLAG_DATA_SACKED; |
1462 | tp->sacked_out += tcp_skb_pcount(skb); | 1473 | tp->sacked_out += tcp_skb_pcount(skb); |
1463 | 1474 | ||
1475 | fack_count += tcp_skb_pcount(skb); | ||
1464 | if (fack_count > tp->fackets_out) | 1476 | if (fack_count > tp->fackets_out) |
1465 | tp->fackets_out = fack_count; | 1477 | tp->fackets_out = fack_count; |
1466 | 1478 | ||
@@ -1471,6 +1483,8 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1471 | } else { | 1483 | } else { |
1472 | if (dup_sack && (sacked&TCPCB_RETRANS)) | 1484 | if (dup_sack && (sacked&TCPCB_RETRANS)) |
1473 | reord = min(fack_count, reord); | 1485 | reord = min(fack_count, reord); |
1486 | |||
1487 | fack_count += tcp_skb_pcount(skb); | ||
1474 | } | 1488 | } |
1475 | 1489 | ||
1476 | /* D-SACK. We can detect redundant retransmission | 1490 | /* D-SACK. We can detect redundant retransmission |
@@ -1485,6 +1499,12 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1485 | tp->retransmit_skb_hint = NULL; | 1499 | tp->retransmit_skb_hint = NULL; |
1486 | } | 1500 | } |
1487 | } | 1501 | } |
1502 | |||
1503 | /* SACK enhanced FRTO (RFC4138, Appendix B): Clearing correct | ||
1504 | * due to in-order walk | ||
1505 | */ | ||
1506 | if (after(end_seq, tp->frto_highmark)) | ||
1507 | flag &= ~FLAG_ONLY_ORIG_SACKED; | ||
1488 | } | 1508 | } |
1489 | 1509 | ||
1490 | if (tp->retrans_out && | 1510 | if (tp->retrans_out && |
@@ -1496,7 +1516,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1496 | 1516 | ||
1497 | if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss && | 1517 | if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss && |
1498 | (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark))) | 1518 | (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark))) |
1499 | tcp_update_reordering(sk, ((tp->fackets_out + 1) - reord), 0); | 1519 | tcp_update_reordering(sk, tp->fackets_out - reord, 0); |
1520 | |||
1521 | out: | ||
1500 | 1522 | ||
1501 | #if FASTRETRANS_DEBUG > 0 | 1523 | #if FASTRETRANS_DEBUG > 0 |
1502 | BUG_TRAP((int)tp->sacked_out >= 0); | 1524 | BUG_TRAP((int)tp->sacked_out >= 0); |
@@ -1652,6 +1674,9 @@ void tcp_enter_frto(struct sock *sk) | |||
1652 | } | 1674 | } |
1653 | tcp_verify_left_out(tp); | 1675 | tcp_verify_left_out(tp); |
1654 | 1676 | ||
1677 | /* Too bad if TCP was application limited */ | ||
1678 | tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp) + 1); | ||
1679 | |||
1655 | /* Earlier loss recovery underway (see RFC4138; Appendix B). | 1680 | /* Earlier loss recovery underway (see RFC4138; Appendix B). |
1656 | * The last condition is necessary at least in tp->frto_counter case. | 1681 | * The last condition is necessary at least in tp->frto_counter case. |
1657 | */ | 1682 | */ |
@@ -1684,6 +1709,8 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1684 | tcp_for_write_queue(skb, sk) { | 1709 | tcp_for_write_queue(skb, sk) { |
1685 | if (skb == tcp_send_head(sk)) | 1710 | if (skb == tcp_send_head(sk)) |
1686 | break; | 1711 | break; |
1712 | |||
1713 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST; | ||
1687 | /* | 1714 | /* |
1688 | * Count the retransmission made on RTO correctly (only when | 1715 | * Count the retransmission made on RTO correctly (only when |
1689 | * waiting for the first ACK and did not get it)... | 1716 | * waiting for the first ACK and did not get it)... |
@@ -1697,7 +1724,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1697 | } else { | 1724 | } else { |
1698 | if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) | 1725 | if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) |
1699 | tp->undo_marker = 0; | 1726 | tp->undo_marker = 0; |
1700 | TCP_SKB_CB(skb)->sacked &= ~(TCPCB_LOST|TCPCB_SACKED_RETRANS); | 1727 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1701 | } | 1728 | } |
1702 | 1729 | ||
1703 | /* Don't lost mark skbs that were fwd transmitted after RTO */ | 1730 | /* Don't lost mark skbs that were fwd transmitted after RTO */ |
@@ -2059,7 +2086,7 @@ static void tcp_update_scoreboard(struct sock *sk) | |||
2059 | if (!tcp_skb_timedout(sk, skb)) | 2086 | if (!tcp_skb_timedout(sk, skb)) |
2060 | break; | 2087 | break; |
2061 | 2088 | ||
2062 | if (!(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) { | 2089 | if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) { |
2063 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 2090 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
2064 | tp->lost_out += tcp_skb_pcount(skb); | 2091 | tp->lost_out += tcp_skb_pcount(skb); |
2065 | tcp_verify_retransmit_hint(tp, skb); | 2092 | tcp_verify_retransmit_hint(tp, skb); |
@@ -2611,7 +2638,8 @@ static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb) | |||
2611 | * is before the ack sequence we can discard it as it's confirmed to have | 2638 | * is before the ack sequence we can discard it as it's confirmed to have |
2612 | * arrived at the other end. | 2639 | * arrived at the other end. |
2613 | */ | 2640 | */ |
2614 | static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | 2641 | static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p, |
2642 | int prior_fackets) | ||
2615 | { | 2643 | { |
2616 | struct tcp_sock *tp = tcp_sk(sk); | 2644 | struct tcp_sock *tp = tcp_sk(sk); |
2617 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2645 | const struct inet_connection_sock *icsk = inet_csk(sk); |
@@ -2620,6 +2648,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | |||
2620 | int fully_acked = 1; | 2648 | int fully_acked = 1; |
2621 | int flag = 0; | 2649 | int flag = 0; |
2622 | int prior_packets = tp->packets_out; | 2650 | int prior_packets = tp->packets_out; |
2651 | u32 cnt = 0; | ||
2652 | u32 reord = tp->packets_out; | ||
2623 | s32 seq_rtt = -1; | 2653 | s32 seq_rtt = -1; |
2624 | ktime_t last_ackt = net_invalid_timestamp(); | 2654 | ktime_t last_ackt = net_invalid_timestamp(); |
2625 | 2655 | ||
@@ -2660,10 +2690,14 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | |||
2660 | if ((flag & FLAG_DATA_ACKED) || | 2690 | if ((flag & FLAG_DATA_ACKED) || |
2661 | (packets_acked > 1)) | 2691 | (packets_acked > 1)) |
2662 | flag |= FLAG_NONHEAD_RETRANS_ACKED; | 2692 | flag |= FLAG_NONHEAD_RETRANS_ACKED; |
2663 | } else if (seq_rtt < 0) { | 2693 | } else { |
2664 | seq_rtt = now - scb->when; | 2694 | if (seq_rtt < 0) { |
2665 | if (fully_acked) | 2695 | seq_rtt = now - scb->when; |
2666 | last_ackt = skb->tstamp; | 2696 | if (fully_acked) |
2697 | last_ackt = skb->tstamp; | ||
2698 | } | ||
2699 | if (!(sacked & TCPCB_SACKED_ACKED)) | ||
2700 | reord = min(cnt, reord); | ||
2667 | } | 2701 | } |
2668 | 2702 | ||
2669 | if (sacked & TCPCB_SACKED_ACKED) | 2703 | if (sacked & TCPCB_SACKED_ACKED) |
@@ -2674,12 +2708,16 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | |||
2674 | if ((sacked & TCPCB_URG) && tp->urg_mode && | 2708 | if ((sacked & TCPCB_URG) && tp->urg_mode && |
2675 | !before(end_seq, tp->snd_up)) | 2709 | !before(end_seq, tp->snd_up)) |
2676 | tp->urg_mode = 0; | 2710 | tp->urg_mode = 0; |
2677 | } else if (seq_rtt < 0) { | 2711 | } else { |
2678 | seq_rtt = now - scb->when; | 2712 | if (seq_rtt < 0) { |
2679 | if (fully_acked) | 2713 | seq_rtt = now - scb->when; |
2680 | last_ackt = skb->tstamp; | 2714 | if (fully_acked) |
2715 | last_ackt = skb->tstamp; | ||
2716 | } | ||
2717 | reord = min(cnt, reord); | ||
2681 | } | 2718 | } |
2682 | tp->packets_out -= packets_acked; | 2719 | tp->packets_out -= packets_acked; |
2720 | cnt += packets_acked; | ||
2683 | 2721 | ||
2684 | /* Initial outgoing SYN's get put onto the write_queue | 2722 | /* Initial outgoing SYN's get put onto the write_queue |
2685 | * just like anything else we transmit. It is not | 2723 | * just like anything else we transmit. It is not |
@@ -2711,13 +2749,18 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | |||
2711 | tcp_ack_update_rtt(sk, flag, seq_rtt); | 2749 | tcp_ack_update_rtt(sk, flag, seq_rtt); |
2712 | tcp_rearm_rto(sk); | 2750 | tcp_rearm_rto(sk); |
2713 | 2751 | ||
2752 | if (tcp_is_reno(tp)) { | ||
2753 | tcp_remove_reno_sacks(sk, pkts_acked); | ||
2754 | } else { | ||
2755 | /* Non-retransmitted hole got filled? That's reordering */ | ||
2756 | if (reord < prior_fackets) | ||
2757 | tcp_update_reordering(sk, tp->fackets_out - reord, 0); | ||
2758 | } | ||
2759 | |||
2714 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); | 2760 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); |
2715 | /* hint's skb might be NULL but we don't need to care */ | 2761 | /* hint's skb might be NULL but we don't need to care */ |
2716 | tp->fastpath_cnt_hint -= min_t(u32, pkts_acked, | 2762 | tp->fastpath_cnt_hint -= min_t(u32, pkts_acked, |
2717 | tp->fastpath_cnt_hint); | 2763 | tp->fastpath_cnt_hint); |
2718 | if (tcp_is_reno(tp)) | ||
2719 | tcp_remove_reno_sacks(sk, pkts_acked); | ||
2720 | |||
2721 | if (ca_ops->pkts_acked) { | 2764 | if (ca_ops->pkts_acked) { |
2722 | s32 rtt_us = -1; | 2765 | s32 rtt_us = -1; |
2723 | 2766 | ||
@@ -3000,6 +3043,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3000 | u32 ack_seq = TCP_SKB_CB(skb)->seq; | 3043 | u32 ack_seq = TCP_SKB_CB(skb)->seq; |
3001 | u32 ack = TCP_SKB_CB(skb)->ack_seq; | 3044 | u32 ack = TCP_SKB_CB(skb)->ack_seq; |
3002 | u32 prior_in_flight; | 3045 | u32 prior_in_flight; |
3046 | u32 prior_fackets; | ||
3003 | s32 seq_rtt; | 3047 | s32 seq_rtt; |
3004 | int prior_packets; | 3048 | int prior_packets; |
3005 | int frto_cwnd = 0; | 3049 | int frto_cwnd = 0; |
@@ -3024,6 +3068,8 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3024 | tp->bytes_acked += min(ack - prior_snd_una, tp->mss_cache); | 3068 | tp->bytes_acked += min(ack - prior_snd_una, tp->mss_cache); |
3025 | } | 3069 | } |
3026 | 3070 | ||
3071 | prior_fackets = tp->fackets_out; | ||
3072 | |||
3027 | if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) { | 3073 | if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) { |
3028 | /* Window is constant, pure forward advance. | 3074 | /* Window is constant, pure forward advance. |
3029 | * No more checks are required. | 3075 | * No more checks are required. |
@@ -3065,13 +3111,13 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3065 | prior_in_flight = tcp_packets_in_flight(tp); | 3111 | prior_in_flight = tcp_packets_in_flight(tp); |
3066 | 3112 | ||
3067 | /* See if we can take anything off of the retransmit queue. */ | 3113 | /* See if we can take anything off of the retransmit queue. */ |
3068 | flag |= tcp_clean_rtx_queue(sk, &seq_rtt); | 3114 | flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets); |
3069 | 3115 | ||
3116 | if (tp->frto_counter) | ||
3117 | frto_cwnd = tcp_process_frto(sk, flag); | ||
3070 | /* Guarantee sacktag reordering detection against wrap-arounds */ | 3118 | /* Guarantee sacktag reordering detection against wrap-arounds */ |
3071 | if (before(tp->frto_highmark, tp->snd_una)) | 3119 | if (before(tp->frto_highmark, tp->snd_una)) |
3072 | tp->frto_highmark = 0; | 3120 | tp->frto_highmark = 0; |
3073 | if (tp->frto_counter) | ||
3074 | frto_cwnd = tcp_process_frto(sk, flag); | ||
3075 | 3121 | ||
3076 | if (tcp_ack_is_dubious(sk, flag)) { | 3122 | if (tcp_ack_is_dubious(sk, flag)) { |
3077 | /* Advance CWND, if state allows this. */ | 3123 | /* Advance CWND, if state allows this. */ |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index ad759f1c3777..652c32368ccc 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -858,16 +858,16 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, | |||
858 | u8 *newkey, u8 newkeylen) | 858 | u8 *newkey, u8 newkeylen) |
859 | { | 859 | { |
860 | /* Add Key to the list */ | 860 | /* Add Key to the list */ |
861 | struct tcp4_md5sig_key *key; | 861 | struct tcp_md5sig_key *key; |
862 | struct tcp_sock *tp = tcp_sk(sk); | 862 | struct tcp_sock *tp = tcp_sk(sk); |
863 | struct tcp4_md5sig_key *keys; | 863 | struct tcp4_md5sig_key *keys; |
864 | 864 | ||
865 | key = (struct tcp4_md5sig_key *)tcp_v4_md5_do_lookup(sk, addr); | 865 | key = tcp_v4_md5_do_lookup(sk, addr); |
866 | if (key) { | 866 | if (key) { |
867 | /* Pre-existing entry - just update that one. */ | 867 | /* Pre-existing entry - just update that one. */ |
868 | kfree(key->base.key); | 868 | kfree(key->key); |
869 | key->base.key = newkey; | 869 | key->key = newkey; |
870 | key->base.keylen = newkeylen; | 870 | key->keylen = newkeylen; |
871 | } else { | 871 | } else { |
872 | struct tcp_md5sig_info *md5sig; | 872 | struct tcp_md5sig_info *md5sig; |
873 | 873 | ||
@@ -900,8 +900,7 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, | |||
900 | sizeof(*keys) * md5sig->entries4); | 900 | sizeof(*keys) * md5sig->entries4); |
901 | 901 | ||
902 | /* Free old key list, and reference new one */ | 902 | /* Free old key list, and reference new one */ |
903 | if (md5sig->keys4) | 903 | kfree(md5sig->keys4); |
904 | kfree(md5sig->keys4); | ||
905 | md5sig->keys4 = keys; | 904 | md5sig->keys4 = keys; |
906 | md5sig->alloced4++; | 905 | md5sig->alloced4++; |
907 | } | 906 | } |
@@ -939,10 +938,10 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) | |||
939 | tp->md5sig_info->alloced4 = 0; | 938 | tp->md5sig_info->alloced4 = 0; |
940 | } else if (tp->md5sig_info->entries4 != i) { | 939 | } else if (tp->md5sig_info->entries4 != i) { |
941 | /* Need to do some manipulation */ | 940 | /* Need to do some manipulation */ |
942 | memcpy(&tp->md5sig_info->keys4[i], | 941 | memmove(&tp->md5sig_info->keys4[i], |
943 | &tp->md5sig_info->keys4[i+1], | 942 | &tp->md5sig_info->keys4[i+1], |
944 | (tp->md5sig_info->entries4 - i) * | 943 | (tp->md5sig_info->entries4 - i) * |
945 | sizeof(struct tcp4_md5sig_key)); | 944 | sizeof(struct tcp4_md5sig_key)); |
946 | } | 945 | } |
947 | tcp_free_md5sig_pool(); | 946 | tcp_free_md5sig_pool(); |
948 | return 0; | 947 | return 0; |
@@ -1083,7 +1082,7 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
1083 | sg_set_buf(&sg[block++], key->key, key->keylen); | 1082 | sg_set_buf(&sg[block++], key->key, key->keylen); |
1084 | nbytes += key->keylen; | 1083 | nbytes += key->keylen; |
1085 | 1084 | ||
1086 | sg_mark_end(sg, block); | 1085 | sg_mark_end(&sg[block - 1]); |
1087 | 1086 | ||
1088 | /* Now store the Hash into the packet */ | 1087 | /* Now store the Hash into the packet */ |
1089 | err = crypto_hash_init(desc); | 1088 | err = crypto_hash_init(desc); |
@@ -2049,8 +2048,9 @@ static void *established_get_first(struct seq_file *seq) | |||
2049 | struct sock *sk; | 2048 | struct sock *sk; |
2050 | struct hlist_node *node; | 2049 | struct hlist_node *node; |
2051 | struct inet_timewait_sock *tw; | 2050 | struct inet_timewait_sock *tw; |
2051 | rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket); | ||
2052 | 2052 | ||
2053 | read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock); | 2053 | read_lock_bh(lock); |
2054 | sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { | 2054 | sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { |
2055 | if (sk->sk_family != st->family) { | 2055 | if (sk->sk_family != st->family) { |
2056 | continue; | 2056 | continue; |
@@ -2067,7 +2067,7 @@ static void *established_get_first(struct seq_file *seq) | |||
2067 | rc = tw; | 2067 | rc = tw; |
2068 | goto out; | 2068 | goto out; |
2069 | } | 2069 | } |
2070 | read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); | 2070 | read_unlock_bh(lock); |
2071 | st->state = TCP_SEQ_STATE_ESTABLISHED; | 2071 | st->state = TCP_SEQ_STATE_ESTABLISHED; |
2072 | } | 2072 | } |
2073 | out: | 2073 | out: |
@@ -2094,11 +2094,11 @@ get_tw: | |||
2094 | cur = tw; | 2094 | cur = tw; |
2095 | goto out; | 2095 | goto out; |
2096 | } | 2096 | } |
2097 | read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); | 2097 | read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket)); |
2098 | st->state = TCP_SEQ_STATE_ESTABLISHED; | 2098 | st->state = TCP_SEQ_STATE_ESTABLISHED; |
2099 | 2099 | ||
2100 | if (++st->bucket < tcp_hashinfo.ehash_size) { | 2100 | if (++st->bucket < tcp_hashinfo.ehash_size) { |
2101 | read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock); | 2101 | read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket)); |
2102 | sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain); | 2102 | sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain); |
2103 | } else { | 2103 | } else { |
2104 | cur = NULL; | 2104 | cur = NULL; |
@@ -2206,7 +2206,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v) | |||
2206 | case TCP_SEQ_STATE_TIME_WAIT: | 2206 | case TCP_SEQ_STATE_TIME_WAIT: |
2207 | case TCP_SEQ_STATE_ESTABLISHED: | 2207 | case TCP_SEQ_STATE_ESTABLISHED: |
2208 | if (v) | 2208 | if (v) |
2209 | read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock); | 2209 | read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket)); |
2210 | break; | 2210 | break; |
2211 | } | 2211 | } |
2212 | } | 2212 | } |
@@ -2417,6 +2417,8 @@ void tcp4_proc_exit(void) | |||
2417 | } | 2417 | } |
2418 | #endif /* CONFIG_PROC_FS */ | 2418 | #endif /* CONFIG_PROC_FS */ |
2419 | 2419 | ||
2420 | DEFINE_PROTO_INUSE(tcp) | ||
2421 | |||
2420 | struct proto tcp_prot = { | 2422 | struct proto tcp_prot = { |
2421 | .name = "TCP", | 2423 | .name = "TCP", |
2422 | .owner = THIS_MODULE, | 2424 | .owner = THIS_MODULE, |
@@ -2451,6 +2453,7 @@ struct proto tcp_prot = { | |||
2451 | .compat_setsockopt = compat_tcp_setsockopt, | 2453 | .compat_setsockopt = compat_tcp_setsockopt, |
2452 | .compat_getsockopt = compat_tcp_getsockopt, | 2454 | .compat_getsockopt = compat_tcp_getsockopt, |
2453 | #endif | 2455 | #endif |
2456 | REF_PROTO_INUSE(tcp) | ||
2454 | }; | 2457 | }; |
2455 | 2458 | ||
2456 | void __init tcp_v4_init(struct net_proto_family *ops) | 2459 | void __init tcp_v4_init(struct net_proto_family *ops) |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 324b4207254a..e5130a7fe181 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -1295,6 +1295,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1295 | struct sk_buff *skb, *nskb, *next; | 1295 | struct sk_buff *skb, *nskb, *next; |
1296 | int len; | 1296 | int len; |
1297 | int probe_size; | 1297 | int probe_size; |
1298 | int size_needed; | ||
1298 | unsigned int pif; | 1299 | unsigned int pif; |
1299 | int copy; | 1300 | int copy; |
1300 | int mss_now; | 1301 | int mss_now; |
@@ -1313,27 +1314,20 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1313 | /* Very simple search strategy: just double the MSS. */ | 1314 | /* Very simple search strategy: just double the MSS. */ |
1314 | mss_now = tcp_current_mss(sk, 0); | 1315 | mss_now = tcp_current_mss(sk, 0); |
1315 | probe_size = 2*tp->mss_cache; | 1316 | probe_size = 2*tp->mss_cache; |
1317 | size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; | ||
1316 | if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { | 1318 | if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { |
1317 | /* TODO: set timer for probe_converge_event */ | 1319 | /* TODO: set timer for probe_converge_event */ |
1318 | return -1; | 1320 | return -1; |
1319 | } | 1321 | } |
1320 | 1322 | ||
1321 | /* Have enough data in the send queue to probe? */ | 1323 | /* Have enough data in the send queue to probe? */ |
1322 | len = 0; | 1324 | if (tp->write_seq - tp->snd_nxt < size_needed) |
1323 | if ((skb = tcp_send_head(sk)) == NULL) | ||
1324 | return -1; | ||
1325 | while ((len += skb->len) < probe_size && !tcp_skb_is_last(sk, skb)) | ||
1326 | skb = tcp_write_queue_next(sk, skb); | ||
1327 | if (len < probe_size) | ||
1328 | return -1; | 1325 | return -1; |
1329 | 1326 | ||
1330 | /* Receive window check. */ | 1327 | if (tp->snd_wnd < size_needed) |
1331 | if (after(TCP_SKB_CB(skb)->seq + probe_size, tp->snd_una + tp->snd_wnd)) { | 1328 | return -1; |
1332 | if (tp->snd_wnd < probe_size) | 1329 | if (after(tp->snd_nxt + size_needed, tp->snd_una + tp->snd_wnd)) |
1333 | return -1; | 1330 | return 0; |
1334 | else | ||
1335 | return 0; | ||
1336 | } | ||
1337 | 1331 | ||
1338 | /* Do we need to wait to drain cwnd? */ | 1332 | /* Do we need to wait to drain cwnd? */ |
1339 | pif = tcp_packets_in_flight(tp); | 1333 | pif = tcp_packets_in_flight(tp); |
@@ -1352,7 +1346,6 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1352 | 1346 | ||
1353 | skb = tcp_send_head(sk); | 1347 | skb = tcp_send_head(sk); |
1354 | tcp_insert_write_queue_before(nskb, skb, sk); | 1348 | tcp_insert_write_queue_before(nskb, skb, sk); |
1355 | tcp_advance_send_head(sk, skb); | ||
1356 | 1349 | ||
1357 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; | 1350 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; |
1358 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; | 1351 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; |
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c index b49dedcda52d..007304e99842 100644 --- a/net/ipv4/tcp_vegas.c +++ b/net/ipv4/tcp_vegas.c | |||
@@ -266,26 +266,25 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, | |||
266 | */ | 266 | */ |
267 | diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd; | 267 | diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd; |
268 | 268 | ||
269 | if (tp->snd_cwnd <= tp->snd_ssthresh) { | 269 | if (diff > gamma && tp->snd_ssthresh > 2 ) { |
270 | /* Slow start. */ | 270 | /* Going too fast. Time to slow down |
271 | if (diff > gamma) { | 271 | * and switch to congestion avoidance. |
272 | /* Going too fast. Time to slow down | 272 | */ |
273 | * and switch to congestion avoidance. | 273 | tp->snd_ssthresh = 2; |
274 | */ | 274 | |
275 | tp->snd_ssthresh = 2; | 275 | /* Set cwnd to match the actual rate |
276 | 276 | * exactly: | |
277 | /* Set cwnd to match the actual rate | 277 | * cwnd = (actual rate) * baseRTT |
278 | * exactly: | 278 | * Then we add 1 because the integer |
279 | * cwnd = (actual rate) * baseRTT | 279 | * truncation robs us of full link |
280 | * Then we add 1 because the integer | 280 | * utilization. |
281 | * truncation robs us of full link | 281 | */ |
282 | * utilization. | 282 | tp->snd_cwnd = min(tp->snd_cwnd, |
283 | */ | 283 | (target_cwnd >> |
284 | tp->snd_cwnd = min(tp->snd_cwnd, | 284 | V_PARAM_SHIFT)+1); |
285 | (target_cwnd >> | ||
286 | V_PARAM_SHIFT)+1); | ||
287 | 285 | ||
288 | } | 286 | } else if (tp->snd_cwnd <= tp->snd_ssthresh) { |
287 | /* Slow start. */ | ||
289 | tcp_slow_start(tp); | 288 | tcp_slow_start(tp); |
290 | } else { | 289 | } else { |
291 | /* Congestion avoidance. */ | 290 | /* Congestion avoidance. */ |
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c index a794a8ca8b4f..978b3fd61e65 100644 --- a/net/ipv4/tunnel4.c +++ b/net/ipv4/tunnel4.c | |||
@@ -17,6 +17,11 @@ static struct xfrm_tunnel *tunnel4_handlers; | |||
17 | static struct xfrm_tunnel *tunnel64_handlers; | 17 | static struct xfrm_tunnel *tunnel64_handlers; |
18 | static DEFINE_MUTEX(tunnel4_mutex); | 18 | static DEFINE_MUTEX(tunnel4_mutex); |
19 | 19 | ||
20 | static inline struct xfrm_tunnel **fam_handlers(unsigned short family) | ||
21 | { | ||
22 | return (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; | ||
23 | } | ||
24 | |||
20 | int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) | 25 | int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) |
21 | { | 26 | { |
22 | struct xfrm_tunnel **pprev; | 27 | struct xfrm_tunnel **pprev; |
@@ -25,8 +30,7 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) | |||
25 | 30 | ||
26 | mutex_lock(&tunnel4_mutex); | 31 | mutex_lock(&tunnel4_mutex); |
27 | 32 | ||
28 | for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; | 33 | for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) { |
29 | *pprev; pprev = &(*pprev)->next) { | ||
30 | if ((*pprev)->priority > priority) | 34 | if ((*pprev)->priority > priority) |
31 | break; | 35 | break; |
32 | if ((*pprev)->priority == priority) | 36 | if ((*pprev)->priority == priority) |
@@ -53,8 +57,7 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family) | |||
53 | 57 | ||
54 | mutex_lock(&tunnel4_mutex); | 58 | mutex_lock(&tunnel4_mutex); |
55 | 59 | ||
56 | for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; | 60 | for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) { |
57 | *pprev; pprev = &(*pprev)->next) { | ||
58 | if (*pprev == handler) { | 61 | if (*pprev == handler) { |
59 | *pprev = handler->next; | 62 | *pprev = handler->next; |
60 | ret = 0; | 63 | ret = 0; |
@@ -118,6 +121,17 @@ static void tunnel4_err(struct sk_buff *skb, u32 info) | |||
118 | break; | 121 | break; |
119 | } | 122 | } |
120 | 123 | ||
124 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
125 | static void tunnel64_err(struct sk_buff *skb, u32 info) | ||
126 | { | ||
127 | struct xfrm_tunnel *handler; | ||
128 | |||
129 | for (handler = tunnel64_handlers; handler; handler = handler->next) | ||
130 | if (!handler->err_handler(skb, info)) | ||
131 | break; | ||
132 | } | ||
133 | #endif | ||
134 | |||
121 | static struct net_protocol tunnel4_protocol = { | 135 | static struct net_protocol tunnel4_protocol = { |
122 | .handler = tunnel4_rcv, | 136 | .handler = tunnel4_rcv, |
123 | .err_handler = tunnel4_err, | 137 | .err_handler = tunnel4_err, |
@@ -127,7 +141,7 @@ static struct net_protocol tunnel4_protocol = { | |||
127 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 141 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
128 | static struct net_protocol tunnel64_protocol = { | 142 | static struct net_protocol tunnel64_protocol = { |
129 | .handler = tunnel64_rcv, | 143 | .handler = tunnel64_rcv, |
130 | .err_handler = tunnel4_err, | 144 | .err_handler = tunnel64_err, |
131 | .no_policy = 1, | 145 | .no_policy = 1, |
132 | }; | 146 | }; |
133 | #endif | 147 | #endif |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 4bc25b46f33f..03c400ca14c5 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1430,6 +1430,8 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
1430 | 1430 | ||
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | DEFINE_PROTO_INUSE(udp) | ||
1434 | |||
1433 | struct proto udp_prot = { | 1435 | struct proto udp_prot = { |
1434 | .name = "UDP", | 1436 | .name = "UDP", |
1435 | .owner = THIS_MODULE, | 1437 | .owner = THIS_MODULE, |
@@ -1452,6 +1454,7 @@ struct proto udp_prot = { | |||
1452 | .compat_setsockopt = compat_udp_setsockopt, | 1454 | .compat_setsockopt = compat_udp_setsockopt, |
1453 | .compat_getsockopt = compat_udp_getsockopt, | 1455 | .compat_getsockopt = compat_udp_getsockopt, |
1454 | #endif | 1456 | #endif |
1457 | REF_PROTO_INUSE(udp) | ||
1455 | }; | 1458 | }; |
1456 | 1459 | ||
1457 | /* ------------------------------------------------------------------------ */ | 1460 | /* ------------------------------------------------------------------------ */ |
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 94977205abb4..f5baeb3e8b85 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
@@ -44,6 +44,8 @@ static struct net_protocol udplite_protocol = { | |||
44 | .no_policy = 1, | 44 | .no_policy = 1, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | DEFINE_PROTO_INUSE(udplite) | ||
48 | |||
47 | struct proto udplite_prot = { | 49 | struct proto udplite_prot = { |
48 | .name = "UDP-Lite", | 50 | .name = "UDP-Lite", |
49 | .owner = THIS_MODULE, | 51 | .owner = THIS_MODULE, |
@@ -67,6 +69,7 @@ struct proto udplite_prot = { | |||
67 | .compat_setsockopt = compat_udp_setsockopt, | 69 | .compat_setsockopt = compat_udp_setsockopt, |
68 | .compat_getsockopt = compat_udp_getsockopt, | 70 | .compat_getsockopt = compat_udp_getsockopt, |
69 | #endif | 71 | #endif |
72 | REF_PROTO_INUSE(udplite) | ||
70 | }; | 73 | }; |
71 | 74 | ||
72 | static struct inet_protosw udplite4_protosw = { | 75 | static struct inet_protosw udplite4_protosw = { |