aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/Kconfig4
-rw-r--r--net/ipv4/devinet.c8
-rw-r--r--net/ipv4/multipath_random.c18
-rw-r--r--net/ipv4/multipath_wrandom.c15
-rw-r--r--net/ipv4/tcp.c24
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c1
-rw-r--r--net/ipv4/xfrm4_policy.c2
7 files changed, 25 insertions, 47 deletions
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 91f3a5cdbcf8..9e8ef509c51d 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -442,7 +442,7 @@ config INET_DIAG
442 ---help--- 442 ---help---
443 Support for INET (TCP, DCCP, etc) socket monitoring interface used by 443 Support for INET (TCP, DCCP, etc) socket monitoring interface used by
444 native Linux tools such as ss. ss is included in iproute2, currently 444 native Linux tools such as ss. ss is included in iproute2, currently
445 downloadable at <http://developer.osdl.org/dev/iproute2>. 445 downloadable at <http://linux-net.osdl.org/index.php/Iproute2>.
446 446
447 If unsure, say Y. 447 If unsure, say Y.
448 448
@@ -550,7 +550,7 @@ config TCP_CONG_SCALABLE
550 Scalable TCP is a sender-side only change to TCP which uses a 550 Scalable TCP is a sender-side only change to TCP which uses a
551 MIMD congestion control algorithm which has some nice scaling 551 MIMD congestion control algorithm which has some nice scaling
552 properties, though is known to have fairness issues. 552 properties, though is known to have fairness issues.
553 See http://www-lce.eng.cam.ac.uk/~ctk21/scalable/ 553 See http://www.deneholme.net/tom/scalable/
554 554
555config TCP_CONG_LP 555config TCP_CONG_LP
556 tristate "TCP Low Priority" 556 tristate "TCP Low Priority"
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8a0ec10a13a7..e10794dc5f64 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1054,12 +1054,14 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
1054 ASSERT_RTNL(); 1054 ASSERT_RTNL();
1055 1055
1056 if (!in_dev) { 1056 if (!in_dev) {
1057 if (event == NETDEV_REGISTER && dev == &loopback_dev) { 1057 if (event == NETDEV_REGISTER) {
1058 in_dev = inetdev_init(dev); 1058 in_dev = inetdev_init(dev);
1059 if (!in_dev) 1059 if (!in_dev)
1060 panic("devinet: Failed to create loopback\n"); 1060 panic("devinet: Failed to create loopback\n");
1061 in_dev->cnf.no_xfrm = 1; 1061 if (dev == &loopback_dev) {
1062 in_dev->cnf.no_policy = 1; 1062 in_dev->cnf.no_xfrm = 1;
1063 in_dev->cnf.no_policy = 1;
1064 }
1063 } 1065 }
1064 goto out; 1066 goto out;
1065 } 1067 }
diff --git a/net/ipv4/multipath_random.c b/net/ipv4/multipath_random.c
index 57f481498fbb..c312785d14d0 100644
--- a/net/ipv4/multipath_random.c
+++ b/net/ipv4/multipath_random.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/mroute.h> 33#include <linux/mroute.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/random.h>
35#include <net/ip.h> 36#include <net/ip.h>
36#include <net/protocol.h> 37#include <net/protocol.h>
37#include <linux/skbuff.h> 38#include <linux/skbuff.h>
@@ -48,21 +49,6 @@
48 49
49#define MULTIPATH_MAX_CANDIDATES 40 50#define MULTIPATH_MAX_CANDIDATES 40
50 51
51/* interface to random number generation */
52static unsigned int RANDOM_SEED = 93186752;
53
54static inline unsigned int random(unsigned int ubound)
55{
56 static unsigned int a = 1588635695,
57 q = 2,
58 r = 1117695901;
59
60 RANDOM_SEED = a*(RANDOM_SEED % q) - r*(RANDOM_SEED / q);
61
62 return RANDOM_SEED % ubound;
63}
64
65
66static void random_select_route(const struct flowi *flp, 52static void random_select_route(const struct flowi *flp,
67 struct rtable *first, 53 struct rtable *first,
68 struct rtable **rp) 54 struct rtable **rp)
@@ -84,7 +70,7 @@ static void random_select_route(const struct flowi *flp,
84 if (candidate_count > 1) { 70 if (candidate_count > 1) {
85 unsigned char i = 0; 71 unsigned char i = 0;
86 unsigned char candidate_no = (unsigned char) 72 unsigned char candidate_no = (unsigned char)
87 random(candidate_count); 73 (random32() % candidate_count);
88 74
89 /* find chosen candidate and adjust GC data for all candidates 75 /* find chosen candidate and adjust GC data for all candidates
90 * to ensure they stay in cache 76 * to ensure they stay in cache
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index 2bdbb92b450a..57c503694539 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/mroute.h> 33#include <linux/mroute.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/random.h>
35#include <net/ip.h> 36#include <net/ip.h>
36#include <net/protocol.h> 37#include <net/protocol.h>
37#include <linux/skbuff.h> 38#include <linux/skbuff.h>
@@ -84,18 +85,6 @@ struct multipath_route {
84/* state: primarily weight per route information */ 85/* state: primarily weight per route information */
85static struct multipath_bucket state[MULTIPATH_STATE_SIZE]; 86static struct multipath_bucket state[MULTIPATH_STATE_SIZE];
86 87
87/* interface to random number generation */
88static unsigned int RANDOM_SEED = 93186752;
89
90static inline unsigned int random(unsigned int ubound)
91{
92 static unsigned int a = 1588635695,
93 q = 2,
94 r = 1117695901;
95 RANDOM_SEED = a*(RANDOM_SEED % q) - r*(RANDOM_SEED / q);
96 return RANDOM_SEED % ubound;
97}
98
99static unsigned char __multipath_lookup_weight(const struct flowi *fl, 88static unsigned char __multipath_lookup_weight(const struct flowi *fl,
100 const struct rtable *rt) 89 const struct rtable *rt)
101{ 90{
@@ -193,7 +182,7 @@ static void wrandom_select_route(const struct flowi *flp,
193 182
194 /* choose a weighted random candidate */ 183 /* choose a weighted random candidate */
195 decision = first; 184 decision = first;
196 selector = random(power); 185 selector = random32() % power;
197 last_power = 0; 186 last_power = 0;
198 187
199 /* select candidate, adjust GC data and cleanup local state */ 188 /* select candidate, adjust GC data and cleanup local state */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index ac6516c642a1..74c4d103ebc2 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2266,12 +2266,12 @@ void tcp_free_md5sig_pool(void)
2266{ 2266{
2267 struct tcp_md5sig_pool **pool = NULL; 2267 struct tcp_md5sig_pool **pool = NULL;
2268 2268
2269 spin_lock(&tcp_md5sig_pool_lock); 2269 spin_lock_bh(&tcp_md5sig_pool_lock);
2270 if (--tcp_md5sig_users == 0) { 2270 if (--tcp_md5sig_users == 0) {
2271 pool = tcp_md5sig_pool; 2271 pool = tcp_md5sig_pool;
2272 tcp_md5sig_pool = NULL; 2272 tcp_md5sig_pool = NULL;
2273 } 2273 }
2274 spin_unlock(&tcp_md5sig_pool_lock); 2274 spin_unlock_bh(&tcp_md5sig_pool_lock);
2275 if (pool) 2275 if (pool)
2276 __tcp_free_md5sig_pool(pool); 2276 __tcp_free_md5sig_pool(pool);
2277} 2277}
@@ -2314,36 +2314,36 @@ struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void)
2314 int alloc = 0; 2314 int alloc = 0;
2315 2315
2316retry: 2316retry:
2317 spin_lock(&tcp_md5sig_pool_lock); 2317 spin_lock_bh(&tcp_md5sig_pool_lock);
2318 pool = tcp_md5sig_pool; 2318 pool = tcp_md5sig_pool;
2319 if (tcp_md5sig_users++ == 0) { 2319 if (tcp_md5sig_users++ == 0) {
2320 alloc = 1; 2320 alloc = 1;
2321 spin_unlock(&tcp_md5sig_pool_lock); 2321 spin_unlock_bh(&tcp_md5sig_pool_lock);
2322 } else if (!pool) { 2322 } else if (!pool) {
2323 tcp_md5sig_users--; 2323 tcp_md5sig_users--;
2324 spin_unlock(&tcp_md5sig_pool_lock); 2324 spin_unlock_bh(&tcp_md5sig_pool_lock);
2325 cpu_relax(); 2325 cpu_relax();
2326 goto retry; 2326 goto retry;
2327 } else 2327 } else
2328 spin_unlock(&tcp_md5sig_pool_lock); 2328 spin_unlock_bh(&tcp_md5sig_pool_lock);
2329 2329
2330 if (alloc) { 2330 if (alloc) {
2331 /* we cannot hold spinlock here because this may sleep. */ 2331 /* we cannot hold spinlock here because this may sleep. */
2332 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool(); 2332 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool();
2333 spin_lock(&tcp_md5sig_pool_lock); 2333 spin_lock_bh(&tcp_md5sig_pool_lock);
2334 if (!p) { 2334 if (!p) {
2335 tcp_md5sig_users--; 2335 tcp_md5sig_users--;
2336 spin_unlock(&tcp_md5sig_pool_lock); 2336 spin_unlock_bh(&tcp_md5sig_pool_lock);
2337 return NULL; 2337 return NULL;
2338 } 2338 }
2339 pool = tcp_md5sig_pool; 2339 pool = tcp_md5sig_pool;
2340 if (pool) { 2340 if (pool) {
2341 /* oops, it has already been assigned. */ 2341 /* oops, it has already been assigned. */
2342 spin_unlock(&tcp_md5sig_pool_lock); 2342 spin_unlock_bh(&tcp_md5sig_pool_lock);
2343 __tcp_free_md5sig_pool(p); 2343 __tcp_free_md5sig_pool(p);
2344 } else { 2344 } else {
2345 tcp_md5sig_pool = pool = p; 2345 tcp_md5sig_pool = pool = p;
2346 spin_unlock(&tcp_md5sig_pool_lock); 2346 spin_unlock_bh(&tcp_md5sig_pool_lock);
2347 } 2347 }
2348 } 2348 }
2349 return pool; 2349 return pool;
@@ -2354,11 +2354,11 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2354struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu) 2354struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
2355{ 2355{
2356 struct tcp_md5sig_pool **p; 2356 struct tcp_md5sig_pool **p;
2357 spin_lock(&tcp_md5sig_pool_lock); 2357 spin_lock_bh(&tcp_md5sig_pool_lock);
2358 p = tcp_md5sig_pool; 2358 p = tcp_md5sig_pool;
2359 if (p) 2359 if (p)
2360 tcp_md5sig_users++; 2360 tcp_md5sig_users++;
2361 spin_unlock(&tcp_md5sig_pool_lock); 2361 spin_unlock_bh(&tcp_md5sig_pool_lock);
2362 return (p ? *per_cpu_ptr(p, cpu) : NULL); 2362 return (p ? *per_cpu_ptr(p, cpu) : NULL);
2363} 2363}
2364 2364
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index e1cab33fdad1..ceb4376f572a 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -111,6 +111,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
111 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) 111 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
112 goto out; 112 goto out;
113 113
114 iph = skb->nh.iph;
114 if (iph->protocol == IPPROTO_IPIP) { 115 if (iph->protocol == IPPROTO_IPIP) {
115 if (x->props.flags & XFRM_STATE_DECAP_DSCP) 116 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
116 ipv4_copy_dscp(iph, skb->h.ipiph); 117 ipv4_copy_dscp(iph, skb->h.ipiph);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index fef19c6bcb98..5d51a2af34c1 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -291,7 +291,7 @@ static void xfrm4_dst_destroy(struct dst_entry *dst)
291 291
292 if (likely(xdst->u.rt.idev)) 292 if (likely(xdst->u.rt.idev))
293 in_dev_put(xdst->u.rt.idev); 293 in_dev_put(xdst->u.rt.idev);
294 if (dst->xfrm->props.family == AF_INET && likely(xdst->u.rt.peer)) 294 if (dst->xfrm && dst->xfrm->props.family == AF_INET && likely(xdst->u.rt.peer))
295 inet_putpeer(xdst->u.rt.peer); 295 inet_putpeer(xdst->u.rt.peer);
296 xfrm_dst_destroy(xdst); 296 xfrm_dst_destroy(xdst);
297} 297}