aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-13 20:57:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-13 20:57:07 -0400
commitb8fa7d410a8f693db75548c843c3bb1db2d5ed1a (patch)
tree4e5fb5e8a98b837af3cfbf2f30aea8f6673438cb
parent69539ab1006f6c55cc5243fa82341bb6e59c07ed (diff)
parent750084b51bc9a7962e7f7c9a29cede0234aed824 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking changes from David Miller: "The most important bit here is the TCP syncookies issue, which seems to have been busted for some time. That fix has been verified in production by the reporter. 1) Persistent TUN devices erroneously hold on to the network namespace in such a way that it cannot be shutdown. Fix from Stanislav Kinsbursky with help from Eric Dumazet. 2) TCP SYN cookies have been broken for a while due to how the route lookup flow key is managed, connections can be delayed by as much as 20 seconds due to this bug. Fix from Eric Dumazet. 3) Missing jiffies.h include in lib/dynamic_queue_limits.c can break the build, from Tom Herbert. 4) Add USB device ID for Sitecom LN-031, from Joerg Neikes. 5) Fix OOPS in delayed workqueue in iwlegacy, from Stanislaw Gruszka. 6) rt2x00 TX queue can be disabled forever due to races, fix by synchronizing pause/unpause with a lock. Also from Stanislaw Gruszka. 7) Statistics and endian fix in bnx2x driver from Yuval Mintz, Eilon Greenstein, and Ariel Elior." * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: tun: don't hold network namespace by tun sockets bnx2x: FCoE statistics id fixed bnx2x: dcb bit indices flags used as bits bnx2x: added cpu_to_le16 when preparing ramrod's data bnx2x: pfc statistics counts pfc events twice rt2x00: fix random stalls iwl3945: fix possible il->txq NULL pointer dereference in delayed works dql: Fix undefined jiffies tcp: fix syncookie regression usb: asix: Patch for Sitecom LN-031
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c8
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c12
-rw-r--r--drivers/net/tun.c15
-rw-r--r--drivers/net/usb/asix.c4
-rw-r--r--drivers/net/wireless/iwlegacy/3945-mac.c2
-rw-r--r--drivers/net/wireless/iwlegacy/3945.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c3
-rw-r--r--lib/dynamic_queue_limits.c1
-rw-r--r--net/ipv4/syncookies.c30
-rw-r--r--net/ipv4/tcp_ipv4.c10
15 files changed, 78 insertions, 45 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 7aee46983be4..99389c8dda21 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1934,7 +1934,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1934 } 1934 }
1935 1935
1936 if (bp->port.pmf) 1936 if (bp->port.pmf)
1937 bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 0); 1937 bnx2x_update_drv_flags(bp, 1 << DRV_FLAGS_DCB_CONFIGURED, 0);
1938 else 1938 else
1939 bnx2x__link_status_update(bp); 1939 bnx2x__link_status_update(bp);
1940 1940
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index bf27c54ff2e0..4f40f7d7d8c6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -1179,10 +1179,16 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp,
1179 */ 1179 */
1180static inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp) 1180static inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp)
1181{ 1181{
1182 if (!CHIP_IS_E1x(fp->bp)) 1182 struct bnx2x *bp = fp->bp;
1183 if (!CHIP_IS_E1x(bp)) {
1184#ifdef BCM_CNIC
1185 /* there are special statistics counters for FCoE 136..140 */
1186 if (IS_FCOE_FP(fp))
1187 return bp->cnic_base_cl_id + (bp->pf_num >> 1);
1188#endif
1183 return fp->cl_id; 1189 return fp->cl_id;
1184 else 1190 }
1185 return fp->cl_id + BP_PORT(fp->bp) * FP_SB_MAX_E1x; 1191 return fp->cl_id + BP_PORT(bp) * FP_SB_MAX_E1x;
1186} 1192}
1187 1193
1188static inline void bnx2x_init_vlan_mac_fp_objs(struct bnx2x_fastpath *fp, 1194static inline void bnx2x_init_vlan_mac_fp_objs(struct bnx2x_fastpath *fp,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
index 5051cf3deb20..6d82ade4c31c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
@@ -735,7 +735,9 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
735 bp->dcbx_error); 735 bp->dcbx_error);
736 736
737 /* mark DCBX result for PMF migration */ 737 /* mark DCBX result for PMF migration */
738 bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 1); 738 bnx2x_update_drv_flags(bp,
739 1 << DRV_FLAGS_DCB_CONFIGURED,
740 1);
739#ifdef BCM_DCBNL 741#ifdef BCM_DCBNL
740 /* 742 /*
741 * Add new app tlvs to dcbnl 743 * Add new app tlvs to dcbnl
@@ -1020,7 +1022,7 @@ void bnx2x_dcbx_init(struct bnx2x *bp)
1020 DP(NETIF_MSG_LINK, "dcbx_lldp_params_offset 0x%x\n", 1022 DP(NETIF_MSG_LINK, "dcbx_lldp_params_offset 0x%x\n",
1021 dcbx_lldp_params_offset); 1023 dcbx_lldp_params_offset);
1022 1024
1023 bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 0); 1025 bnx2x_update_drv_flags(bp, 1 << DRV_FLAGS_DCB_CONFIGURED, 0);
1024 1026
1025 if (SHMEM_LLDP_DCBX_PARAMS_NONE != dcbx_lldp_params_offset) { 1027 if (SHMEM_LLDP_DCBX_PARAMS_NONE != dcbx_lldp_params_offset) {
1026 bnx2x_dcbx_admin_mib_updated_params(bp, 1028 bnx2x_dcbx_admin_mib_updated_params(bp,
@@ -1857,7 +1859,7 @@ void bnx2x_dcbx_pmf_update(struct bnx2x *bp)
1857 * read it from shmem and update bp and netdev accordingly 1859 * read it from shmem and update bp and netdev accordingly
1858 */ 1860 */
1859 if (SHMEM2_HAS(bp, drv_flags) && 1861 if (SHMEM2_HAS(bp, drv_flags) &&
1860 GET_FLAGS(SHMEM2_RD(bp, drv_flags), DRV_FLAGS_DCB_CONFIGURED)) { 1862 GET_FLAGS(SHMEM2_RD(bp, drv_flags), 1 << DRV_FLAGS_DCB_CONFIGURED)) {
1861 /* Read neg results if dcbx is in the FW */ 1863 /* Read neg results if dcbx is in the FW */
1862 if (bnx2x_dcbx_read_shmem_neg_results(bp)) 1864 if (bnx2x_dcbx_read_shmem_neg_results(bp))
1863 return; 1865 return;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index cb6339c35571..94110e9ce51d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -5601,7 +5601,7 @@ static inline int bnx2x_func_send_start(struct bnx2x *bp,
5601 5601
5602 /* Fill the ramrod data with provided parameters */ 5602 /* Fill the ramrod data with provided parameters */
5603 rdata->function_mode = cpu_to_le16(start_params->mf_mode); 5603 rdata->function_mode = cpu_to_le16(start_params->mf_mode);
5604 rdata->sd_vlan_tag = start_params->sd_vlan_tag; 5604 rdata->sd_vlan_tag = cpu_to_le16(start_params->sd_vlan_tag);
5605 rdata->path_id = BP_PATH(bp); 5605 rdata->path_id = BP_PATH(bp);
5606 rdata->network_cos_mode = start_params->network_cos_mode; 5606 rdata->network_cos_mode = start_params->network_cos_mode;
5607 5607
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 1adef266fcd5..a766b25eec5f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -554,23 +554,11 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
554 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl); 554 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
555 555
556 /* collect PFC stats */ 556 /* collect PFC stats */
557 DIFF_64(diff.hi, new->tx_stat_gtpp_hi,
558 pstats->pfc_frames_tx_hi,
559 diff.lo, new->tx_stat_gtpp_lo,
560 pstats->pfc_frames_tx_lo);
561 pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi; 557 pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi;
562 pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo; 558 pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo;
563 ADD_64(pstats->pfc_frames_tx_hi, diff.hi,
564 pstats->pfc_frames_tx_lo, diff.lo);
565 559
566 DIFF_64(diff.hi, new->rx_stat_grpp_hi,
567 pstats->pfc_frames_rx_hi,
568 diff.lo, new->rx_stat_grpp_lo,
569 pstats->pfc_frames_rx_lo);
570 pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi; 560 pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi;
571 pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo; 561 pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo;
572 ADD_64(pstats->pfc_frames_rx_hi, diff.hi,
573 pstats->pfc_frames_rx_lo, diff.lo);
574 } 562 }
575 563
576 estats->pause_frames_received_hi = 564 estats->pause_frames_received_hi =
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 93c5d72711b0..2d7601dd6660 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -359,7 +359,7 @@ static void tun_free_netdev(struct net_device *dev)
359{ 359{
360 struct tun_struct *tun = netdev_priv(dev); 360 struct tun_struct *tun = netdev_priv(dev);
361 361
362 sock_put(tun->socket.sk); 362 sk_release_kernel(tun->socket.sk);
363} 363}
364 364
365/* Net device open. */ 365/* Net device open. */
@@ -980,10 +980,18 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
980 return ret; 980 return ret;
981} 981}
982 982
983static int tun_release(struct socket *sock)
984{
985 if (sock->sk)
986 sock_put(sock->sk);
987 return 0;
988}
989
983/* Ops structure to mimic raw sockets with tun */ 990/* Ops structure to mimic raw sockets with tun */
984static const struct proto_ops tun_socket_ops = { 991static const struct proto_ops tun_socket_ops = {
985 .sendmsg = tun_sendmsg, 992 .sendmsg = tun_sendmsg,
986 .recvmsg = tun_recvmsg, 993 .recvmsg = tun_recvmsg,
994 .release = tun_release,
987}; 995};
988 996
989static struct proto tun_proto = { 997static struct proto tun_proto = {
@@ -1110,10 +1118,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1110 tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); 1118 tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
1111 1119
1112 err = -ENOMEM; 1120 err = -ENOMEM;
1113 sk = sk_alloc(net, AF_UNSPEC, GFP_KERNEL, &tun_proto); 1121 sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto);
1114 if (!sk) 1122 if (!sk)
1115 goto err_free_dev; 1123 goto err_free_dev;
1116 1124
1125 sk_change_net(sk, net);
1117 tun->socket.wq = &tun->wq; 1126 tun->socket.wq = &tun->wq;
1118 init_waitqueue_head(&tun->wq.wait); 1127 init_waitqueue_head(&tun->wq.wait);
1119 tun->socket.ops = &tun_socket_ops; 1128 tun->socket.ops = &tun_socket_ops;
@@ -1174,7 +1183,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1174 return 0; 1183 return 0;
1175 1184
1176 err_free_sk: 1185 err_free_sk:
1177 sock_put(sk); 1186 tun_free_netdev(dev);
1178 err_free_dev: 1187 err_free_dev:
1179 free_netdev(dev); 1188 free_netdev(dev);
1180 failed: 1189 failed:
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 8e84f5bdd6ca..d6da5eed5453 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1599,6 +1599,10 @@ static const struct usb_device_id products [] = {
1599 USB_DEVICE (0x6189, 0x182d), 1599 USB_DEVICE (0x6189, 0x182d),
1600 .driver_info = (unsigned long) &ax8817x_info, 1600 .driver_info = (unsigned long) &ax8817x_info,
1601}, { 1601}, {
1602 // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter"
1603 USB_DEVICE (0x0df6, 0x0056),
1604 .driver_info = (unsigned long) &ax88178_info,
1605}, {
1602 // corega FEther USB2-TX 1606 // corega FEther USB2-TX
1603 USB_DEVICE (0x07aa, 0x0017), 1607 USB_DEVICE (0x07aa, 0x0017),
1604 .driver_info = (unsigned long) &ax8817x_info, 1608 .driver_info = (unsigned long) &ax8817x_info,
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index 54b2d391e91a..a7dfba8d164e 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -2475,7 +2475,7 @@ il3945_bg_alive_start(struct work_struct *data)
2475 container_of(data, struct il_priv, alive_start.work); 2475 container_of(data, struct il_priv, alive_start.work);
2476 2476
2477 mutex_lock(&il->mutex); 2477 mutex_lock(&il->mutex);
2478 if (test_bit(S_EXIT_PENDING, &il->status)) 2478 if (test_bit(S_EXIT_PENDING, &il->status) || il->txq == NULL)
2479 goto out; 2479 goto out;
2480 2480
2481 il3945_alive_start(il); 2481 il3945_alive_start(il);
diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c
index 1489b1573a6a..c80eb9b31551 100644
--- a/drivers/net/wireless/iwlegacy/3945.c
+++ b/drivers/net/wireless/iwlegacy/3945.c
@@ -1870,11 +1870,12 @@ il3945_bg_reg_txpower_periodic(struct work_struct *work)
1870 struct il_priv *il = container_of(work, struct il_priv, 1870 struct il_priv *il = container_of(work, struct il_priv,
1871 _3945.thermal_periodic.work); 1871 _3945.thermal_periodic.work);
1872 1872
1873 if (test_bit(S_EXIT_PENDING, &il->status))
1874 return;
1875
1876 mutex_lock(&il->mutex); 1873 mutex_lock(&il->mutex);
1874 if (test_bit(S_EXIT_PENDING, &il->status) || il->txq == NULL)
1875 goto out;
1876
1877 il3945_reg_txpower_periodic(il); 1877 il3945_reg_txpower_periodic(il);
1878out:
1878 mutex_unlock(&il->mutex); 1879 mutex_unlock(&il->mutex);
1879} 1880}
1880 1881
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index d2a1ea98d0f2..fd356b7c0476 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -426,10 +426,14 @@ void rt2x00lib_txdone(struct queue_entry *entry,
426 /* 426 /*
427 * If the data queue was below the threshold before the txdone 427 * If the data queue was below the threshold before the txdone
428 * handler we must make sure the packet queue in the mac80211 stack 428 * handler we must make sure the packet queue in the mac80211 stack
429 * is reenabled when the txdone handler has finished. 429 * is reenabled when the txdone handler has finished. This has to be
430 * serialized with rt2x00mac_tx(), otherwise we can wake up queue
431 * before it was stopped.
430 */ 432 */
433 spin_lock_bh(&entry->queue->tx_lock);
431 if (!rt2x00queue_threshold(entry->queue)) 434 if (!rt2x00queue_threshold(entry->queue))
432 rt2x00queue_unpause_queue(entry->queue); 435 rt2x00queue_unpause_queue(entry->queue);
436 spin_unlock_bh(&entry->queue->tx_lock);
433} 437}
434EXPORT_SYMBOL_GPL(rt2x00lib_txdone); 438EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
435 439
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index ede3c58e6783..2df2eb6d3e06 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -152,13 +152,22 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
152 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false))) 152 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
153 goto exit_fail; 153 goto exit_fail;
154 154
155 /*
156 * Pausing queue has to be serialized with rt2x00lib_txdone(). Note
157 * we should not use spin_lock_bh variant as bottom halve was already
158 * disabled before ieee80211_xmit() call.
159 */
160 spin_lock(&queue->tx_lock);
155 if (rt2x00queue_threshold(queue)) 161 if (rt2x00queue_threshold(queue))
156 rt2x00queue_pause_queue(queue); 162 rt2x00queue_pause_queue(queue);
163 spin_unlock(&queue->tx_lock);
157 164
158 return; 165 return;
159 166
160 exit_fail: 167 exit_fail:
168 spin_lock(&queue->tx_lock);
161 rt2x00queue_pause_queue(queue); 169 rt2x00queue_pause_queue(queue);
170 spin_unlock(&queue->tx_lock);
162 exit_free_skb: 171 exit_free_skb:
163 ieee80211_free_txskb(hw, skb); 172 ieee80211_free_txskb(hw, skb);
164} 173}
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 5adfb3eab9cd..9b1b2b7a7807 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -619,6 +619,9 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
619 else if (test_bit(REQUIRE_DMA, &queue->rt2x00dev->cap_flags)) 619 else if (test_bit(REQUIRE_DMA, &queue->rt2x00dev->cap_flags))
620 rt2x00queue_align_frame(skb); 620 rt2x00queue_align_frame(skb);
621 621
622 /*
623 * That function must be called with bh disabled.
624 */
622 spin_lock(&queue->tx_lock); 625 spin_lock(&queue->tx_lock);
623 626
624 if (unlikely(rt2x00queue_full(queue))) { 627 if (unlikely(rt2x00queue_full(queue))) {
diff --git a/lib/dynamic_queue_limits.c b/lib/dynamic_queue_limits.c
index 3d1bdcdd7db4..6ab4587d052b 100644
--- a/lib/dynamic_queue_limits.c
+++ b/lib/dynamic_queue_limits.c
@@ -7,6 +7,7 @@
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/ctype.h> 8#include <linux/ctype.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/jiffies.h>
10#include <linux/dynamic_queue_limits.h> 11#include <linux/dynamic_queue_limits.h>
11 12
12#define POSDIFF(A, B) ((A) > (B) ? (A) - (B) : 0) 13#define POSDIFF(A, B) ((A) > (B) ? (A) - (B) : 0)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 51fdbb490437..eab2a7fb15d1 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -278,6 +278,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
278 struct rtable *rt; 278 struct rtable *rt;
279 __u8 rcv_wscale; 279 __u8 rcv_wscale;
280 bool ecn_ok = false; 280 bool ecn_ok = false;
281 struct flowi4 fl4;
281 282
282 if (!sysctl_tcp_syncookies || !th->ack || th->rst) 283 if (!sysctl_tcp_syncookies || !th->ack || th->rst)
283 goto out; 284 goto out;
@@ -346,20 +347,16 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
346 * hasn't changed since we received the original syn, but I see 347 * hasn't changed since we received the original syn, but I see
347 * no easy way to do this. 348 * no easy way to do this.
348 */ 349 */
349 { 350 flowi4_init_output(&fl4, 0, sk->sk_mark, RT_CONN_FLAGS(sk),
350 struct flowi4 fl4; 351 RT_SCOPE_UNIVERSE, IPPROTO_TCP,
351 352 inet_sk_flowi_flags(sk),
352 flowi4_init_output(&fl4, 0, sk->sk_mark, RT_CONN_FLAGS(sk), 353 (opt && opt->srr) ? opt->faddr : ireq->rmt_addr,
353 RT_SCOPE_UNIVERSE, IPPROTO_TCP, 354 ireq->loc_addr, th->source, th->dest);
354 inet_sk_flowi_flags(sk), 355 security_req_classify_flow(req, flowi4_to_flowi(&fl4));
355 (opt && opt->srr) ? opt->faddr : ireq->rmt_addr, 356 rt = ip_route_output_key(sock_net(sk), &fl4);
356 ireq->loc_addr, th->source, th->dest); 357 if (IS_ERR(rt)) {
357 security_req_classify_flow(req, flowi4_to_flowi(&fl4)); 358 reqsk_free(req);
358 rt = ip_route_output_key(sock_net(sk), &fl4); 359 goto out;
359 if (IS_ERR(rt)) {
360 reqsk_free(req);
361 goto out;
362 }
363 } 360 }
364 361
365 /* Try to redo what tcp_v4_send_synack did. */ 362 /* Try to redo what tcp_v4_send_synack did. */
@@ -373,5 +370,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
373 ireq->rcv_wscale = rcv_wscale; 370 ireq->rcv_wscale = rcv_wscale;
374 371
375 ret = get_cookie_sock(sk, skb, req, &rt->dst); 372 ret = get_cookie_sock(sk, skb, req, &rt->dst);
373 /* ip_queue_xmit() depends on our flow being setup
374 * Normal sockets get it right from inet_csk_route_child_sock()
375 */
376 if (ret)
377 inet_sk(ret)->cork.fl.u.ip4 = fl4;
376out: return ret; 378out: return ret;
377} 379}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 94d683a61cba..fd54c5f8a255 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1466,9 +1466,13 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1466 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 1466 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
1467 newinet->inet_id = newtp->write_seq ^ jiffies; 1467 newinet->inet_id = newtp->write_seq ^ jiffies;
1468 1468
1469 if (!dst && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL) 1469 if (!dst) {
1470 goto put_and_exit; 1470 dst = inet_csk_route_child_sock(sk, newsk, req);
1471 1471 if (!dst)
1472 goto put_and_exit;
1473 } else {
1474 /* syncookie case : see end of cookie_v4_check() */
1475 }
1472 sk_setup_caps(newsk, dst); 1476 sk_setup_caps(newsk, dst);
1473 1477
1474 tcp_mtup_init(newsk); 1478 tcp_mtup_init(newsk);