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
1667316673 S: Maintained
1667416674 F: drivers/media/tuners/tuner-xc2028.*
1667516675
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+
1667616694 XDP SOCKETS (AF_XDP)
1667716695 M: Björn Töpel <bjorn.topel@intel.com>
1667816696 M: 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
257257 if (skb->len == 0) {
258258 struct sk_buff *tmp = skb_dequeue(&ser->head);
259259 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);
264261 }
265262 }
266263 /* 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
664664 if (port < 9)
665665 return 0;
666666
667− return mv88e6390_serdes_irq_setup(chip, port);
667+ return mv88e6390x_serdes_irq_setup(chip, port);
668668 }
669669
670670 void 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
20592059 if (skb) {
20602060 dev->stats.tx_packets++;
20612061 dev->stats.tx_bytes += skb->len;
2062− dev_kfree_skb_irq(skb);
2062+ dev_consume_skb_irq(skb);
20632063 info->skb = NULL;
20642064 }
20652065
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
145145 & 0xffff;
146146
147147 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);
149150 } else {
150151 /* Check for buffered last packet */
151152 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
666666 pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[tx_index],
667667 lp->tx_skbuff[tx_index]->len,
668668 PCI_DMA_TODEVICE);
669− dev_kfree_skb_irq (lp->tx_skbuff[tx_index]);
669+ dev_consume_skb_irq(lp->tx_skbuff[tx_index]);
670670 lp->tx_skbuff[tx_index] = NULL;
671671 lp->tx_dma_addr[tx_index] = 0;
672672 }
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
777777
778778 if (bp->tx_bufs[bp->tx_empty]) {
779779 ++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]);
781781 }
782782 bp->tx_bufs[bp->tx_empty] = NULL;
783783 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
638638 bytes_compl += skb->len;
639639 pkts_compl++;
640640
641− dev_kfree_skb_irq(skb);
641+ dev_consume_skb_irq(skb);
642642 }
643643
644644 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
10121012 }
10131013
10141014 skb_copy_from_linear_data(skb, skb_put(bounce_skb, len), len);
1015− dev_kfree_skb_any(skb);
1015+ dev_consume_skb_any(skb);
10161016 skb = bounce_skb;
10171017 }
10181018
drivers/net/ethernet/cadence/macb.h+3−0
@@ -643,6 +643,7 @@ · 642 unmodified lines
643643 #define MACB_CAPS_JUMBO 0x00000020
644644 #define MACB_CAPS_GEM_HAS_PTP 0x00000040
645645 #define MACB_CAPS_BD_RD_PREFETCH 0x00000080
646+#define MACB_CAPS_NEEDS_RSTONUBR 0x00000100
646647 #define MACB_CAPS_FIFO_MODE 0x10000000
647648 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
648649 #define MACB_CAPS_SG_DISABLED 0x40000000
@@ -1214,6 +1215,8 @@ struct macb { · 565 unmodified lines
12141215
12151216 int rx_bd_rd_prefetch;
12161217 int tx_bd_rd_prefetch;
1218+
1219+ u32 rx_intr_mask;
12171220 };
12181221
12191222 #ifdef CONFIG_MACB_USE_HWSTAMP
drivers/net/ethernet/cadence/macb_main.c+17−11
@@ -56,8 +56,7 @@ · 55 unmodified lines
5656 /* level of occupied TX descriptors under which we wake up TX process */
5757 #define MACB_TX_WAKEUP_THRESH(bp) (3 * (bp)->tx_ring_size / 4)
5858
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))
6160 #define MACB_TX_ERR_FLAGS (MACB_BIT(ISR_TUND) \
6261 | MACB_BIT(ISR_RLE) \
6362 | MACB_BIT(TXERR))
@@ -1270,7 +1269,7 @@ static int macb_poll(struct napi_struct *napi, int budget) · 1206 unmodified lines
12701269 queue_writel(queue, ISR, MACB_BIT(RCOMP));
12711270 napi_reschedule(napi);
12721271 } else {
1273− queue_writel(queue, IER, MACB_RX_INT_FLAGS);
1272+ queue_writel(queue, IER, bp->rx_intr_mask);
12741273 }
12751274 }
12761275
@@ -1288,7 +1287,7 @@ static void macb_hresp_error_task(unsigned long data) · 11 unmodified lines
12881287 u32 ctrl;
12891288
12901289 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 |
12921291 MACB_TX_INT_FLAGS |
12931292 MACB_BIT(HRESP));
12941293 }
@@ -1318,7 +1317,7 @@ static void macb_hresp_error_task(unsigned long data) · 23 unmodified lines
13181317
13191318 /* Enable interrupts */
13201319 queue_writel(queue, IER,
1321− MACB_RX_INT_FLAGS |
1320+ bp->rx_intr_mask |
13221321 MACB_TX_INT_FLAGS |
13231322 MACB_BIT(HRESP));
13241323 }
@@ -1372,14 +1371,14 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 47 unmodified lines
13721371 (unsigned int)(queue - bp->queues),
13731372 (unsigned long)status);
13741373
1375− if (status & MACB_RX_INT_FLAGS) {
1374+ if (status & bp->rx_intr_mask) {
13761375 /* There's no point taking any more interrupts
13771376 * until we have processed the buffers. The
13781377 * scheduling call may fail if the poll routine
13791378 * is already scheduled, so disable interrupts
13801379 * now.
13811380 */
1382− queue_writel(queue, IDR, MACB_RX_INT_FLAGS);
1381+ queue_writel(queue, IDR, bp->rx_intr_mask);
13831382 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
13841383 queue_writel(queue, ISR, MACB_BIT(RCOMP));
13851384
@@ -1412,8 +1411,9 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 26 unmodified lines
14121411 /* There is a hardware issue under heavy load where DMA can
14131412 * stop, this causes endless "used buffer descriptor read"
14141413 * 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.
14171417 */
14181418 if (status & MACB_BIT(RXUBR)) {
14191419 ctrl = macb_readl(bp, NCR);
@@ -2259,7 +2259,7 @@ static void macb_init_hw(struct macb *bp) · 839 unmodified lines
22592259
22602260 /* Enable interrupts */
22612261 queue_writel(queue, IER,
2262− MACB_RX_INT_FLAGS |
2262+ bp->rx_intr_mask |
22632263 MACB_TX_INT_FLAGS |
22642264 MACB_BIT(HRESP));
22652265 }
@@ -3907,6 +3907,7 @@ static const struct macb_config sama5d4_config = { · 1641 unmodified lines
39073907 };
39083908
39093909 static const struct macb_config emac_config = {
3910+ .caps = MACB_CAPS_NEEDS_RSTONUBR,
39103911 .clk_init = at91ether_clk_init,
39113912 .init = at91ether_init,
39123913 };
@@ -3928,7 +3929,8 @@ static const struct macb_config zynqmp_config = { · 15 unmodified lines
39283929 };
39293930
39303931 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,
39323934 .dma_burst_length = 16,
39333935 .clk_init = macb_clk_init,
39343936 .init = macb_init,
@@ -4083,6 +4085,10 @@ static int macb_probe(struct platform_device *pdev) · 148 unmodified lines
40834085 macb_dma_desc_get_size(bp);
40844086 }
40854087
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+
40864092 mac = of_get_mac_address(np);
40874093 if (mac) {
40884094 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
24182418 out_notify_fail:
24192419 (void)cancel_work_sync(&priv->service_task);
24202420 out_read_prop_fail:
2421+ /* safe for ACPI FW */
2422+ of_node_put(to_of_node(priv->fwnode));
24212423 free_netdev(ndev);
24222424 return ret;
24232425 }
@@ -2447,6 +2449,9 @@ static int hns_nic_dev_remove(struct platform_device *pdev) · 23 unmodified lines
24472449 set_bit(NIC_STATE_REMOVING, &priv->state);
24482450 (void)cancel_work_sync(&priv->service_task);
24492451
2452+ /* safe for ACPI FW */
2453+ of_node_put(to_of_node(priv->fwnode));
2454+
24502455 free_netdev(ndev);
24512456 return 0;
24522457 }
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
11571157 */
11581158 static int hns_nic_nway_reset(struct net_device *netdev)
11591159 {
1160− int ret = 0;
11611160 struct phy_device *phy = netdev->phydev;
11621161
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;
11681164
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);
11701172 }
11711173
11721174 static 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
321321 }
322322
323323 hns_mdio_cmd_write(mdio_dev, is_c45,
324− MDIO_C45_WRITE_ADDR, phy_id, devad);
324+ MDIO_C45_READ, phy_id, devad);
325325 }
326326
327327 /* 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
13101310 dev->stats.tx_aborted_errors++;
13111311 }
13121312
1313− dev_kfree_skb_irq(skb);
1313+ dev_consume_skb_irq(skb);
13141314
13151315 tx_cmd->cmd.command = 0; /* Mark free */
13161316 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
950950 if (params->rx_dim_enabled)
951951 __set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
952952
953− if (params->pflags & MLX5E_PFLAG_RX_NO_CSUM_COMPLETE)
953+ if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
954954 __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
955955
956956 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
11261126 struct mlx5e_priv *priv = netdev_priv(dev);
11271127 struct mlx5e_rep_priv *rpriv = priv->ppriv;
11281128 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);
11301139
1131− ret = snprintf(buf, len, "%d", rep->vport - 1);
11321140 if (ret >= len)
11331141 return -EOPNOTSUPP;
11341142
@@ -1285,6 +1293,18 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr) · 150 unmodified lines
12851293 return 0;
12861294 }
12871295
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+
12881308 static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
12891309 .switchdev_port_attr_get = mlx5e_attr_get,
12901310 };
@@ -1319,6 +1339,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { · 28 unmodified lines
13191339 .ndo_set_vf_rate = mlx5e_set_vf_rate,
13201340 .ndo_get_vf_config = mlx5e_get_vf_config,
13211341 .ndo_get_vf_stats = mlx5e_get_vf_stats,
1342+ .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
13221343 };
13231344
13241345 bool 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
11341134 int err = 0;
11351135 u8 *smac_v;
11361136
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−
11441137 esw_vport_cleanup_ingress_rules(esw, vport);
11451138
11461139 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
17281721 int vport_num;
17291722 int err;
17301723
1731− if (!MLX5_ESWITCH_MANAGER(dev))
1724+ if (!MLX5_VPORT_MANAGER(dev))
17321725 return 0;
17331726
17341727 esw_info(dev,
@@ -1797,7 +1790,7 @@ abort: · 62 unmodified lines
17971790
17981791 void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
17991792 {
1800− if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev))
1793+ if (!esw || !MLX5_VPORT_MANAGER(esw->dev))
18011794 return;
18021795
18031796 esw_info(esw->dev, "cleanup\n");
@@ -1827,13 +1820,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, · 23 unmodified lines
18271820 mutex_lock(&esw->state_lock);
18281821 evport = &esw->vports[vport];
18291822
1830− if (evport->info.spoofchk && !is_valid_ether_addr(mac)) {
1823+ if (evport->info.spoofchk && !is_valid_ether_addr(mac))
18311824 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",
18331826 vport);
1834− err = -EPERM;
1835− goto unlock;
1836− }
18371827
18381828 err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);
18391829 if (err) {
@@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 139 unmodified lines
19791969 evport = &esw->vports[vport];
19801970 pschk = evport->info.spoofchk;
19811971 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);
19821976 if (evport->enabled && esw->mode == SRIOV_LEGACY)
19831977 err = esw_vport_ingress_config(esw, evport);
19841978 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
616616 }
617617 }
618618
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+
619640 /* Must be called with intf_mutex held */
620641 void mlx5_lag_remove(struct mlx5_core_dev *dev)
621642 {
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
187187 MLX5_CAP_GEN(dev, lag_master);
188188 }
189189
190+int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num);
191+
190192 void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);
191193 void mlx5_lag_update(struct mlx5_core_dev *dev);
192194
drivers/net/ethernet/mellanox/mlx5/core/qp.c+3−2
@@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common * · 43 unmodified lines
4444 mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
4545 {
4646 struct mlx5_core_rsc_common *common;
47+ unsigned long flags;
4748
48− spin_lock(&table->lock);
49+ spin_lock_irqsave(&table->lock, flags);
4950
5051 common = radix_tree_lookup(&table->tree, rsn);
5152 if (common)
5253 atomic_inc(&common->refcount);
5354
54− spin_unlock(&table->lock);
55+ spin_unlock_irqrestore(&table->lock, flags);
5556
5657 return common;
5758 }
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
795795
796796 /* get pq index according to PQ_FLAGS */
797797 static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn,
798− u32 pq_flags)
798+ unsigned long pq_flags)
799799 {
800800 struct qed_qm_info *qm_info = &p_hwfn->qm_info;
801801
802802 /* Can't have multiple flags set here */
803− if (bitmap_weight((unsigned long *)&pq_flags,
803+ if (bitmap_weight(&pq_flags,
804804 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);
806806 goto err;
807807 }
808808
809809 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);
811811 goto err;
812812 }
813813
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
609609 (!!(accept_filter & QED_ACCEPT_MCAST_MATCHED) &&
610610 !!(accept_filter & QED_ACCEPT_MCAST_UNMATCHED)));
611611
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+
612616 SET_FIELD(state, ETH_VPORT_TX_MODE_BCAST_ACCEPT_ALL,
613617 !!(accept_filter & QED_ACCEPT_BCAST));
614618
@@ -744,6 +748,11 @@ int qed_sp_vport_update(struct qed_hwfn *p_hwfn, · 129 unmodified lines
744748 return rc;
745749 }
746750
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+
747756 /* Update mcast bins for VFs, PF doesn't use this functionality */
748757 qed_sp_update_mcast_bin(p_hwfn, p_ramrod, p_params);
749758
@@ -2688,7 +2697,8 @@ static int qed_configure_filter_rx_mode(struct qed_dev *cdev, · 1938 unmodified lines
26882697 if (type == QED_FILTER_RX_MODE_TYPE_PROMISC) {
26892698 accept_flags.rx_accept_filter |= QED_ACCEPT_UCAST_UNMATCHED |
26902699 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;
26922702 } else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC) {
26932703 accept_flags.rx_accept_filter |= QED_ACCEPT_MCAST_UNMATCHED;
26942704 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
219219 struct qed_rss_params *rss_params;
220220 struct qed_filter_accept_flags accept_flags;
221221 struct qed_sge_tpa_params *sge_tpa_params;
222+ u8 update_ctl_frame_check;
223+ u8 mac_chk_en;
224+ u8 ethtype_chk_en;
222225 };
223226
224227 int 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
24512451 {
24522452 struct qed_ll2_tx_pkt_info pkt;
24532453 const skb_frag_t *frag;
2454+ u8 flags = 0, nr_frags;
24542455 int rc = -EINVAL, i;
24552456 dma_addr_t mapping;
24562457 u16 vlan = 0;
2457− u8 flags = 0;
24582458
24592459 if (unlikely(skb->ip_summed != CHECKSUM_NONE)) {
24602460 DP_INFO(cdev, "Cannot transmit a checksummed packet\n");
24612461 return -EINVAL;
24622462 }
24632463
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) {
24652470 DP_ERR(cdev, "Cannot transmit a packet with %d fragments\n",
2466− 1 + skb_shinfo(skb)->nr_frags);
2471+ 1 + nr_frags);
24672472 return -EINVAL;
24682473 }
24692474
@@ -2485,7 +2490,7 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb, · 15 unmodified lines
24852490 }
24862491
24872492 memset(&pkt, 0, sizeof(pkt));
2488− pkt.num_of_bds = 1 + skb_shinfo(skb)->nr_frags;
2493+ pkt.num_of_bds = 1 + nr_frags;
24892494 pkt.vlan = vlan;
24902495 pkt.bd_flags = flags;
24912496 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
24962501 test_bit(QED_LL2_XMIT_FLAGS_FIP_DISCOVERY, &xmit_flags))
24972502 pkt.remove_stag = true;
24982503
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+ */
24992509 rc = qed_ll2_prepare_tx_packet(&cdev->hwfns[0], cdev->ll2->handle,
25002510 &pkt, 1);
25012511 if (rc)
25022512 goto err;
25032513
2504− for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2514+ for (i = 0; i < nr_frags; i++) {
25052515 frag = &skb_shinfo(skb)->frags[i];
25062516
25072517 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
19691969 params.vport_id = vf->vport_id;
19701970 params.max_buffers_per_cqe = start->max_buffers_per_cqe;
19711971 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;
19731975
19741976 rc = qed_sp_eth_vport_start(p_hwfn, &params);
19751977 if (rc) {
@@ -5130,6 +5132,9 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn) · 3154 unmodified lines
51305132 params.opaque_fid = vf->opaque_fid;
51315133 params.vport_id = vf->vport_id;
51325134
5135+ params.update_ctl_frame_check = 1;
5136+ params.mac_chk_en = !vf_info->is_trusted_configured;
5137+
51335138 if (vf_info->rx_accept_mode & mask) {
51345139 flags->update_rx_mode_config = 1;
51355140 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
51475152 }
51485153
51495154 if (flags->update_rx_mode_config ||
5150− flags->update_tx_mode_config)
5155+ flags->update_tx_mode_config ||
5156+ params.update_ctl_frame_check)
51515157 qed_sp_vport_update(hwfn, &params,
51525158 QED_SPQ_MODE_EBLOCK, NULL);
51535159 }
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
261261 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
262262 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
263263 struct vf_pf_resc_request *p_resc;
264+ u8 retry_cnt = VF_ACQUIRE_THRESH;
264265 bool resources_acquired = false;
265266 struct vfpf_acquire_tlv *req;
266267 int rc = 0, attempts = 0;
@@ -314,6 +315,15 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn) · 47 unmodified lines
314315
315316 /* send acquire request */
316317 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+
317327 if (rc)
318328 goto exit;
319329
drivers/net/ethernet/realtek/8139cp.c+1−1
@@ -691,7 +691,7 @@ static void cp_tx (struct cp_private *cp) · 690 unmodified lines
691691 }
692692 bytes_compl += skb->len;
693693 pkts_compl++;
694− dev_kfree_skb_irq(skb);
694+ dev_consume_skb_irq(skb);
695695 }
696696
697697 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
13421342 }
13431343
13441344 ret = phy_power_on(bsp_priv, true);
1345− if (ret)
1345+ if (ret) {
1346+ gmac_clk_enable(bsp_priv, false);
13461347 return ret;
1348+ }
13471349
13481350 pm_runtime_enable(dev);
13491351 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
608608 netdev_dbg(dev, "sent 0x%p, len=%d\n",
609609 desc->skb, desc->skb->len);
610610
611− dev_kfree_skb_irq(desc->skb);
611+ dev_consume_skb_irq(desc->skb);
612612 desc->skb = NULL;
613613 if (__netif_subqueue_stopped(dev, queue))
614614 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
13371337 n->vqs[i].rx_ring = NULL;
13381338 vhost_net_buf_init(&n->vqs[i].rxq);
13391339 }
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);
13411342
13421343 vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev);
13431344 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
16271627 vqs[i] = &vs->vqs[i].vq;
16281628 vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
16291629 }
1630− vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
1630+ vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV);
16311631
16321632 vhost_scsi_init_inflight(vs, NULL);
16331633
drivers/vhost/vhost.c+4−3
@@ -390,9 +390,9 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) · 389 unmodified lines
390390 vq->indirect = kmalloc_array(UIO_MAXIOV,
391391 sizeof(*vq->indirect),
392392 GFP_KERNEL);
393− vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log),
393+ vq->log = kmalloc_array(dev->iov_limit, sizeof(*vq->log),
394394 GFP_KERNEL);
395− vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads),
395+ vq->heads = kmalloc_array(dev->iov_limit, sizeof(*vq->heads),
396396 GFP_KERNEL);
397397 if (!vq->indirect || !vq->log || !vq->heads)
398398 goto err_nomem;
@@ -414,7 +414,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev) · 15 unmodified lines
414414 }
415415
416416 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)
418418 {
419419 struct vhost_virtqueue *vq;
420420 int i;
@@ -427,6 +427,7 @@ void vhost_dev_init(struct vhost_dev *dev, · 6 unmodified lines
427427 dev->iotlb = NULL;
428428 dev->mm = NULL;
429429 dev->worker = NULL;
430+ dev->iov_limit = iov_limit;
430431 init_llist_head(&dev->work_list);
431432 init_waitqueue_head(&dev->wait);
432433 INIT_LIST_HEAD(&dev->read_list);
drivers/vhost/vhost.h+3−1
@@ -170,9 +170,11 @@ struct vhost_dev { · 169 unmodified lines
170170 struct list_head read_list;
171171 struct list_head pending_list;
172172 wait_queue_head_t wait;
173+ int iov_limit;
173174 };
174175
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);
176178 long vhost_dev_set_owner(struct vhost_dev *dev);
177179 bool vhost_dev_has_owner(struct vhost_dev *dev);
178180 long 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
531531 vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick;
532532 vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick;
533533
534− vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs));
534+ vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), UIO_MAXIOV);
535535
536536 file->private_data = vsock;
537537 spin_lock_init(&vsock->send_pkt_list_lock);
include/net/tls.h+2−0
@@ -120,6 +120,8 @@ struct tls_rec { · 119 unmodified lines
120120 struct scatterlist sg_aead_out[2];
121121
122122 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];
123125 struct aead_request aead_req;
124126 u8 aead_req_ctx[];
125127 };
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
22932293
22942294 xt_compat_lock(NFPROTO_BRIDGE);
22952295
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+
22992302 ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
23002303 if (ret < 0)
23012304 goto out_unlock;
net/core/dev.c+3−0
@@ -8712,6 +8712,9 @@ int init_dummy_netdev(struct net_device *dev) · 8711 unmodified lines
87128712 set_bit(__LINK_STATE_PRESENT, &dev->state);
87138713 set_bit(__LINK_STATE_START, &dev->state);
87148714
8715+ /* napi_busy_loop stats accounting wants this */
8716+ dev_net_set(dev, &init_net);
8717+
87158718 /* Note : We dont allocate pcpu_refcnt for dummy devices,
87168719 * because users of this 'device' dont need to change
87178720 * its refcount.
net/decnet/dn_dev.c+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
5656 #include <net/dn_neigh.h>
5757 #include <net/dn_fib.h>
5858
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))
6060
6161 static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00};
6262 static 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
7474 return 0;
7575 }
7676
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+
77104 static int vti_rcv(struct sk_buff *skb)
78105 {
79106 XFRM_SPI_SKB_CB(skb)->family = AF_INET;
@@ -82,6 +109,14 @@ static int vti_rcv(struct sk_buff *skb) · 2 unmodified lines
82109 return vti_input(skb, ip_hdr(skb)->protocol, 0, 0);
83110 }
84111
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+
85120 static int vti_rcv_cb(struct sk_buff *skb, int err)
86121 {
87122 unsigned short family;
@@ -435,6 +470,12 @@ static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = { · 347 unmodified lines
435470 .priority = 100,
436471 };
437472
473+static struct xfrm_tunnel ipip_handler __read_mostly = {
474+ .handler = vti_rcv_ipip,
475+ .err_handler = vti4_err,
476+ .priority = 0,
477+};
478+
438479 static int __net_init vti_init_net(struct net *net)
439480 {
440481 int err;
@@ -603,6 +644,13 @@ static int __init vti_init(void) · 162 unmodified lines
603644 if (err < 0)
604645 goto xfrm_proto_comp_failed;
605646
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+
606654 msg = "netlink interface";
607655 err = rtnl_link_register(&vti_link_ops);
608656 if (err < 0)
@@ -612,6 +660,8 @@ static int __init vti_init(void) · 3 unmodified lines
612660
613661 rtnl_link_failed:
614662 xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);
663+xfrm_tunnel_failed:
664+ xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
615665 xfrm_proto_comp_failed:
616666 xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
617667 xfrm_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
846846
847847 static void clusterip_net_exit(struct net *net)
848848 {
849+#ifdef CONFIG_PROC_FS
849850 struct clusterip_net *cn = clusterip_pernet(net);
850851
851−#ifdef CONFIG_PROC_FS
852852 mutex_lock(&cn->mutex);
853853 proc_remove(cn->procdir);
854854 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
15161516 continue;
15171517 rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params);
15181518 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);
15191522 mr6_netlink_event(mrt, (struct mfc6_cache *)c, RTM_DELROUTE);
15201523 mr_cache_put(c);
15211524 }
@@ -1524,10 +1527,6 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) · 2 unmodified lines
15241527 spin_lock_bh(&mfc_unres_lock);
15251528 list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) {
15261529 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);
15311530 mr6_netlink_event(mrt, (struct mfc6_cache *)c,
15321531 RTM_DELROUTE);
15331532 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
22202220 u->tcp_fin_timeout,
22212221 u->udp_timeout);
22222222
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+
22232235 #ifdef CONFIG_IP_VS_PROTO_TCP
22242236 if (u->tcp_timeout) {
22252237 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
6666 int ttl_check,
6767 struct nf_osf_hdr_ctx *ctx)
6868 {
69+ const __u8 *optpinit = ctx->optp;
6970 unsigned int check_WSS = 0;
7071 int fmatch = FMATCH_WRONG;
7172 int foptsize, optnum;
@@ -155,6 +156,9 @@ static bool nf_osf_match_one(const struct sk_buff *skb, · 83 unmodified lines
155156 }
156157 }
157158
159+ if (fmatch != FMATCH_OK)
160+ ctx->optp = optpinit;
161+
158162 return fmatch == FMATCH_OK;
159163 }
160164
net/netfilter/nft_compat.c+142−47
@@ -22,11 +22,15 @@ · 21 unmodified lines
2222 #include <linux/netfilter_bridge/ebtables.h>
2323 #include <linux/netfilter_arp/arp_tables.h>
2424 #include <net/netfilter/nf_tables.h>
25+#include <net/netns/generic.h>
2526
2627 struct nft_xt {
2728 struct list_head head;
2829 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;
3034
3135 /* Unlike other expressions, ops doesn't have static storage duration.
3236 * 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
4347 void *info;
4448 };
4549
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+
4664 static bool nft_xt_put(struct nft_xt *xt)
4765 {
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));
5068 kfree_rcu(xt, rcu_head);
5169 return true;
5270 }
@@ -273,7 +291,7 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr, · 220 unmodified lines
273291 return -EINVAL;
274292
275293 nft_xt = container_of(expr->ops, struct nft_xt, ops);
276− nft_xt->refcnt++;
294+ refcount_inc(&nft_xt->refcnt);
277295 return 0;
278296 }
279297
@@ -486,7 +504,7 @@ __nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr, · 206 unmodified lines
486504 return ret;
487505
488506 nft_xt = container_of(expr->ops, struct nft_xt, ops);
489− nft_xt->refcnt++;
507+ refcount_inc(&nft_xt->refcnt);
490508 return 0;
491509 }
492510
@@ -540,6 +558,43 @@ nft_match_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr) · 47 unmodified lines
540558 __nft_match_destroy(ctx, expr, nft_expr_priv(expr));
541559 }
542560
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+
543598 static void
544599 nft_match_large_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
545600 {
@@ -734,10 +789,6 @@ static const struct nfnetlink_subsystem nfnl_compat_subsys = { · 188 unmodified lines
734789 .cb = nfnl_nft_compat_cb,
735790 };
736791
737−static LIST_HEAD(nft_match_list);
738−
739−static struct nft_expr_type nft_match_type;
740−
741792 static bool nft_match_cmp(const struct xt_match *match,
742793 const char *name, u32 rev, u32 family)
743794 {
@@ -749,6 +800,7 @@ static const struct nft_expr_ops * · 5 unmodified lines
749800 nft_match_select_ops(const struct nft_ctx *ctx,
750801 const struct nlattr * const tb[])
751802 {
803+ struct nft_compat_net *cn;
752804 struct nft_xt *nft_match;
753805 struct xt_match *match;
754806 unsigned int matchsize;
@@ -765,8 +817,10 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 10 unmodified lines
765817 rev = ntohl(nla_get_be32(tb[NFTA_MATCH_REV]));
766818 family = ctx->family;
767819
820+ cn = nft_compat_pernet(ctx->net);
821+
768822 /* 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) {
770824 struct xt_match *match = nft_match->ops.data;
771825
772826 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
789843 goto err;
790844 }
791845
792− nft_match->refcnt = 0;
846+ refcount_set(&nft_match->refcnt, 0);
793847 nft_match->ops.type = &nft_match_type;
794848 nft_match->ops.eval = nft_match_eval;
795849 nft_match->ops.init = nft_match_init;
796850 nft_match->ops.destroy = nft_match_destroy;
851+ nft_match->ops.activate = nft_compat_activate_mt;
852+ nft_match->ops.deactivate = nft_compat_deactivate;
797853 nft_match->ops.dump = nft_match_dump;
798854 nft_match->ops.validate = nft_match_validate;
799855 nft_match->ops.data = match;
@@ -810,7 +866,8 @@ nft_match_select_ops(const struct nft_ctx *ctx, · 10 unmodified lines
810866
811867 nft_match->ops.size = matchsize;
812868
813− list_add(&nft_match->head, &nft_match_list);
869+ nft_match->listcnt = 1;
870+ list_add(&nft_match->head, &cn->nft_match_list);
814871
815872 return &nft_match->ops;
816873 err:
@@ -826,10 +883,6 @@ static struct nft_expr_type nft_match_type __read_mostly = { · 9 unmodified lines
826883 .owner = THIS_MODULE,
827884 };
828885
829−static LIST_HEAD(nft_target_list);
830−
831−static struct nft_expr_type nft_target_type;
832−
833886 static bool nft_target_cmp(const struct xt_target *tg,
834887 const char *name, u32 rev, u32 family)
835888 {
@@ -841,6 +894,7 @@ static const struct nft_expr_ops * · 5 unmodified lines
841894 nft_target_select_ops(const struct nft_ctx *ctx,
842895 const struct nlattr * const tb[])
843896 {
897+ struct nft_compat_net *cn;
844898 struct nft_xt *nft_target;
845899 struct xt_target *target;
846900 char *tg_name;
@@ -861,8 +915,9 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 14 unmodified lines
861915 strcmp(tg_name, "standard") == 0)
862916 return ERR_PTR(-EINVAL);
863917
918+ cn = nft_compat_pernet(ctx->net);
864919 /* 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) {
866921 struct xt_target *target = nft_target->ops.data;
867922
868923 if (!target->target)
@@ -893,11 +948,13 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 24 unmodified lines
893948 goto err;
894949 }
895950
896− nft_target->refcnt = 0;
951+ refcount_set(&nft_target->refcnt, 0);
897952 nft_target->ops.type = &nft_target_type;
898953 nft_target->ops.size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize));
899954 nft_target->ops.init = nft_target_init;
900955 nft_target->ops.destroy = nft_target_destroy;
956+ nft_target->ops.activate = nft_compat_activate_tg;
957+ nft_target->ops.deactivate = nft_compat_deactivate;
901958 nft_target->ops.dump = nft_target_dump;
902959 nft_target->ops.validate = nft_target_validate;
903960 nft_target->ops.data = target;
@@ -907,7 +964,8 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 3 unmodified lines
907964 else
908965 nft_target->ops.eval = nft_target_eval_xt;
909966
910− list_add(&nft_target->head, &nft_target_list);
967+ nft_target->listcnt = 1;
968+ list_add(&nft_target->head, &cn->nft_target_list);
911969
912970 return &nft_target->ops;
913971 err:
@@ -923,13 +981,74 @@ static struct nft_expr_type nft_target_type __read_mostly = { · 9 unmodified lines
923981 .owner = THIS_MODULE,
924982 };
925983
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+
9261041 static int __init nft_compat_module_init(void)
9271042 {
9281043 int ret;
9291044
1045+ ret = register_pernet_subsys(&nft_compat_net_ops);
1046+ if (ret < 0)
1047+ goto err_target;
1048+
9301049 ret = nft_register_expr(&nft_match_type);
9311050 if (ret < 0)
932− return ret;
1051+ goto err_pernet;
9331052
9341053 ret = nft_register_expr(&nft_target_type);
9351054 if (ret < 0)
@@ -942,45 +1061,21 @@ static int __init nft_compat_module_init(void) · 6 unmodified lines
9421061 }
9431062
9441063 return ret;
945−
9461064 err_target:
9471065 nft_unregister_expr(&nft_target_type);
9481066 err_match:
9491067 nft_unregister_expr(&nft_match_type);
1068+err_pernet:
1069+ unregister_pernet_subsys(&nft_compat_net_ops);
9501070 return ret;
9511071 }
9521072
9531073 static void __exit nft_compat_module_exit(void)
9541074 {
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− }
9811075 nfnetlink_subsys_unregister(&nfnl_compat_subsys);
9821076 nft_unregister_expr(&nft_target_type);
9831077 nft_unregister_expr(&nft_match_type);
1078+ unregister_pernet_subsys(&nft_compat_net_ops);
9841079 }
9851080
9861081 MODULE_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
5252 {
5353 struct nr_sock *nr = nr_sk(sk);
5454
55− mod_timer(&nr->t1timer, jiffies + nr->t1);
55+ sk_reset_timer(sk, &nr->t1timer, jiffies + nr->t1);
5656 }
5757
5858 void nr_start_t2timer(struct sock *sk)
5959 {
6060 struct nr_sock *nr = nr_sk(sk);
6161
62− mod_timer(&nr->t2timer, jiffies + nr->t2);
62+ sk_reset_timer(sk, &nr->t2timer, jiffies + nr->t2);
6363 }
6464
6565 void nr_start_t4timer(struct sock *sk)
6666 {
6767 struct nr_sock *nr = nr_sk(sk);
6868
69− mod_timer(&nr->t4timer, jiffies + nr->t4);
69+ sk_reset_timer(sk, &nr->t4timer, jiffies + nr->t4);
7070 }
7171
7272 void nr_start_idletimer(struct sock *sk)
@@ -74,37 +74,37 @@ void nr_start_idletimer(struct sock *sk) · 1 unmodified line
7474 struct nr_sock *nr = nr_sk(sk);
7575
7676 if (nr->idle > 0)
77− mod_timer(&nr->idletimer, jiffies + nr->idle);
77+ sk_reset_timer(sk, &nr->idletimer, jiffies + nr->idle);
7878 }
7979
8080 void nr_start_heartbeat(struct sock *sk)
8181 {
82− mod_timer(&sk->sk_timer, jiffies + 5 * HZ);
82+ sk_reset_timer(sk, &sk->sk_timer, jiffies + 5 * HZ);
8383 }
8484
8585 void nr_stop_t1timer(struct sock *sk)
8686 {
87− del_timer(&nr_sk(sk)->t1timer);
87+ sk_stop_timer(sk, &nr_sk(sk)->t1timer);
8888 }
8989
9090 void nr_stop_t2timer(struct sock *sk)
9191 {
92− del_timer(&nr_sk(sk)->t2timer);
92+ sk_stop_timer(sk, &nr_sk(sk)->t2timer);
9393 }
9494
9595 void nr_stop_t4timer(struct sock *sk)
9696 {
97− del_timer(&nr_sk(sk)->t4timer);
97+ sk_stop_timer(sk, &nr_sk(sk)->t4timer);
9898 }
9999
100100 void nr_stop_idletimer(struct sock *sk)
101101 {
102− del_timer(&nr_sk(sk)->idletimer);
102+ sk_stop_timer(sk, &nr_sk(sk)->idletimer);
103103 }
104104
105105 void nr_stop_heartbeat(struct sock *sk)
106106 {
107− del_timer(&sk->sk_timer);
107+ sk_stop_timer(sk, &sk->sk_timer);
108108 }
109109
110110 int 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
850850
851851 /*
852852 * Route a frame to an appropriate AX.25 connection.
853+ * A NULL ax25_cb indicates an internally generated frame.
853854 */
854855 int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
855856 {
@@ -867,6 +868,10 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) · 11 unmodified lines
867868
868869 if (skb->len < ROSE_MIN_LEN)
869870 return res;
871+
872+ if (!ax25)
873+ return rose_loopback_queue(skb, NULL);
874+
870875 frametype = skb->data[2];
871876 lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
872877 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
439439 struct scatterlist *sge = sk_msg_elem(msg_en, start);
440440 int rc;
441441
442+ memcpy(rec->iv_data, tls_ctx->tx.iv, sizeof(rec->iv_data));
443+
442444 sge->offset += tls_ctx->tx.prepend_size;
443445 sge->length -= tls_ctx->tx.prepend_size;
444446
@@ -448,7 +450,7 @@ static int tls_do_encryption(struct sock *sk, · 3 unmodified lines
448450 aead_request_set_ad(aead_req, TLS_AAD_SPACE_SIZE);
449451 aead_request_set_crypt(aead_req, rec->sg_aead_in,
450452 rec->sg_aead_out,
451− data_len, tls_ctx->tx.iv);
453+ data_len, rec->iv_data);
452454
453455 aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG,
454456 tls_encrypt_done, sk);
@@ -1792,7 +1794,9 @@ void tls_sw_free_resources_tx(struct sock *sk) · 1337 unmodified lines
17921794 if (atomic_read(&ctx->encrypt_pending))
17931795 crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
17941796
1797+ release_sock(sk);
17951798 cancel_delayed_work_sync(&ctx->tx_work.work);
1799+ lock_sock(sk);
17961800
17971801 /* Tx whatever records we can transmit and abandon the rest */
17981802 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
680680 mutex_unlock(&hash_resize_mutex);
681681 }
682682
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−
693683 /* Make sure *pol can be inserted into fastbin.
694684 * Useful to check that later insert requests will be sucessful
695685 * (provided xfrm_policy_lock is held throughout).
@@ -833,13 +823,13 @@ static void xfrm_policy_inexact_list_reinsert(struct net *net, · 137 unmodified lines
833823 u16 family)
834824 {
835825 unsigned int matched_s, matched_d;
836− struct hlist_node *newpos = NULL;
837826 struct xfrm_policy *policy, *p;
838827
839828 matched_s = 0;
840829 matched_d = 0;
841830
842831 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
832+ struct hlist_node *newpos = NULL;
843833 bool matches_s, matches_d;
844834
845835 if (!policy->bydst_reinsert)
@@ -849,16 +839,19 @@ static void xfrm_policy_inexact_list_reinsert(struct net *net, · 3 unmodified lines
849839
850840 policy->bydst_reinsert = false;
851841 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)
853846 newpos = &p->bydst;
854847 else
855848 break;
856849 }
857850
858851 if (newpos)
859− hlist_add_behind(&policy->bydst, newpos);
852+ hlist_add_behind_rcu(&policy->bydst, newpos);
860853 else
861− hlist_add_head(&policy->bydst, &n->hhead);
854+ hlist_add_head_rcu(&policy->bydst, &n->hhead);
862855
863856 /* paranoia checks follow.
864857 * 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
893886 struct rb_root *new,
894887 u16 family)
895888 {
896− struct rb_node **p, *parent = NULL;
897889 struct xfrm_pol_inexact_node *node;
890+ struct rb_node **p, *parent;
898891
899892 /* we should not have another subtree here */
900893 WARN_ON_ONCE(!RB_EMPTY_ROOT(&n->root));
901−
894+restart:
895+ parent = NULL;
902896 p = &new->rb_node;
903897 while (*p) {
904898 u8 prefixlen;
@@ -918,12 +912,11 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 13 unmodified lines
918912 } else {
919913 struct xfrm_policy *tmp;
920914
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) {
924916 tmp->bydst_reinsert = true;
917+ hlist_del_rcu(&tmp->bydst);
918+ }
925919
926− INIT_HLIST_HEAD(&node->hhead);
927920 xfrm_policy_inexact_list_reinsert(net, node, family);
928921
929922 if (node->prefixlen == n->prefixlen) {
@@ -935,8 +928,7 @@ static void xfrm_policy_inexact_node_reinsert(struct net *net, · 5 unmodified lines
935928 kfree_rcu(n, rcu);
936929 n = node;
937930 n->prefixlen = prefixlen;
938− *p = new->rb_node;
939− parent = NULL;
931+ goto restart;
940932 }
941933 }
942934
@@ -965,12 +957,11 @@ static void xfrm_policy_inexact_node_merge(struct net *net, · 22 unmodified lines
965957 family);
966958 }
967959
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) {
971961 tmp->bydst_reinsert = true;
962+ hlist_del_rcu(&tmp->bydst);
963+ }
972964
973− INIT_HLIST_HEAD(&n->hhead);
974965 xfrm_policy_inexact_list_reinsert(net, n, family);
975966 }
976967
@@ -1235,6 +1226,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 258 unmodified lines
12351226 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq));
12361227
12371228 spin_lock_bh(&net->xfrm.xfrm_policy_lock);
1229+ write_seqcount_begin(&xfrm_policy_hash_generation);
12381230
12391231 /* make sure that we can insert the indirect policies again before
12401232 * we start with destructive action.
@@ -1278,10 +1270,14 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 37 unmodified lines
12781270 }
12791271
12801272 /* reset the bydst and inexact table in all directions */
1281− xfrm_hash_reset_inexact_table(net);
1282−
12831273 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+
12851281 hmask = net->xfrm.policy_bydst[dir].hmask;
12861282 odst = net->xfrm.policy_bydst[dir].table;
12871283 for (i = hmask; i >= 0; i--)
@@ -1313,6 +1309,9 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 25 unmodified lines
13131309 newpos = NULL;
13141310 chain = policy_hash_bysel(net, &policy->selector,
13151311 policy->family, dir);
1312+
1313+ hlist_del_rcu(&policy->bydst);
1314+
13161315 if (!chain) {
13171316 void *p = xfrm_policy_inexact_insert(policy, dir, 0);
13181317
@@ -1334,6 +1333,7 @@ static void xfrm_hash_rebuild(struct work_struct *work) · 15 unmodified lines
13341333
13351334 out_unlock:
13361335 __xfrm_policy_inexact_flush(net);
1336+ write_seqcount_end(&xfrm_policy_hash_generation);
13371337 spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
13381338
13391339 mutex_unlock(&hash_resize_mutex);
@@ -2600,7 +2600,10 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, · 1260 unmodified lines
26002600 dst_copy_metrics(dst1, dst);
26012601
26022602 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]);
26042607
26052608 family = xfrm[i]->props.family;
26062609 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
14881488 if (!ut[i].family)
14891489 ut[i].family = family;
14901490
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+ }
14951500 if (ut[i].mode >= XFRM_MODE_MAX)
14961501 return -EINVAL;
14971502
tools/testing/selftests/net/xfrm_policy.sh+131−22
@@ -28,6 +28,19 @@ KEY_AES=0x0123456789abcdef0123456789012345 · 27 unmodified lines
2828 SPI1=0x1
2929 SPI2=0x2
3030
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+
3144 do_esp() {
3245 local ns=$1
3346 local me=$2
@@ -40,10 +53,59 @@ do_esp() { · 6 unmodified lines
4053 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
4154 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
4255
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
47109 }
48110
49111 do_esp_policy_get_check() {
@@ -160,6 +222,41 @@ check_xfrm() { · 110 unmodified lines
160222 return $lret
161223 }
162224
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+
163260 #check for needed privileges
164261 if [ "$(id -u)" -ne 0 ];then
165262 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
270367 do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96
271368 do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96
272369
273−# ping to .254 should now be excluded from the tunnel
274−check_xfrm 0 254
370+check_exceptions "exceptions"
275371 if [ $? -ne 0 ]; then
276− echo "FAIL: expected ping to .254 to fail"
277372 ret=1
278−else
279− echo "PASS: ping to .254 bypassed ipsec tunnel"
280373 fi
281374
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
290377
291−# ping to .2 should use ipsec.
292−check_xfrm 1 2
378+check_exceptions "exceptions and block policies"
293379 if [ $? -ne 0 ]; then
294− echo "FAIL: expected ping to .2 to use ipsec tunnel"
295380 ret=1
296−else
297− echo "PASS: policy matches"
298381 fi
299382
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+
300409 for i in 1 2 3 4;do ip netns del ns$i;done
301410
302411 exit $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