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 ...
Unified · Split
| @@ -16673,6 +16673,24 @@ T: git git://linuxtv.org/media_tree.git · 16672 unmodified lines | ||
| 16673 | 16673 | S: Maintained |
| 16674 | 16674 | F: drivers/media/tuners/tuner-xc2028.* |
| 16675 | 16675 | |
| 16676 | +XDP (eXpress Data Path) | |
| 16677 | +M: Alexei Starovoitov <ast@kernel.org> | |
| 16678 | +M: Daniel Borkmann <daniel@iogearbox.net> | |
| 16679 | +M: David S. Miller <davem@davemloft.net> | |
| 16680 | +M: Jakub Kicinski <jakub.kicinski@netronome.com> | |
| 16681 | +M: Jesper Dangaard Brouer <hawk@kernel.org> | |
| 16682 | +M: John Fastabend <john.fastabend@gmail.com> | |
| 16683 | +L: netdev@vger.kernel.org | |
| 16684 | +L: xdp-newbies@vger.kernel.org | |
| 16685 | +S: Supported | |
| 16686 | +F: net/core/xdp.c | |
| 16687 | +F: include/net/xdp.h | |
| 16688 | +F: kernel/bpf/devmap.c | |
| 16689 | +F: kernel/bpf/cpumap.c | |
| 16690 | +F: include/trace/events/xdp.h | |
| 16691 | +K: xdp | |
| 16692 | +N: xdp | |
| 16693 | + | |
| 16676 | 16694 | XDP SOCKETS (AF_XDP) |
| 16677 | 16695 | M: Björn Töpel <bjorn.topel@intel.com> |
| 16678 | 16696 | M: Magnus Karlsson <magnus.karlsson@intel.com> |
| @@ -257,10 +257,7 @@ static int handle_tx(struct ser_device *ser) · 256 unmodified lines | ||
| 257 | 257 | if (skb->len == 0) { |
| 258 | 258 | struct sk_buff *tmp = skb_dequeue(&ser->head); |
| 259 | 259 | WARN_ON(tmp != skb); |
| 260 | − if (in_interrupt()) | |
| 261 | − dev_kfree_skb_irq(skb); | |
| 262 | − else | |
| 263 | − kfree_skb(skb); | |
| 260 | + dev_consume_skb_any(skb); | |
| 264 | 261 | } |
| 265 | 262 | } |
| 266 | 263 | /* Send flow off if queue is empty */ |
| @@ -664,7 +664,7 @@ int mv88e6390_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port) · 663 unmodified lines | ||
| 664 | 664 | if (port < 9) |
| 665 | 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 | |
| 670 | 670 | void mv88e6390x_serdes_irq_free(struct mv88e6xxx_chip *chip, int port) |
| @@ -2059,7 +2059,7 @@ static inline void ace_tx_int(struct net_device *dev, · 2058 unmodified lines | ||
| 2059 | 2059 | if (skb) { |
| 2060 | 2060 | dev->stats.tx_packets++; |
| 2061 | 2061 | dev->stats.tx_bytes += skb->len; |
| 2062 | − dev_kfree_skb_irq(skb); | |
| 2062 | + dev_consume_skb_irq(skb); | |
| 2063 | 2063 | info->skb = NULL; |
| 2064 | 2064 | } |
| 2065 | 2065 | |
| @@ -145,7 +145,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv) · 144 unmodified lines | ||
| 145 | 145 | & 0xffff; |
| 146 | 146 | |
| 147 | 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 | 150 | } else { |
| 150 | 151 | /* Check for buffered last packet */ |
| 151 | 152 | status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status)); |
| @@ -666,7 +666,7 @@ static int amd8111e_tx(struct net_device *dev) · 665 unmodified lines | ||
| 666 | 666 | pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[tx_index], |
| 667 | 667 | lp->tx_skbuff[tx_index]->len, |
| 668 | 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 | 670 | lp->tx_skbuff[tx_index] = NULL; |
| 671 | 671 | lp->tx_dma_addr[tx_index] = 0; |
| 672 | 672 | } |
| @@ -777,7 +777,7 @@ static irqreturn_t bmac_txdma_intr(int irq, void *dev_id) · 776 unmodified lines | ||
| 777 | 777 | |
| 778 | 778 | if (bp->tx_bufs[bp->tx_empty]) { |
| 779 | 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 | 782 | bp->tx_bufs[bp->tx_empty] = NULL; |
| 783 | 783 | bp->tx_fullup = 0; |
| @@ -638,7 +638,7 @@ static void b44_tx(struct b44 *bp) · 637 unmodified lines | ||
| 638 | 638 | bytes_compl += skb->len; |
| 639 | 639 | pkts_compl++; |
| 640 | 640 | |
| 641 | − dev_kfree_skb_irq(skb); | |
| 641 | + dev_consume_skb_irq(skb); | |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 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 | 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 | 1016 | skb = bounce_skb; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| @@ -643,6 +643,7 @@ · 642 unmodified lines | ||
| 643 | 643 | #define MACB_CAPS_JUMBO 0x00000020 |
| 644 | 644 | #define MACB_CAPS_GEM_HAS_PTP 0x00000040 |
| 645 | 645 | #define MACB_CAPS_BD_RD_PREFETCH 0x00000080 |
| 646 | +#define MACB_CAPS_NEEDS_RSTONUBR 0x00000100 | |
| 646 | 647 | #define MACB_CAPS_FIFO_MODE 0x10000000 |
| 647 | 648 | #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000 |
| 648 | 649 | #define MACB_CAPS_SG_DISABLED 0x40000000 |
| @@ -1214,6 +1215,8 @@ struct macb { · 565 unmodified lines | ||
| 1214 | 1215 | |
| 1215 | 1216 | int rx_bd_rd_prefetch; |
| 1216 | 1217 | int tx_bd_rd_prefetch; |
| 1218 | + | |
| 1219 | + u32 rx_intr_mask; | |
| 1217 | 1220 | }; |
| 1218 | 1221 | |
| 1219 | 1222 | #ifdef CONFIG_MACB_USE_HWSTAMP |
| @@ -56,8 +56,7 @@ · 55 unmodified lines | ||
| 56 | 56 | /* level of occupied TX descriptors under which we wake up TX process */ |
| 57 | 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) \ | |
| 60 | − | MACB_BIT(ISR_ROVR)) | |
| 59 | +#define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(ISR_ROVR)) | |
| 61 | 60 | #define MACB_TX_ERR_FLAGS (MACB_BIT(ISR_TUND) \ |
| 62 | 61 | | MACB_BIT(ISR_RLE) \ |
| 63 | 62 | | MACB_BIT(TXERR)) |
| @@ -1270,7 +1269,7 @@ static int macb_poll(struct napi_struct *napi, int budget) · 1206 unmodified lines | ||
| 1270 | 1269 | queue_writel(queue, ISR, MACB_BIT(RCOMP)); |
| 1271 | 1270 | napi_reschedule(napi); |
| 1272 | 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 | 1287 | u32 ctrl; |
| 1289 | 1288 | |
| 1290 | 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 | 1291 | MACB_TX_INT_FLAGS | |
| 1293 | 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 | 1318 | /* Enable interrupts */ |
| 1320 | 1319 | queue_writel(queue, IER, |
| 1321 | − MACB_RX_INT_FLAGS | | |
| 1320 | + bp->rx_intr_mask | | |
| 1322 | 1321 | MACB_TX_INT_FLAGS | |
| 1323 | 1322 | MACB_BIT(HRESP)); |
| 1324 | 1323 | } |
| @@ -1372,14 +1371,14 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 47 unmodified lines | ||
| 1372 | 1371 | (unsigned int)(queue - bp->queues), |
| 1373 | 1372 | (unsigned long)status); |
| 1374 | 1373 | |
| 1375 | − if (status & MACB_RX_INT_FLAGS) { | |
| 1374 | + if (status & bp->rx_intr_mask) { | |
| 1376 | 1375 | /* There's no point taking any more interrupts |
| 1377 | 1376 | * until we have processed the buffers. The |
| 1378 | 1377 | * scheduling call may fail if the poll routine |
| 1379 | 1378 | * is already scheduled, so disable interrupts |
| 1380 | 1379 | * now. |
| 1381 | 1380 | */ |
| 1382 | − queue_writel(queue, IDR, MACB_RX_INT_FLAGS); | |
| 1381 | + queue_writel(queue, IDR, bp->rx_intr_mask); | |
| 1383 | 1382 | if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) |
| 1384 | 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 | 1411 | /* There is a hardware issue under heavy load where DMA can |
| 1413 | 1412 | * stop, this causes endless "used buffer descriptor read" |
| 1414 | 1413 | * interrupts but it can be cleared by re-enabling RX. See |
| 1415 | − * the at91 manual, section 41.3.1 or the Zynq manual | |
| 1416 | − * section 16.7.4 for details. | |
| 1414 | + * the at91rm9200 manual, section 41.3.1 or the Zynq manual | |
| 1415 | + * section 16.7.4 for details. RXUBR is only enabled for | |
| 1416 | + * these two versions. | |
| 1417 | 1417 | */ |
| 1418 | 1418 | if (status & MACB_BIT(RXUBR)) { |
| 1419 | 1419 | ctrl = macb_readl(bp, NCR); |
| @@ -2259,7 +2259,7 @@ static void macb_init_hw(struct macb *bp) · 839 unmodified lines | ||
| 2259 | 2259 | |
| 2260 | 2260 | /* Enable interrupts */ |
| 2261 | 2261 | queue_writel(queue, IER, |
| 2262 | − MACB_RX_INT_FLAGS | | |
| 2262 | + bp->rx_intr_mask | | |
| 2263 | 2263 | MACB_TX_INT_FLAGS | |
| 2264 | 2264 | MACB_BIT(HRESP)); |
| 2265 | 2265 | } |
| @@ -3907,6 +3907,7 @@ static const struct macb_config sama5d4_config = { · 1641 unmodified lines | ||
| 3907 | 3907 | }; |
| 3908 | 3908 | |
| 3909 | 3909 | static const struct macb_config emac_config = { |
| 3910 | + .caps = MACB_CAPS_NEEDS_RSTONUBR, | |
| 3910 | 3911 | .clk_init = at91ether_clk_init, |
| 3911 | 3912 | .init = at91ether_init, |
| 3912 | 3913 | }; |
| @@ -3928,7 +3929,8 @@ static const struct macb_config zynqmp_config = { · 15 unmodified lines | ||
| 3928 | 3929 | }; |
| 3929 | 3930 | |
| 3930 | 3931 | static 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 | 3934 | .dma_burst_length = 16, |
| 3933 | 3935 | .clk_init = macb_clk_init, |
| 3934 | 3936 | .init = macb_init, |
| @@ -4083,6 +4085,10 @@ static int macb_probe(struct platform_device *pdev) · 148 unmodified lines | ||
| 4083 | 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 | 4092 | mac = of_get_mac_address(np); |
| 4087 | 4093 | if (mac) { |
| 4088 | 4094 | ether_addr_copy(bp->dev->dev_addr, mac); |
| @@ -2418,6 +2418,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev) · 2417 unmodified lines | ||
| 2418 | 2418 | out_notify_fail: |
| 2419 | 2419 | (void)cancel_work_sync(&priv->service_task); |
| 2420 | 2420 | out_read_prop_fail: |
| 2421 | + /* safe for ACPI FW */ | |
| 2422 | + of_node_put(to_of_node(priv->fwnode)); | |
| 2421 | 2423 | free_netdev(ndev); |
| 2422 | 2424 | return ret; |
| 2423 | 2425 | } |
| @@ -2447,6 +2449,9 @@ static int hns_nic_dev_remove(struct platform_device *pdev) · 23 unmodified lines | ||
| 2447 | 2449 | set_bit(NIC_STATE_REMOVING, &priv->state); |
| 2448 | 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 | 2455 | free_netdev(ndev); |
| 2451 | 2456 | return 0; |
| 2452 | 2457 | } |
| @@ -1157,16 +1157,18 @@ static int hns_get_regs_len(struct net_device *net_dev) · 1156 unmodified lines | ||
| 1157 | 1157 | */ |
| 1158 | 1158 | static int hns_nic_nway_reset(struct net_device *netdev) |
| 1159 | 1159 | { |
| 1160 | − int ret = 0; | |
| 1161 | 1160 | struct phy_device *phy = netdev->phydev; |
| 1162 | 1161 | |
| 1163 | − if (netif_running(netdev)) { | |
| 1164 | − /* if autoneg is disabled, don't restart auto-negotiation */ | |
| 1165 | − if (phy && phy->autoneg == AUTONEG_ENABLE) | |
| 1166 | − ret = genphy_restart_aneg(phy); | |
| 1167 | − } | |
| 1162 | + if (!netif_running(netdev)) | |
| 1163 | + return 0; | |
| 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 | |
| 1172 | 1174 | static u32 |
| @@ -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 | 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 | 327 | /* Step 5: waitting for MDIO_COMMAND_REG 's mdio_start==0,*/ |
| @@ -1310,7 +1310,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id) · 1309 unmodified lines | ||
| 1310 | 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 | 1315 | tx_cmd->cmd.command = 0; /* Mark free */ |
| 1316 | 1316 | break; |
| @@ -950,7 +950,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c, · 949 unmodified lines | ||
| 950 | 950 | if (params->rx_dim_enabled) |
| 951 | 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 | 954 | __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state); |
| 955 | 955 | |
| 956 | 956 | return 0; |
| @@ -1126,9 +1126,17 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev, · 1125 unmodified lines | ||
| 1126 | 1126 | struct mlx5e_priv *priv = netdev_priv(dev); |
| 1127 | 1127 | struct mlx5e_rep_priv *rpriv = priv->ppriv; |
| 1128 | 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 | 1140 | if (ret >= len) |
| 1133 | 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 | 1293 | return 0; |
| 1286 | 1294 | } |
| 1287 | 1295 | |
| 1296 | +static 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 | + | |
| 1288 | 1308 | static const struct switchdev_ops mlx5e_rep_switchdev_ops = { |
| 1289 | 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 | 1339 | .ndo_set_vf_rate = mlx5e_set_vf_rate, |
| 1320 | 1340 | .ndo_get_vf_config = mlx5e_get_vf_config, |
| 1321 | 1341 | .ndo_get_vf_stats = mlx5e_get_vf_stats, |
| 1342 | + .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan, | |
| 1322 | 1343 | }; |
| 1323 | 1344 | |
| 1324 | 1345 | bool mlx5e_eswitch_rep(struct net_device *netdev) |
| @@ -1134,13 +1134,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, · 1133 unmodified lines | ||
| 1134 | 1134 | int err = 0; |
| 1135 | 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 | 1137 | esw_vport_cleanup_ingress_rules(esw, vport); |
| 1145 | 1138 | |
| 1146 | 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 | 1721 | int vport_num; |
| 1729 | 1722 | int err; |
| 1730 | 1723 | |
| 1731 | − if (!MLX5_ESWITCH_MANAGER(dev)) | |
| 1724 | + if (!MLX5_VPORT_MANAGER(dev)) | |
| 1732 | 1725 | return 0; |
| 1733 | 1726 | |
| 1734 | 1727 | esw_info(dev, |
| @@ -1797,7 +1790,7 @@ abort: · 62 unmodified lines | ||
| 1797 | 1790 | |
| 1798 | 1791 | void 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 | 1794 | return; |
| 1802 | 1795 | |
| 1803 | 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 | 1820 | mutex_lock(&esw->state_lock); |
| 1828 | 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 | 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 | 1826 | vport); |
| 1834 | − err = -EPERM; | |
| 1835 | − goto unlock; | |
| 1836 | − } | |
| 1837 | 1827 | |
| 1838 | 1828 | err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac); |
| 1839 | 1829 | if (err) { |
| @@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 139 unmodified lines | ||
| 1979 | 1969 | evport = &esw->vports[vport]; |
| 1980 | 1970 | pschk = evport->info.spoofchk; |
| 1981 | 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 | 1976 | if (evport->enabled && esw->mode == SRIOV_LEGACY) |
| 1983 | 1977 | err = esw_vport_ingress_config(esw, evport); |
| 1984 | 1978 | if (err) |
| @@ -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 | |
| 619 | +int 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 | 640 | /* Must be called with intf_mutex held */ |
| 620 | 641 | void mlx5_lag_remove(struct mlx5_core_dev *dev) |
| 621 | 642 | { |
| @@ -187,6 +187,8 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev) · 186 unmodified lines | ||
| 187 | 187 | MLX5_CAP_GEN(dev, lag_master); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | +int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num); | |
| 191 | + | |
| 190 | 192 | void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol); |
| 191 | 193 | void mlx5_lag_update(struct mlx5_core_dev *dev); |
| 192 | 194 | |
| @@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common * · 43 unmodified lines | ||
| 44 | 44 | mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn) |
| 45 | 45 | { |
| 46 | 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 | 51 | common = radix_tree_lookup(&table->tree, rsn); |
| 51 | 52 | if (common) |
| 52 | 53 | atomic_inc(&common->refcount); |
| 53 | 54 | |
| 54 | − spin_unlock(&table->lock); | |
| 55 | + spin_unlock_irqrestore(&table->lock, flags); | |
| 55 | 56 | |
| 56 | 57 | return common; |
| 57 | 58 | } |
| @@ -795,19 +795,19 @@ static void qed_init_qm_pq(struct qed_hwfn *p_hwfn, · 794 unmodified lines | ||
| 795 | 795 | |
| 796 | 796 | /* get pq index according to PQ_FLAGS */ |
| 797 | 797 | static 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 | 800 | struct qed_qm_info *qm_info = &p_hwfn->qm_info; |
| 801 | 801 | |
| 802 | 802 | /* Can't have multiple flags set here */ |
| 803 | − if (bitmap_weight((unsigned long *)&pq_flags, | |
| 803 | + if (bitmap_weight(&pq_flags, | |
| 804 | 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 | 806 | goto err; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 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 | 811 | goto err; |
| 812 | 812 | } |
| 813 | 813 | |
| @@ -609,6 +609,10 @@ qed_sp_update_accept_mode(struct qed_hwfn *p_hwfn, · 608 unmodified lines | ||
| 609 | 609 | (!!(accept_filter & QED_ACCEPT_MCAST_MATCHED) && |
| 610 | 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 | 616 | SET_FIELD(state, ETH_VPORT_TX_MODE_BCAST_ACCEPT_ALL, |
| 613 | 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 | 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 | 756 | /* Update mcast bins for VFs, PF doesn't use this functionality */ |
| 748 | 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 | 2697 | if (type == QED_FILTER_RX_MODE_TYPE_PROMISC) { |
| 2689 | 2698 | accept_flags.rx_accept_filter |= QED_ACCEPT_UCAST_UNMATCHED | |
| 2690 | 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 | 2702 | } else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC) { |
| 2693 | 2703 | accept_flags.rx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED; |
| 2694 | 2704 | accept_flags.tx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED; |
| @@ -219,6 +219,9 @@ struct qed_sp_vport_update_params { · 218 unmodified lines | ||
| 219 | 219 | struct qed_rss_params *rss_params; |
| 220 | 220 | struct qed_filter_accept_flags accept_flags; |
| 221 | 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 | |
| 224 | 227 | int qed_sp_vport_update(struct qed_hwfn *p_hwfn, |
| @@ -2451,19 +2451,24 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb, · 2450 unmodified lines | ||
| 2451 | 2451 | { |
| 2452 | 2452 | struct qed_ll2_tx_pkt_info pkt; |
| 2453 | 2453 | const skb_frag_t *frag; |
| 2454 | + u8 flags = 0, nr_frags; | |
| 2454 | 2455 | int rc = -EINVAL, i; |
| 2455 | 2456 | dma_addr_t mapping; |
| 2456 | 2457 | u16 vlan = 0; |
| 2457 | − u8 flags = 0; | |
| 2458 | 2458 | |
| 2459 | 2459 | if (unlikely(skb->ip_summed != CHECKSUM_NONE)) { |
| 2460 | 2460 | DP_INFO(cdev, "Cannot transmit a checksummed packet\n"); |
| 2461 | 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 | 2470 | DP_ERR(cdev, "Cannot transmit a packet with %d fragments\n", |
| 2466 | − 1 + skb_shinfo(skb)->nr_frags); | |
| 2471 | + 1 + nr_frags); | |
| 2467 | 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 | 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 | 2494 | pkt.vlan = vlan; |
| 2490 | 2495 | pkt.bd_flags = flags; |
| 2491 | 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 | 2501 | test_bit(QED_LL2_XMIT_FLAGS_FIP_DISCOVERY, &xmit_flags)) |
| 2497 | 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 | 2509 | rc = qed_ll2_prepare_tx_packet(&cdev->hwfns[0], cdev->ll2->handle, |
| 2500 | 2510 | &pkt, 1); |
| 2501 | 2511 | if (rc) |
| 2502 | 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 | 2515 | frag = &skb_shinfo(skb)->frags[i]; |
| 2506 | 2516 | |
| 2507 | 2517 | mapping = skb_frag_dma_map(&cdev->pdev->dev, frag, 0, |
| @@ -1969,7 +1969,9 @@ static void qed_iov_vf_mbx_start_vport(struct qed_hwfn *p_hwfn, · 1968 unmodified lines | ||
| 1969 | 1969 | params.vport_id = vf->vport_id; |
| 1970 | 1970 | params.max_buffers_per_cqe = start->max_buffers_per_cqe; |
| 1971 | 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 | 1976 | rc = qed_sp_eth_vport_start(p_hwfn, ¶ms); |
| 1975 | 1977 | if (rc) { |
| @@ -5130,6 +5132,9 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn) · 3154 unmodified lines | ||
| 5130 | 5132 | params.opaque_fid = vf->opaque_fid; |
| 5131 | 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 | 5138 | if (vf_info->rx_accept_mode & mask) { |
| 5134 | 5139 | flags->update_rx_mode_config = 1; |
| 5135 | 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 | 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 | 5157 | qed_sp_vport_update(hwfn, ¶ms, |
| 5152 | 5158 | QED_SPQ_MODE_EBLOCK, NULL); |
| 5153 | 5159 | } |
| @@ -261,6 +261,7 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn) · 260 unmodified lines | ||
| 261 | 261 | struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp; |
| 262 | 262 | struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info; |
| 263 | 263 | struct vf_pf_resc_request *p_resc; |
| 264 | + u8 retry_cnt = VF_ACQUIRE_THRESH; | |
| 264 | 265 | bool resources_acquired = false; |
| 265 | 266 | struct vfpf_acquire_tlv *req; |
| 266 | 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 | 316 | /* send acquire request */ |
| 316 | 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 | 327 | if (rc) |
| 318 | 328 | goto exit; |
| 319 | 329 | |
| @@ -691,7 +691,7 @@ static void cp_tx (struct cp_private *cp) · 690 unmodified lines | ||
| 691 | 691 | } |
| 692 | 692 | bytes_compl += skb->len; |
| 693 | 693 | pkts_compl++; |
| 694 | − dev_kfree_skb_irq(skb); | |
| 694 | + dev_consume_skb_irq(skb); | |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | cp->tx_skb[tx_tail] = NULL; |
| @@ -1342,8 +1342,10 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) · 1341 unmodified lines | ||
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | 1344 | ret = phy_power_on(bsp_priv, true); |
| 1345 | − if (ret) | |
| 1345 | + if (ret) { | |
| 1346 | + gmac_clk_enable(bsp_priv, false); | |
| 1346 | 1347 | return ret; |
| 1348 | + } | |
| 1347 | 1349 | |
| 1348 | 1350 | pm_runtime_enable(dev); |
| 1349 | 1351 | pm_runtime_get_sync(dev); |
| @@ -608,7 +608,7 @@ static void cpmac_end_xmit(struct net_device *dev, int queue) · 607 unmodified lines | ||
| 608 | 608 | netdev_dbg(dev, "sent 0x%p, len=%d\n", |
| 609 | 609 | desc->skb, desc->skb->len); |
| 610 | 610 | |
| 611 | − dev_kfree_skb_irq(desc->skb); | |
| 611 | + dev_consume_skb_irq(desc->skb); | |
| 612 | 612 | desc->skb = NULL; |
| 613 | 613 | if (__netif_subqueue_stopped(dev, queue)) |
| 614 | 614 | netif_wake_subqueue(dev, queue); |
| @@ -1337,7 +1337,8 @@ static int vhost_net_open(struct inode *inode, struct file *f) · 1336 unmodified lines | ||
| 1337 | 1337 | n->vqs[i].rx_ring = NULL; |
| 1338 | 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 | 1343 | vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev); |
| 1343 | 1344 | vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev); |
| @@ -1627,7 +1627,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) · 1626 unmodified lines | ||
| 1627 | 1627 | vqs[i] = &vs->vqs[i].vq; |
| 1628 | 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 | 1632 | vhost_scsi_init_inflight(vs, NULL); |
| 1633 | 1633 | |
| @@ -390,9 +390,9 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) · 389 unmodified lines | ||
| 390 | 390 | vq->indirect = kmalloc_array(UIO_MAXIOV, |
| 391 | 391 | sizeof(*vq->indirect), |
| 392 | 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 | 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 | 396 | GFP_KERNEL); |
| 397 | 397 | if (!vq->indirect || !vq->log || !vq->heads) |
| 398 | 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 | |
| 416 | 416 | void 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 | 419 | struct vhost_virtqueue *vq; |
| 420 | 420 | int i; |
| @@ -427,6 +427,7 @@ void vhost_dev_init(struct vhost_dev *dev, · 6 unmodified lines | ||
| 427 | 427 | dev->iotlb = NULL; |
| 428 | 428 | dev->mm = NULL; |
| 429 | 429 | dev->worker = NULL; |
| 430 | + dev->iov_limit = iov_limit; | |
| 430 | 431 | init_llist_head(&dev->work_list); |
| 431 | 432 | init_waitqueue_head(&dev->wait); |
| 432 | 433 | INIT_LIST_HEAD(&dev->read_list); |
| @@ -170,9 +170,11 @@ struct vhost_dev { · 169 unmodified lines | ||
| 170 | 170 | struct list_head read_list; |
| 171 | 171 | struct list_head pending_list; |
| 172 | 172 | wait_queue_head_t wait; |
| 173 | + int iov_limit; | |
| 173 | 174 | }; |
| 174 | 175 | |
| 175 | −void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs); | |
| 176 | +void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, | |
| 177 | + int nvqs, int iov_limit); | |
| 176 | 178 | long vhost_dev_set_owner(struct vhost_dev *dev); |
| 177 | 179 | bool vhost_dev_has_owner(struct vhost_dev *dev); |
| 178 | 180 | long vhost_dev_check_owner(struct vhost_dev *); |
| @@ -531,7 +531,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) · 530 unmodified lines | ||
| 531 | 531 | vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; |
| 532 | 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 | 536 | file->private_data = vsock; |
| 537 | 537 | spin_lock_init(&vsock->send_pkt_list_lock); |
| @@ -120,6 +120,8 @@ struct tls_rec { · 119 unmodified lines | ||
| 120 | 120 | struct scatterlist sg_aead_out[2]; |
| 121 | 121 | |
| 122 | 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 | 125 | struct aead_request aead_req; |
| 124 | 126 | u8 aead_req_ctx[]; |
| 125 | 127 | }; |
| @@ -2293,9 +2293,12 @@ static int compat_do_replace(struct net *net, void __user *user, · 2292 unmodified lines | ||
| 2293 | 2293 | |
| 2294 | 2294 | xt_compat_lock(NFPROTO_BRIDGE); |
| 2295 | 2295 | |
| 2296 | − ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries); | |
| 2297 | − if (ret < 0) | |
| 2298 | − goto out_unlock; | |
| 2296 | + if (tmp.nentries) { | |
| 2297 | + ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries); | |
| 2298 | + if (ret < 0) | |
| 2299 | + goto out_unlock; | |
| 2300 | + } | |
| 2301 | + | |
| 2299 | 2302 | ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); |
| 2300 | 2303 | if (ret < 0) |
| 2301 | 2304 | goto out_unlock; |
| @@ -8712,6 +8712,9 @@ int init_dummy_netdev(struct net_device *dev) · 8711 unmodified lines | ||
| 8712 | 8712 | set_bit(__LINK_STATE_PRESENT, &dev->state); |
| 8713 | 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 | 8718 | /* Note : We dont allocate pcpu_refcnt for dummy devices, |
| 8716 | 8719 | * because users of this 'device' dont need to change |
| 8717 | 8720 | * its refcount. |
| @@ -56,7 +56,7 @@ · 55 unmodified lines | ||
| 56 | 56 | #include <net/dn_neigh.h> |
| 57 | 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 | |
| 61 | 61 | static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00}; |
| 62 | 62 | static char dn_rt_all_rt_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x03,0x00,0x00}; |
| @@ -74,6 +74,33 @@ drop: · 73 unmodified lines | ||
| 74 | 74 | return 0; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | +static 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; | |
| 99 | +drop: | |
| 100 | + kfree_skb(skb); | |
| 101 | + return 0; | |
| 102 | +} | |
| 103 | + | |
| 77 | 104 | static int vti_rcv(struct sk_buff *skb) |
| 78 | 105 | { |
| 79 | 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 | 109 | return vti_input(skb, ip_hdr(skb)->protocol, 0, 0); |
| 83 | 110 | } |
| 84 | 111 | |
| 112 | +static 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 | + | |
| 85 | 120 | static int vti_rcv_cb(struct sk_buff *skb, int err) |
| 86 | 121 | { |
| 87 | 122 | unsigned short family; |
| @@ -435,6 +470,12 @@ static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = { · 347 unmodified lines | ||
| 435 | 470 | .priority = 100, |
| 436 | 471 | }; |
| 437 | 472 | |
| 473 | +static struct xfrm_tunnel ipip_handler __read_mostly = { | |
| 474 | + .handler = vti_rcv_ipip, | |
| 475 | + .err_handler = vti4_err, | |
| 476 | + .priority = 0, | |
| 477 | +}; | |
| 478 | + | |
| 438 | 479 | static int __net_init vti_init_net(struct net *net) |
| 439 | 480 | { |
| 440 | 481 | int err; |
| @@ -603,6 +644,13 @@ static int __init vti_init(void) · 162 unmodified lines | ||
| 603 | 644 | if (err < 0) |
| 604 | 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 | 654 | msg = "netlink interface"; |
| 607 | 655 | err = rtnl_link_register(&vti_link_ops); |
| 608 | 656 | if (err < 0) |
| @@ -612,6 +660,8 @@ static int __init vti_init(void) · 3 unmodified lines | ||
| 612 | 660 | |
| 613 | 661 | rtnl_link_failed: |
| 614 | 662 | xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP); |
| 663 | +xfrm_tunnel_failed: | |
| 664 | + xfrm4_tunnel_deregister(&ipip_handler, AF_INET); | |
| 615 | 665 | xfrm_proto_comp_failed: |
| 616 | 666 | xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH); |
| 617 | 667 | xfrm_proto_ah_failed: |
| @@ -846,9 +846,9 @@ static int clusterip_net_init(struct net *net) · 845 unmodified lines | ||
| 846 | 846 | |
| 847 | 847 | static void clusterip_net_exit(struct net *net) |
| 848 | 848 | { |
| 849 | +#ifdef CONFIG_PROC_FS | |
| 849 | 850 | struct clusterip_net *cn = clusterip_pernet(net); |
| 850 | 851 | |
| 851 | −#ifdef CONFIG_PROC_FS | |
| 852 | 852 | mutex_lock(&cn->mutex); |
| 853 | 853 | proc_remove(cn->procdir); |
| 854 | 854 | cn->procdir = NULL; |
| @@ -1516,6 +1516,9 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) · 1515 unmodified lines | ||
| 1516 | 1516 | continue; |
| 1517 | 1517 | rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params); |
| 1518 | 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 | 1522 | mr6_netlink_event(mrt, (struct mfc6_cache *)c, RTM_DELROUTE); |
| 1520 | 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 | 1527 | spin_lock_bh(&mfc_unres_lock); |
| 1525 | 1528 | list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) { |
| 1526 | 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 | 1530 | mr6_netlink_event(mrt, (struct mfc6_cache *)c, |
| 1532 | 1531 | RTM_DELROUTE); |
| 1533 | 1532 | ip6mr_destroy_unres(mrt, (struct mfc6_cache *)c); |
| @@ -2220,6 +2220,18 @@ static int ip_vs_set_timeout(struct netns_ipvs *ipvs, struct ip_vs_timeout_user · 2219 unmodified lines | ||
| 2220 | 2220 | u->tcp_fin_timeout, |
| 2221 | 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 | 2235 | #ifdef CONFIG_IP_VS_PROTO_TCP |
| 2224 | 2236 | if (u->tcp_timeout) { |
| 2225 | 2237 | pd = ip_vs_proto_data_get(ipvs, IPPROTO_TCP); |
| @@ -66,6 +66,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb, · 65 unmodified lines | ||
| 66 | 66 | int ttl_check, |
| 67 | 67 | struct nf_osf_hdr_ctx *ctx) |
| 68 | 68 | { |
| 69 | + const __u8 *optpinit = ctx->optp; | |
| 69 | 70 | unsigned int check_WSS = 0; |
| 70 | 71 | int fmatch = FMATCH_WRONG; |
| 71 | 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 | 162 | return fmatch == FMATCH_OK; |
| 159 | 163 | } |
| 160 | 164 | |
| @@ -22,11 +22,15 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/netfilter_bridge/ebtables.h> |
| 23 | 23 | #include <linux/netfilter_arp/arp_tables.h> |
| 24 | 24 | #include <net/netfilter/nf_tables.h> |
| 25 | +#include <net/netns/generic.h> | |
| 25 | 26 | |
| 26 | 27 | struct nft_xt { |
| 27 | 28 | struct list_head head; |
| 28 | 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 | 35 | /* Unlike other expressions, ops doesn't have static storage duration. |
| 32 | 36 | * 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 | 47 | void *info; |
| 44 | 48 | }; |
| 45 | 49 | |
| 50 | +struct nft_compat_net { | |
| 51 | + struct list_head nft_target_list; | |
| 52 | + struct list_head nft_match_list; | |
| 53 | +}; | |
| 54 | + | |
| 55 | +static unsigned int nft_compat_net_id __read_mostly; | |
| 56 | +static struct nft_expr_type nft_match_type; | |
| 57 | +static struct nft_expr_type nft_target_type; | |
| 58 | + | |
| 59 | +static struct nft_compat_net *nft_compat_pernet(struct net *net) | |
| 60 | +{ | |
| 61 | + return net_generic(net, nft_compat_net_id); | |
| 62 | +} | |
| 63 | + | |
| 46 | 64 | static bool nft_xt_put(struct nft_xt *xt) |
| 47 | 65 | { |
| 48 | − if (--xt->refcnt == 0) { | |
| 49 | − list_del(&xt->head); | |
| 66 | + if (refcount_dec_and_test(&xt->refcnt)) { | |
| 67 | + WARN_ON_ONCE(!list_empty(&xt->head)); | |
| 50 | 68 | kfree_rcu(xt, rcu_head); |
| 51 | 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 | 291 | return -EINVAL; |
| 274 | 292 | |
| 275 | 293 | nft_xt = container_of(expr->ops, struct nft_xt, ops); |
| 276 | − nft_xt->refcnt++; | |
| 294 | + refcount_inc(&nft_xt->refcnt); | |
| 277 | 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 | 504 | return ret; |
| 487 | 505 | |
| 488 | 506 | nft_xt = container_of(expr->ops, struct nft_xt, ops); |
| 489 | − nft_xt->refcnt++; | |
| 507 | + refcount_inc(&nft_xt->refcnt); | |
| 490 | 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 | 558 | __nft_match_destroy(ctx, expr, nft_expr_priv(expr)); |
| 541 | 559 | } |
| 542 | 560 | |
| 561 | +static 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 | + | |
| 573 | +static 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 | + | |
| 581 | +static 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 | + | |
| 589 | +static 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 | + | |
| 543 | 598 | static void |
| 544 | 599 | nft_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 | 789 | .cb = nfnl_nft_compat_cb, |
| 735 | 790 | }; |
| 736 | 791 | |
| 737 | −static LIST_HEAD(nft_match_list); | |
| 738 | − | |
| 739 | −static struct nft_expr_type nft_match_type; | |
| 740 | − | |
| 741 | 792 | static bool nft_match_cmp(const struct xt_match *match, |
| 742 | 793 | const char *name, u32 rev, u32 family) |
| 743 | 794 | { |
| @@ -749,6 +800,7 @@ static const struct nft_expr_ops * · 5 unmodified lines | ||
| 749 | 800 | nft_match_select_ops(const struct nft_ctx *ctx, |
| 750 | 801 | const struct nlattr * const tb[]) |
| 751 | 802 | { |
| 803 | + struct nft_compat_net *cn; | |
| 752 | 804 | struct nft_xt *nft_match; |
| 753 | 805 | struct xt_match *match; |
| 754 | 806 | unsigned int matchsize; |
| @@ -765,8 +817,10 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 10 unmodified lines | ||
| 765 | 817 | rev = ntohl(nla_get_be32(tb[NFTA_MATCH_REV])); |
| 766 | 818 | family = ctx->family; |
| 767 | 819 | |
| 820 | + cn = nft_compat_pernet(ctx->net); | |
| 821 | + | |
| 768 | 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 | 824 | struct xt_match *match = nft_match->ops.data; |
| 771 | 825 | |
| 772 | 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 | 843 | goto err; |
| 790 | 844 | } |
| 791 | 845 | |
| 792 | − nft_match->refcnt = 0; | |
| 846 | + refcount_set(&nft_match->refcnt, 0); | |
| 793 | 847 | nft_match->ops.type = &nft_match_type; |
| 794 | 848 | nft_match->ops.eval = nft_match_eval; |
| 795 | 849 | nft_match->ops.init = nft_match_init; |
| 796 | 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 | 853 | nft_match->ops.dump = nft_match_dump; |
| 798 | 854 | nft_match->ops.validate = nft_match_validate; |
| 799 | 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 | 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 | 872 | return &nft_match->ops; |
| 816 | 873 | err: |
| @@ -826,10 +883,6 @@ static struct nft_expr_type nft_match_type __read_mostly = { · 9 unmodified lines | ||
| 826 | 883 | .owner = THIS_MODULE, |
| 827 | 884 | }; |
| 828 | 885 | |
| 829 | −static LIST_HEAD(nft_target_list); | |
| 830 | − | |
| 831 | −static struct nft_expr_type nft_target_type; | |
| 832 | − | |
| 833 | 886 | static bool nft_target_cmp(const struct xt_target *tg, |
| 834 | 887 | const char *name, u32 rev, u32 family) |
| 835 | 888 | { |
| @@ -841,6 +894,7 @@ static const struct nft_expr_ops * · 5 unmodified lines | ||
| 841 | 894 | nft_target_select_ops(const struct nft_ctx *ctx, |
| 842 | 895 | const struct nlattr * const tb[]) |
| 843 | 896 | { |
| 897 | + struct nft_compat_net *cn; | |
| 844 | 898 | struct nft_xt *nft_target; |
| 845 | 899 | struct xt_target *target; |
| 846 | 900 | char *tg_name; |
| @@ -861,8 +915,9 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 14 unmodified lines | ||
| 861 | 915 | strcmp(tg_name, "standard") == 0) |
| 862 | 916 | return ERR_PTR(-EINVAL); |
| 863 | 917 | |
| 918 | + cn = nft_compat_pernet(ctx->net); | |
| 864 | 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 | 921 | struct xt_target *target = nft_target->ops.data; |
| 867 | 922 | |
| 868 | 923 | if (!target->target) |
| @@ -893,11 +948,13 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 24 unmodified lines | ||
| 893 | 948 | goto err; |
| 894 | 949 | } |
| 895 | 950 | |
| 896 | − nft_target->refcnt = 0; | |
| 951 | + refcount_set(&nft_target->refcnt, 0); | |
| 897 | 952 | nft_target->ops.type = &nft_target_type; |
| 898 | 953 | nft_target->ops.size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize)); |
| 899 | 954 | nft_target->ops.init = nft_target_init; |
| 900 | 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 | 958 | nft_target->ops.dump = nft_target_dump; |
| 902 | 959 | nft_target->ops.validate = nft_target_validate; |
| 903 | 960 | nft_target->ops.data = target; |
| @@ -907,7 +964,8 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 3 unmodified lines | ||
| 907 | 964 | else |
| 908 | 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 | 970 | return &nft_target->ops; |
| 913 | 971 | err: |
| @@ -923,13 +981,74 @@ static struct nft_expr_type nft_target_type __read_mostly = { · 9 unmodified lines | ||
| 923 | 981 | .owner = THIS_MODULE, |
| 924 | 982 | }; |
| 925 | 983 | |
| 984 | +static 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 | + | |
| 994 | +static 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 | + | |
| 1034 | +static 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 | + | |
| 926 | 1041 | static int __init nft_compat_module_init(void) |
| 927 | 1042 | { |
| 928 | 1043 | int ret; |
| 929 | 1044 | |
| 1045 | + ret = register_pernet_subsys(&nft_compat_net_ops); | |
| 1046 | + if (ret < 0) | |
| 1047 | + goto err_target; | |
| 1048 | + | |
| 930 | 1049 | ret = nft_register_expr(&nft_match_type); |
| 931 | 1050 | if (ret < 0) |
| 932 | − return ret; | |
| 1051 | + goto err_pernet; | |
| 933 | 1052 | |
| 934 | 1053 | ret = nft_register_expr(&nft_target_type); |
| 935 | 1054 | if (ret < 0) |
| @@ -942,45 +1061,21 @@ static int __init nft_compat_module_init(void) · 6 unmodified lines | ||
| 942 | 1061 | } |
| 943 | 1062 | |
| 944 | 1063 | return ret; |
| 945 | − | |
| 946 | 1064 | err_target: |
| 947 | 1065 | nft_unregister_expr(&nft_target_type); |
| 948 | 1066 | err_match: |
| 949 | 1067 | nft_unregister_expr(&nft_match_type); |
| 1068 | +err_pernet: | |
| 1069 | + unregister_pernet_subsys(&nft_compat_net_ops); | |
| 950 | 1070 | return ret; |
| 951 | 1071 | } |
| 952 | 1072 | |
| 953 | 1073 | static 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 | 1075 | nfnetlink_subsys_unregister(&nfnl_compat_subsys); |
| 982 | 1076 | nft_unregister_expr(&nft_target_type); |
| 983 | 1077 | nft_unregister_expr(&nft_match_type); |
| 1078 | + unregister_pernet_subsys(&nft_compat_net_ops); | |
| 984 | 1079 | } |
| 985 | 1080 | |
| 986 | 1081 | MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT); |
| @@ -52,21 +52,21 @@ void nr_start_t1timer(struct sock *sk) · 51 unmodified lines | ||
| 52 | 52 | { |
| 53 | 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 | |
| 58 | 58 | void nr_start_t2timer(struct sock *sk) |
| 59 | 59 | { |
| 60 | 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 | |
| 65 | 65 | void nr_start_t4timer(struct sock *sk) |
| 66 | 66 | { |
| 67 | 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 | |
| 72 | 72 | void nr_start_idletimer(struct sock *sk) |
| @@ -74,37 +74,37 @@ void nr_start_idletimer(struct sock *sk) · 1 unmodified line | ||
| 74 | 74 | struct nr_sock *nr = nr_sk(sk); |
| 75 | 75 | |
| 76 | 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 | |
| 80 | 80 | void 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 | |
| 85 | 85 | void 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 | |
| 90 | 90 | void 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 | |
| 95 | 95 | void 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 | |
| 100 | 100 | void 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 | |
| 105 | 105 | void 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 | |
| 110 | 110 | int nr_t1timer_running(struct sock *sk) |
| @@ -850,6 +850,7 @@ void rose_link_device_down(struct net_device *dev) · 849 unmodified lines | ||
| 850 | 850 | |
| 851 | 851 | /* |
| 852 | 852 | * Route a frame to an appropriate AX.25 connection. |
| 853 | + * A NULL ax25_cb indicates an internally generated frame. | |
| 853 | 854 | */ |
| 854 | 855 | int 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 | 869 | if (skb->len < ROSE_MIN_LEN) |
| 869 | 870 | return res; |
| 871 | + | |
| 872 | + if (!ax25) | |
| 873 | + return rose_loopback_queue(skb, NULL); | |
| 874 | + | |
| 870 | 875 | frametype = skb->data[2]; |
| 871 | 876 | lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF); |
| 872 | 877 | if (frametype == ROSE_CALL_REQUEST && |
| @@ -439,6 +439,8 @@ static int tls_do_encryption(struct sock *sk, · 438 unmodified lines | ||
| 439 | 439 | struct scatterlist *sge = sk_msg_elem(msg_en, start); |
| 440 | 440 | int rc; |
| 441 | 441 | |
| 442 | + memcpy(rec->iv_data, tls_ctx->tx.iv, sizeof(rec->iv_data)); | |
| 443 | + | |
| 442 | 444 | sge->offset += tls_ctx->tx.prepend_size; |
| 443 | 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 | 450 | aead_request_set_ad(aead_req, TLS_AAD_SPACE_SIZE); |
| 449 | 451 | aead_request_set_crypt(aead_req, rec->sg_aead_in, |
| 450 | 452 | rec->sg_aead_out, |
| 451 | − data_len, tls_ctx->tx.iv); | |
| 453 | + data_len, rec->iv_data); | |
| 452 | 454 | |
| 453 | 455 | aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 454 | 456 | tls_encrypt_done, sk); |
| @@ -1792,7 +1794,9 @@ void tls_sw_free_resources_tx(struct sock *sk) · 1337 unmodified lines | ||
| 1792 | 1794 | if (atomic_read(&ctx->encrypt_pending)) |
| 1793 | 1795 | crypto_wait_req(-EINPROGRESS, &ctx->async_wait); |
| 1794 | 1796 | |
| 1797 | + release_sock(sk); | |
| 1795 | 1798 | cancel_delayed_work_sync(&ctx->tx_work.work); |
| 1799 | + lock_sock(sk); | |
| 1796 | 1800 | |
| 1797 | 1801 | /* Tx whatever records we can transmit and abandon the rest */ |
| 1798 | 1802 | tls_tx_records(sk, -1); |
| @@ -680,16 +680,6 @@ static void xfrm_hash_resize(struct work_struct *work) · 679 unmodified lines | ||
| 680 | 680 | mutex_unlock(&hash_resize_mutex); |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | −static 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 | 683 | /* Make sure *pol can be inserted into fastbin. |
| 694 | 684 | * Useful to check that later insert requests will be sucessful |
| 695 | 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 | 823 | u16 family) |
| 834 | 824 | { |
| 835 | 825 | unsigned int matched_s, matched_d; |
| 836 | − struct hlist_node *newpos = NULL; | |
| 837 | 826 | struct xfrm_policy *policy, *p; |
| 838 | 827 | |
| 839 | 828 | matched_s = 0; |
| 840 | 829 | matched_d = 0; |
| 841 | 830 | |
| 842 | 831 | list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { |
| 832 | + struct hlist_node *newpos = NULL; | |
| 843 | 833 | bool matches_s, matches_d; |
| 844 | 834 | |
| 845 | 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 | 840 | policy->bydst_reinsert = false; |
| 851 | 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 | 846 | newpos = &p->bydst; |
| 854 | 847 | else |
| 855 | 848 | break; |
| 856 | 849 | } |
| 857 | 850 | |
| 858 | 851 | if (newpos) |
| 859 | − hlist_add_behind(&policy->bydst, newpos); | |
| 852 | + hlist_add_behind_rcu(&policy->bydst, newpos); | |
| 860 | 853 | else |
| 861 | − hlist_add_head(&policy->bydst, &n->hhead); | |
| 854 | + hlist_add_head_rcu(&policy->bydst, &n->hhead); | |
| 862 | 855 | |
| 863 | 856 | /* paranoia checks follow. |
| 864 | 857 | * 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 | 886 | struct rb_root *new, |
| 894 | 887 | u16 family) |
| 895 | 888 | { |
| 896 | − struct rb_node **p, *parent = NULL; | |
| 897 | 889 | struct xfrm_pol_inexact_node *node; |
| 890 | + struct rb_node **p, *parent; | |
| 898 | 891 | |
| 899 | 892 | /* we should not have another subtree here */ |
| 900 | 893 | WARN_ON_ONCE(!RB_EMPTY_ROOT(&n->root)); |
| 901 | − | |
| 894 | +restart: | |
| 895 | + parent = NULL; | |
| 902 | 896 | p = &new->rb_node; |
| 903 | 897 | while (*p) { |
| 904 | 898 | u8 prefixlen; |
| @@ -918,12 +912,11 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 13 unmodified lines | ||
| 918 | 912 | } else { |
| 919 | 913 | struct xfrm_policy *tmp; |
| 920 | 914 | |
| 921 | − hlist_for_each_entry(tmp, &node->hhead, bydst) | |
| 922 | − tmp->bydst_reinsert = true; | |
| 923 | − hlist_for_each_entry(tmp, &n->hhead, bydst) | |
| 915 | + hlist_for_each_entry(tmp, &n->hhead, bydst) { | |
| 924 | 916 | tmp->bydst_reinsert = true; |
| 917 | + hlist_del_rcu(&tmp->bydst); | |
| 918 | + } | |
| 925 | 919 | |
| 926 | − INIT_HLIST_HEAD(&node->hhead); | |
| 927 | 920 | xfrm_policy_inexact_list_reinsert(net, node, family); |
| 928 | 921 | |
| 929 | 922 | if (node->prefixlen == n->prefixlen) { |
| @@ -935,8 +928,7 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 5 unmodified lines | ||
| 935 | 928 | kfree_rcu(n, rcu); |
| 936 | 929 | n = node; |
| 937 | 930 | n->prefixlen = prefixlen; |
| 938 | − *p = new->rb_node; | |
| 939 | − parent = NULL; | |
| 931 | + goto restart; | |
| 940 | 932 | } |
| 941 | 933 | } |
| 942 | 934 | |
| @@ -965,12 +957,11 @@ static void xfrm_policy_inexact_node_merge(struct net *net, · 22 unmodified lines | ||
| 965 | 957 | family); |
| 966 | 958 | } |
| 967 | 959 | |
| 968 | − hlist_for_each_entry(tmp, &v->hhead, bydst) | |
| 969 | − tmp->bydst_reinsert = true; | |
| 970 | − hlist_for_each_entry(tmp, &n->hhead, bydst) | |
| 960 | + hlist_for_each_entry(tmp, &v->hhead, bydst) { | |
| 971 | 961 | tmp->bydst_reinsert = true; |
| 962 | + hlist_del_rcu(&tmp->bydst); | |
| 963 | + } | |
| 972 | 964 | |
| 973 | − INIT_HLIST_HEAD(&n->hhead); | |
| 974 | 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 | 1226 | } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); |
| 1236 | 1227 | |
| 1237 | 1228 | spin_lock_bh(&net->xfrm.xfrm_policy_lock); |
| 1229 | + write_seqcount_begin(&xfrm_policy_hash_generation); | |
| 1238 | 1230 | |
| 1239 | 1231 | /* make sure that we can insert the indirect policies again before |
| 1240 | 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 | 1272 | /* reset the bydst and inexact table in all directions */ |
| 1281 | − xfrm_hash_reset_inexact_table(net); | |
| 1282 | − | |
| 1283 | 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 | 1281 | hmask = net->xfrm.policy_bydst[dir].hmask; |
| 1286 | 1282 | odst = net->xfrm.policy_bydst[dir].table; |
| 1287 | 1283 | for (i = hmask; i >= 0; i--) |
| @@ -1313,6 +1309,9 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 25 unmodified lines | ||
| 1313 | 1309 | newpos = NULL; |
| 1314 | 1310 | chain = policy_hash_bysel(net, &policy->selector, |
| 1315 | 1311 | policy->family, dir); |
| 1312 | + | |
| 1313 | + hlist_del_rcu(&policy->bydst); | |
| 1314 | + | |
| 1316 | 1315 | if (!chain) { |
| 1317 | 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 | |
| 1335 | 1334 | out_unlock: |
| 1336 | 1335 | __xfrm_policy_inexact_flush(net); |
| 1336 | + write_seqcount_end(&xfrm_policy_hash_generation); | |
| 1337 | 1337 | spin_unlock_bh(&net->xfrm.xfrm_policy_lock); |
| 1338 | 1338 | |
| 1339 | 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 | 2600 | dst_copy_metrics(dst1, dst); |
| 2601 | 2601 | |
| 2602 | 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 | 2608 | family = xfrm[i]->props.family; |
| 2606 | 2609 | dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif, |
| @@ -1488,10 +1488,15 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family) · 1487 unmodified lines | ||
| 1488 | 1488 | if (!ut[i].family) |
| 1489 | 1489 | ut[i].family = family; |
| 1490 | 1490 | |
| 1491 | − if ((ut[i].mode == XFRM_MODE_TRANSPORT) && | |
| 1492 | − (ut[i].family != prev_family)) | |
| 1493 | − return -EINVAL; | |
| 1494 | − | |
| 1491 | + switch (ut[i].mode) { | |
| 1492 | + case XFRM_MODE_TUNNEL: | |
| 1493 | + case XFRM_MODE_BEET: | |
| 1494 | + break; | |
| 1495 | + default: | |
| 1496 | + if (ut[i].family != prev_family) | |
| 1497 | + return -EINVAL; | |
| 1498 | + break; | |
| 1499 | + } | |
| 1495 | 1500 | if (ut[i].mode >= XFRM_MODE_MAX) |
| 1496 | 1501 | return -EINVAL; |
| 1497 | 1502 | |
| @@ -28,6 +28,19 @@ KEY_AES=0x0123456789abcdef0123456789012345 · 27 unmodified lines | ||
| 28 | 28 | SPI1=0x1 |
| 29 | 29 | SPI2=0x2 |
| 30 | 30 | |
| 31 | +do_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 | + | |
| 31 | 44 | do_esp() { |
| 32 | 45 | local ns=$1 |
| 33 | 46 | local me=$2 |
| @@ -40,10 +53,59 @@ do_esp() { · 6 unmodified lines | ||
| 40 | 53 | 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 | 54 | 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) | |
| 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 allow | |
| 45 | − # to fwd decrypted packets after esp processing: | |
| 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 allow | |
| 56 | + do_esp_policy $ns $me $remote $lnet $rnet | |
| 57 | +} | |
| 58 | + | |
| 59 | +# 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. | |
| 71 | +do_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 | |
| 49 | 111 | do_esp_policy_get_check() { |
| @@ -160,6 +222,41 @@ check_xfrm() { · 110 unmodified lines | ||
| 160 | 222 | return $lret |
| 161 | 223 | } |
| 162 | 224 | |
| 225 | +check_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 | 260 | #check for needed privileges |
| 164 | 261 | if [ "$(id -u)" -ne 0 ];then |
| 165 | 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 | ||
| 270 | 367 | do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96 |
| 271 | 368 | do_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 tunnel | |
| 274 | −check_xfrm 0 254 | |
| 370 | +check_exceptions "exceptions" | |
| 275 | 371 | if [ $? -ne 0 ]; then |
| 276 | − echo "FAIL: expected ping to .254 to fail" | |
| 277 | 372 | ret=1 |
| 278 | −else | |
| 279 | − echo "PASS: ping to .254 bypassed ipsec tunnel" | |
| 280 | 373 | fi |
| 281 | 374 | |
| 282 | −# ping to .253 should use use ipsec due to direct policy exception. | |
| 283 | −check_xfrm 1 253 | |
| 284 | −if [ $? -ne 0 ]; then | |
| 285 | − echo "FAIL: expected ping to .253 to use ipsec tunnel" | |
| 286 | − ret=1 | |
| 287 | −else | |
| 288 | − echo "PASS: direct policy matches" | |
| 289 | −fi | |
| 375 | +# insert block policies with adjacent/overlapping netmasks | |
| 376 | +do_overlap ns3 | |
| 290 | 377 | |
| 291 | −# ping to .2 should use ipsec. | |
| 292 | −check_xfrm 1 2 | |
| 378 | +check_exceptions "exceptions and block policies" | |
| 293 | 379 | if [ $? -ne 0 ]; then |
| 294 | − echo "FAIL: expected ping to .2 to use ipsec tunnel" | |
| 295 | 380 | ret=1 |
| 296 | −else | |
| 297 | − echo "PASS: policy matches" | |
| 298 | 381 | fi |
| 299 | 382 | |
| 383 | +for n in ns3 ns4;do | |
| 384 | + ip -net $n xfrm policy set hthresh4 28 24 hthresh6 126 125 | |
| 385 | + sleep $((RANDOM%5)) | |
| 386 | +done | |
| 387 | + | |
| 388 | +check_exceptions "exceptions and block policies after hresh changes" | |
| 389 | + | |
| 390 | +# full flush of policy db, check everything gets freed incl. internal meta data | |
| 391 | +ip -net ns3 xfrm policy flush | |
| 392 | + | |
| 393 | +do_esp_policy ns3 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24 | |
| 394 | +do_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 | |
| 397 | +ip -net ns3 xfrm policy set hthresh4 16 16 | |
| 398 | + | |
| 399 | +sleep $((RANDOM%5)) | |
| 400 | +check_exceptions "exceptions and block policies after hthresh change in ns3" | |
| 401 | + | |
| 402 | +# restore original hthresh settings -- move policies back to tables | |
| 403 | +for n in ns3 ns4;do | |
| 404 | + ip -net $n xfrm policy set hthresh4 32 32 hthresh6 128 128 | |
| 405 | + sleep $((RANDOM%5)) | |
| 406 | +done | |
| 407 | +check_exceptions "exceptions and block policies after hresh change to normal" | |
| 408 | + | |
| 300 | 409 | for i in 1 2 3 4;do ip netns del ns$i;done |
| 301 | 410 | |
| 302 | 411 | exit $ret |