aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-28 18:42:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-28 18:42:44 -0400
commit29cfcddc0e745b515ec360ffe2ee4e7a4015efd8 (patch)
tree1682b6caaf84d4863e65b2e4e387afa6a972146f
parent303fd2c2ce5addef1aacac962a5b099cc0af71ea (diff)
parentc34186ed008229e7f7e3f1de8e6acf6374995358 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: net/ipv4: Eliminate kstrdup memory leak net/caif/cfrfml.c: use asm/unaligned.h ax25: missplaced sock_put(sk) qlge: reset the chip before freeing the buffers l2tp: test for ethernet header in l2tp_eth_dev_recv() tcp: select(writefds) don't hang up when a peer close connection tcp: fix three tcp sysctls tuning tcp: Combat per-cpu skew in orphan tests. pxa168_eth: silence gcc warnings pxa168_eth: update call to phy_mii_ioctl() pxa168_eth: fix error handling in prope pxa168_eth: remove unneeded null check phylib: Fix race between returning phydev and calling adjust_link caif-driver: add HAS_DMA dependency 3c59x: Fix deadlock between boomerang_interrupt and boomerang_start_tx qlcnic: fix poll implementation netxen: fix poll implementation bridge: netfilter: fix a memory leak
-rw-r--r--drivers/net/3c59x.c15
-rw-r--r--drivers/net/caif/Kconfig2
-rw-r--r--drivers/net/netxen/netxen_nic_main.c9
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/pxa168_eth.c58
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c9
-rw-r--r--drivers/net/qlge/qlge_main.c4
-rw-r--r--include/net/tcp.h18
-rw-r--r--net/ax25/ax25_ds_timer.c2
-rw-r--r--net/bridge/br_netfilter.c2
-rw-r--r--net/caif/cfrfml.c2
-rw-r--r--net/ipv4/tcp.c32
-rw-r--r--net/ipv4/tcp_cong.c5
-rw-r--r--net/ipv4/tcp_timer.c8
-rw-r--r--net/l2tp/l2tp_eth.c2
15 files changed, 98 insertions, 72 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index c754d88e5ec9..c685a55fc2f4 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -633,7 +633,8 @@ struct vortex_private {
633 open:1, 633 open:1,
634 medialock:1, 634 medialock:1,
635 must_free_region:1, /* Flag: if zero, Cardbus owns the I/O region */ 635 must_free_region:1, /* Flag: if zero, Cardbus owns the I/O region */
636 large_frames:1; /* accept large frames */ 636 large_frames:1, /* accept large frames */
637 handling_irq:1; /* private in_irq indicator */
637 int drv_flags; 638 int drv_flags;
638 u16 status_enable; 639 u16 status_enable;
639 u16 intr_enable; 640 u16 intr_enable;
@@ -2133,6 +2134,15 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)
2133 dev->name, vp->cur_tx); 2134 dev->name, vp->cur_tx);
2134 } 2135 }
2135 2136
2137 /*
2138 * We can't allow a recursion from our interrupt handler back into the
2139 * tx routine, as they take the same spin lock, and that causes
2140 * deadlock. Just return NETDEV_TX_BUSY and let the stack try again in
2141 * a bit
2142 */
2143 if (vp->handling_irq)
2144 return NETDEV_TX_BUSY;
2145
2136 if (vp->cur_tx - vp->dirty_tx >= TX_RING_SIZE) { 2146 if (vp->cur_tx - vp->dirty_tx >= TX_RING_SIZE) {
2137 if (vortex_debug > 0) 2147 if (vortex_debug > 0)
2138 pr_warning("%s: BUG! Tx Ring full, refusing to send buffer.\n", 2148 pr_warning("%s: BUG! Tx Ring full, refusing to send buffer.\n",
@@ -2335,11 +2345,13 @@ boomerang_interrupt(int irq, void *dev_id)
2335 2345
2336 ioaddr = vp->ioaddr; 2346 ioaddr = vp->ioaddr;
2337 2347
2348
2338 /* 2349 /*
2339 * It seems dopey to put the spinlock this early, but we could race against vortex_tx_timeout 2350 * It seems dopey to put the spinlock this early, but we could race against vortex_tx_timeout
2340 * and boomerang_start_xmit 2351 * and boomerang_start_xmit
2341 */ 2352 */
2342 spin_lock(&vp->lock); 2353 spin_lock(&vp->lock);
2354 vp->handling_irq = 1;
2343 2355
2344 status = ioread16(ioaddr + EL3_STATUS); 2356 status = ioread16(ioaddr + EL3_STATUS);
2345 2357
@@ -2447,6 +2459,7 @@ boomerang_interrupt(int irq, void *dev_id)
2447 pr_debug("%s: exiting interrupt, status %4.4x.\n", 2459 pr_debug("%s: exiting interrupt, status %4.4x.\n",
2448 dev->name, status); 2460 dev->name, status);
2449handler_exit: 2461handler_exit:
2462 vp->handling_irq = 0;
2450 spin_unlock(&vp->lock); 2463 spin_unlock(&vp->lock);
2451 return IRQ_HANDLED; 2464 return IRQ_HANDLED;
2452} 2465}
diff --git a/drivers/net/caif/Kconfig b/drivers/net/caif/Kconfig
index 631a6242b011..75bfc3a9d95f 100644
--- a/drivers/net/caif/Kconfig
+++ b/drivers/net/caif/Kconfig
@@ -15,7 +15,7 @@ config CAIF_TTY
15 15
16config CAIF_SPI_SLAVE 16config CAIF_SPI_SLAVE
17 tristate "CAIF SPI transport driver for slave interface" 17 tristate "CAIF SPI transport driver for slave interface"
18 depends on CAIF 18 depends on CAIF && HAS_DMA
19 default n 19 default n
20 ---help--- 20 ---help---
21 The CAIF Link layer SPI Protocol driver for Slave SPI interface. 21 The CAIF Link layer SPI Protocol driver for Slave SPI interface.
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index cb30df106a2c..73d314592230 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -2131,9 +2131,16 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget)
2131#ifdef CONFIG_NET_POLL_CONTROLLER 2131#ifdef CONFIG_NET_POLL_CONTROLLER
2132static void netxen_nic_poll_controller(struct net_device *netdev) 2132static void netxen_nic_poll_controller(struct net_device *netdev)
2133{ 2133{
2134 int ring;
2135 struct nx_host_sds_ring *sds_ring;
2134 struct netxen_adapter *adapter = netdev_priv(netdev); 2136 struct netxen_adapter *adapter = netdev_priv(netdev);
2137 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
2138
2135 disable_irq(adapter->irq); 2139 disable_irq(adapter->irq);
2136 netxen_intr(adapter->irq, adapter); 2140 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
2141 sds_ring = &recv_ctx->sds_rings[ring];
2142 netxen_intr(adapter->irq, sds_ring);
2143 }
2137 enable_irq(adapter->irq); 2144 enable_irq(adapter->irq);
2138} 2145}
2139#endif 2146#endif
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c0761197c07e..16ddc77313cb 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -466,6 +466,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
466 466
467 phydev->interface = interface; 467 phydev->interface = interface;
468 468
469 phydev->state = PHY_READY;
470
469 /* Do initial configuration here, now that 471 /* Do initial configuration here, now that
470 * we have certain key parameters 472 * we have certain key parameters
471 * (dev_flags and interface) */ 473 * (dev_flags and interface) */
diff --git a/drivers/net/pxa168_eth.c b/drivers/net/pxa168_eth.c
index ecc64d750cce..410ea0a61371 100644
--- a/drivers/net/pxa168_eth.c
+++ b/drivers/net/pxa168_eth.c
@@ -654,15 +654,15 @@ static void eth_port_start(struct net_device *dev)
654 /* Assignment of Tx CTRP of given queue */ 654 /* Assignment of Tx CTRP of given queue */
655 tx_curr_desc = pep->tx_curr_desc_q; 655 tx_curr_desc = pep->tx_curr_desc_q;
656 wrl(pep, ETH_C_TX_DESC_1, 656 wrl(pep, ETH_C_TX_DESC_1,
657 (u32) ((struct tx_desc *)pep->tx_desc_dma + tx_curr_desc)); 657 (u32) (pep->tx_desc_dma + tx_curr_desc * sizeof(struct tx_desc)));
658 658
659 /* Assignment of Rx CRDP of given queue */ 659 /* Assignment of Rx CRDP of given queue */
660 rx_curr_desc = pep->rx_curr_desc_q; 660 rx_curr_desc = pep->rx_curr_desc_q;
661 wrl(pep, ETH_C_RX_DESC_0, 661 wrl(pep, ETH_C_RX_DESC_0,
662 (u32) ((struct rx_desc *)pep->rx_desc_dma + rx_curr_desc)); 662 (u32) (pep->rx_desc_dma + rx_curr_desc * sizeof(struct rx_desc)));
663 663
664 wrl(pep, ETH_F_RX_DESC_0, 664 wrl(pep, ETH_F_RX_DESC_0,
665 (u32) ((struct rx_desc *)pep->rx_desc_dma + rx_curr_desc)); 665 (u32) (pep->rx_desc_dma + rx_curr_desc * sizeof(struct rx_desc)));
666 666
667 /* Clear all interrupts */ 667 /* Clear all interrupts */
668 wrl(pep, INT_CAUSE, 0); 668 wrl(pep, INT_CAUSE, 0);
@@ -1350,7 +1350,7 @@ static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr,
1350{ 1350{
1351 struct pxa168_eth_private *pep = netdev_priv(dev); 1351 struct pxa168_eth_private *pep = netdev_priv(dev);
1352 if (pep->phy != NULL) 1352 if (pep->phy != NULL)
1353 return phy_mii_ioctl(pep->phy, if_mii(ifr), cmd); 1353 return phy_mii_ioctl(pep->phy, ifr, cmd);
1354 1354
1355 return -EOPNOTSUPP; 1355 return -EOPNOTSUPP;
1356} 1356}
@@ -1414,10 +1414,8 @@ static int ethernet_phy_setup(struct net_device *dev)
1414{ 1414{
1415 struct pxa168_eth_private *pep = netdev_priv(dev); 1415 struct pxa168_eth_private *pep = netdev_priv(dev);
1416 1416
1417 if (pep->pd != NULL) { 1417 if (pep->pd->init)
1418 if (pep->pd->init) 1418 pep->pd->init();
1419 pep->pd->init();
1420 }
1421 pep->phy = phy_scan(pep, pep->pd->phy_addr & 0x1f); 1419 pep->phy = phy_scan(pep, pep->pd->phy_addr & 0x1f);
1422 if (pep->phy != NULL) 1420 if (pep->phy != NULL)
1423 phy_init(pep, pep->pd->speed, pep->pd->duplex); 1421 phy_init(pep, pep->pd->speed, pep->pd->duplex);
@@ -1499,7 +1497,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1499 dev = alloc_etherdev(sizeof(struct pxa168_eth_private)); 1497 dev = alloc_etherdev(sizeof(struct pxa168_eth_private));
1500 if (!dev) { 1498 if (!dev) {
1501 err = -ENOMEM; 1499 err = -ENOMEM;
1502 goto out; 1500 goto err_clk;
1503 } 1501 }
1504 1502
1505 platform_set_drvdata(pdev, dev); 1503 platform_set_drvdata(pdev, dev);
@@ -1509,12 +1507,12 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1509 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1507 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1510 if (res == NULL) { 1508 if (res == NULL) {
1511 err = -ENODEV; 1509 err = -ENODEV;
1512 goto out; 1510 goto err_netdev;
1513 } 1511 }
1514 pep->base = ioremap(res->start, res->end - res->start + 1); 1512 pep->base = ioremap(res->start, res->end - res->start + 1);
1515 if (pep->base == NULL) { 1513 if (pep->base == NULL) {
1516 err = -ENOMEM; 1514 err = -ENOMEM;
1517 goto out; 1515 goto err_netdev;
1518 } 1516 }
1519 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1517 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1520 BUG_ON(!res); 1518 BUG_ON(!res);
@@ -1551,7 +1549,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1551 pep->smi_bus = mdiobus_alloc(); 1549 pep->smi_bus = mdiobus_alloc();
1552 if (pep->smi_bus == NULL) { 1550 if (pep->smi_bus == NULL) {
1553 err = -ENOMEM; 1551 err = -ENOMEM;
1554 goto out; 1552 goto err_base;
1555 } 1553 }
1556 pep->smi_bus->priv = pep; 1554 pep->smi_bus->priv = pep;
1557 pep->smi_bus->name = "pxa168_eth smi"; 1555 pep->smi_bus->name = "pxa168_eth smi";
@@ -1560,31 +1558,31 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1560 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id); 1558 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id);
1561 pep->smi_bus->parent = &pdev->dev; 1559 pep->smi_bus->parent = &pdev->dev;
1562 pep->smi_bus->phy_mask = 0xffffffff; 1560 pep->smi_bus->phy_mask = 0xffffffff;
1563 if (mdiobus_register(pep->smi_bus) < 0) { 1561 err = mdiobus_register(pep->smi_bus);
1564 err = -ENOMEM; 1562 if (err)
1565 goto out; 1563 goto err_free_mdio;
1566 } 1564
1567 pxa168_init_hw(pep); 1565 pxa168_init_hw(pep);
1568 err = ethernet_phy_setup(dev); 1566 err = ethernet_phy_setup(dev);
1569 if (err) 1567 if (err)
1570 goto out; 1568 goto err_mdiobus;
1571 SET_NETDEV_DEV(dev, &pdev->dev); 1569 SET_NETDEV_DEV(dev, &pdev->dev);
1572 err = register_netdev(dev); 1570 err = register_netdev(dev);
1573 if (err) 1571 if (err)
1574 goto out; 1572 goto err_mdiobus;
1575 return 0; 1573 return 0;
1576out: 1574
1577 if (pep->clk) { 1575err_mdiobus:
1578 clk_disable(pep->clk); 1576 mdiobus_unregister(pep->smi_bus);
1579 clk_put(pep->clk); 1577err_free_mdio:
1580 pep->clk = NULL; 1578 mdiobus_free(pep->smi_bus);
1581 } 1579err_base:
1582 if (pep->base) { 1580 iounmap(pep->base);
1583 iounmap(pep->base); 1581err_netdev:
1584 pep->base = NULL; 1582 free_netdev(dev);
1585 } 1583err_clk:
1586 if (dev) 1584 clk_disable(clk);
1587 free_netdev(dev); 1585 clk_put(clk);
1588 return err; 1586 return err;
1589} 1587}
1590 1588
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 213e3656d953..66eea5972020 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -2188,9 +2188,16 @@ static int qlcnic_rx_poll(struct napi_struct *napi, int budget)
2188#ifdef CONFIG_NET_POLL_CONTROLLER 2188#ifdef CONFIG_NET_POLL_CONTROLLER
2189static void qlcnic_poll_controller(struct net_device *netdev) 2189static void qlcnic_poll_controller(struct net_device *netdev)
2190{ 2190{
2191 int ring;
2192 struct qlcnic_host_sds_ring *sds_ring;
2191 struct qlcnic_adapter *adapter = netdev_priv(netdev); 2193 struct qlcnic_adapter *adapter = netdev_priv(netdev);
2194 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx;
2195
2192 disable_irq(adapter->irq); 2196 disable_irq(adapter->irq);
2193 qlcnic_intr(adapter->irq, adapter); 2197 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
2198 sds_ring = &recv_ctx->sds_rings[ring];
2199 qlcnic_intr(adapter->irq, sds_ring);
2200 }
2194 enable_irq(adapter->irq); 2201 enable_irq(adapter->irq);
2195} 2202}
2196#endif 2203#endif
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 8d63f69b27d9..5f89e83501f4 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -3919,12 +3919,12 @@ static int ql_adapter_down(struct ql_adapter *qdev)
3919 for (i = 0; i < qdev->rss_ring_count; i++) 3919 for (i = 0; i < qdev->rss_ring_count; i++)
3920 netif_napi_del(&qdev->rx_ring[i].napi); 3920 netif_napi_del(&qdev->rx_ring[i].napi);
3921 3921
3922 ql_free_rx_buffers(qdev);
3923
3924 status = ql_adapter_reset(qdev); 3922 status = ql_adapter_reset(qdev);
3925 if (status) 3923 if (status)
3926 netif_err(qdev, ifdown, qdev->ndev, "reset(func #%d) FAILED!\n", 3924 netif_err(qdev, ifdown, qdev->ndev, "reset(func #%d) FAILED!\n",
3927 qdev->func); 3925 qdev->func);
3926 ql_free_rx_buffers(qdev);
3927
3928 return status; 3928 return status;
3929} 3929}
3930 3930
diff --git a/include/net/tcp.h b/include/net/tcp.h
index df6a2eb20193..eaa9582779d0 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -268,11 +268,21 @@ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3)
268 return seq3 - seq2 >= seq1 - seq2; 268 return seq3 - seq2 >= seq1 - seq2;
269} 269}
270 270
271static inline int tcp_too_many_orphans(struct sock *sk, int num) 271static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
272{ 272{
273 return (num > sysctl_tcp_max_orphans) || 273 struct percpu_counter *ocp = sk->sk_prot->orphan_count;
274 (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && 274 int orphans = percpu_counter_read_positive(ocp);
275 atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]); 275
276 if (orphans << shift > sysctl_tcp_max_orphans) {
277 orphans = percpu_counter_sum_positive(ocp);
278 if (orphans << shift > sysctl_tcp_max_orphans)
279 return true;
280 }
281
282 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
283 atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2])
284 return true;
285 return false;
276} 286}
277 287
278/* syncookies: remember time of last synqueue overflow */ 288/* syncookies: remember time of last synqueue overflow */
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
index 2ce79df00680..c7d81436213d 100644
--- a/net/ax25/ax25_ds_timer.c
+++ b/net/ax25/ax25_ds_timer.c
@@ -112,8 +112,8 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
112 if (sk) { 112 if (sk) {
113 sock_hold(sk); 113 sock_hold(sk);
114 ax25_destroy_socket(ax25); 114 ax25_destroy_socket(ax25);
115 sock_put(sk);
116 bh_unlock_sock(sk); 115 bh_unlock_sock(sk);
116 sock_put(sk);
117 } else 117 } else
118 ax25_destroy_socket(ax25); 118 ax25_destroy_socket(ax25);
119 return; 119 return;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 2c911c0759c2..5ed00bd7009f 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -162,8 +162,8 @@ static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)
162 if (tmp) { 162 if (tmp) {
163 memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info)); 163 memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));
164 atomic_set(&tmp->use, 1); 164 atomic_set(&tmp->use, 1);
165 nf_bridge_put(nf_bridge);
166 } 165 }
166 nf_bridge_put(nf_bridge);
167 nf_bridge = tmp; 167 nf_bridge = tmp;
168 } 168 }
169 return nf_bridge; 169 return nf_bridge;
diff --git a/net/caif/cfrfml.c b/net/caif/cfrfml.c
index eb1602022ac0..9a699242d104 100644
--- a/net/caif/cfrfml.c
+++ b/net/caif/cfrfml.c
@@ -7,7 +7,7 @@
7#include <linux/stddef.h> 7#include <linux/stddef.h>
8#include <linux/spinlock.h> 8#include <linux/spinlock.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/unaligned/le_byteshift.h> 10#include <asm/unaligned.h>
11#include <net/caif/caif_layer.h> 11#include <net/caif/caif_layer.h>
12#include <net/caif/cfsrvl.h> 12#include <net/caif/cfsrvl.h>
13#include <net/caif/cfpkt.h> 13#include <net/caif/cfpkt.h>
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 176e11aaea77..3fb1428e526e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -451,7 +451,8 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
451 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) 451 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
452 mask |= POLLOUT | POLLWRNORM; 452 mask |= POLLOUT | POLLWRNORM;
453 } 453 }
454 } 454 } else
455 mask |= POLLOUT | POLLWRNORM;
455 456
456 if (tp->urg_data & TCP_URG_VALID) 457 if (tp->urg_data & TCP_URG_VALID)
457 mask |= POLLPRI; 458 mask |= POLLPRI;
@@ -2011,11 +2012,8 @@ adjudge_to_death:
2011 } 2012 }
2012 } 2013 }
2013 if (sk->sk_state != TCP_CLOSE) { 2014 if (sk->sk_state != TCP_CLOSE) {
2014 int orphan_count = percpu_counter_read_positive(
2015 sk->sk_prot->orphan_count);
2016
2017 sk_mem_reclaim(sk); 2015 sk_mem_reclaim(sk);
2018 if (tcp_too_many_orphans(sk, orphan_count)) { 2016 if (tcp_too_many_orphans(sk, 0)) {
2019 if (net_ratelimit()) 2017 if (net_ratelimit())
2020 printk(KERN_INFO "TCP: too many of orphaned " 2018 printk(KERN_INFO "TCP: too many of orphaned "
2021 "sockets\n"); 2019 "sockets\n");
@@ -3212,7 +3210,7 @@ void __init tcp_init(void)
3212{ 3210{
3213 struct sk_buff *skb = NULL; 3211 struct sk_buff *skb = NULL;
3214 unsigned long nr_pages, limit; 3212 unsigned long nr_pages, limit;
3215 int order, i, max_share; 3213 int i, max_share, cnt;
3216 unsigned long jiffy = jiffies; 3214 unsigned long jiffy = jiffies;
3217 3215
3218 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); 3216 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));
@@ -3261,22 +3259,12 @@ void __init tcp_init(void)
3261 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); 3259 INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);
3262 } 3260 }
3263 3261
3264 /* Try to be a bit smarter and adjust defaults depending 3262
3265 * on available memory. 3263 cnt = tcp_hashinfo.ehash_mask + 1;
3266 */ 3264
3267 for (order = 0; ((1 << order) << PAGE_SHIFT) < 3265 tcp_death_row.sysctl_max_tw_buckets = cnt / 2;
3268 (tcp_hashinfo.bhash_size * sizeof(struct inet_bind_hashbucket)); 3266 sysctl_tcp_max_orphans = cnt / 2;
3269 order++) 3267 sysctl_max_syn_backlog = max(128, cnt / 256);
3270 ;
3271 if (order >= 4) {
3272 tcp_death_row.sysctl_max_tw_buckets = 180000;
3273 sysctl_tcp_max_orphans = 4096 << (order - 4);
3274 sysctl_max_syn_backlog = 1024;
3275 } else if (order < 3) {
3276 tcp_death_row.sysctl_max_tw_buckets >>= (3 - order);
3277 sysctl_tcp_max_orphans >>= (3 - order);
3278 sysctl_max_syn_backlog = 128;
3279 }
3280 3268
3281 /* Set the pressure threshold to be a fraction of global memory that 3269 /* Set the pressure threshold to be a fraction of global memory that
3282 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of 3270 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 0ec9bd0ae94f..850c737e08e2 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -196,10 +196,10 @@ void tcp_get_allowed_congestion_control(char *buf, size_t maxlen)
196int tcp_set_allowed_congestion_control(char *val) 196int tcp_set_allowed_congestion_control(char *val)
197{ 197{
198 struct tcp_congestion_ops *ca; 198 struct tcp_congestion_ops *ca;
199 char *clone, *name; 199 char *saved_clone, *clone, *name;
200 int ret = 0; 200 int ret = 0;
201 201
202 clone = kstrdup(val, GFP_USER); 202 saved_clone = clone = kstrdup(val, GFP_USER);
203 if (!clone) 203 if (!clone)
204 return -ENOMEM; 204 return -ENOMEM;
205 205
@@ -226,6 +226,7 @@ int tcp_set_allowed_congestion_control(char *val)
226 } 226 }
227out: 227out:
228 spin_unlock(&tcp_cong_list_lock); 228 spin_unlock(&tcp_cong_list_lock);
229 kfree(saved_clone);
229 230
230 return ret; 231 return ret;
231} 232}
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 808bb920c9f5..c35b469e851c 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -66,18 +66,18 @@ static void tcp_write_err(struct sock *sk)
66static int tcp_out_of_resources(struct sock *sk, int do_reset) 66static int tcp_out_of_resources(struct sock *sk, int do_reset)
67{ 67{
68 struct tcp_sock *tp = tcp_sk(sk); 68 struct tcp_sock *tp = tcp_sk(sk);
69 int orphans = percpu_counter_read_positive(&tcp_orphan_count); 69 int shift = 0;
70 70
71 /* If peer does not open window for long time, or did not transmit 71 /* If peer does not open window for long time, or did not transmit
72 * anything for long time, penalize it. */ 72 * anything for long time, penalize it. */
73 if ((s32)(tcp_time_stamp - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset) 73 if ((s32)(tcp_time_stamp - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset)
74 orphans <<= 1; 74 shift++;
75 75
76 /* If some dubious ICMP arrived, penalize even more. */ 76 /* If some dubious ICMP arrived, penalize even more. */
77 if (sk->sk_err_soft) 77 if (sk->sk_err_soft)
78 orphans <<= 1; 78 shift++;
79 79
80 if (tcp_too_many_orphans(sk, orphans)) { 80 if (tcp_too_many_orphans(sk, shift)) {
81 if (net_ratelimit()) 81 if (net_ratelimit())
82 printk(KERN_INFO "Out of socket memory\n"); 82 printk(KERN_INFO "Out of socket memory\n");
83 83
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 58c6c4cda73b..1ae697681bc7 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -132,7 +132,7 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
132 printk("\n"); 132 printk("\n");
133 } 133 }
134 134
135 if (data_len < ETH_HLEN) 135 if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
136 goto error; 136 goto error;
137 137
138 secpath_reset(skb); 138 secpath_reset(skb);