History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller: 1) Need to save away the IV across tls async operations, from Dave Watson. 2) Upon successful packet processing, we should liberate the SKB with dev_consume_skb{_irq}(). From Yang Wei. 3) Only apply RX hang workaround on effected macb chips, from Harini Katakam. 4) Dummy netdev need a proper namespace assigned to them, from Josh Elsasser. 5) Some paths of nft_compat run lockless now, and thus we need to use a proper refcnt_t. From Florian Westphal. 6) Avoid deadlock in mlx5 by doing IRQ locking, from Moni Shoua. 7) netrom does not refcount sockets properly wrt. timers, fix that by using the sock timer API. From Cong Wang. 8) Fix locking of inexact inserts of xfrm policies, from Florian Westphal. 9) Missing xfrm hash generation bump, also from Florian. 10) Missing of_node_put() in hns driver, from Yonglong Liu. 11) Fix DN_IFREQ_SIZE, from Johannes Berg. 12) ip6mr notifier is invoked during traversal of wrong table, from Nir Dotan. 13) TX promisc settings not performed correctly in qed, from Manish Chopra. 14) Fix OOB access in vhost, from Jason Wang. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (52 commits) MAINTAINERS: Add entry for XDP (eXpress Data Path) net: set default network namespace in init_dummy_netdev() net: b44: replace dev_kfree_skb_xxx by dev_consume_skb_xxx for drop profiles net: caif: call dev_consume_skb_any when skb xmit done net: 8139cp: replace dev_kfree_skb_irq by dev_consume_skb_irq for drop profiles net: macb: Apply RXUBR workaround only to versions with errata net: ti: replace dev_kfree_skb_irq by dev_consume_skb_irq for drop profiles net: apple: replace dev_kfree_skb_irq by dev_consume_skb_irq for drop profiles net: amd8111e: replace dev_kfree_skb_irq by dev_consume_skb_irq net: alteon: replace dev_kfree_skb_irq by dev_consume_skb_irq net: tls: Fix deadlock in free_resources tx net: tls: Save iv in tls_rec for async crypto requests vhost: fix OOB in get_rx_bufs() qed: Fix stack out of bounds bug qed: Fix system crash in ll2 xmit qed: Fix VF probe failure while FLR qed: Fix LACP pdu drops for VFs qed: Fix bug in tx promiscuous mode settings net: i825xx: replace dev_kfree_skb_irq by dev_consume_skb_irq for drop profiles netfilter: ipt_CLUSTERIP: fix warning unused variable cn ...

Linus Torvalds committed 7 years ago

Commit 62967892 parents 4aa9fc2 d07e1e050 files · +605 −195Browse files

Unified · Split

50 files
  1. MAINTAINERS +18 −0
  2. drivers/net/caif/caif_serial.c +1 −4
  3. drivers/net/dsa/mv88e6xxx/serdes.c +1 −1
  4. drivers/net/ethernet/alteon/acenic.c +1 −1
  5. drivers/net/ethernet/altera/altera_msgdma.c +2 −1
  6. drivers/net/ethernet/amd/amd8111e.c +1 −1
  7. drivers/net/ethernet/apple/bmac.c +1 −1
  8. drivers/net/ethernet/broadcom/b44.c +2 −2
  9. drivers/net/ethernet/cadence/macb.h +3 −0
  10. drivers/net/ethernet/cadence/macb_main.c +17 −11
  11. drivers/net/ethernet/hisilicon/hns/hns_enet.c +5 −0
  12. drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +9 −7
  13. drivers/net/ethernet/hisilicon/hns_mdio.c +1 −1
  14. drivers/net/ethernet/i825xx/82596.c +1 −1
  15. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 −1
  16. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +23 −2
  17. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8 −14
  18. drivers/net/ethernet/mellanox/mlx5/core/lag.c +21 −0
  19. drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 −0
  20. drivers/net/ethernet/mellanox/mlx5/core/qp.c +3 −2
  21. drivers/net/ethernet/qlogic/qed/qed_dev.c +4 −4
  22. drivers/net/ethernet/qlogic/qed/qed_l2.c +11 −1
  23. drivers/net/ethernet/qlogic/qed/qed_l2.h +3 −0
  24. drivers/net/ethernet/qlogic/qed/qed_ll2.c +15 −5
  25. drivers/net/ethernet/qlogic/qed/qed_sriov.c +8 −2
  26. drivers/net/ethernet/qlogic/qed/qed_vf.c +10 −0
  27. drivers/net/ethernet/realtek/8139cp.c +1 −1
  28. drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +3 −1
  29. drivers/net/ethernet/ti/cpmac.c +1 −1
  30. drivers/vhost/net.c +2 −1
  31. drivers/vhost/scsi.c +1 −1
  32. drivers/vhost/vhost.c +4 −3
  33. drivers/vhost/vhost.h +3 −1
  34. drivers/vhost/vsock.c +1 −1
  35. include/net/tls.h +2 −0
  36. net/bridge/netfilter/ebtables.c +6 −3
  37. net/core/dev.c +3 −0
  38. net/decnet/dn_dev.c +1 −1
  39. net/ipv4/ip_vti.c +50 −0
  40. net/ipv4/netfilter/ipt_CLUSTERIP.c +1 −1
  41. net/ipv6/ip6mr.c +3 −4
  42. net/netfilter/ipvs/ip_vs_ctl.c +12 −0
  43. net/netfilter/nfnetlink_osf.c +4 −0
  44. net/netfilter/nft_compat.c +142 −47
  45. net/netrom/nr_timer.c +10 −10
  46. net/rose/rose_route.c +5 −0
  47. net/tls/tls_sw.c +5 −1
  48. net/xfrm/xfrm_policy.c +33 −30
  49. net/xfrm/xfrm_user.c +9 −4
  50. tools/testing/selftests/net/xfrm_policy.sh +131 −22
MAINTAINERS+18−0
@@ -16673,6 +16673,24 @@ T: git git://linuxtv.org/media_tree.git · 16672 unmodified lines
16673S: Maintained16673S: Maintained
16674F: drivers/media/tuners/tuner-xc2028.*16674F: drivers/media/tuners/tuner-xc2028.*
16675 16675
16676XDP (eXpress Data Path)
16677M: Alexei Starovoitov <ast@kernel.org>
16678M: Daniel Borkmann <daniel@iogearbox.net>
16679M: David S. Miller <davem@davemloft.net>
16680M: Jakub Kicinski <jakub.kicinski@netronome.com>
16681M: Jesper Dangaard Brouer <hawk@kernel.org>
16682M: John Fastabend <john.fastabend@gmail.com>
16683L: netdev@vger.kernel.org
16684L: xdp-newbies@vger.kernel.org
16685S: Supported
16686F: net/core/xdp.c
16687F: include/net/xdp.h
16688F: kernel/bpf/devmap.c
16689F: kernel/bpf/cpumap.c
16690F: include/trace/events/xdp.h
16691K: xdp
16692N: xdp
16693
16676XDP SOCKETS (AF_XDP)16694XDP SOCKETS (AF_XDP)
16677M: Björn Töpel <bjorn.topel@intel.com>16695M: Björn Töpel <bjorn.topel@intel.com>
16678M: Magnus Karlsson <magnus.karlsson@intel.com>16696M: Magnus Karlsson <magnus.karlsson@intel.com>
drivers/net/caif/caif_serial.c+1−4
@@ -257,10 +257,7 @@ static int handle_tx(struct ser_device *ser) · 256 unmodified lines
257 if (skb->len == 0) {257 if (skb->len == 0) {
258 struct sk_buff *tmp = skb_dequeue(&ser->head);258 struct sk_buff *tmp = skb_dequeue(&ser->head);
259 WARN_ON(tmp != skb);259 WARN_ON(tmp != skb);
260 if (in_interrupt())260 dev_consume_skb_any(skb);
261 dev_kfree_skb_irq(skb);
262 else
263 kfree_skb(skb);
264 }261 }
265 }262 }
266 /* Send flow off if queue is empty */263 /* Send flow off if queue is empty */
drivers/net/dsa/mv88e6xxx/serdes.c+1−1
@@ -664,7 +664,7 @@ int mv88e6390_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port) · 663 unmodified lines
664 if (port < 9)664 if (port < 9)
665 return 0;665 return 0;
666 666
667 return mv88e6390_serdes_irq_setup(chip, port);667 return mv88e6390x_serdes_irq_setup(chip, port);
668}668}
669 669
670void mv88e6390x_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)670void mv88e6390x_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
drivers/net/ethernet/alteon/acenic.c+1−1
@@ -2059,7 +2059,7 @@ static inline void ace_tx_int(struct net_device *dev, · 2058 unmodified lines
2059 if (skb) {2059 if (skb) {
2060 dev->stats.tx_packets++;2060 dev->stats.tx_packets++;
2061 dev->stats.tx_bytes += skb->len;2061 dev->stats.tx_bytes += skb->len;
2062 dev_kfree_skb_irq(skb);2062 dev_consume_skb_irq(skb);
2063 info->skb = NULL;2063 info->skb = NULL;
2064 }2064 }
2065 2065
drivers/net/ethernet/altera/altera_msgdma.c+2−1
@@ -145,7 +145,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv) · 144 unmodified lines
145 & 0xffff;145 & 0xffff;
146 146
147 if (inuse) { /* Tx FIFO is not empty */147 if (inuse) { /* Tx FIFO is not empty */
148 ready = priv->tx_prod - priv->tx_cons - inuse - 1;148 ready = max_t(int,
149 priv->tx_prod - priv->tx_cons - inuse - 1, 0);
149 } else {150 } else {
150 /* Check for buffered last packet */151 /* Check for buffered last packet */
151 status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status));152 status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status));
drivers/net/ethernet/amd/amd8111e.c+1−1
@@ -666,7 +666,7 @@ static int amd8111e_tx(struct net_device *dev) · 665 unmodified lines
666 pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[tx_index],666 pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[tx_index],
667 lp->tx_skbuff[tx_index]->len,667 lp->tx_skbuff[tx_index]->len,
668 PCI_DMA_TODEVICE);668 PCI_DMA_TODEVICE);
669 dev_kfree_skb_irq (lp->tx_skbuff[tx_index]);669 dev_consume_skb_irq(lp->tx_skbuff[tx_index]);
670 lp->tx_skbuff[tx_index] = NULL;670 lp->tx_skbuff[tx_index] = NULL;
671 lp->tx_dma_addr[tx_index] = 0;671 lp->tx_dma_addr[tx_index] = 0;
672 }672 }
drivers/net/ethernet/apple/bmac.c+1−1
@@ -777,7 +777,7 @@ static irqreturn_t bmac_txdma_intr(int irq, void *dev_id) · 776 unmodified lines
777 777
778 if (bp->tx_bufs[bp->tx_empty]) {778 if (bp->tx_bufs[bp->tx_empty]) {
779 ++dev->stats.tx_packets;779 ++dev->stats.tx_packets;
780 dev_kfree_skb_irq(bp->tx_bufs[bp->tx_empty]);780 dev_consume_skb_irq(bp->tx_bufs[bp->tx_empty]);
781 }781 }
782 bp->tx_bufs[bp->tx_empty] = NULL;782 bp->tx_bufs[bp->tx_empty] = NULL;
783 bp->tx_fullup = 0;783 bp->tx_fullup = 0;
drivers/net/ethernet/broadcom/b44.c+2−2
@@ -638,7 +638,7 @@ static void b44_tx(struct b44 *bp) · 637 unmodified lines
638 bytes_compl += skb->len;638 bytes_compl += skb->len;
639 pkts_compl++;639 pkts_compl++;
640 640
641 dev_kfree_skb_irq(skb);641 dev_consume_skb_irq(skb);
642 }642 }
643 643
644 netdev_completed_queue(bp->dev, pkts_compl, bytes_compl);644 netdev_completed_queue(bp->dev, pkts_compl, bytes_compl);
@@ -1012,7 +1012,7 @@ static netdev_tx_t b44_start_xmit(struct sk_buff *skb, struct net_device *dev) · 367 unmodified lines
1012 }1012 }
1013 1013
1014 skb_copy_from_linear_data(skb, skb_put(bounce_skb, len), len);1014 skb_copy_from_linear_data(skb, skb_put(bounce_skb, len), len);
1015 dev_kfree_skb_any(skb);1015 dev_consume_skb_any(skb);
1016 skb = bounce_skb;1016 skb = bounce_skb;
1017 }1017 }
1018 1018
drivers/net/ethernet/cadence/macb.h+3−0
@@ -643,6 +643,7 @@ · 642 unmodified lines
643#define MACB_CAPS_JUMBO 0x00000020643#define MACB_CAPS_JUMBO 0x00000020
644#define MACB_CAPS_GEM_HAS_PTP 0x00000040644#define MACB_CAPS_GEM_HAS_PTP 0x00000040
645#define MACB_CAPS_BD_RD_PREFETCH 0x00000080645#define MACB_CAPS_BD_RD_PREFETCH 0x00000080
646#define MACB_CAPS_NEEDS_RSTONUBR 0x00000100
646#define MACB_CAPS_FIFO_MODE 0x10000000647#define MACB_CAPS_FIFO_MODE 0x10000000
647#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000648#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
648#define MACB_CAPS_SG_DISABLED 0x40000000649#define MACB_CAPS_SG_DISABLED 0x40000000
@@ -1214,6 +1215,8 @@ struct macb { · 565 unmodified lines
1214 1215
1215 int rx_bd_rd_prefetch;1216 int rx_bd_rd_prefetch;
1216 int tx_bd_rd_prefetch;1217 int tx_bd_rd_prefetch;
1218
1219 u32 rx_intr_mask;
1217};1220};
1218 1221
1219#ifdef CONFIG_MACB_USE_HWSTAMP1222#ifdef CONFIG_MACB_USE_HWSTAMP
drivers/net/ethernet/cadence/macb_main.c+17−11
@@ -56,8 +56,7 @@ · 55 unmodified lines
56/* level of occupied TX descriptors under which we wake up TX process */56/* level of occupied TX descriptors under which we wake up TX process */
57#define MACB_TX_WAKEUP_THRESH(bp) (3 * (bp)->tx_ring_size / 4)57#define MACB_TX_WAKEUP_THRESH(bp) (3 * (bp)->tx_ring_size / 4)
58 58
59#define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(RXUBR) \59#define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(ISR_ROVR))
60 | MACB_BIT(ISR_ROVR))
61#define MACB_TX_ERR_FLAGS (MACB_BIT(ISR_TUND) \60#define MACB_TX_ERR_FLAGS (MACB_BIT(ISR_TUND) \
62 | MACB_BIT(ISR_RLE) \61 | MACB_BIT(ISR_RLE) \
63 | MACB_BIT(TXERR))62 | MACB_BIT(TXERR))
@@ -1270,7 +1269,7 @@ static int macb_poll(struct napi_struct *napi, int budget) · 1206 unmodified lines
1270 queue_writel(queue, ISR, MACB_BIT(RCOMP));1269 queue_writel(queue, ISR, MACB_BIT(RCOMP));
1271 napi_reschedule(napi);1270 napi_reschedule(napi);
1272 } else {1271 } else {
1273 queue_writel(queue, IER, MACB_RX_INT_FLAGS);1272 queue_writel(queue, IER, bp->rx_intr_mask);
1274 }1273 }
1275 }1274 }
1276 1275
@@ -1288,7 +1287,7 @@ static void macb_hresp_error_task(unsigned long data) · 11 unmodified lines
1288 u32 ctrl;1287 u32 ctrl;
1289 1288
1290 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {1289 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1291 queue_writel(queue, IDR, MACB_RX_INT_FLAGS |1290 queue_writel(queue, IDR, bp->rx_intr_mask |
1292 MACB_TX_INT_FLAGS |1291 MACB_TX_INT_FLAGS |
1293 MACB_BIT(HRESP));1292 MACB_BIT(HRESP));
1294 }1293 }
@@ -1318,7 +1317,7 @@ static void macb_hresp_error_task(unsigned long data) · 23 unmodified lines
1318 1317
1319 /* Enable interrupts */1318 /* Enable interrupts */
1320 queue_writel(queue, IER,1319 queue_writel(queue, IER,
1321 MACB_RX_INT_FLAGS |1320 bp->rx_intr_mask |
1322 MACB_TX_INT_FLAGS |1321 MACB_TX_INT_FLAGS |
1323 MACB_BIT(HRESP));1322 MACB_BIT(HRESP));
1324 }1323 }
@@ -1372,14 +1371,14 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 47 unmodified lines
1372 (unsigned int)(queue - bp->queues),1371 (unsigned int)(queue - bp->queues),
1373 (unsigned long)status);1372 (unsigned long)status);
1374 1373
1375 if (status & MACB_RX_INT_FLAGS) {1374 if (status & bp->rx_intr_mask) {
1376 /* There's no point taking any more interrupts1375 /* There's no point taking any more interrupts
1377 * until we have processed the buffers. The1376 * until we have processed the buffers. The
1378 * scheduling call may fail if the poll routine1377 * scheduling call may fail if the poll routine
1379 * is already scheduled, so disable interrupts1378 * is already scheduled, so disable interrupts
1380 * now.1379 * now.
1381 */1380 */
1382 queue_writel(queue, IDR, MACB_RX_INT_FLAGS);1381 queue_writel(queue, IDR, bp->rx_intr_mask);
1383 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)1382 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
1384 queue_writel(queue, ISR, MACB_BIT(RCOMP));1383 queue_writel(queue, ISR, MACB_BIT(RCOMP));
1385 1384
@@ -1412,8 +1411,9 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 26 unmodified lines
1412 /* There is a hardware issue under heavy load where DMA can1411 /* There is a hardware issue under heavy load where DMA can
1413 * stop, this causes endless "used buffer descriptor read"1412 * stop, this causes endless "used buffer descriptor read"
1414 * interrupts but it can be cleared by re-enabling RX. See1413 * interrupts but it can be cleared by re-enabling RX. See
1415 * the at91 manual, section 41.3.1 or the Zynq manual1414 * the at91rm9200 manual, section 41.3.1 or the Zynq manual
1416 * section 16.7.4 for details.1415 * section 16.7.4 for details. RXUBR is only enabled for
1416 * these two versions.
1417 */1417 */
1418 if (status & MACB_BIT(RXUBR)) {1418 if (status & MACB_BIT(RXUBR)) {
1419 ctrl = macb_readl(bp, NCR);1419 ctrl = macb_readl(bp, NCR);
@@ -2259,7 +2259,7 @@ static void macb_init_hw(struct macb *bp) · 839 unmodified lines
2259 2259
2260 /* Enable interrupts */2260 /* Enable interrupts */
2261 queue_writel(queue, IER,2261 queue_writel(queue, IER,
2262 MACB_RX_INT_FLAGS |2262 bp->rx_intr_mask |
2263 MACB_TX_INT_FLAGS |2263 MACB_TX_INT_FLAGS |
2264 MACB_BIT(HRESP));2264 MACB_BIT(HRESP));
2265 }2265 }
@@ -3907,6 +3907,7 @@ static const struct macb_config sama5d4_config = { · 1641 unmodified lines
3907};3907};
3908 3908
3909static const struct macb_config emac_config = {3909static const struct macb_config emac_config = {
3910 .caps = MACB_CAPS_NEEDS_RSTONUBR,
3910 .clk_init = at91ether_clk_init,3911 .clk_init = at91ether_clk_init,
3911 .init = at91ether_init,3912 .init = at91ether_init,
3912};3913};
@@ -3928,7 +3929,8 @@ static const struct macb_config zynqmp_config = { · 15 unmodified lines
3928};3929};
3929 3930
3930static const struct macb_config zynq_config = {3931static const struct macb_config zynq_config = {
3931 .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_NO_GIGABIT_HALF,3932 .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_NO_GIGABIT_HALF |
3933 MACB_CAPS_NEEDS_RSTONUBR,
3932 .dma_burst_length = 16,3934 .dma_burst_length = 16,
3933 .clk_init = macb_clk_init,3935 .clk_init = macb_clk_init,
3934 .init = macb_init,3936 .init = macb_init,
@@ -4083,6 +4085,10 @@ static int macb_probe(struct platform_device *pdev) · 148 unmodified lines
4083 macb_dma_desc_get_size(bp);4085 macb_dma_desc_get_size(bp);
4084 }4086 }
4085 4087
4088 bp->rx_intr_mask = MACB_RX_INT_FLAGS;
4089 if (bp->caps & MACB_CAPS_NEEDS_RSTONUBR)
4090 bp->rx_intr_mask |= MACB_BIT(RXUBR);
4091
4086 mac = of_get_mac_address(np);4092 mac = of_get_mac_address(np);
4087 if (mac) {4093 if (mac) {
4088 ether_addr_copy(bp->dev->dev_addr, mac);4094 ether_addr_copy(bp->dev->dev_addr, mac);
drivers/net/ethernet/hisilicon/hns/hns_enet.c+5−0
@@ -2418,6 +2418,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev) · 2417 unmodified lines
2418out_notify_fail:2418out_notify_fail:
2419 (void)cancel_work_sync(&priv->service_task);2419 (void)cancel_work_sync(&priv->service_task);
2420out_read_prop_fail:2420out_read_prop_fail:
2421 /* safe for ACPI FW */
2422 of_node_put(to_of_node(priv->fwnode));
2421 free_netdev(ndev);2423 free_netdev(ndev);
2422 return ret;2424 return ret;
2423}2425}
@@ -2447,6 +2449,9 @@ static int hns_nic_dev_remove(struct platform_device *pdev) · 23 unmodified lines
2447 set_bit(NIC_STATE_REMOVING, &priv->state);2449 set_bit(NIC_STATE_REMOVING, &priv->state);
2448 (void)cancel_work_sync(&priv->service_task);2450 (void)cancel_work_sync(&priv->service_task);
2449 2451
2452 /* safe for ACPI FW */
2453 of_node_put(to_of_node(priv->fwnode));
2454
2450 free_netdev(ndev);2455 free_netdev(ndev);
2451 return 0;2456 return 0;
2452}2457}
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c+9−7
@@ -1157,16 +1157,18 @@ static int hns_get_regs_len(struct net_device *net_dev) · 1156 unmodified lines
1157 */1157 */
1158static int hns_nic_nway_reset(struct net_device *netdev)1158static int hns_nic_nway_reset(struct net_device *netdev)
1159{1159{
1160 int ret = 0;
1161 struct phy_device *phy = netdev->phydev;1160 struct phy_device *phy = netdev->phydev;
1162 1161
1163 if (netif_running(netdev)) {1162 if (!netif_running(netdev))
1164 /* if autoneg is disabled, don't restart auto-negotiation */1163 return 0;
1165 if (phy && phy->autoneg == AUTONEG_ENABLE)
1166 ret = genphy_restart_aneg(phy);
1167 }
1168 1164
1169 return ret;1165 if (!phy)
1166 return -EOPNOTSUPP;
1167
1168 if (phy->autoneg != AUTONEG_ENABLE)
1169 return -EINVAL;
1170
1171 return genphy_restart_aneg(phy);
1170}1172}
1171 1173
1172static u321174static u32
drivers/net/ethernet/hisilicon/hns_mdio.c+1−1
@@ -321,7 +321,7 @@ static int hns_mdio_read(struct mii_bus *bus, int phy_id, int regnum) · 320 unmodified lines
321 }321 }
322 322
323 hns_mdio_cmd_write(mdio_dev, is_c45,323 hns_mdio_cmd_write(mdio_dev, is_c45,
324 MDIO_C45_WRITE_ADDR, phy_id, devad);324 MDIO_C45_READ, phy_id, devad);
325 }325 }
326 326
327 /* Step 5: waitting for MDIO_COMMAND_REG 's mdio_start==0,*/327 /* Step 5: waitting for MDIO_COMMAND_REG 's mdio_start==0,*/
drivers/net/ethernet/i825xx/82596.c+1−1
@@ -1310,7 +1310,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id) · 1309 unmodified lines
1310 dev->stats.tx_aborted_errors++;1310 dev->stats.tx_aborted_errors++;
1311 }1311 }
1312 1312
1313 dev_kfree_skb_irq(skb);1313 dev_consume_skb_irq(skb);
1314 1314
1315 tx_cmd->cmd.command = 0; /* Mark free */1315 tx_cmd->cmd.command = 0; /* Mark free */
1316 break;1316 break;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+1−1
@@ -950,7 +950,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c, · 949 unmodified lines
950 if (params->rx_dim_enabled)950 if (params->rx_dim_enabled)
951 __set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);951 __set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
952 952
953 if (params->pflags & MLX5E_PFLAG_RX_NO_CSUM_COMPLETE)953 if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
954 __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);954 __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
955 955
956 return 0;956 return 0;
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+23−2
@@ -1126,9 +1126,17 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev, · 1125 unmodified lines
1126 struct mlx5e_priv *priv = netdev_priv(dev);1126 struct mlx5e_priv *priv = netdev_priv(dev);
1127 struct mlx5e_rep_priv *rpriv = priv->ppriv;1127 struct mlx5e_rep_priv *rpriv = priv->ppriv;
1128 struct mlx5_eswitch_rep *rep = rpriv->rep;1128 struct mlx5_eswitch_rep *rep = rpriv->rep;
1129 int ret;1129 int ret, pf_num;
1130
1131 ret = mlx5_lag_get_pf_num(priv->mdev, &pf_num);
1132 if (ret)
1133 return ret;
1134
1135 if (rep->vport == FDB_UPLINK_VPORT)
1136 ret = snprintf(buf, len, "p%d", pf_num);
1137 else
1138 ret = snprintf(buf, len, "pf%dvf%d", pf_num, rep->vport - 1);
1130 1139
1131 ret = snprintf(buf, len, "%d", rep->vport - 1);
1132 if (ret >= len)1140 if (ret >= len)
1133 return -EOPNOTSUPP;1141 return -EOPNOTSUPP;
1134 1142
@@ -1285,6 +1293,18 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr) · 150 unmodified lines
1285 return 0;1293 return 0;
1286}1294}
1287 1295
1296static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
1297 __be16 vlan_proto)
1298{
1299 netdev_warn_once(dev, "legacy vf vlan setting isn't supported in switchdev mode\n");
1300
1301 if (vlan != 0)
1302 return -EOPNOTSUPP;
1303
1304 /* allow setting 0-vid for compatibility with libvirt */
1305 return 0;
1306}
1307
1288static const struct switchdev_ops mlx5e_rep_switchdev_ops = {1308static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
1289 .switchdev_port_attr_get = mlx5e_attr_get,1309 .switchdev_port_attr_get = mlx5e_attr_get,
1290};1310};
@@ -1319,6 +1339,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { · 28 unmodified lines
1319 .ndo_set_vf_rate = mlx5e_set_vf_rate,1339 .ndo_set_vf_rate = mlx5e_set_vf_rate,
1320 .ndo_get_vf_config = mlx5e_get_vf_config,1340 .ndo_get_vf_config = mlx5e_get_vf_config,
1321 .ndo_get_vf_stats = mlx5e_get_vf_stats,1341 .ndo_get_vf_stats = mlx5e_get_vf_stats,
1342 .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
1322};1343};
1323 1344
1324bool mlx5e_eswitch_rep(struct net_device *netdev)1345bool mlx5e_eswitch_rep(struct net_device *netdev)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+8−14
@@ -1134,13 +1134,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, · 1133 unmodified lines
1134 int err = 0;1134 int err = 0;
1135 u8 *smac_v;1135 u8 *smac_v;
1136 1136
1137 if (vport->info.spoofchk && !is_valid_ether_addr(vport->info.mac)) {
1138 mlx5_core_warn(esw->dev,
1139 "vport[%d] configure ingress rules failed, illegal mac with spoofchk\n",
1140 vport->vport);
1141 return -EPERM;
1142 }
1143
1144 esw_vport_cleanup_ingress_rules(esw, vport);1137 esw_vport_cleanup_ingress_rules(esw, vport);
1145 1138
1146 if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) {1139 if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) {
@@ -1728,7 +1721,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) · 581 unmodified lines
1728 int vport_num;1721 int vport_num;
1729 int err;1722 int err;
1730 1723
1731 if (!MLX5_ESWITCH_MANAGER(dev))1724 if (!MLX5_VPORT_MANAGER(dev))
1732 return 0;1725 return 0;
1733 1726
1734 esw_info(dev,1727 esw_info(dev,
@@ -1797,7 +1790,7 @@ abort: · 62 unmodified lines
1797 1790
1798void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)1791void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
1799{1792{
1800 if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev))1793 if (!esw || !MLX5_VPORT_MANAGER(esw->dev))
1801 return;1794 return;
1802 1795
1803 esw_info(esw->dev, "cleanup\n");1796 esw_info(esw->dev, "cleanup\n");
@@ -1827,13 +1820,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, · 23 unmodified lines
1827 mutex_lock(&esw->state_lock);1820 mutex_lock(&esw->state_lock);
1828 evport = &esw->vports[vport];1821 evport = &esw->vports[vport];
1829 1822
1830 if (evport->info.spoofchk && !is_valid_ether_addr(mac)) {1823 if (evport->info.spoofchk && !is_valid_ether_addr(mac))
1831 mlx5_core_warn(esw->dev,1824 mlx5_core_warn(esw->dev,
1832 "MAC invalidation is not allowed when spoofchk is on, vport(%d)\n",1825 "Set invalid MAC while spoofchk is on, vport(%d)\n",
1833 vport);1826 vport);
1834 err = -EPERM;
1835 goto unlock;
1836 }
1837 1827
1838 err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);1828 err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);
1839 if (err) {1829 if (err) {
@@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 139 unmodified lines
1979 evport = &esw->vports[vport];1969 evport = &esw->vports[vport];
1980 pschk = evport->info.spoofchk;1970 pschk = evport->info.spoofchk;
1981 evport->info.spoofchk = spoofchk;1971 evport->info.spoofchk = spoofchk;
1972 if (pschk && !is_valid_ether_addr(evport->info.mac))
1973 mlx5_core_warn(esw->dev,
1974 "Spoofchk in set while MAC is invalid, vport(%d)\n",
1975 evport->vport);
1982 if (evport->enabled && esw->mode == SRIOV_LEGACY)1976 if (evport->enabled && esw->mode == SRIOV_LEGACY)
1983 err = esw_vport_ingress_config(esw, evport);1977 err = esw_vport_ingress_config(esw, evport);
1984 if (err)1978 if (err)
drivers/net/ethernet/mellanox/mlx5/core/lag.c+21−0
@@ -616,6 +616,27 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev) · 615 unmodified lines
616 }616 }
617}617}
618 618
619int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num)
620{
621 struct mlx5_lag *ldev;
622 int n;
623
624 ldev = mlx5_lag_dev_get(dev);
625 if (!ldev) {
626 mlx5_core_warn(dev, "no lag device, can't get pf num\n");
627 return -EINVAL;
628 }
629
630 for (n = 0; n < MLX5_MAX_PORTS; n++)
631 if (ldev->pf[n].dev == dev) {
632 *pf_num = n;
633 return 0;
634 }
635
636 mlx5_core_warn(dev, "wasn't able to locate pf in the lag device\n");
637 return -EINVAL;
638}
639
619/* Must be called with intf_mutex held */640/* Must be called with intf_mutex held */
620void mlx5_lag_remove(struct mlx5_core_dev *dev)641void mlx5_lag_remove(struct mlx5_core_dev *dev)
621{642{
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h+2−0
@@ -187,6 +187,8 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev) · 186 unmodified lines
187 MLX5_CAP_GEN(dev, lag_master);187 MLX5_CAP_GEN(dev, lag_master);
188}188}
189 189
190int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num);
191
190void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);192void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);
191void mlx5_lag_update(struct mlx5_core_dev *dev);193void mlx5_lag_update(struct mlx5_core_dev *dev);
192 194
drivers/net/ethernet/mellanox/mlx5/core/qp.c+3−2
@@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common * · 43 unmodified lines
44mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)44mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
45{45{
46 struct mlx5_core_rsc_common *common;46 struct mlx5_core_rsc_common *common;
47 unsigned long flags;
47 48
48 spin_lock(&table->lock);49 spin_lock_irqsave(&table->lock, flags);
49 50
50 common = radix_tree_lookup(&table->tree, rsn);51 common = radix_tree_lookup(&table->tree, rsn);
51 if (common)52 if (common)
52 atomic_inc(&common->refcount);53 atomic_inc(&common->refcount);
53 54
54 spin_unlock(&table->lock);55 spin_unlock_irqrestore(&table->lock, flags);
55 56
56 return common;57 return common;
57}58}
drivers/net/ethernet/qlogic/qed/qed_dev.c+4−4
@@ -795,19 +795,19 @@ static void qed_init_qm_pq(struct qed_hwfn *p_hwfn, · 794 unmodified lines
795 795
796/* get pq index according to PQ_FLAGS */796/* get pq index according to PQ_FLAGS */
797static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn,797static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn,
798 u32 pq_flags)798 unsigned long pq_flags)
799{799{
800 struct qed_qm_info *qm_info = &p_hwfn->qm_info;800 struct qed_qm_info *qm_info = &p_hwfn->qm_info;
801 801
802 /* Can't have multiple flags set here */802 /* Can't have multiple flags set here */
803 if (bitmap_weight((unsigned long *)&pq_flags,803 if (bitmap_weight(&pq_flags,
804 sizeof(pq_flags) * BITS_PER_BYTE) > 1) {804 sizeof(pq_flags) * BITS_PER_BYTE) > 1) {
805 DP_ERR(p_hwfn, "requested multiple pq flags 0x%x\n", pq_flags);805 DP_ERR(p_hwfn, "requested multiple pq flags 0x%lx\n", pq_flags);
806 goto err;806 goto err;
807 }807 }
808 808
809 if (!(qed_get_pq_flags(p_hwfn) & pq_flags)) {809 if (!(qed_get_pq_flags(p_hwfn) & pq_flags)) {
810 DP_ERR(p_hwfn, "pq flag 0x%x is not set\n", pq_flags);810 DP_ERR(p_hwfn, "pq flag 0x%lx is not set\n", pq_flags);
811 goto err;811 goto err;
812 }812 }
813 813
drivers/net/ethernet/qlogic/qed/qed_l2.c+11−1
@@ -609,6 +609,10 @@ qed_sp_update_accept_mode(struct qed_hwfn *p_hwfn, · 608 unmodified lines
609 (!!(accept_filter & QED_ACCEPT_MCAST_MATCHED) &&609 (!!(accept_filter & QED_ACCEPT_MCAST_MATCHED) &&
610 !!(accept_filter & QED_ACCEPT_MCAST_UNMATCHED)));610 !!(accept_filter & QED_ACCEPT_MCAST_UNMATCHED)));
611 611
612 SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_ACCEPT_ALL,
613 (!!(accept_filter & QED_ACCEPT_UCAST_MATCHED) &&
614 !!(accept_filter & QED_ACCEPT_UCAST_UNMATCHED)));
615
612 SET_FIELD(state, ETH_VPORT_TX_MODE_BCAST_ACCEPT_ALL,616 SET_FIELD(state, ETH_VPORT_TX_MODE_BCAST_ACCEPT_ALL,
613 !!(accept_filter & QED_ACCEPT_BCAST));617 !!(accept_filter & QED_ACCEPT_BCAST));
614 618
@@ -744,6 +748,11 @@ int qed_sp_vport_update(struct qed_hwfn *p_hwfn, · 129 unmodified lines
744 return rc;748 return rc;
745 }749 }
746 750
751 if (p_params->update_ctl_frame_check) {
752 p_cmn->ctl_frame_mac_check_en = p_params->mac_chk_en;
753 p_cmn->ctl_frame_ethtype_check_en = p_params->ethtype_chk_en;
754 }
755
747 /* Update mcast bins for VFs, PF doesn't use this functionality */756 /* Update mcast bins for VFs, PF doesn't use this functionality */
748 qed_sp_update_mcast_bin(p_hwfn, p_ramrod, p_params);757 qed_sp_update_mcast_bin(p_hwfn, p_ramrod, p_params);
749 758
@@ -2688,7 +2697,8 @@ static int qed_configure_filter_rx_mode(struct qed_dev *cdev, · 1938 unmodified lines
2688 if (type == QED_FILTER_RX_MODE_TYPE_PROMISC) {2697 if (type == QED_FILTER_RX_MODE_TYPE_PROMISC) {
2689 accept_flags.rx_accept_filter |= QED_ACCEPT_UCAST_UNMATCHED |2698 accept_flags.rx_accept_filter |= QED_ACCEPT_UCAST_UNMATCHED |
2690 QED_ACCEPT_MCAST_UNMATCHED;2699 QED_ACCEPT_MCAST_UNMATCHED;
2691 accept_flags.tx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;2700 accept_flags.tx_accept_filter |= QED_ACCEPT_UCAST_UNMATCHED |
2701 QED_ACCEPT_MCAST_UNMATCHED;
2692 } else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC) {2702 } else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC) {
2693 accept_flags.rx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;2703 accept_flags.rx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;
2694 accept_flags.tx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;2704 accept_flags.tx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;
drivers/net/ethernet/qlogic/qed/qed_l2.h+3−0
@@ -219,6 +219,9 @@ struct qed_sp_vport_update_params { · 218 unmodified lines
219 struct qed_rss_params *rss_params;219 struct qed_rss_params *rss_params;
220 struct qed_filter_accept_flags accept_flags;220 struct qed_filter_accept_flags accept_flags;
221 struct qed_sge_tpa_params *sge_tpa_params;221 struct qed_sge_tpa_params *sge_tpa_params;
222 u8 update_ctl_frame_check;
223 u8 mac_chk_en;
224 u8 ethtype_chk_en;
222};225};
223 226
224int qed_sp_vport_update(struct qed_hwfn *p_hwfn,227int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
drivers/net/ethernet/qlogic/qed/qed_ll2.c+15−5
@@ -2451,19 +2451,24 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb, · 2450 unmodified lines
2451{2451{
2452 struct qed_ll2_tx_pkt_info pkt;2452 struct qed_ll2_tx_pkt_info pkt;
2453 const skb_frag_t *frag;2453 const skb_frag_t *frag;
2454 u8 flags = 0, nr_frags;
2454 int rc = -EINVAL, i;2455 int rc = -EINVAL, i;
2455 dma_addr_t mapping;2456 dma_addr_t mapping;
2456 u16 vlan = 0;2457 u16 vlan = 0;
2457 u8 flags = 0;
2458 2458
2459 if (unlikely(skb->ip_summed != CHECKSUM_NONE)) {2459 if (unlikely(skb->ip_summed != CHECKSUM_NONE)) {
2460 DP_INFO(cdev, "Cannot transmit a checksummed packet\n");2460 DP_INFO(cdev, "Cannot transmit a checksummed packet\n");
2461 return -EINVAL;2461 return -EINVAL;
2462 }2462 }
2463 2463
2464 if (1 + skb_shinfo(skb)->nr_frags > CORE_LL2_TX_MAX_BDS_PER_PACKET) {2464 /* Cache number of fragments from SKB since SKB may be freed by
2465 * the completion routine after calling qed_ll2_prepare_tx_packet()
2466 */
2467 nr_frags = skb_shinfo(skb)->nr_frags;
2468
2469 if (1 + nr_frags > CORE_LL2_TX_MAX_BDS_PER_PACKET) {
2465 DP_ERR(cdev, "Cannot transmit a packet with %d fragments\n",2470 DP_ERR(cdev, "Cannot transmit a packet with %d fragments\n",
2466 1 + skb_shinfo(skb)->nr_frags);2471 1 + nr_frags);
2467 return -EINVAL;2472 return -EINVAL;
2468 }2473 }
2469 2474
@@ -2485,7 +2490,7 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb, · 15 unmodified lines
2485 }2490 }
2486 2491
2487 memset(&pkt, 0, sizeof(pkt));2492 memset(&pkt, 0, sizeof(pkt));
2488 pkt.num_of_bds = 1 + skb_shinfo(skb)->nr_frags;2493 pkt.num_of_bds = 1 + nr_frags;
2489 pkt.vlan = vlan;2494 pkt.vlan = vlan;
2490 pkt.bd_flags = flags;2495 pkt.bd_flags = flags;
2491 pkt.tx_dest = QED_LL2_TX_DEST_NW;2496 pkt.tx_dest = QED_LL2_TX_DEST_NW;
@@ -2496,12 +2501,17 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb, · 4 unmodified lines
2496 test_bit(QED_LL2_XMIT_FLAGS_FIP_DISCOVERY, &xmit_flags))2501 test_bit(QED_LL2_XMIT_FLAGS_FIP_DISCOVERY, &xmit_flags))
2497 pkt.remove_stag = true;2502 pkt.remove_stag = true;
2498 2503
2504 /* qed_ll2_prepare_tx_packet() may actually send the packet if
2505 * there are no fragments in the skb and subsequently the completion
2506 * routine may run and free the SKB, so no dereferencing the SKB
2507 * beyond this point unless skb has any fragments.
2508 */
2499 rc = qed_ll2_prepare_tx_packet(&cdev->hwfns[0], cdev->ll2->handle,2509 rc = qed_ll2_prepare_tx_packet(&cdev->hwfns[0], cdev->ll2->handle,
2500 &pkt, 1);2510 &pkt, 1);
2501 if (rc)2511 if (rc)
2502 goto err;2512 goto err;
2503 2513
2504 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {2514 for (i = 0; i < nr_frags; i++) {
2505 frag = &skb_shinfo(skb)->frags[i];2515 frag = &skb_shinfo(skb)->frags[i];
2506 2516
2507 mapping = skb_frag_dma_map(&cdev->pdev->dev, frag, 0,2517 mapping = skb_frag_dma_map(&cdev->pdev->dev, frag, 0,
drivers/net/ethernet/qlogic/qed/qed_sriov.c+8−2
@@ -1969,7 +1969,9 @@ static void qed_iov_vf_mbx_start_vport(struct qed_hwfn *p_hwfn, · 1968 unmodified lines
1969 params.vport_id = vf->vport_id;1969 params.vport_id = vf->vport_id;
1970 params.max_buffers_per_cqe = start->max_buffers_per_cqe;1970 params.max_buffers_per_cqe = start->max_buffers_per_cqe;
1971 params.mtu = vf->mtu;1971 params.mtu = vf->mtu;
1972 params.check_mac = true;1972
1973 /* Non trusted VFs should enable control frame filtering */
1974 params.check_mac = !vf->p_vf_info.is_trusted_configured;
1973 1975
1974 rc = qed_sp_eth_vport_start(p_hwfn, &params);1976 rc = qed_sp_eth_vport_start(p_hwfn, &params);
1975 if (rc) {1977 if (rc) {
@@ -5130,6 +5132,9 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn) · 3154 unmodified lines
5130 params.opaque_fid = vf->opaque_fid;5132 params.opaque_fid = vf->opaque_fid;
5131 params.vport_id = vf->vport_id;5133 params.vport_id = vf->vport_id;
5132 5134
5135 params.update_ctl_frame_check = 1;
5136 params.mac_chk_en = !vf_info->is_trusted_configured;
5137
5133 if (vf_info->rx_accept_mode & mask) {5138 if (vf_info->rx_accept_mode & mask) {
5134 flags->update_rx_mode_config = 1;5139 flags->update_rx_mode_config = 1;
5135 flags->rx_accept_filter = vf_info->rx_accept_mode;5140 flags->rx_accept_filter = vf_info->rx_accept_mode;
@@ -5147,7 +5152,8 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn) · 11 unmodified lines
5147 }5152 }
5148 5153
5149 if (flags->update_rx_mode_config ||5154 if (flags->update_rx_mode_config ||
5150 flags->update_tx_mode_config)5155 flags->update_tx_mode_config ||
5156 params.update_ctl_frame_check)
5151 qed_sp_vport_update(hwfn, &params,5157 qed_sp_vport_update(hwfn, &params,
5152 QED_SPQ_MODE_EBLOCK, NULL);5158 QED_SPQ_MODE_EBLOCK, NULL);
5153 }5159 }
drivers/net/ethernet/qlogic/qed/qed_vf.c+10−0
@@ -261,6 +261,7 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn) · 260 unmodified lines
261 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;261 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
262 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;262 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
263 struct vf_pf_resc_request *p_resc;263 struct vf_pf_resc_request *p_resc;
264 u8 retry_cnt = VF_ACQUIRE_THRESH;
264 bool resources_acquired = false;265 bool resources_acquired = false;
265 struct vfpf_acquire_tlv *req;266 struct vfpf_acquire_tlv *req;
266 int rc = 0, attempts = 0;267 int rc = 0, attempts = 0;
@@ -314,6 +315,15 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn) · 47 unmodified lines
314 315
315 /* send acquire request */316 /* send acquire request */
316 rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));317 rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
318
319 /* Re-try acquire in case of vf-pf hw channel timeout */
320 if (retry_cnt && rc == -EBUSY) {
321 DP_VERBOSE(p_hwfn, QED_MSG_IOV,
322 "VF retrying to acquire due to VPC timeout\n");
323 retry_cnt--;
324 continue;
325 }
326
317 if (rc)327 if (rc)
318 goto exit;328 goto exit;
319 329
drivers/net/ethernet/realtek/8139cp.c+1−1
@@ -691,7 +691,7 @@ static void cp_tx (struct cp_private *cp) · 690 unmodified lines
691 }691 }
692 bytes_compl += skb->len;692 bytes_compl += skb->len;
693 pkts_compl++;693 pkts_compl++;
694 dev_kfree_skb_irq(skb);694 dev_consume_skb_irq(skb);
695 }695 }
696 696
697 cp->tx_skb[tx_tail] = NULL;697 cp->tx_skb[tx_tail] = NULL;
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c+3−1
@@ -1342,8 +1342,10 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) · 1341 unmodified lines
1342 }1342 }
1343 1343
1344 ret = phy_power_on(bsp_priv, true);1344 ret = phy_power_on(bsp_priv, true);
1345 if (ret)1345 if (ret) {
1346 gmac_clk_enable(bsp_priv, false);
1346 return ret;1347 return ret;
1348 }
1347 1349
1348 pm_runtime_enable(dev);1350 pm_runtime_enable(dev);
1349 pm_runtime_get_sync(dev);1351 pm_runtime_get_sync(dev);
drivers/net/ethernet/ti/cpmac.c+1−1
@@ -608,7 +608,7 @@ static void cpmac_end_xmit(struct net_device *dev, int queue) · 607 unmodified lines
608 netdev_dbg(dev, "sent 0x%p, len=%d\n",608 netdev_dbg(dev, "sent 0x%p, len=%d\n",
609 desc->skb, desc->skb->len);609 desc->skb, desc->skb->len);
610 610
611 dev_kfree_skb_irq(desc->skb);611 dev_consume_skb_irq(desc->skb);
612 desc->skb = NULL;612 desc->skb = NULL;
613 if (__netif_subqueue_stopped(dev, queue))613 if (__netif_subqueue_stopped(dev, queue))
614 netif_wake_subqueue(dev, queue);614 netif_wake_subqueue(dev, queue);
drivers/vhost/net.c+2−1
@@ -1337,7 +1337,8 @@ static int vhost_net_open(struct inode *inode, struct file *f) · 1336 unmodified lines
1337 n->vqs[i].rx_ring = NULL;1337 n->vqs[i].rx_ring = NULL;
1338 vhost_net_buf_init(&n->vqs[i].rxq);1338 vhost_net_buf_init(&n->vqs[i].rxq);
1339 }1339 }
1340 vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);1340 vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX,
1341 UIO_MAXIOV + VHOST_NET_BATCH);
1341 1342
1342 vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev);1343 vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev);
1343 vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev);1344 vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev);
drivers/vhost/scsi.c+1−1
@@ -1627,7 +1627,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) · 1626 unmodified lines
1627 vqs[i] = &vs->vqs[i].vq;1627 vqs[i] = &vs->vqs[i].vq;
1628 vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;1628 vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
1629 }1629 }
1630 vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);1630 vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV);
1631 1631
1632 vhost_scsi_init_inflight(vs, NULL);1632 vhost_scsi_init_inflight(vs, NULL);
1633 1633
drivers/vhost/vhost.c+4−3
@@ -390,9 +390,9 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) · 389 unmodified lines
390 vq->indirect = kmalloc_array(UIO_MAXIOV,390 vq->indirect = kmalloc_array(UIO_MAXIOV,
391 sizeof(*vq->indirect),391 sizeof(*vq->indirect),
392 GFP_KERNEL);392 GFP_KERNEL);
393 vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log),393 vq->log = kmalloc_array(dev->iov_limit, sizeof(*vq->log),
394 GFP_KERNEL);394 GFP_KERNEL);
395 vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads),395 vq->heads = kmalloc_array(dev->iov_limit, sizeof(*vq->heads),
396 GFP_KERNEL);396 GFP_KERNEL);
397 if (!vq->indirect || !vq->log || !vq->heads)397 if (!vq->indirect || !vq->log || !vq->heads)
398 goto err_nomem;398 goto err_nomem;
@@ -414,7 +414,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev) · 15 unmodified lines
414}414}
415 415
416void vhost_dev_init(struct vhost_dev *dev,416void vhost_dev_init(struct vhost_dev *dev,
417 struct vhost_virtqueue **vqs, int nvqs)417 struct vhost_virtqueue **vqs, int nvqs, int iov_limit)
418{418{
419 struct vhost_virtqueue *vq;419 struct vhost_virtqueue *vq;
420 int i;420 int i;
@@ -427,6 +427,7 @@ void vhost_dev_init(struct vhost_dev *dev, · 6 unmodified lines
427 dev->iotlb = NULL;427 dev->iotlb = NULL;
428 dev->mm = NULL;428 dev->mm = NULL;
429 dev->worker = NULL;429 dev->worker = NULL;
430 dev->iov_limit = iov_limit;
430 init_llist_head(&dev->work_list);431 init_llist_head(&dev->work_list);
431 init_waitqueue_head(&dev->wait);432 init_waitqueue_head(&dev->wait);
432 INIT_LIST_HEAD(&dev->read_list);433 INIT_LIST_HEAD(&dev->read_list);
drivers/vhost/vhost.h+3−1
@@ -170,9 +170,11 @@ struct vhost_dev { · 169 unmodified lines
170 struct list_head read_list;170 struct list_head read_list;
171 struct list_head pending_list;171 struct list_head pending_list;
172 wait_queue_head_t wait;172 wait_queue_head_t wait;
173 int iov_limit;
173};174};
174 175
175void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);176void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs,
177 int nvqs, int iov_limit);
176long vhost_dev_set_owner(struct vhost_dev *dev);178long vhost_dev_set_owner(struct vhost_dev *dev);
177bool vhost_dev_has_owner(struct vhost_dev *dev);179bool vhost_dev_has_owner(struct vhost_dev *dev);
178long vhost_dev_check_owner(struct vhost_dev *);180long vhost_dev_check_owner(struct vhost_dev *);
drivers/vhost/vsock.c+1−1
@@ -531,7 +531,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) · 530 unmodified lines
531 vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick;531 vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick;
532 vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick;532 vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick;
533 533
534 vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs));534 vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), UIO_MAXIOV);
535 535
536 file->private_data = vsock;536 file->private_data = vsock;
537 spin_lock_init(&vsock->send_pkt_list_lock);537 spin_lock_init(&vsock->send_pkt_list_lock);
include/net/tls.h+2−0
@@ -120,6 +120,8 @@ struct tls_rec { · 119 unmodified lines
120 struct scatterlist sg_aead_out[2];120 struct scatterlist sg_aead_out[2];
121 121
122 char aad_space[TLS_AAD_SPACE_SIZE];122 char aad_space[TLS_AAD_SPACE_SIZE];
123 u8 iv_data[TLS_CIPHER_AES_GCM_128_IV_SIZE +
124 TLS_CIPHER_AES_GCM_128_SALT_SIZE];
123 struct aead_request aead_req;125 struct aead_request aead_req;
124 u8 aead_req_ctx[];126 u8 aead_req_ctx[];
125};127};
net/bridge/netfilter/ebtables.c+6−3
@@ -2293,9 +2293,12 @@ static int compat_do_replace(struct net *net, void __user *user, · 2292 unmodified lines
2293 2293
2294 xt_compat_lock(NFPROTO_BRIDGE);2294 xt_compat_lock(NFPROTO_BRIDGE);
2295 2295
2296 ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);2296 if (tmp.nentries) {
2297 if (ret < 0)2297 ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
2298 goto out_unlock;2298 if (ret < 0)
2299 goto out_unlock;
2300 }
2301
2299 ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);2302 ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
2300 if (ret < 0)2303 if (ret < 0)
2301 goto out_unlock;2304 goto out_unlock;
net/core/dev.c+3−0
@@ -8712,6 +8712,9 @@ int init_dummy_netdev(struct net_device *dev) · 8711 unmodified lines
8712 set_bit(__LINK_STATE_PRESENT, &dev->state);8712 set_bit(__LINK_STATE_PRESENT, &dev->state);
8713 set_bit(__LINK_STATE_START, &dev->state);8713 set_bit(__LINK_STATE_START, &dev->state);
8714 8714
8715 /* napi_busy_loop stats accounting wants this */
8716 dev_net_set(dev, &init_net);
8717
8715 /* Note : We dont allocate pcpu_refcnt for dummy devices,8718 /* Note : We dont allocate pcpu_refcnt for dummy devices,
8716 * because users of this 'device' dont need to change8719 * because users of this 'device' dont need to change
8717 * its refcount.8720 * its refcount.
net/decnet/dn_dev.c+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
56#include <net/dn_neigh.h>56#include <net/dn_neigh.h>
57#include <net/dn_fib.h>57#include <net/dn_fib.h>
58 58
59#define DN_IFREQ_SIZE (sizeof(struct ifreq) - sizeof(struct sockaddr) + sizeof(struct sockaddr_dn))59#define DN_IFREQ_SIZE (offsetof(struct ifreq, ifr_ifru) + sizeof(struct sockaddr_dn))
60 60
61static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00};61static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00};
62static char dn_rt_all_rt_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x03,0x00,0x00};62static char dn_rt_all_rt_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x03,0x00,0x00};
net/ipv4/ip_vti.c+50−0
@@ -74,6 +74,33 @@ drop: · 73 unmodified lines
74 return 0;74 return 0;
75}75}
76 76
77static int vti_input_ipip(struct sk_buff *skb, int nexthdr, __be32 spi,
78 int encap_type)
79{
80 struct ip_tunnel *tunnel;
81 const struct iphdr *iph = ip_hdr(skb);
82 struct net *net = dev_net(skb->dev);
83 struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
84
85 tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
86 iph->saddr, iph->daddr, 0);
87 if (tunnel) {
88 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
89 goto drop;
90
91 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel;
92
93 skb->dev = tunnel->dev;
94
95 return xfrm_input(skb, nexthdr, spi, encap_type);
96 }
97
98 return -EINVAL;
99drop:
100 kfree_skb(skb);
101 return 0;
102}
103
77static int vti_rcv(struct sk_buff *skb)104static int vti_rcv(struct sk_buff *skb)
78{105{
79 XFRM_SPI_SKB_CB(skb)->family = AF_INET;106 XFRM_SPI_SKB_CB(skb)->family = AF_INET;
@@ -82,6 +109,14 @@ static int vti_rcv(struct sk_buff *skb) · 2 unmodified lines
82 return vti_input(skb, ip_hdr(skb)->protocol, 0, 0);109 return vti_input(skb, ip_hdr(skb)->protocol, 0, 0);
83}110}
84 111
112static int vti_rcv_ipip(struct sk_buff *skb)
113{
114 XFRM_SPI_SKB_CB(skb)->family = AF_INET;
115 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
116
117 return vti_input_ipip(skb, ip_hdr(skb)->protocol, ip_hdr(skb)->saddr, 0);
118}
119
85static int vti_rcv_cb(struct sk_buff *skb, int err)120static int vti_rcv_cb(struct sk_buff *skb, int err)
86{121{
87 unsigned short family;122 unsigned short family;
@@ -435,6 +470,12 @@ static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = { · 347 unmodified lines
435 .priority = 100,470 .priority = 100,
436};471};
437 472
473static struct xfrm_tunnel ipip_handler __read_mostly = {
474 .handler = vti_rcv_ipip,
475 .err_handler = vti4_err,
476 .priority = 0,
477};
478
438static int __net_init vti_init_net(struct net *net)479static int __net_init vti_init_net(struct net *net)
439{480{
440 int err;481 int err;
@@ -603,6 +644,13 @@ static int __init vti_init(void) · 162 unmodified lines
603 if (err < 0)644 if (err < 0)
604 goto xfrm_proto_comp_failed;645 goto xfrm_proto_comp_failed;
605 646
647 msg = "ipip tunnel";
648 err = xfrm4_tunnel_register(&ipip_handler, AF_INET);
649 if (err < 0) {
650 pr_info("%s: cant't register tunnel\n",__func__);
651 goto xfrm_tunnel_failed;
652 }
653
606 msg = "netlink interface";654 msg = "netlink interface";
607 err = rtnl_link_register(&vti_link_ops);655 err = rtnl_link_register(&vti_link_ops);
608 if (err < 0)656 if (err < 0)
@@ -612,6 +660,8 @@ static int __init vti_init(void) · 3 unmodified lines
612 660
613rtnl_link_failed:661rtnl_link_failed:
614 xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);662 xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);
663xfrm_tunnel_failed:
664 xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
615xfrm_proto_comp_failed:665xfrm_proto_comp_failed:
616 xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);666 xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
617xfrm_proto_ah_failed:667xfrm_proto_ah_failed:
net/ipv4/netfilter/ipt_CLUSTERIP.c+1−1
@@ -846,9 +846,9 @@ static int clusterip_net_init(struct net *net) · 845 unmodified lines
846 846
847static void clusterip_net_exit(struct net *net)847static void clusterip_net_exit(struct net *net)
848{848{
849#ifdef CONFIG_PROC_FS
849 struct clusterip_net *cn = clusterip_pernet(net);850 struct clusterip_net *cn = clusterip_pernet(net);
850 851
851#ifdef CONFIG_PROC_FS
852 mutex_lock(&cn->mutex);852 mutex_lock(&cn->mutex);
853 proc_remove(cn->procdir);853 proc_remove(cn->procdir);
854 cn->procdir = NULL;854 cn->procdir = NULL;
net/ipv6/ip6mr.c+3−4
@@ -1516,6 +1516,9 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) · 1515 unmodified lines
1516 continue;1516 continue;
1517 rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params);1517 rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params);
1518 list_del_rcu(&c->list);1518 list_del_rcu(&c->list);
1519 call_ip6mr_mfc_entry_notifiers(read_pnet(&mrt->net),
1520 FIB_EVENT_ENTRY_DEL,
1521 (struct mfc6_cache *)c, mrt->id);
1519 mr6_netlink_event(mrt, (struct mfc6_cache *)c, RTM_DELROUTE);1522 mr6_netlink_event(mrt, (struct mfc6_cache *)c, RTM_DELROUTE);
1520 mr_cache_put(c);1523 mr_cache_put(c);
1521 }1524 }
@@ -1524,10 +1527,6 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) · 2 unmodified lines
1524 spin_lock_bh(&mfc_unres_lock);1527 spin_lock_bh(&mfc_unres_lock);
1525 list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) {1528 list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) {
1526 list_del(&c->list);1529 list_del(&c->list);
1527 call_ip6mr_mfc_entry_notifiers(read_pnet(&mrt->net),
1528 FIB_EVENT_ENTRY_DEL,
1529 (struct mfc6_cache *)c,
1530 mrt->id);
1531 mr6_netlink_event(mrt, (struct mfc6_cache *)c,1530 mr6_netlink_event(mrt, (struct mfc6_cache *)c,
1532 RTM_DELROUTE);1531 RTM_DELROUTE);
1533 ip6mr_destroy_unres(mrt, (struct mfc6_cache *)c);1532 ip6mr_destroy_unres(mrt, (struct mfc6_cache *)c);
net/netfilter/ipvs/ip_vs_ctl.c+12−0
@@ -2220,6 +2220,18 @@ static int ip_vs_set_timeout(struct netns_ipvs *ipvs, struct ip_vs_timeout_user · 2219 unmodified lines
2220 u->tcp_fin_timeout,2220 u->tcp_fin_timeout,
2221 u->udp_timeout);2221 u->udp_timeout);
2222 2222
2223#ifdef CONFIG_IP_VS_PROTO_TCP
2224 if (u->tcp_timeout < 0 || u->tcp_timeout > (INT_MAX / HZ) ||
2225 u->tcp_fin_timeout < 0 || u->tcp_fin_timeout > (INT_MAX / HZ)) {
2226 return -EINVAL;
2227 }
2228#endif
2229
2230#ifdef CONFIG_IP_VS_PROTO_UDP
2231 if (u->udp_timeout < 0 || u->udp_timeout > (INT_MAX / HZ))
2232 return -EINVAL;
2233#endif
2234
2223#ifdef CONFIG_IP_VS_PROTO_TCP2235#ifdef CONFIG_IP_VS_PROTO_TCP
2224 if (u->tcp_timeout) {2236 if (u->tcp_timeout) {
2225 pd = ip_vs_proto_data_get(ipvs, IPPROTO_TCP);2237 pd = ip_vs_proto_data_get(ipvs, IPPROTO_TCP);
net/netfilter/nfnetlink_osf.c+4−0
@@ -66,6 +66,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb, · 65 unmodified lines
66 int ttl_check,66 int ttl_check,
67 struct nf_osf_hdr_ctx *ctx)67 struct nf_osf_hdr_ctx *ctx)
68{68{
69 const __u8 *optpinit = ctx->optp;
69 unsigned int check_WSS = 0;70 unsigned int check_WSS = 0;
70 int fmatch = FMATCH_WRONG;71 int fmatch = FMATCH_WRONG;
71 int foptsize, optnum;72 int foptsize, optnum;
@@ -155,6 +156,9 @@ static bool nf_osf_match_one(const struct sk_buff *skb, · 83 unmodified lines
155 }156 }
156 }157 }
157 158
159 if (fmatch != FMATCH_OK)
160 ctx->optp = optpinit;
161
158 return fmatch == FMATCH_OK;162 return fmatch == FMATCH_OK;
159}163}
160 164
net/netfilter/nft_compat.c+142−47
@@ -22,11 +22,15 @@ · 21 unmodified lines
22#include <linux/netfilter_bridge/ebtables.h>22#include <linux/netfilter_bridge/ebtables.h>
23#include <linux/netfilter_arp/arp_tables.h>23#include <linux/netfilter_arp/arp_tables.h>
24#include <net/netfilter/nf_tables.h>24#include <net/netfilter/nf_tables.h>
25#include <net/netns/generic.h>
25 26
26struct nft_xt {27struct nft_xt {
27 struct list_head head;28 struct list_head head;
28 struct nft_expr_ops ops;29 struct nft_expr_ops ops;
29 unsigned int refcnt;30 refcount_t refcnt;
31
32 /* used only when transaction mutex is locked */
33 unsigned int listcnt;
30 34
31 /* Unlike other expressions, ops doesn't have static storage duration.35 /* Unlike other expressions, ops doesn't have static storage duration.
32 * nft core assumes they do. We use kfree_rcu so that nft core can36 * nft core assumes they do. We use kfree_rcu so that nft core can
@@ -43,10 +47,24 @@ struct nft_xt_match_priv { · 10 unmodified lines
43 void *info;47 void *info;
44};48};
45 49
50struct nft_compat_net {
51 struct list_head nft_target_list;
52 struct list_head nft_match_list;
53};
54
55static unsigned int nft_compat_net_id __read_mostly;
56static struct nft_expr_type nft_match_type;
57static struct nft_expr_type nft_target_type;
58
59static struct nft_compat_net *nft_compat_pernet(struct net *net)
60{
61 return net_generic(net, nft_compat_net_id);
62}
63
46static bool nft_xt_put(struct nft_xt *xt)64static bool nft_xt_put(struct nft_xt *xt)
47{65{
48 if (--xt->refcnt == 0) {66 if (refcount_dec_and_test(&xt->refcnt)) {
49 list_del(&xt->head);67 WARN_ON_ONCE(!list_empty(&xt->head));
50 kfree_rcu(xt, rcu_head);68 kfree_rcu(xt, rcu_head);
51 return true;69 return true;
52 }70 }
@@ -273,7 +291,7 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr, · 220 unmodified lines
273 return -EINVAL;291 return -EINVAL;
274 292
275 nft_xt = container_of(expr->ops, struct nft_xt, ops);293 nft_xt = container_of(expr->ops, struct nft_xt, ops);
276 nft_xt->refcnt++;294 refcount_inc(&nft_xt->refcnt);
277 return 0;295 return 0;
278}296}
279 297
@@ -486,7 +504,7 @@ __nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr, · 206 unmodified lines
486 return ret;504 return ret;
487 505
488 nft_xt = container_of(expr->ops, struct nft_xt, ops);506 nft_xt = container_of(expr->ops, struct nft_xt, ops);
489 nft_xt->refcnt++;507 refcount_inc(&nft_xt->refcnt);
490 return 0;508 return 0;
491}509}
492 510
@@ -540,6 +558,43 @@ nft_match_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr) · 47 unmodified lines
540 __nft_match_destroy(ctx, expr, nft_expr_priv(expr));558 __nft_match_destroy(ctx, expr, nft_expr_priv(expr));
541}559}
542 560
561static void nft_compat_activate(const struct nft_ctx *ctx,
562 const struct nft_expr *expr,
563 struct list_head *h)
564{
565 struct nft_xt *xt = container_of(expr->ops, struct nft_xt, ops);
566
567 if (xt->listcnt == 0)
568 list_add(&xt->head, h);
569
570 xt->listcnt++;
571}
572
573static void nft_compat_activate_mt(const struct nft_ctx *ctx,
574 const struct nft_expr *expr)
575{
576 struct nft_compat_net *cn = nft_compat_pernet(ctx->net);
577
578 nft_compat_activate(ctx, expr, &cn->nft_match_list);
579}
580
581static void nft_compat_activate_tg(const struct nft_ctx *ctx,
582 const struct nft_expr *expr)
583{
584 struct nft_compat_net *cn = nft_compat_pernet(ctx->net);
585
586 nft_compat_activate(ctx, expr, &cn->nft_target_list);
587}
588
589static void nft_compat_deactivate(const struct nft_ctx *ctx,
590 const struct nft_expr *expr)
591{
592 struct nft_xt *xt = container_of(expr->ops, struct nft_xt, ops);
593
594 if (--xt->listcnt == 0)
595 list_del_init(&xt->head);
596}
597
543static void598static void
544nft_match_large_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)599nft_match_large_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
545{600{
@@ -734,10 +789,6 @@ static const struct nfnetlink_subsystem nfnl_compat_subsys = { · 188 unmodified lines
734 .cb = nfnl_nft_compat_cb,789 .cb = nfnl_nft_compat_cb,
735};790};
736 791
737static LIST_HEAD(nft_match_list);
738
739static struct nft_expr_type nft_match_type;
740
741static bool nft_match_cmp(const struct xt_match *match,792static bool nft_match_cmp(const struct xt_match *match,
742 const char *name, u32 rev, u32 family)793 const char *name, u32 rev, u32 family)
743{794{
@@ -749,6 +800,7 @@ static const struct nft_expr_ops * · 5 unmodified lines
749nft_match_select_ops(const struct nft_ctx *ctx,800nft_match_select_ops(const struct nft_ctx *ctx,
750 const struct nlattr * const tb[])801 const struct nlattr * const tb[])
751{802{
803 struct nft_compat_net *cn;
752 struct nft_xt *nft_match;804 struct nft_xt *nft_match;
753 struct xt_match *match;805 struct xt_match *match;
754 unsigned int matchsize;806 unsigned int matchsize;
@@ -765,8 +817,10 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 10 unmodified lines
765 rev = ntohl(nla_get_be32(tb[NFTA_MATCH_REV]));817 rev = ntohl(nla_get_be32(tb[NFTA_MATCH_REV]));
766 family = ctx->family;818 family = ctx->family;
767 819
820 cn = nft_compat_pernet(ctx->net);
821
768 /* Re-use the existing match if it's already loaded. */822 /* Re-use the existing match if it's already loaded. */
769 list_for_each_entry(nft_match, &nft_match_list, head) {823 list_for_each_entry(nft_match, &cn->nft_match_list, head) {
770 struct xt_match *match = nft_match->ops.data;824 struct xt_match *match = nft_match->ops.data;
771 825
772 if (nft_match_cmp(match, mt_name, rev, family))826 if (nft_match_cmp(match, mt_name, rev, family))
@@ -789,11 +843,13 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 16 unmodified lines
789 goto err;843 goto err;
790 }844 }
791 845
792 nft_match->refcnt = 0;846 refcount_set(&nft_match->refcnt, 0);
793 nft_match->ops.type = &nft_match_type;847 nft_match->ops.type = &nft_match_type;
794 nft_match->ops.eval = nft_match_eval;848 nft_match->ops.eval = nft_match_eval;
795 nft_match->ops.init = nft_match_init;849 nft_match->ops.init = nft_match_init;
796 nft_match->ops.destroy = nft_match_destroy;850 nft_match->ops.destroy = nft_match_destroy;
851 nft_match->ops.activate = nft_compat_activate_mt;
852 nft_match->ops.deactivate = nft_compat_deactivate;
797 nft_match->ops.dump = nft_match_dump;853 nft_match->ops.dump = nft_match_dump;
798 nft_match->ops.validate = nft_match_validate;854 nft_match->ops.validate = nft_match_validate;
799 nft_match->ops.data = match;855 nft_match->ops.data = match;
@@ -810,7 +866,8 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 10 unmodified lines
810 866
811 nft_match->ops.size = matchsize;867 nft_match->ops.size = matchsize;
812 868
813 list_add(&nft_match->head, &nft_match_list);869 nft_match->listcnt = 1;
870 list_add(&nft_match->head, &cn->nft_match_list);
814 871
815 return &nft_match->ops;872 return &nft_match->ops;
816err:873err:
@@ -826,10 +883,6 @@ static struct nft_expr_type nft_match_type __read_mostly = { · 9 unmodified lines
826 .owner = THIS_MODULE,883 .owner = THIS_MODULE,
827};884};
828 885
829static LIST_HEAD(nft_target_list);
830
831static struct nft_expr_type nft_target_type;
832
833static bool nft_target_cmp(const struct xt_target *tg,886static bool nft_target_cmp(const struct xt_target *tg,
834 const char *name, u32 rev, u32 family)887 const char *name, u32 rev, u32 family)
835{888{
@@ -841,6 +894,7 @@ static const struct nft_expr_ops * · 5 unmodified lines
841nft_target_select_ops(const struct nft_ctx *ctx,894nft_target_select_ops(const struct nft_ctx *ctx,
842 const struct nlattr * const tb[])895 const struct nlattr * const tb[])
843{896{
897 struct nft_compat_net *cn;
844 struct nft_xt *nft_target;898 struct nft_xt *nft_target;
845 struct xt_target *target;899 struct xt_target *target;
846 char *tg_name;900 char *tg_name;
@@ -861,8 +915,9 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 14 unmodified lines
861 strcmp(tg_name, "standard") == 0)915 strcmp(tg_name, "standard") == 0)
862 return ERR_PTR(-EINVAL);916 return ERR_PTR(-EINVAL);
863 917
918 cn = nft_compat_pernet(ctx->net);
864 /* Re-use the existing target if it's already loaded. */919 /* Re-use the existing target if it's already loaded. */
865 list_for_each_entry(nft_target, &nft_target_list, head) {920 list_for_each_entry(nft_target, &cn->nft_target_list, head) {
866 struct xt_target *target = nft_target->ops.data;921 struct xt_target *target = nft_target->ops.data;
867 922
868 if (!target->target)923 if (!target->target)
@@ -893,11 +948,13 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 24 unmodified lines
893 goto err;948 goto err;
894 }949 }
895 950
896 nft_target->refcnt = 0;951 refcount_set(&nft_target->refcnt, 0);
897 nft_target->ops.type = &nft_target_type;952 nft_target->ops.type = &nft_target_type;
898 nft_target->ops.size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize));953 nft_target->ops.size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize));
899 nft_target->ops.init = nft_target_init;954 nft_target->ops.init = nft_target_init;
900 nft_target->ops.destroy = nft_target_destroy;955 nft_target->ops.destroy = nft_target_destroy;
956 nft_target->ops.activate = nft_compat_activate_tg;
957 nft_target->ops.deactivate = nft_compat_deactivate;
901 nft_target->ops.dump = nft_target_dump;958 nft_target->ops.dump = nft_target_dump;
902 nft_target->ops.validate = nft_target_validate;959 nft_target->ops.validate = nft_target_validate;
903 nft_target->ops.data = target;960 nft_target->ops.data = target;
@@ -907,7 +964,8 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 3 unmodified lines
907 else964 else
908 nft_target->ops.eval = nft_target_eval_xt;965 nft_target->ops.eval = nft_target_eval_xt;
909 966
910 list_add(&nft_target->head, &nft_target_list);967 nft_target->listcnt = 1;
968 list_add(&nft_target->head, &cn->nft_target_list);
911 969
912 return &nft_target->ops;970 return &nft_target->ops;
913err:971err:
@@ -923,13 +981,74 @@ static struct nft_expr_type nft_target_type __read_mostly = { · 9 unmodified lines
923 .owner = THIS_MODULE,981 .owner = THIS_MODULE,
924};982};
925 983
984static int __net_init nft_compat_init_net(struct net *net)
985{
986 struct nft_compat_net *cn = nft_compat_pernet(net);
987
988 INIT_LIST_HEAD(&cn->nft_target_list);
989 INIT_LIST_HEAD(&cn->nft_match_list);
990
991 return 0;
992}
993
994static void __net_exit nft_compat_exit_net(struct net *net)
995{
996 struct nft_compat_net *cn = nft_compat_pernet(net);
997 struct nft_xt *xt, *next;
998
999 if (list_empty(&cn->nft_match_list) &&
1000 list_empty(&cn->nft_target_list))
1001 return;
1002
1003 /* If there was an error that caused nft_xt expr to not be initialized
1004 * fully and noone else requested the same expression later, the lists
1005 * contain 0-refcount entries that still hold module reference.
1006 *
1007 * Clean them here.
1008 */
1009 mutex_lock(&net->nft.commit_mutex);
1010 list_for_each_entry_safe(xt, next, &cn->nft_target_list, head) {
1011 struct xt_target *target = xt->ops.data;
1012
1013 list_del_init(&xt->head);
1014
1015 if (refcount_read(&xt->refcnt))
1016 continue;
1017 module_put(target->me);
1018 kfree(xt);
1019 }
1020
1021 list_for_each_entry_safe(xt, next, &cn->nft_match_list, head) {
1022 struct xt_match *match = xt->ops.data;
1023
1024 list_del_init(&xt->head);
1025
1026 if (refcount_read(&xt->refcnt))
1027 continue;
1028 module_put(match->me);
1029 kfree(xt);
1030 }
1031 mutex_unlock(&net->nft.commit_mutex);
1032}
1033
1034static struct pernet_operations nft_compat_net_ops = {
1035 .init = nft_compat_init_net,
1036 .exit = nft_compat_exit_net,
1037 .id = &nft_compat_net_id,
1038 .size = sizeof(struct nft_compat_net),
1039};
1040
926static int __init nft_compat_module_init(void)1041static int __init nft_compat_module_init(void)
927{1042{
928 int ret;1043 int ret;
929 1044
1045 ret = register_pernet_subsys(&nft_compat_net_ops);
1046 if (ret < 0)
1047 goto err_target;
1048
930 ret = nft_register_expr(&nft_match_type);1049 ret = nft_register_expr(&nft_match_type);
931 if (ret < 0)1050 if (ret < 0)
932 return ret;1051 goto err_pernet;
933 1052
934 ret = nft_register_expr(&nft_target_type);1053 ret = nft_register_expr(&nft_target_type);
935 if (ret < 0)1054 if (ret < 0)
@@ -942,45 +1061,21 @@ static int __init nft_compat_module_init(void) · 6 unmodified lines
942 }1061 }
943 1062
944 return ret;1063 return ret;
945
946err_target:1064err_target:
947 nft_unregister_expr(&nft_target_type);1065 nft_unregister_expr(&nft_target_type);
948err_match:1066err_match:
949 nft_unregister_expr(&nft_match_type);1067 nft_unregister_expr(&nft_match_type);
1068err_pernet:
1069 unregister_pernet_subsys(&nft_compat_net_ops);
950 return ret;1070 return ret;
951}1071}
952 1072
953static void __exit nft_compat_module_exit(void)1073static void __exit nft_compat_module_exit(void)
954{1074{
955 struct nft_xt *xt, *next;
956
957 /* list should be empty here, it can be non-empty only in case there
958 * was an error that caused nft_xt expr to not be initialized fully
959 * and noone else requested the same expression later.
960 *
961 * In this case, the lists contain 0-refcount entries that still
962 * hold module reference.
963 */
964 list_for_each_entry_safe(xt, next, &nft_target_list, head) {
965 struct xt_target *target = xt->ops.data;
966
967 if (WARN_ON_ONCE(xt->refcnt))
968 continue;
969 module_put(target->me);
970 kfree(xt);
971 }
972
973 list_for_each_entry_safe(xt, next, &nft_match_list, head) {
974 struct xt_match *match = xt->ops.data;
975
976 if (WARN_ON_ONCE(xt->refcnt))
977 continue;
978 module_put(match->me);
979 kfree(xt);
980 }
981 nfnetlink_subsys_unregister(&nfnl_compat_subsys);1075 nfnetlink_subsys_unregister(&nfnl_compat_subsys);
982 nft_unregister_expr(&nft_target_type);1076 nft_unregister_expr(&nft_target_type);
983 nft_unregister_expr(&nft_match_type);1077 nft_unregister_expr(&nft_match_type);
1078 unregister_pernet_subsys(&nft_compat_net_ops);
984}1079}
985 1080
986MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT);1081MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT);
net/netrom/nr_timer.c+10−10
@@ -52,21 +52,21 @@ void nr_start_t1timer(struct sock *sk) · 51 unmodified lines
52{52{
53 struct nr_sock *nr = nr_sk(sk);53 struct nr_sock *nr = nr_sk(sk);
54 54
55 mod_timer(&nr->t1timer, jiffies + nr->t1);55 sk_reset_timer(sk, &nr->t1timer, jiffies + nr->t1);
56}56}
57 57
58void nr_start_t2timer(struct sock *sk)58void nr_start_t2timer(struct sock *sk)
59{59{
60 struct nr_sock *nr = nr_sk(sk);60 struct nr_sock *nr = nr_sk(sk);
61 61
62 mod_timer(&nr->t2timer, jiffies + nr->t2);62 sk_reset_timer(sk, &nr->t2timer, jiffies + nr->t2);
63}63}
64 64
65void nr_start_t4timer(struct sock *sk)65void nr_start_t4timer(struct sock *sk)
66{66{
67 struct nr_sock *nr = nr_sk(sk);67 struct nr_sock *nr = nr_sk(sk);
68 68
69 mod_timer(&nr->t4timer, jiffies + nr->t4);69 sk_reset_timer(sk, &nr->t4timer, jiffies + nr->t4);
70}70}
71 71
72void nr_start_idletimer(struct sock *sk)72void nr_start_idletimer(struct sock *sk)
@@ -74,37 +74,37 @@ void nr_start_idletimer(struct sock *sk) · 1 unmodified line
74 struct nr_sock *nr = nr_sk(sk);74 struct nr_sock *nr = nr_sk(sk);
75 75
76 if (nr->idle > 0)76 if (nr->idle > 0)
77 mod_timer(&nr->idletimer, jiffies + nr->idle);77 sk_reset_timer(sk, &nr->idletimer, jiffies + nr->idle);
78}78}
79 79
80void nr_start_heartbeat(struct sock *sk)80void nr_start_heartbeat(struct sock *sk)
81{81{
82 mod_timer(&sk->sk_timer, jiffies + 5 * HZ);82 sk_reset_timer(sk, &sk->sk_timer, jiffies + 5 * HZ);
83}83}
84 84
85void nr_stop_t1timer(struct sock *sk)85void nr_stop_t1timer(struct sock *sk)
86{86{
87 del_timer(&nr_sk(sk)->t1timer);87 sk_stop_timer(sk, &nr_sk(sk)->t1timer);
88}88}
89 89
90void nr_stop_t2timer(struct sock *sk)90void nr_stop_t2timer(struct sock *sk)
91{91{
92 del_timer(&nr_sk(sk)->t2timer);92 sk_stop_timer(sk, &nr_sk(sk)->t2timer);
93}93}
94 94
95void nr_stop_t4timer(struct sock *sk)95void nr_stop_t4timer(struct sock *sk)
96{96{
97 del_timer(&nr_sk(sk)->t4timer);97 sk_stop_timer(sk, &nr_sk(sk)->t4timer);
98}98}
99 99
100void nr_stop_idletimer(struct sock *sk)100void nr_stop_idletimer(struct sock *sk)
101{101{
102 del_timer(&nr_sk(sk)->idletimer);102 sk_stop_timer(sk, &nr_sk(sk)->idletimer);
103}103}
104 104
105void nr_stop_heartbeat(struct sock *sk)105void nr_stop_heartbeat(struct sock *sk)
106{106{
107 del_timer(&sk->sk_timer);107 sk_stop_timer(sk, &sk->sk_timer);
108}108}
109 109
110int nr_t1timer_running(struct sock *sk)110int nr_t1timer_running(struct sock *sk)
net/rose/rose_route.c+5−0
@@ -850,6 +850,7 @@ void rose_link_device_down(struct net_device *dev) · 849 unmodified lines
850 850
851/*851/*
852 * Route a frame to an appropriate AX.25 connection.852 * Route a frame to an appropriate AX.25 connection.
853 * A NULL ax25_cb indicates an internally generated frame.
853 */854 */
854int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)855int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
855{856{
@@ -867,6 +868,10 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) · 11 unmodified lines
867 868
868 if (skb->len < ROSE_MIN_LEN)869 if (skb->len < ROSE_MIN_LEN)
869 return res;870 return res;
871
872 if (!ax25)
873 return rose_loopback_queue(skb, NULL);
874
870 frametype = skb->data[2];875 frametype = skb->data[2];
871 lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);876 lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
872 if (frametype == ROSE_CALL_REQUEST &&877 if (frametype == ROSE_CALL_REQUEST &&
net/tls/tls_sw.c+5−1
@@ -439,6 +439,8 @@ static int tls_do_encryption(struct sock *sk, · 438 unmodified lines
439 struct scatterlist *sge = sk_msg_elem(msg_en, start);439 struct scatterlist *sge = sk_msg_elem(msg_en, start);
440 int rc;440 int rc;
441 441
442 memcpy(rec->iv_data, tls_ctx->tx.iv, sizeof(rec->iv_data));
443
442 sge->offset += tls_ctx->tx.prepend_size;444 sge->offset += tls_ctx->tx.prepend_size;
443 sge->length -= tls_ctx->tx.prepend_size;445 sge->length -= tls_ctx->tx.prepend_size;
444 446
@@ -448,7 +450,7 @@ static int tls_do_encryption(struct sock *sk, · 3 unmodified lines
448 aead_request_set_ad(aead_req, TLS_AAD_SPACE_SIZE);450 aead_request_set_ad(aead_req, TLS_AAD_SPACE_SIZE);
449 aead_request_set_crypt(aead_req, rec->sg_aead_in,451 aead_request_set_crypt(aead_req, rec->sg_aead_in,
450 rec->sg_aead_out,452 rec->sg_aead_out,
451 data_len, tls_ctx->tx.iv);453 data_len, rec->iv_data);
452 454
453 aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG,455 aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG,
454 tls_encrypt_done, sk);456 tls_encrypt_done, sk);
@@ -1792,7 +1794,9 @@ void tls_sw_free_resources_tx(struct sock *sk) · 1337 unmodified lines
1792 if (atomic_read(&ctx->encrypt_pending))1794 if (atomic_read(&ctx->encrypt_pending))
1793 crypto_wait_req(-EINPROGRESS, &ctx->async_wait);1795 crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
1794 1796
1797 release_sock(sk);
1795 cancel_delayed_work_sync(&ctx->tx_work.work);1798 cancel_delayed_work_sync(&ctx->tx_work.work);
1799 lock_sock(sk);
1796 1800
1797 /* Tx whatever records we can transmit and abandon the rest */1801 /* Tx whatever records we can transmit and abandon the rest */
1798 tls_tx_records(sk, -1);1802 tls_tx_records(sk, -1);
net/xfrm/xfrm_policy.c+33−30
@@ -680,16 +680,6 @@ static void xfrm_hash_resize(struct work_struct *work) · 679 unmodified lines
680 mutex_unlock(&hash_resize_mutex);680 mutex_unlock(&hash_resize_mutex);
681}681}
682 682
683static void xfrm_hash_reset_inexact_table(struct net *net)
684{
685 struct xfrm_pol_inexact_bin *b;
686
687 lockdep_assert_held(&net->xfrm.xfrm_policy_lock);
688
689 list_for_each_entry(b, &net->xfrm.inexact_bins, inexact_bins)
690 INIT_HLIST_HEAD(&b->hhead);
691}
692
693/* Make sure *pol can be inserted into fastbin.683/* Make sure *pol can be inserted into fastbin.
694 * Useful to check that later insert requests will be sucessful684 * Useful to check that later insert requests will be sucessful
695 * (provided xfrm_policy_lock is held throughout).685 * (provided xfrm_policy_lock is held throughout).
@@ -833,13 +823,13 @@ static void xfrm_policy_inexact_list_reinsert(struct net *net, · 137 unmodified lines
833 u16 family)823 u16 family)
834{824{
835 unsigned int matched_s, matched_d;825 unsigned int matched_s, matched_d;
836 struct hlist_node *newpos = NULL;
837 struct xfrm_policy *policy, *p;826 struct xfrm_policy *policy, *p;
838 827
839 matched_s = 0;828 matched_s = 0;
840 matched_d = 0;829 matched_d = 0;
841 830
842 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {831 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
832 struct hlist_node *newpos = NULL;
843 bool matches_s, matches_d;833 bool matches_s, matches_d;
844 834
845 if (!policy->bydst_reinsert)835 if (!policy->bydst_reinsert)
@@ -849,16 +839,19 @@ static void xfrm_policy_inexact_list_reinsert(struct net *net, · 3 unmodified lines
849 839
850 policy->bydst_reinsert = false;840 policy->bydst_reinsert = false;
851 hlist_for_each_entry(p, &n->hhead, bydst) {841 hlist_for_each_entry(p, &n->hhead, bydst) {
852 if (policy->priority >= p->priority)842 if (policy->priority > p->priority)
843 newpos = &p->bydst;
844 else if (policy->priority == p->priority &&
845 policy->pos > p->pos)
853 newpos = &p->bydst;846 newpos = &p->bydst;
854 else847 else
855 break;848 break;
856 }849 }
857 850
858 if (newpos)851 if (newpos)
859 hlist_add_behind(&policy->bydst, newpos);852 hlist_add_behind_rcu(&policy->bydst, newpos);
860 else853 else
861 hlist_add_head(&policy->bydst, &n->hhead);854 hlist_add_head_rcu(&policy->bydst, &n->hhead);
862 855
863 /* paranoia checks follow.856 /* paranoia checks follow.
864 * Check that the reinserted policy matches at least857 * Check that the reinserted policy matches at least
@@ -893,12 +886,13 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 28 unmodified lines
893 struct rb_root *new,886 struct rb_root *new,
894 u16 family)887 u16 family)
895{888{
896 struct rb_node **p, *parent = NULL;
897 struct xfrm_pol_inexact_node *node;889 struct xfrm_pol_inexact_node *node;
890 struct rb_node **p, *parent;
898 891
899 /* we should not have another subtree here */892 /* we should not have another subtree here */
900 WARN_ON_ONCE(!RB_EMPTY_ROOT(&n->root));893 WARN_ON_ONCE(!RB_EMPTY_ROOT(&n->root));
901 894restart:
895 parent = NULL;
902 p = &new->rb_node;896 p = &new->rb_node;
903 while (*p) {897 while (*p) {
904 u8 prefixlen;898 u8 prefixlen;
@@ -918,12 +912,11 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 13 unmodified lines
918 } else {912 } else {
919 struct xfrm_policy *tmp;913 struct xfrm_policy *tmp;
920 914
921 hlist_for_each_entry(tmp, &node->hhead, bydst)915 hlist_for_each_entry(tmp, &n->hhead, bydst) {
922 tmp->bydst_reinsert = true;
923 hlist_for_each_entry(tmp, &n->hhead, bydst)
924 tmp->bydst_reinsert = true;916 tmp->bydst_reinsert = true;
917 hlist_del_rcu(&tmp->bydst);
918 }
925 919
926 INIT_HLIST_HEAD(&node->hhead);
927 xfrm_policy_inexact_list_reinsert(net, node, family);920 xfrm_policy_inexact_list_reinsert(net, node, family);
928 921
929 if (node->prefixlen == n->prefixlen) {922 if (node->prefixlen == n->prefixlen) {
@@ -935,8 +928,7 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 5 unmodified lines
935 kfree_rcu(n, rcu);928 kfree_rcu(n, rcu);
936 n = node;929 n = node;
937 n->prefixlen = prefixlen;930 n->prefixlen = prefixlen;
938 *p = new->rb_node;931 goto restart;
939 parent = NULL;
940 }932 }
941 }933 }
942 934
@@ -965,12 +957,11 @@ static void xfrm_policy_inexact_node_merge(struct net *net, · 22 unmodified lines
965 family);957 family);
966 }958 }
967 959
968 hlist_for_each_entry(tmp, &v->hhead, bydst)960 hlist_for_each_entry(tmp, &v->hhead, bydst) {
969 tmp->bydst_reinsert = true;
970 hlist_for_each_entry(tmp, &n->hhead, bydst)
971 tmp->bydst_reinsert = true;961 tmp->bydst_reinsert = true;
962 hlist_del_rcu(&tmp->bydst);
963 }
972 964
973 INIT_HLIST_HEAD(&n->hhead);
974 xfrm_policy_inexact_list_reinsert(net, n, family);965 xfrm_policy_inexact_list_reinsert(net, n, family);
975}966}
976 967
@@ -1235,6 +1226,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 258 unmodified lines
1235 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq));1226 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq));
1236 1227
1237 spin_lock_bh(&net->xfrm.xfrm_policy_lock);1228 spin_lock_bh(&net->xfrm.xfrm_policy_lock);
1229 write_seqcount_begin(&xfrm_policy_hash_generation);
1238 1230
1239 /* make sure that we can insert the indirect policies again before1231 /* make sure that we can insert the indirect policies again before
1240 * we start with destructive action.1232 * we start with destructive action.
@@ -1278,10 +1270,14 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 37 unmodified lines
1278 }1270 }
1279 1271
1280 /* reset the bydst and inexact table in all directions */1272 /* reset the bydst and inexact table in all directions */
1281 xfrm_hash_reset_inexact_table(net);
1282
1283 for (dir = 0; dir < XFRM_POLICY_MAX; dir++) {1273 for (dir = 0; dir < XFRM_POLICY_MAX; dir++) {
1284 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]);1274 struct hlist_node *n;
1275
1276 hlist_for_each_entry_safe(policy, n,
1277 &net->xfrm.policy_inexact[dir],
1278 bydst_inexact_list)
1279 hlist_del_init(&policy->bydst_inexact_list);
1280
1285 hmask = net->xfrm.policy_bydst[dir].hmask;1281 hmask = net->xfrm.policy_bydst[dir].hmask;
1286 odst = net->xfrm.policy_bydst[dir].table;1282 odst = net->xfrm.policy_bydst[dir].table;
1287 for (i = hmask; i >= 0; i--)1283 for (i = hmask; i >= 0; i--)
@@ -1313,6 +1309,9 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 25 unmodified lines
1313 newpos = NULL;1309 newpos = NULL;
1314 chain = policy_hash_bysel(net, &policy->selector,1310 chain = policy_hash_bysel(net, &policy->selector,
1315 policy->family, dir);1311 policy->family, dir);
1312
1313 hlist_del_rcu(&policy->bydst);
1314
1316 if (!chain) {1315 if (!chain) {
1317 void *p = xfrm_policy_inexact_insert(policy, dir, 0);1316 void *p = xfrm_policy_inexact_insert(policy, dir, 0);
1318 1317
@@ -1334,6 +1333,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 15 unmodified lines
1334 1333
1335out_unlock:1334out_unlock:
1336 __xfrm_policy_inexact_flush(net);1335 __xfrm_policy_inexact_flush(net);
1336 write_seqcount_end(&xfrm_policy_hash_generation);
1337 spin_unlock_bh(&net->xfrm.xfrm_policy_lock);1337 spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
1338 1338
1339 mutex_unlock(&hash_resize_mutex);1339 mutex_unlock(&hash_resize_mutex);
@@ -2600,7 +2600,10 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, · 1260 unmodified lines
2600 dst_copy_metrics(dst1, dst);2600 dst_copy_metrics(dst1, dst);
2601 2601
2602 if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {2602 if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
2603 __u32 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);2603 __u32 mark = 0;
2604
2605 if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m)
2606 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);
2604 2607
2605 family = xfrm[i]->props.family;2608 family = xfrm[i]->props.family;
2606 dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif,2609 dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif,
net/xfrm/xfrm_user.c+9−4
@@ -1488,10 +1488,15 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family) · 1487 unmodified lines
1488 if (!ut[i].family)1488 if (!ut[i].family)
1489 ut[i].family = family;1489 ut[i].family = family;
1490 1490
1491 if ((ut[i].mode == XFRM_MODE_TRANSPORT) &&1491 switch (ut[i].mode) {
1492 (ut[i].family != prev_family))1492 case XFRM_MODE_TUNNEL:
1493 return -EINVAL;1493 case XFRM_MODE_BEET:
1494 1494 break;
1495 default:
1496 if (ut[i].family != prev_family)
1497 return -EINVAL;
1498 break;
1499 }
1495 if (ut[i].mode >= XFRM_MODE_MAX)1500 if (ut[i].mode >= XFRM_MODE_MAX)
1496 return -EINVAL;1501 return -EINVAL;
1497 1502
tools/testing/selftests/net/xfrm_policy.sh+131−22
@@ -28,6 +28,19 @@ KEY_AES=0x0123456789abcdef0123456789012345 · 27 unmodified lines
28SPI1=0x128SPI1=0x1
29SPI2=0x229SPI2=0x2
30 30
31do_esp_policy() {
32 local ns=$1
33 local me=$2
34 local remote=$3
35 local lnet=$4
36 local rnet=$5
37
38 # to encrypt packets as they go out (includes forwarded packets that need encapsulation)
39 ip -net $ns xfrm policy add src $lnet dst $rnet dir out tmpl src $me dst $remote proto esp mode tunnel priority 100 action allow
40 # to fwd decrypted packets after esp processing:
41 ip -net $ns xfrm policy add src $rnet dst $lnet dir fwd tmpl src $remote dst $me proto esp mode tunnel priority 100 action allow
42}
43
31do_esp() {44do_esp() {
32 local ns=$145 local ns=$1
33 local me=$246 local me=$2
@@ -40,10 +53,59 @@ do_esp() { · 6 unmodified lines
40 ip -net $ns xfrm state add src $remote dst $me proto esp spi $spi_in enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $rnet dst $lnet53 ip -net $ns xfrm state add src $remote dst $me proto esp spi $spi_in enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $rnet dst $lnet
41 ip -net $ns xfrm state add src $me dst $remote proto esp spi $spi_out enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $lnet dst $rnet54 ip -net $ns xfrm state add src $me dst $remote proto esp spi $spi_out enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $lnet dst $rnet
42 55
43 # to encrypt packets as they go out (includes forwarded packets that need encapsulation)56 do_esp_policy $ns $me $remote $lnet $rnet
44 ip -net $ns xfrm policy add src $lnet dst $rnet dir out tmpl src $me dst $remote proto esp mode tunnel priority 100 action allow57}
45 # to fwd decrypted packets after esp processing:58
46 ip -net $ns xfrm policy add src $rnet dst $lnet dir fwd tmpl src $remote dst $me proto esp mode tunnel priority 100 action allow59# add policies with different netmasks, to make sure kernel carries
60# the policies contained within new netmask over when search tree is
61# re-built.
62# peer netns that are supposed to be encapsulated via esp have addresses
63# in the 10.0.1.0/24 and 10.0.2.0/24 subnets, respectively.
64#
65# Adding a policy for '10.0.1.0/23' will make it necessary to
66# alter the prefix of 10.0.1.0 subnet.
67# In case new prefix overlaps with existing node, the node and all
68# policies it carries need to be merged with the existing one(s).
69#
70# Do that here.
71do_overlap()
72{
73 local ns=$1
74
75 # adds new nodes to tree (neither network exists yet in policy database).
76 ip -net $ns xfrm policy add src 10.1.0.0/24 dst 10.0.0.0/24 dir fwd priority 200 action block
77
78 # adds a new node in the 10.0.0.0/24 tree (dst node exists).
79 ip -net $ns xfrm policy add src 10.2.0.0/24 dst 10.0.0.0/24 dir fwd priority 200 action block
80
81 # adds a 10.2.0.0/23 node, but for different dst.
82 ip -net $ns xfrm policy add src 10.2.0.0/23 dst 10.0.1.0/24 dir fwd priority 200 action block
83
84 # dst now overlaps with the 10.0.1.0/24 ESP policy in fwd.
85 # kernel must 'promote' existing one (10.0.0.0/24) to 10.0.0.0/23.
86 # But 10.0.0.0/23 also includes existing 10.0.1.0/24, so that node
87 # also has to be merged too, including source-sorted subtrees.
88 # old:
89 # 10.0.0.0/24 (node 1 in dst tree of the bin)
90 # 10.1.0.0/24 (node in src tree of dst node 1)
91 # 10.2.0.0/24 (node in src tree of dst node 1)
92 # 10.0.1.0/24 (node 2 in dst tree of the bin)
93 # 10.0.2.0/24 (node in src tree of dst node 2)
94 # 10.2.0.0/24 (node in src tree of dst node 2)
95 #
96 # The next 'policy add' adds dst '10.0.0.0/23', which means
97 # that dst node 1 and dst node 2 have to be merged including
98 # the sub-tree. As no duplicates are allowed, policies in
99 # the two '10.0.2.0/24' are also merged.
100 #
101 # after the 'add', internal search tree should look like this:
102 # 10.0.0.0/23 (node in dst tree of bin)
103 # 10.0.2.0/24 (node in src tree of dst node)
104 # 10.1.0.0/24 (node in src tree of dst node)
105 # 10.2.0.0/24 (node in src tree of dst node)
106 #
107 # 10.0.0.0/24 and 10.0.1.0/24 nodes have been merged as 10.0.0.0/23.
108 ip -net $ns xfrm policy add src 10.1.0.0/24 dst 10.0.0.0/23 dir fwd priority 200 action block
47}109}
48 110
49do_esp_policy_get_check() {111do_esp_policy_get_check() {
@@ -160,6 +222,41 @@ check_xfrm() { · 110 unmodified lines
160 return $lret222 return $lret
161}223}
162 224
225check_exceptions()
226{
227 logpostfix="$1"
228 local lret=0
229
230 # ping to .254 should be excluded from the tunnel (exception is in place).
231 check_xfrm 0 254
232 if [ $? -ne 0 ]; then
233 echo "FAIL: expected ping to .254 to fail ($logpostfix)"
234 lret=1
235 else
236 echo "PASS: ping to .254 bypassed ipsec tunnel ($logpostfix)"
237 fi
238
239 # ping to .253 should use use ipsec due to direct policy exception.
240 check_xfrm 1 253
241 if [ $? -ne 0 ]; then
242 echo "FAIL: expected ping to .253 to use ipsec tunnel ($logpostfix)"
243 lret=1
244 else
245 echo "PASS: direct policy matches ($logpostfix)"
246 fi
247
248 # ping to .2 should use ipsec.
249 check_xfrm 1 2
250 if [ $? -ne 0 ]; then
251 echo "FAIL: expected ping to .2 to use ipsec tunnel ($logpostfix)"
252 lret=1
253 else
254 echo "PASS: policy matches ($logpostfix)"
255 fi
256
257 return $lret
258}
259
163#check for needed privileges260#check for needed privileges
164if [ "$(id -u)" -ne 0 ];then261if [ "$(id -u)" -ne 0 ];then
165 echo "SKIP: Need root privileges"262 echo "SKIP: Need root privileges"
@@ -270,33 +367,45 @@ do_exception ns4 10.0.3.10 10.0.3.1 10.0.1.253 10.0.1.240/28 · 104 unmodified lines
270do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96367do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96
271do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96368do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96
272 369
273# ping to .254 should now be excluded from the tunnel370check_exceptions "exceptions"
274check_xfrm 0 254
275if [ $? -ne 0 ]; then371if [ $? -ne 0 ]; then
276 echo "FAIL: expected ping to .254 to fail"
277 ret=1372 ret=1
278else
279 echo "PASS: ping to .254 bypassed ipsec tunnel"
280fi373fi
281 374
282# ping to .253 should use use ipsec due to direct policy exception.375# insert block policies with adjacent/overlapping netmasks
283check_xfrm 1 253376do_overlap ns3
284if [ $? -ne 0 ]; then
285 echo "FAIL: expected ping to .253 to use ipsec tunnel"
286 ret=1
287else
288 echo "PASS: direct policy matches"
289fi
290 377
291# ping to .2 should use ipsec.378check_exceptions "exceptions and block policies"
292check_xfrm 1 2
293if [ $? -ne 0 ]; then379if [ $? -ne 0 ]; then
294 echo "FAIL: expected ping to .2 to use ipsec tunnel"
295 ret=1380 ret=1
296else
297 echo "PASS: policy matches"
298fi381fi
299 382
383for n in ns3 ns4;do
384 ip -net $n xfrm policy set hthresh4 28 24 hthresh6 126 125
385 sleep $((RANDOM%5))
386done
387
388check_exceptions "exceptions and block policies after hresh changes"
389
390# full flush of policy db, check everything gets freed incl. internal meta data
391ip -net ns3 xfrm policy flush
392
393do_esp_policy ns3 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24
394do_exception ns3 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28
395
396# move inexact policies to hash table
397ip -net ns3 xfrm policy set hthresh4 16 16
398
399sleep $((RANDOM%5))
400check_exceptions "exceptions and block policies after hthresh change in ns3"
401
402# restore original hthresh settings -- move policies back to tables
403for n in ns3 ns4;do
404 ip -net $n xfrm policy set hthresh4 32 32 hthresh6 128 128
405 sleep $((RANDOM%5))
406done
407check_exceptions "exceptions and block policies after hresh change to normal"
408
300for i in 1 2 3 4;do ip netns del ns$i;done409for i in 1 2 3 4;do ip netns del ns$i;done
301 410
302exit $ret411exit $ret

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t