aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-27 19:04:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-27 19:04:37 -0500
commit8f18e4d03ed8fa5e4a300c94550533bd8ce4ff9a (patch)
tree9d9987ff5976a04701bb018bb40309bfdd2d6a9c
parent0dad3a3014a0b9e72521ff44f17e0054f43dcdea (diff)
parent5799fc905930f866c7d32aaf81b31f8027297506 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Various ipvlan fixes from Eric Dumazet and Mahesh Bandewar. The most important is to not assume the packet is RX just because the destination address matches that of the device. Such an assumption causes problems when an interface is put into loopback mode. 2) If we retry when creating a new tc entry (because we dropped the RTNL mutex in order to load a module, for example) we end up with -EAGAIN and then loop trying to replay the request. But we didn't reset some state when looping back to the top like this, and if another thread meanwhile inserted the same tc entry we were trying to, we re-link it creating an enless loop in the tc chain. Fix from Daniel Borkmann. 3) There are two different WRITE bits in the MDIO address register for the stmmac chip, depending upon the chip variant. Due to a bug we could set them both, fix from Hock Leong Kweh. 4) Fix mlx4 bug in XDP_TX handling, from Tariq Toukan. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: net: stmmac: fix incorrect bit set in gmac4 mdio addr register r8169: add support for RTL8168 series add-on card. net: xdp: remove unused bfp_warn_invalid_xdp_buffer() openvswitch: upcall: Fix vlan handling. ipv4: Namespaceify tcp_tw_reuse knob net: korina: Fix NAPI versus resources freeing net, sched: fix soft lockup in tc_classify net/mlx4_en: Fix user prio field in XDP forward tipc: don't send FIN message from connectionless socket ipvlan: fix multicast processing ipvlan: fix various issues in ipvlan_process_multicast()
-rw-r--r--drivers/net/ethernet/korina.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c3
-rw-r--r--drivers/net/ethernet/realtek/r8169.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c4
-rw-r--r--drivers/net/ipvlan/ipvlan.h5
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c60
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c7
-rw-r--r--include/linux/filter.h1
-rw-r--r--include/net/netns/ipv4.h1
-rw-r--r--include/net/tcp.h1
-rw-r--r--net/core/filter.c6
-rw-r--r--net/ipv4/sysctl_net_ipv4.c14
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/openvswitch/datapath.c1
-rw-r--r--net/openvswitch/flow.c54
-rw-r--r--net/sched/cls_api.c4
-rw-r--r--net/tipc/socket.c24
17 files changed, 112 insertions, 86 deletions
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index cbeea915f026..8037426ec50f 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -900,10 +900,10 @@ static void korina_restart_task(struct work_struct *work)
900 DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR, 900 DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR,
901 &lp->rx_dma_regs->dmasm); 901 &lp->rx_dma_regs->dmasm);
902 902
903 korina_free_ring(dev);
904
905 napi_disable(&lp->napi); 903 napi_disable(&lp->napi);
906 904
905 korina_free_ring(dev);
906
907 if (korina_init(dev) < 0) { 907 if (korina_init(dev) < 0) {
908 printk(KERN_ERR "%s: cannot restart device\n", dev->name); 908 printk(KERN_ERR "%s: cannot restart device\n", dev->name);
909 return; 909 return;
@@ -1064,12 +1064,12 @@ static int korina_close(struct net_device *dev)
1064 tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR; 1064 tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR;
1065 writel(tmp, &lp->rx_dma_regs->dmasm); 1065 writel(tmp, &lp->rx_dma_regs->dmasm);
1066 1066
1067 korina_free_ring(dev);
1068
1069 napi_disable(&lp->napi); 1067 napi_disable(&lp->napi);
1070 1068
1071 cancel_work_sync(&lp->restart_task); 1069 cancel_work_sync(&lp->restart_task);
1072 1070
1071 korina_free_ring(dev);
1072
1073 free_irq(lp->rx_irq, dev); 1073 free_irq(lp->rx_irq, dev);
1074 free_irq(lp->tx_irq, dev); 1074 free_irq(lp->tx_irq, dev);
1075 free_irq(lp->ovr_irq, dev); 1075 free_irq(lp->ovr_irq, dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index bcd955339058..edbe200ac2fa 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1638,7 +1638,8 @@ int mlx4_en_start_port(struct net_device *dev)
1638 1638
1639 /* Configure tx cq's and rings */ 1639 /* Configure tx cq's and rings */
1640 for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES; t++) { 1640 for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES; t++) {
1641 u8 num_tx_rings_p_up = t == TX ? priv->num_tx_rings_p_up : 1; 1641 u8 num_tx_rings_p_up = t == TX ?
1642 priv->num_tx_rings_p_up : priv->tx_ring_num[t];
1642 1643
1643 for (i = 0; i < priv->tx_ring_num[t]; i++) { 1644 for (i = 0; i < priv->tx_ring_num[t]; i++) {
1644 /* Configure cq */ 1645 /* Configure cq */
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index f9b97f5946f8..44389c90056a 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -326,6 +326,7 @@ enum cfg_version {
326static const struct pci_device_id rtl8169_pci_tbl[] = { 326static const struct pci_device_id rtl8169_pci_tbl[] = {
327 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, 327 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
328 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, 328 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
329 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161), 0, 0, RTL_CFG_1 },
329 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, 330 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
330 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 }, 331 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
331 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, 332 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index fda01f770eff..b0344c213752 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -116,7 +116,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
116 unsigned int mii_address = priv->hw->mii.addr; 116 unsigned int mii_address = priv->hw->mii.addr;
117 unsigned int mii_data = priv->hw->mii.data; 117 unsigned int mii_data = priv->hw->mii.data;
118 118
119 u32 value = MII_WRITE | MII_BUSY; 119 u32 value = MII_BUSY;
120 120
121 value |= (phyaddr << priv->hw->mii.addr_shift) 121 value |= (phyaddr << priv->hw->mii.addr_shift)
122 & priv->hw->mii.addr_mask; 122 & priv->hw->mii.addr_mask;
@@ -126,6 +126,8 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
126 & priv->hw->mii.clk_csr_mask; 126 & priv->hw->mii.clk_csr_mask;
127 if (priv->plat->has_gmac4) 127 if (priv->plat->has_gmac4)
128 value |= MII_GMAC4_WRITE; 128 value |= MII_GMAC4_WRITE;
129 else
130 value |= MII_WRITE;
129 131
130 /* Wait until any existing MII operation is complete */ 132 /* Wait until any existing MII operation is complete */
131 if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address)) 133 if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
index 031093e1c25f..dbfbb33ac66c 100644
--- a/drivers/net/ipvlan/ipvlan.h
+++ b/drivers/net/ipvlan/ipvlan.h
@@ -99,6 +99,11 @@ struct ipvl_port {
99 int count; 99 int count;
100}; 100};
101 101
102struct ipvl_skb_cb {
103 bool tx_pkt;
104};
105#define IPVL_SKB_CB(_skb) ((struct ipvl_skb_cb *)&((_skb)->cb[0]))
106
102static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d) 107static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d)
103{ 108{
104 return rcu_dereference(d->rx_handler_data); 109 return rcu_dereference(d->rx_handler_data);
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index b4e990743e1d..83ce74acf82d 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -198,7 +198,7 @@ void ipvlan_process_multicast(struct work_struct *work)
198 unsigned int mac_hash; 198 unsigned int mac_hash;
199 int ret; 199 int ret;
200 u8 pkt_type; 200 u8 pkt_type;
201 bool hlocal, dlocal; 201 bool tx_pkt;
202 202
203 __skb_queue_head_init(&list); 203 __skb_queue_head_init(&list);
204 204
@@ -207,8 +207,11 @@ void ipvlan_process_multicast(struct work_struct *work)
207 spin_unlock_bh(&port->backlog.lock); 207 spin_unlock_bh(&port->backlog.lock);
208 208
209 while ((skb = __skb_dequeue(&list)) != NULL) { 209 while ((skb = __skb_dequeue(&list)) != NULL) {
210 struct net_device *dev = skb->dev;
211 bool consumed = false;
212
210 ethh = eth_hdr(skb); 213 ethh = eth_hdr(skb);
211 hlocal = ether_addr_equal(ethh->h_source, port->dev->dev_addr); 214 tx_pkt = IPVL_SKB_CB(skb)->tx_pkt;
212 mac_hash = ipvlan_mac_hash(ethh->h_dest); 215 mac_hash = ipvlan_mac_hash(ethh->h_dest);
213 216
214 if (ether_addr_equal(ethh->h_dest, port->dev->broadcast)) 217 if (ether_addr_equal(ethh->h_dest, port->dev->broadcast))
@@ -216,41 +219,45 @@ void ipvlan_process_multicast(struct work_struct *work)
216 else 219 else
217 pkt_type = PACKET_MULTICAST; 220 pkt_type = PACKET_MULTICAST;
218 221
219 dlocal = false;
220 rcu_read_lock(); 222 rcu_read_lock();
221 list_for_each_entry_rcu(ipvlan, &port->ipvlans, pnode) { 223 list_for_each_entry_rcu(ipvlan, &port->ipvlans, pnode) {
222 if (hlocal && (ipvlan->dev == skb->dev)) { 224 if (tx_pkt && (ipvlan->dev == skb->dev))
223 dlocal = true;
224 continue; 225 continue;
225 }
226 if (!test_bit(mac_hash, ipvlan->mac_filters)) 226 if (!test_bit(mac_hash, ipvlan->mac_filters))
227 continue; 227 continue;
228 228 if (!(ipvlan->dev->flags & IFF_UP))
229 continue;
229 ret = NET_RX_DROP; 230 ret = NET_RX_DROP;
230 len = skb->len + ETH_HLEN; 231 len = skb->len + ETH_HLEN;
231 nskb = skb_clone(skb, GFP_ATOMIC); 232 nskb = skb_clone(skb, GFP_ATOMIC);
232 if (!nskb) 233 local_bh_disable();
233 goto acct; 234 if (nskb) {
234 235 consumed = true;
235 nskb->pkt_type = pkt_type; 236 nskb->pkt_type = pkt_type;
236 nskb->dev = ipvlan->dev; 237 nskb->dev = ipvlan->dev;
237 if (hlocal) 238 if (tx_pkt)
238 ret = dev_forward_skb(ipvlan->dev, nskb); 239 ret = dev_forward_skb(ipvlan->dev, nskb);
239 else 240 else
240 ret = netif_rx(nskb); 241 ret = netif_rx(nskb);
241acct: 242 }
242 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true); 243 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
244 local_bh_enable();
243 } 245 }
244 rcu_read_unlock(); 246 rcu_read_unlock();
245 247
246 if (dlocal) { 248 if (tx_pkt) {
247 /* If the packet originated here, send it out. */ 249 /* If the packet originated here, send it out. */
248 skb->dev = port->dev; 250 skb->dev = port->dev;
249 skb->pkt_type = pkt_type; 251 skb->pkt_type = pkt_type;
250 dev_queue_xmit(skb); 252 dev_queue_xmit(skb);
251 } else { 253 } else {
252 kfree_skb(skb); 254 if (consumed)
255 consume_skb(skb);
256 else
257 kfree_skb(skb);
253 } 258 }
259 if (dev)
260 dev_put(dev);
254 } 261 }
255} 262}
256 263
@@ -470,15 +477,24 @@ out:
470} 477}
471 478
472static void ipvlan_multicast_enqueue(struct ipvl_port *port, 479static void ipvlan_multicast_enqueue(struct ipvl_port *port,
473 struct sk_buff *skb) 480 struct sk_buff *skb, bool tx_pkt)
474{ 481{
475 if (skb->protocol == htons(ETH_P_PAUSE)) { 482 if (skb->protocol == htons(ETH_P_PAUSE)) {
476 kfree_skb(skb); 483 kfree_skb(skb);
477 return; 484 return;
478 } 485 }
479 486
487 /* Record that the deferred packet is from TX or RX path. By
488 * looking at mac-addresses on packet will lead to erronus decisions.
489 * (This would be true for a loopback-mode on master device or a
490 * hair-pin mode of the switch.)
491 */
492 IPVL_SKB_CB(skb)->tx_pkt = tx_pkt;
493
480 spin_lock(&port->backlog.lock); 494 spin_lock(&port->backlog.lock);
481 if (skb_queue_len(&port->backlog) < IPVLAN_QBACKLOG_LIMIT) { 495 if (skb_queue_len(&port->backlog) < IPVLAN_QBACKLOG_LIMIT) {
496 if (skb->dev)
497 dev_hold(skb->dev);
482 __skb_queue_tail(&port->backlog, skb); 498 __skb_queue_tail(&port->backlog, skb);
483 spin_unlock(&port->backlog.lock); 499 spin_unlock(&port->backlog.lock);
484 schedule_work(&port->wq); 500 schedule_work(&port->wq);
@@ -537,7 +553,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)
537 553
538 } else if (is_multicast_ether_addr(eth->h_dest)) { 554 } else if (is_multicast_ether_addr(eth->h_dest)) {
539 ipvlan_skb_crossing_ns(skb, NULL); 555 ipvlan_skb_crossing_ns(skb, NULL);
540 ipvlan_multicast_enqueue(ipvlan->port, skb); 556 ipvlan_multicast_enqueue(ipvlan->port, skb, true);
541 return NET_XMIT_SUCCESS; 557 return NET_XMIT_SUCCESS;
542 } 558 }
543 559
@@ -634,7 +650,7 @@ static rx_handler_result_t ipvlan_handle_mode_l2(struct sk_buff **pskb,
634 */ 650 */
635 if (nskb) { 651 if (nskb) {
636 ipvlan_skb_crossing_ns(nskb, NULL); 652 ipvlan_skb_crossing_ns(nskb, NULL);
637 ipvlan_multicast_enqueue(port, nskb); 653 ipvlan_multicast_enqueue(port, nskb, false);
638 } 654 }
639 } 655 }
640 } else { 656 } else {
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 693ec5b66222..8b0f99300cbc 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -135,6 +135,7 @@ err:
135static void ipvlan_port_destroy(struct net_device *dev) 135static void ipvlan_port_destroy(struct net_device *dev)
136{ 136{
137 struct ipvl_port *port = ipvlan_port_get_rtnl(dev); 137 struct ipvl_port *port = ipvlan_port_get_rtnl(dev);
138 struct sk_buff *skb;
138 139
139 dev->priv_flags &= ~IFF_IPVLAN_MASTER; 140 dev->priv_flags &= ~IFF_IPVLAN_MASTER;
140 if (port->mode == IPVLAN_MODE_L3S) { 141 if (port->mode == IPVLAN_MODE_L3S) {
@@ -144,7 +145,11 @@ static void ipvlan_port_destroy(struct net_device *dev)
144 } 145 }
145 netdev_rx_handler_unregister(dev); 146 netdev_rx_handler_unregister(dev);
146 cancel_work_sync(&port->wq); 147 cancel_work_sync(&port->wq);
147 __skb_queue_purge(&port->backlog); 148 while ((skb = __skb_dequeue(&port->backlog)) != NULL) {
149 if (skb->dev)
150 dev_put(skb->dev);
151 kfree_skb(skb);
152 }
148 kfree(port); 153 kfree(port);
149} 154}
150 155
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 702314253797..a0934e6c9bab 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -610,7 +610,6 @@ bool bpf_helper_changes_pkt_data(void *func);
610struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 610struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
611 const struct bpf_insn *patch, u32 len); 611 const struct bpf_insn *patch, u32 len);
612void bpf_warn_invalid_xdp_action(u32 act); 612void bpf_warn_invalid_xdp_action(u32 act);
613void bpf_warn_invalid_xdp_buffer(void);
614 613
615#ifdef CONFIG_BPF_JIT 614#ifdef CONFIG_BPF_JIT
616extern int bpf_jit_enable; 615extern int bpf_jit_enable;
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index f0cf5a1b777e..0378e88f6fd3 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -110,6 +110,7 @@ struct netns_ipv4 {
110 int sysctl_tcp_orphan_retries; 110 int sysctl_tcp_orphan_retries;
111 int sysctl_tcp_fin_timeout; 111 int sysctl_tcp_fin_timeout;
112 unsigned int sysctl_tcp_notsent_lowat; 112 unsigned int sysctl_tcp_notsent_lowat;
113 int sysctl_tcp_tw_reuse;
113 114
114 int sysctl_igmp_max_memberships; 115 int sysctl_igmp_max_memberships;
115 int sysctl_igmp_max_msf; 116 int sysctl_igmp_max_msf;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 207147b4c6b2..6061963cca98 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -252,7 +252,6 @@ extern int sysctl_tcp_wmem[3];
252extern int sysctl_tcp_rmem[3]; 252extern int sysctl_tcp_rmem[3];
253extern int sysctl_tcp_app_win; 253extern int sysctl_tcp_app_win;
254extern int sysctl_tcp_adv_win_scale; 254extern int sysctl_tcp_adv_win_scale;
255extern int sysctl_tcp_tw_reuse;
256extern int sysctl_tcp_frto; 255extern int sysctl_tcp_frto;
257extern int sysctl_tcp_low_latency; 256extern int sysctl_tcp_low_latency;
258extern int sysctl_tcp_nometrics_save; 257extern int sysctl_tcp_nometrics_save;
diff --git a/net/core/filter.c b/net/core/filter.c
index e6c412b94dec..1969b3f118c1 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2972,12 +2972,6 @@ void bpf_warn_invalid_xdp_action(u32 act)
2972} 2972}
2973EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action); 2973EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
2974 2974
2975void bpf_warn_invalid_xdp_buffer(void)
2976{
2977 WARN_ONCE(1, "Illegal XDP buffer encountered, expect throughput degradation\n");
2978}
2979EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_buffer);
2980
2981static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg, 2975static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg,
2982 int src_reg, int ctx_off, 2976 int src_reg, int ctx_off,
2983 struct bpf_insn *insn_buf, 2977 struct bpf_insn *insn_buf,
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 80bc36b25de2..22cbd61079b5 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -433,13 +433,6 @@ static struct ctl_table ipv4_table[] = {
433 .extra2 = &tcp_adv_win_scale_max, 433 .extra2 = &tcp_adv_win_scale_max,
434 }, 434 },
435 { 435 {
436 .procname = "tcp_tw_reuse",
437 .data = &sysctl_tcp_tw_reuse,
438 .maxlen = sizeof(int),
439 .mode = 0644,
440 .proc_handler = proc_dointvec
441 },
442 {
443 .procname = "tcp_frto", 436 .procname = "tcp_frto",
444 .data = &sysctl_tcp_frto, 437 .data = &sysctl_tcp_frto,
445 .maxlen = sizeof(int), 438 .maxlen = sizeof(int),
@@ -960,6 +953,13 @@ static struct ctl_table ipv4_net_table[] = {
960 .mode = 0644, 953 .mode = 0644,
961 .proc_handler = proc_dointvec, 954 .proc_handler = proc_dointvec,
962 }, 955 },
956 {
957 .procname = "tcp_tw_reuse",
958 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
959 .maxlen = sizeof(int),
960 .mode = 0644,
961 .proc_handler = proc_dointvec
962 },
963#ifdef CONFIG_IP_ROUTE_MULTIPATH 963#ifdef CONFIG_IP_ROUTE_MULTIPATH
964 { 964 {
965 .procname = "fib_multipath_use_neigh", 965 .procname = "fib_multipath_use_neigh",
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 30d81f533ada..fe9da4fb96bf 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -84,7 +84,6 @@
84#include <crypto/hash.h> 84#include <crypto/hash.h>
85#include <linux/scatterlist.h> 85#include <linux/scatterlist.h>
86 86
87int sysctl_tcp_tw_reuse __read_mostly;
88int sysctl_tcp_low_latency __read_mostly; 87int sysctl_tcp_low_latency __read_mostly;
89 88
90#ifdef CONFIG_TCP_MD5SIG 89#ifdef CONFIG_TCP_MD5SIG
@@ -120,7 +119,7 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
120 and use initial timestamp retrieved from peer table. 119 and use initial timestamp retrieved from peer table.
121 */ 120 */
122 if (tcptw->tw_ts_recent_stamp && 121 if (tcptw->tw_ts_recent_stamp &&
123 (!twp || (sysctl_tcp_tw_reuse && 122 (!twp || (sock_net(sk)->ipv4.sysctl_tcp_tw_reuse &&
124 get_seconds() - tcptw->tw_ts_recent_stamp > 1))) { 123 get_seconds() - tcptw->tw_ts_recent_stamp > 1))) {
125 tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2; 124 tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;
126 if (tp->write_seq == 0) 125 if (tp->write_seq == 0)
@@ -2456,6 +2455,7 @@ static int __net_init tcp_sk_init(struct net *net)
2456 net->ipv4.sysctl_tcp_orphan_retries = 0; 2455 net->ipv4.sysctl_tcp_orphan_retries = 0;
2457 net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT; 2456 net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
2458 net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX; 2457 net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
2458 net->ipv4.sysctl_tcp_tw_reuse = 0;
2459 2459
2460 return 0; 2460 return 0;
2461fail: 2461fail:
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 2d4c4d3911c0..9c62b6325f7a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -606,7 +606,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
606 rcu_assign_pointer(flow->sf_acts, acts); 606 rcu_assign_pointer(flow->sf_acts, acts);
607 packet->priority = flow->key.phy.priority; 607 packet->priority = flow->key.phy.priority;
608 packet->mark = flow->key.phy.skb_mark; 608 packet->mark = flow->key.phy.skb_mark;
609 packet->protocol = flow->key.eth.type;
610 609
611 rcu_read_lock(); 610 rcu_read_lock();
612 dp = get_dp_rcu(net, ovs_header->dp_ifindex); 611 dp = get_dp_rcu(net, ovs_header->dp_ifindex);
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 08aa926cd5cf..2c0a00f7f1b7 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -312,7 +312,8 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
312 * Returns 0 if it encounters a non-vlan or incomplete packet. 312 * Returns 0 if it encounters a non-vlan or incomplete packet.
313 * Returns 1 after successfully parsing vlan tag. 313 * Returns 1 after successfully parsing vlan tag.
314 */ 314 */
315static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh) 315static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh,
316 bool untag_vlan)
316{ 317{
317 struct vlan_head *vh = (struct vlan_head *)skb->data; 318 struct vlan_head *vh = (struct vlan_head *)skb->data;
318 319
@@ -330,7 +331,20 @@ static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh)
330 key_vh->tci = vh->tci | htons(VLAN_TAG_PRESENT); 331 key_vh->tci = vh->tci | htons(VLAN_TAG_PRESENT);
331 key_vh->tpid = vh->tpid; 332 key_vh->tpid = vh->tpid;
332 333
333 __skb_pull(skb, sizeof(struct vlan_head)); 334 if (unlikely(untag_vlan)) {
335 int offset = skb->data - skb_mac_header(skb);
336 u16 tci;
337 int err;
338
339 __skb_push(skb, offset);
340 err = __skb_vlan_pop(skb, &tci);
341 __skb_pull(skb, offset);
342 if (err)
343 return err;
344 __vlan_hwaccel_put_tag(skb, key_vh->tpid, tci);
345 } else {
346 __skb_pull(skb, sizeof(struct vlan_head));
347 }
334 return 1; 348 return 1;
335} 349}
336 350
@@ -351,13 +365,13 @@ static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
351 key->eth.vlan.tpid = skb->vlan_proto; 365 key->eth.vlan.tpid = skb->vlan_proto;
352 } else { 366 } else {
353 /* Parse outer vlan tag in the non-accelerated case. */ 367 /* Parse outer vlan tag in the non-accelerated case. */
354 res = parse_vlan_tag(skb, &key->eth.vlan); 368 res = parse_vlan_tag(skb, &key->eth.vlan, true);
355 if (res <= 0) 369 if (res <= 0)
356 return res; 370 return res;
357 } 371 }
358 372
359 /* Parse inner vlan tag. */ 373 /* Parse inner vlan tag. */
360 res = parse_vlan_tag(skb, &key->eth.cvlan); 374 res = parse_vlan_tag(skb, &key->eth.cvlan, false);
361 if (res <= 0) 375 if (res <= 0)
362 return res; 376 return res;
363 377
@@ -800,29 +814,15 @@ int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr,
800 if (err) 814 if (err)
801 return err; 815 return err;
802 816
803 if (ovs_key_mac_proto(key) == MAC_PROTO_NONE) { 817 /* key_extract assumes that skb->protocol is set-up for
804 /* key_extract assumes that skb->protocol is set-up for 818 * layer 3 packets which is the case for other callers,
805 * layer 3 packets which is the case for other callers, 819 * in particular packets received from the network stack.
806 * in particular packets recieved from the network stack. 820 * Here the correct value can be set from the metadata
807 * Here the correct value can be set from the metadata 821 * extracted above.
808 * extracted above. 822 * For L2 packet key eth type would be zero. skb protocol
809 */ 823 * would be set to correct value later during key-extact.
810 skb->protocol = key->eth.type; 824 */
811 } else {
812 struct ethhdr *eth;
813
814 skb_reset_mac_header(skb);
815 eth = eth_hdr(skb);
816
817 /* Normally, setting the skb 'protocol' field would be
818 * handled by a call to eth_type_trans(), but it assumes
819 * there's a sending device, which we may not have.
820 */
821 if (eth_proto_is_802_3(eth->h_proto))
822 skb->protocol = eth->h_proto;
823 else
824 skb->protocol = htons(ETH_P_802_2);
825 }
826 825
826 skb->protocol = key->eth.type;
827 return key_extract(skb, key); 827 return key_extract(skb, key);
828} 828}
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 3fbba79a4ef0..1ecdf809b5fa 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -148,13 +148,15 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
148 unsigned long cl; 148 unsigned long cl;
149 unsigned long fh; 149 unsigned long fh;
150 int err; 150 int err;
151 int tp_created = 0; 151 int tp_created;
152 152
153 if ((n->nlmsg_type != RTM_GETTFILTER) && 153 if ((n->nlmsg_type != RTM_GETTFILTER) &&
154 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) 154 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
155 return -EPERM; 155 return -EPERM;
156 156
157replay: 157replay:
158 tp_created = 0;
159
158 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL); 160 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
159 if (err < 0) 161 if (err < 0)
160 return err; 162 return err;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 333c5dae0072..800caaa699a1 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -441,15 +441,19 @@ static void __tipc_shutdown(struct socket *sock, int error)
441 while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) { 441 while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) {
442 if (TIPC_SKB_CB(skb)->bytes_read) { 442 if (TIPC_SKB_CB(skb)->bytes_read) {
443 kfree_skb(skb); 443 kfree_skb(skb);
444 } else { 444 continue;
445 if (!tipc_sk_type_connectionless(sk) && 445 }
446 sk->sk_state != TIPC_DISCONNECTING) { 446 if (!tipc_sk_type_connectionless(sk) &&
447 tipc_set_sk_state(sk, TIPC_DISCONNECTING); 447 sk->sk_state != TIPC_DISCONNECTING) {
448 tipc_node_remove_conn(net, dnode, tsk->portid); 448 tipc_set_sk_state(sk, TIPC_DISCONNECTING);
449 } 449 tipc_node_remove_conn(net, dnode, tsk->portid);
450 tipc_sk_respond(sk, skb, error);
451 } 450 }
451 tipc_sk_respond(sk, skb, error);
452 } 452 }
453
454 if (tipc_sk_type_connectionless(sk))
455 return;
456
453 if (sk->sk_state != TIPC_DISCONNECTING) { 457 if (sk->sk_state != TIPC_DISCONNECTING) {
454 skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, 458 skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,
455 TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode, 459 TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode,
@@ -457,10 +461,8 @@ static void __tipc_shutdown(struct socket *sock, int error)
457 tsk->portid, error); 461 tsk->portid, error);
458 if (skb) 462 if (skb)
459 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); 463 tipc_node_xmit_skb(net, skb, dnode, tsk->portid);
460 if (!tipc_sk_type_connectionless(sk)) { 464 tipc_node_remove_conn(net, dnode, tsk->portid);
461 tipc_node_remove_conn(net, dnode, tsk->portid); 465 tipc_set_sk_state(sk, TIPC_DISCONNECTING);
462 tipc_set_sk_state(sk, TIPC_DISCONNECTING);
463 }
464 } 466 }
465} 467}
466 468