aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-12-09 23:41:22 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-09 23:41:22 -0500
commitb242a60206881559bb3102110048762422e6b74e (patch)
tree86459efa47b9c3f69d865b4495beede9c4184003 /net/ipv4
parente1fd18656c2963e383d67b7006c0e06c9c1d9c79 (diff)
parent94545baded0bfbabdc30a3a4cb48b3db479dd6ef (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/inet_diag.c69
-rw-r--r--net/ipv4/inet_lro.c3
-rw-r--r--net/ipv4/ipvs/ip_vs_lblc.c7
-rw-r--r--net/ipv4/ipvs/ip_vs_lblcr.c7
-rw-r--r--net/ipv4/ipvs/ip_vs_sched.c27
-rw-r--r--net/ipv4/route.c5
-rw-r--r--net/ipv4/tcp_illinois.c2
-rw-r--r--net/ipv4/tcp_input.c17
-rw-r--r--net/ipv4/tcp_output.c3
9 files changed, 85 insertions, 55 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index b0170732b5e9..e468e7a7aac4 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -51,6 +51,29 @@ static struct sock *idiagnl;
51#define INET_DIAG_PUT(skb, attrtype, attrlen) \ 51#define INET_DIAG_PUT(skb, attrtype, attrlen) \
52 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) 52 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
53 53
54static DEFINE_MUTEX(inet_diag_table_mutex);
55
56static const struct inet_diag_handler *inet_diag_lock_handler(int type)
57{
58#ifdef CONFIG_KMOD
59 if (!inet_diag_table[type])
60 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
61 NETLINK_INET_DIAG, type);
62#endif
63
64 mutex_lock(&inet_diag_table_mutex);
65 if (!inet_diag_table[type])
66 return ERR_PTR(-ENOENT);
67
68 return inet_diag_table[type];
69}
70
71static inline void inet_diag_unlock_handler(
72 const struct inet_diag_handler *handler)
73{
74 mutex_unlock(&inet_diag_table_mutex);
75}
76
54static int inet_csk_diag_fill(struct sock *sk, 77static int inet_csk_diag_fill(struct sock *sk,
55 struct sk_buff *skb, 78 struct sk_buff *skb,
56 int ext, u32 pid, u32 seq, u16 nlmsg_flags, 79 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
@@ -235,9 +258,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
235 struct inet_hashinfo *hashinfo; 258 struct inet_hashinfo *hashinfo;
236 const struct inet_diag_handler *handler; 259 const struct inet_diag_handler *handler;
237 260
238 handler = inet_diag_table[nlh->nlmsg_type]; 261 handler = inet_diag_lock_handler(nlh->nlmsg_type);
239 BUG_ON(handler == NULL); 262 if (!handler)
263 return -ENOENT;
264
240 hashinfo = handler->idiag_hashinfo; 265 hashinfo = handler->idiag_hashinfo;
266 err = -EINVAL;
241 267
242 if (req->idiag_family == AF_INET) { 268 if (req->idiag_family == AF_INET) {
243 sk = inet_lookup(hashinfo, req->id.idiag_dst[0], 269 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
@@ -255,11 +281,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
255 } 281 }
256#endif 282#endif
257 else { 283 else {
258 return -EINVAL; 284 goto unlock;
259 } 285 }
260 286
287 err = -ENOENT;
261 if (sk == NULL) 288 if (sk == NULL)
262 return -ENOENT; 289 goto unlock;
263 290
264 err = -ESTALE; 291 err = -ESTALE;
265 if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE || 292 if ((req->id.idiag_cookie[0] != INET_DIAG_NOCOOKIE ||
@@ -296,6 +323,8 @@ out:
296 else 323 else
297 sock_put(sk); 324 sock_put(sk);
298 } 325 }
326unlock:
327 inet_diag_unlock_handler(handler);
299 return err; 328 return err;
300} 329}
301 330
@@ -678,8 +707,10 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
678 const struct inet_diag_handler *handler; 707 const struct inet_diag_handler *handler;
679 struct inet_hashinfo *hashinfo; 708 struct inet_hashinfo *hashinfo;
680 709
681 handler = inet_diag_table[cb->nlh->nlmsg_type]; 710 handler = inet_diag_lock_handler(cb->nlh->nlmsg_type);
682 BUG_ON(handler == NULL); 711 if (!handler)
712 goto no_handler;
713
683 hashinfo = handler->idiag_hashinfo; 714 hashinfo = handler->idiag_hashinfo;
684 715
685 s_i = cb->args[1]; 716 s_i = cb->args[1];
@@ -743,7 +774,7 @@ skip_listen_ht:
743 } 774 }
744 775
745 if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV))) 776 if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV)))
746 return skb->len; 777 goto unlock;
747 778
748 for (i = s_i; i < hashinfo->ehash_size; i++) { 779 for (i = s_i; i < hashinfo->ehash_size; i++) {
749 struct inet_ehash_bucket *head = &hashinfo->ehash[i]; 780 struct inet_ehash_bucket *head = &hashinfo->ehash[i];
@@ -805,6 +836,9 @@ next_dying:
805done: 836done:
806 cb->args[1] = i; 837 cb->args[1] = i;
807 cb->args[2] = num; 838 cb->args[2] = num;
839unlock:
840 inet_diag_unlock_handler(handler);
841no_handler:
808 return skb->len; 842 return skb->len;
809} 843}
810 844
@@ -816,15 +850,6 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
816 nlmsg_len(nlh) < hdrlen) 850 nlmsg_len(nlh) < hdrlen)
817 return -EINVAL; 851 return -EINVAL;
818 852
819#ifdef CONFIG_KMOD
820 if (inet_diag_table[nlh->nlmsg_type] == NULL)
821 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
822 NETLINK_INET_DIAG, nlh->nlmsg_type);
823#endif
824
825 if (inet_diag_table[nlh->nlmsg_type] == NULL)
826 return -ENOENT;
827
828 if (nlh->nlmsg_flags & NLM_F_DUMP) { 853 if (nlh->nlmsg_flags & NLM_F_DUMP) {
829 if (nlmsg_attrlen(nlh, hdrlen)) { 854 if (nlmsg_attrlen(nlh, hdrlen)) {
830 struct nlattr *attr; 855 struct nlattr *attr;
@@ -853,8 +878,6 @@ static void inet_diag_rcv(struct sk_buff *skb)
853 mutex_unlock(&inet_diag_mutex); 878 mutex_unlock(&inet_diag_mutex);
854} 879}
855 880
856static DEFINE_SPINLOCK(inet_diag_register_lock);
857
858int inet_diag_register(const struct inet_diag_handler *h) 881int inet_diag_register(const struct inet_diag_handler *h)
859{ 882{
860 const __u16 type = h->idiag_type; 883 const __u16 type = h->idiag_type;
@@ -863,13 +886,13 @@ int inet_diag_register(const struct inet_diag_handler *h)
863 if (type >= INET_DIAG_GETSOCK_MAX) 886 if (type >= INET_DIAG_GETSOCK_MAX)
864 goto out; 887 goto out;
865 888
866 spin_lock(&inet_diag_register_lock); 889 mutex_lock(&inet_diag_table_mutex);
867 err = -EEXIST; 890 err = -EEXIST;
868 if (inet_diag_table[type] == NULL) { 891 if (inet_diag_table[type] == NULL) {
869 inet_diag_table[type] = h; 892 inet_diag_table[type] = h;
870 err = 0; 893 err = 0;
871 } 894 }
872 spin_unlock(&inet_diag_register_lock); 895 mutex_unlock(&inet_diag_table_mutex);
873out: 896out:
874 return err; 897 return err;
875} 898}
@@ -882,11 +905,9 @@ void inet_diag_unregister(const struct inet_diag_handler *h)
882 if (type >= INET_DIAG_GETSOCK_MAX) 905 if (type >= INET_DIAG_GETSOCK_MAX)
883 return; 906 return;
884 907
885 spin_lock(&inet_diag_register_lock); 908 mutex_lock(&inet_diag_table_mutex);
886 inet_diag_table[type] = NULL; 909 inet_diag_table[type] = NULL;
887 spin_unlock(&inet_diag_register_lock); 910 mutex_unlock(&inet_diag_table_mutex);
888
889 synchronize_rcu();
890} 911}
891EXPORT_SYMBOL_GPL(inet_diag_unregister); 912EXPORT_SYMBOL_GPL(inet_diag_unregister);
892 913
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c
index ac3b1d3dba2e..9a96c277393d 100644
--- a/net/ipv4/inet_lro.c
+++ b/net/ipv4/inet_lro.c
@@ -401,10 +401,11 @@ static struct sk_buff *lro_gen_skb(struct net_lro_mgr *lro_mgr,
401 int data_len = len; 401 int data_len = len;
402 int hdr_len = min(len, hlen); 402 int hdr_len = min(len, hlen);
403 403
404 skb = netdev_alloc_skb(lro_mgr->dev, hlen); 404 skb = netdev_alloc_skb(lro_mgr->dev, hlen + lro_mgr->frag_align_pad);
405 if (!skb) 405 if (!skb)
406 return NULL; 406 return NULL;
407 407
408 skb_reserve(skb, lro_mgr->frag_align_pad);
408 skb->len = len; 409 skb->len = len;
409 skb->data_len = len - hdr_len; 410 skb->data_len = len - hdr_len;
410 skb->truesize += true_size; 411 skb->truesize += true_size;
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
index b843a11d7cf7..ad89644ef5d2 100644
--- a/net/ipv4/ipvs/ip_vs_lblc.c
+++ b/net/ipv4/ipvs/ip_vs_lblc.c
@@ -580,9 +580,14 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler =
580 580
581static int __init ip_vs_lblc_init(void) 581static int __init ip_vs_lblc_init(void)
582{ 582{
583 int ret;
584
583 INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list); 585 INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list);
584 sysctl_header = register_sysctl_table(lblc_root_table); 586 sysctl_header = register_sysctl_table(lblc_root_table);
585 return register_ip_vs_scheduler(&ip_vs_lblc_scheduler); 587 ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler);
588 if (ret)
589 unregister_sysctl_table(sysctl_header);
590 return ret;
586} 591}
587 592
588 593
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
index e5b323a6b2f7..2a5ed85a3352 100644
--- a/net/ipv4/ipvs/ip_vs_lblcr.c
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c
@@ -769,9 +769,14 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
769 769
770static int __init ip_vs_lblcr_init(void) 770static int __init ip_vs_lblcr_init(void)
771{ 771{
772 int ret;
773
772 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); 774 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
773 sysctl_header = register_sysctl_table(lblcr_root_table); 775 sysctl_header = register_sysctl_table(lblcr_root_table);
774 return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); 776 ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
777 if (ret)
778 unregister_sysctl_table(sysctl_header);
779 return ret;
775} 780}
776 781
777 782
diff --git a/net/ipv4/ipvs/ip_vs_sched.c b/net/ipv4/ipvs/ip_vs_sched.c
index 1602304abbf9..432235861908 100644
--- a/net/ipv4/ipvs/ip_vs_sched.c
+++ b/net/ipv4/ipvs/ip_vs_sched.c
@@ -183,19 +183,6 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
183 /* increase the module use count */ 183 /* increase the module use count */
184 ip_vs_use_count_inc(); 184 ip_vs_use_count_inc();
185 185
186 /*
187 * Make sure that the scheduler with this name doesn't exist
188 * in the scheduler list.
189 */
190 sched = ip_vs_sched_getbyname(scheduler->name);
191 if (sched) {
192 ip_vs_scheduler_put(sched);
193 ip_vs_use_count_dec();
194 IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
195 "already existed in the system\n", scheduler->name);
196 return -EINVAL;
197 }
198
199 write_lock_bh(&__ip_vs_sched_lock); 186 write_lock_bh(&__ip_vs_sched_lock);
200 187
201 if (scheduler->n_list.next != &scheduler->n_list) { 188 if (scheduler->n_list.next != &scheduler->n_list) {
@@ -207,6 +194,20 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
207 } 194 }
208 195
209 /* 196 /*
197 * Make sure that the scheduler with this name doesn't exist
198 * in the scheduler list.
199 */
200 list_for_each_entry(sched, &ip_vs_schedulers, n_list) {
201 if (strcmp(scheduler->name, sched->name) == 0) {
202 write_unlock_bh(&__ip_vs_sched_lock);
203 ip_vs_use_count_dec();
204 IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
205 "already existed in the system\n",
206 scheduler->name);
207 return -EINVAL;
208 }
209 }
210 /*
210 * Add it into the d-linked scheduler list 211 * Add it into the d-linked scheduler list
211 */ 212 */
212 list_add(&scheduler->n_list, &ip_vs_schedulers); 213 list_add(&scheduler->n_list, &ip_vs_schedulers);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c426dec6d579..d2bc6148a737 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1161,7 +1161,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1161 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, 1161 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1162 rt->fl.oif); 1162 rt->fl.oif);
1163#if RT_CACHE_DEBUG >= 1 1163#if RT_CACHE_DEBUG >= 1
1164 printk(KERN_DEBUG "ip_rt_advice: redirect to " 1164 printk(KERN_DEBUG "ipv4_negative_advice: redirect to "
1165 "%u.%u.%u.%u/%02x dropped\n", 1165 "%u.%u.%u.%u/%02x dropped\n",
1166 NIPQUAD(rt->rt_dst), rt->fl.fl4_tos); 1166 NIPQUAD(rt->rt_dst), rt->fl.fl4_tos);
1167#endif 1167#endif
@@ -1252,6 +1252,7 @@ static int ip_error(struct sk_buff *skb)
1252 break; 1252 break;
1253 case ENETUNREACH: 1253 case ENETUNREACH:
1254 code = ICMP_NET_UNREACH; 1254 code = ICMP_NET_UNREACH;
1255 IP_INC_STATS_BH(IPSTATS_MIB_INNOROUTES);
1255 break; 1256 break;
1256 case EACCES: 1257 case EACCES:
1257 code = ICMP_PKT_FILTERED; 1258 code = ICMP_PKT_FILTERED;
@@ -1881,6 +1882,8 @@ no_route:
1881 RT_CACHE_STAT_INC(in_no_route); 1882 RT_CACHE_STAT_INC(in_no_route);
1882 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE); 1883 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
1883 res.type = RTN_UNREACHABLE; 1884 res.type = RTN_UNREACHABLE;
1885 if (err == -ESRCH)
1886 err = -ENETUNREACH;
1884 goto local_input; 1887 goto local_input;
1885 1888
1886 /* 1889 /*
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 64f1cbaf96e8..5aa5f5496d6d 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -298,7 +298,7 @@ static u32 tcp_illinois_ssthresh(struct sock *sk)
298 struct illinois *ca = inet_csk_ca(sk); 298 struct illinois *ca = inet_csk_ca(sk);
299 299
300 /* Multiplicative decrease */ 300 /* Multiplicative decrease */
301 return max((tp->snd_cwnd * ca->beta) >> BETA_SHIFT, 2U); 301 return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->beta) >> BETA_SHIFT), 2U);
302} 302}
303 303
304 304
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0f0c1c9829a1..b9e429d2d1de 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3003,17 +3003,13 @@ static int tcp_process_frto(struct sock *sk, int flag)
3003 } 3003 }
3004 3004
3005 if (tp->frto_counter == 1) { 3005 if (tp->frto_counter == 1) {
3006 /* Sending of the next skb must be allowed or no F-RTO */ 3006 /* tcp_may_send_now needs to see updated state */
3007 if (!tcp_send_head(sk) ||
3008 after(TCP_SKB_CB(tcp_send_head(sk))->end_seq,
3009 tp->snd_una + tp->snd_wnd)) {
3010 tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 2 : 3),
3011 flag);
3012 return 1;
3013 }
3014
3015 tp->snd_cwnd = tcp_packets_in_flight(tp) + 2; 3007 tp->snd_cwnd = tcp_packets_in_flight(tp) + 2;
3016 tp->frto_counter = 2; 3008 tp->frto_counter = 2;
3009
3010 if (!tcp_may_send_now(sk))
3011 tcp_enter_frto_loss(sk, 2, flag);
3012
3017 return 1; 3013 return 1;
3018 } else { 3014 } else {
3019 switch (sysctl_tcp_frto_response) { 3015 switch (sysctl_tcp_frto_response) {
@@ -3069,6 +3065,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3069 } 3065 }
3070 3066
3071 prior_fackets = tp->fackets_out; 3067 prior_fackets = tp->fackets_out;
3068 prior_in_flight = tcp_packets_in_flight(tp);
3072 3069
3073 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) { 3070 if (!(flag&FLAG_SLOWPATH) && after(ack, prior_snd_una)) {
3074 /* Window is constant, pure forward advance. 3071 /* Window is constant, pure forward advance.
@@ -3108,8 +3105,6 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
3108 if (!prior_packets) 3105 if (!prior_packets)
3109 goto no_queue; 3106 goto no_queue;
3110 3107
3111 prior_in_flight = tcp_packets_in_flight(tp);
3112
3113 /* See if we can take anything off of the retransmit queue. */ 3108 /* See if we can take anything off of the retransmit queue. */
3114 flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets); 3109 flag |= tcp_clean_rtx_queue(sk, &seq_rtt, prior_fackets);
3115 3110
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e5130a7fe181..f4c1eef89af0 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1162,8 +1162,7 @@ int tcp_may_send_now(struct sock *sk)
1162 return (skb && 1162 return (skb &&
1163 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1), 1163 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1),
1164 (tcp_skb_is_last(sk, skb) ? 1164 (tcp_skb_is_last(sk, skb) ?
1165 TCP_NAGLE_PUSH : 1165 tp->nonagle : TCP_NAGLE_PUSH)));
1166 tp->nonagle)));
1167} 1166}
1168 1167
1169/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet 1168/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet