aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/icmp.c22
-rw-r--r--net/ipv4/route.c24
-rw-r--r--net/ipv4/tcp_output.c6
3 files changed, 38 insertions, 14 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 860558633b2c..55c355e63234 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -204,18 +204,22 @@ static struct sock *icmp_sk(struct net *net)
204 return net->ipv4.icmp_sk[smp_processor_id()]; 204 return net->ipv4.icmp_sk[smp_processor_id()];
205} 205}
206 206
207static inline int icmp_xmit_lock(struct sock *sk) 207static inline struct sock *icmp_xmit_lock(struct net *net)
208{ 208{
209 struct sock *sk;
210
209 local_bh_disable(); 211 local_bh_disable();
210 212
213 sk = icmp_sk(net);
214
211 if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { 215 if (unlikely(!spin_trylock(&sk->sk_lock.slock))) {
212 /* This can happen if the output path signals a 216 /* This can happen if the output path signals a
213 * dst_link_failure() for an outgoing ICMP packet. 217 * dst_link_failure() for an outgoing ICMP packet.
214 */ 218 */
215 local_bh_enable(); 219 local_bh_enable();
216 return 1; 220 return NULL;
217 } 221 }
218 return 0; 222 return sk;
219} 223}
220 224
221static inline void icmp_xmit_unlock(struct sock *sk) 225static inline void icmp_xmit_unlock(struct sock *sk)
@@ -354,15 +358,17 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
354 struct ipcm_cookie ipc; 358 struct ipcm_cookie ipc;
355 struct rtable *rt = skb->rtable; 359 struct rtable *rt = skb->rtable;
356 struct net *net = dev_net(rt->u.dst.dev); 360 struct net *net = dev_net(rt->u.dst.dev);
357 struct sock *sk = icmp_sk(net); 361 struct sock *sk;
358 struct inet_sock *inet = inet_sk(sk); 362 struct inet_sock *inet;
359 __be32 daddr; 363 __be32 daddr;
360 364
361 if (ip_options_echo(&icmp_param->replyopts, skb)) 365 if (ip_options_echo(&icmp_param->replyopts, skb))
362 return; 366 return;
363 367
364 if (icmp_xmit_lock(sk)) 368 sk = icmp_xmit_lock(net);
369 if (sk == NULL)
365 return; 370 return;
371 inet = inet_sk(sk);
366 372
367 icmp_param->data.icmph.checksum = 0; 373 icmp_param->data.icmph.checksum = 0;
368 374
@@ -419,7 +425,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
419 if (!rt) 425 if (!rt)
420 goto out; 426 goto out;
421 net = dev_net(rt->u.dst.dev); 427 net = dev_net(rt->u.dst.dev);
422 sk = icmp_sk(net);
423 428
424 /* 429 /*
425 * Find the original header. It is expected to be valid, of course. 430 * Find the original header. It is expected to be valid, of course.
@@ -483,7 +488,8 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
483 } 488 }
484 } 489 }
485 490
486 if (icmp_xmit_lock(sk)) 491 sk = icmp_xmit_lock(net);
492 if (sk == NULL)
487 return; 493 return;
488 494
489 /* 495 /*
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 71598f64c113..f62187bb6d08 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3122,14 +3122,23 @@ static ctl_table ipv4_route_table[] = {
3122 { .ctl_name = 0 } 3122 { .ctl_name = 0 }
3123}; 3123};
3124 3124
3125static __net_initdata struct ctl_path ipv4_route_path[] = { 3125static struct ctl_table empty[1];
3126
3127static struct ctl_table ipv4_skeleton[] =
3128{
3129 { .procname = "route", .ctl_name = NET_IPV4_ROUTE,
3130 .mode = 0555, .child = ipv4_route_table},
3131 { .procname = "neigh", .ctl_name = NET_IPV4_NEIGH,
3132 .mode = 0555, .child = empty},
3133 { }
3134};
3135
3136static __net_initdata struct ctl_path ipv4_path[] = {
3126 { .procname = "net", .ctl_name = CTL_NET, }, 3137 { .procname = "net", .ctl_name = CTL_NET, },
3127 { .procname = "ipv4", .ctl_name = NET_IPV4, }, 3138 { .procname = "ipv4", .ctl_name = NET_IPV4, },
3128 { .procname = "route", .ctl_name = NET_IPV4_ROUTE, },
3129 { }, 3139 { },
3130}; 3140};
3131 3141
3132
3133static struct ctl_table ipv4_route_flush_table[] = { 3142static struct ctl_table ipv4_route_flush_table[] = {
3134 { 3143 {
3135 .ctl_name = NET_IPV4_ROUTE_FLUSH, 3144 .ctl_name = NET_IPV4_ROUTE_FLUSH,
@@ -3142,6 +3151,13 @@ static struct ctl_table ipv4_route_flush_table[] = {
3142 { .ctl_name = 0 }, 3151 { .ctl_name = 0 },
3143}; 3152};
3144 3153
3154static __net_initdata struct ctl_path ipv4_route_path[] = {
3155 { .procname = "net", .ctl_name = CTL_NET, },
3156 { .procname = "ipv4", .ctl_name = NET_IPV4, },
3157 { .procname = "route", .ctl_name = NET_IPV4_ROUTE, },
3158 { },
3159};
3160
3145static __net_init int sysctl_route_net_init(struct net *net) 3161static __net_init int sysctl_route_net_init(struct net *net)
3146{ 3162{
3147 struct ctl_table *tbl; 3163 struct ctl_table *tbl;
@@ -3293,7 +3309,7 @@ int __init ip_rt_init(void)
3293 */ 3309 */
3294void __init ip_static_sysctl_init(void) 3310void __init ip_static_sysctl_init(void)
3295{ 3311{
3296 register_sysctl_paths(ipv4_route_path, ipv4_route_table); 3312 register_sysctl_paths(ipv4_path, ipv4_skeleton);
3297} 3313}
3298#endif 3314#endif
3299 3315
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a00532de2a8c..8165f5aa8c71 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -468,7 +468,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
468 } 468 }
469 if (likely(sysctl_tcp_window_scaling)) { 469 if (likely(sysctl_tcp_window_scaling)) {
470 opts->ws = tp->rx_opt.rcv_wscale; 470 opts->ws = tp->rx_opt.rcv_wscale;
471 size += TCPOLEN_WSCALE_ALIGNED; 471 if(likely(opts->ws))
472 size += TCPOLEN_WSCALE_ALIGNED;
472 } 473 }
473 if (likely(sysctl_tcp_sack)) { 474 if (likely(sysctl_tcp_sack)) {
474 opts->options |= OPTION_SACK_ADVERTISE; 475 opts->options |= OPTION_SACK_ADVERTISE;
@@ -509,7 +510,8 @@ static unsigned tcp_synack_options(struct sock *sk,
509 510
510 if (likely(ireq->wscale_ok)) { 511 if (likely(ireq->wscale_ok)) {
511 opts->ws = ireq->rcv_wscale; 512 opts->ws = ireq->rcv_wscale;
512 size += TCPOLEN_WSCALE_ALIGNED; 513 if(likely(opts->ws))
514 size += TCPOLEN_WSCALE_ALIGNED;
513 } 515 }
514 if (likely(doing_ts)) { 516 if (likely(doing_ts)) {
515 opts->options |= OPTION_TS; 517 opts->options |= OPTION_TS;