]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 20 Jul 2017 23:33:39 +0000 (16:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 20 Jul 2017 23:33:39 +0000 (16:33 -0700)
Pull networking fixes from David Miller:

 1) BPF verifier signed/unsigned value tracking fix, from Daniel
    Borkmann, Edward Cree, and Josef Bacik.

 2) Fix memory allocation length when setting up calls to
    ->ndo_set_mac_address, from Cong Wang.

 3) Add a new cxgb4 device ID, from Ganesh Goudar.

 4) Fix FIB refcount handling, we have to set it's initial value before
    the configure callback (which can bump it). From David Ahern.

 5) Fix double-free in qcom/emac driver, from Timur Tabi.

 6) A bunch of gcc-7 string format overflow warning fixes from Arnd
    Bergmann.

 7) Fix link level headroom tests in ip_do_fragment(), from Vasily
    Averin.

 8) Fix chunk walking in SCTP when iterating over error and parameter
    headers. From Alexander Potapenko.

 9) TCP BBR congestion control fixes from Neal Cardwell.

10) Fix SKB fragment handling in bcmgenet driver, from Doug Berger.

11) BPF_CGROUP_RUN_PROG_SOCK_OPS needs to check for null __sk, from Cong
    Wang.

12) xmit_recursion in ppp driver needs to be per-device not per-cpu,
    from Gao Feng.

13) Cannot release skb->dst in UDP if IP options processing needs it.
    From Paolo Abeni.

14) Some netdev ioctl ifr_name[] NULL termination fixes. From Alexander
    Levin and myself.

15) Revert some rtnetlink notification changes that are causing
    regressions, from David Ahern.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (83 commits)
  net: bonding: Fix transmit load balancing in balance-alb mode
  rds: Make sure updates to cp_send_gen can be observed
  net: ethernet: ti: cpsw: Push the request_irq function to the end of probe
  ipv4: initialize fib_trie prior to register_netdev_notifier call.
  rtnetlink: allocate more memory for dev_set_mac_address()
  net: dsa: b53: Add missing ARL entries for BCM53125
  bpf: more tests for mixed signed and unsigned bounds checks
  bpf: add test for mixed signed and unsigned bounds checks
  bpf: fix up test cases with mixed signed/unsigned bounds
  bpf: allow to specify log level and reduce it for test_verifier
  bpf: fix mixed signed/unsigned derived min/max value bounds
  ipv6: avoid overflow of offset in ip6_find_1stfragopt
  net: tehuti: don't process data if it has not been copied from userspace
  Revert "rtnetlink: Do not generate notifications for CHANGEADDR event"
  net: dsa: mv88e6xxx: Enable CMODE config support for 6390X
  dt-binding: ptp: Add SoC compatibility strings for dte ptp clock
  NET: dwmac: Make dwmac reset unconditional
  net: Zero terminate ifr_name in dev_ifname().
  wireless: wext: terminate ifr name coming from userspace
  netfilter: fix netfilter_net_init() return
  ...

83 files changed:
Documentation/devicetree/bindings/net/brcm,amac.txt
Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt [deleted file]
Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
drivers/atm/zatm.c
drivers/isdn/divert/isdn_divert.c
drivers/isdn/hardware/avm/c4.c
drivers/isdn/hardware/eicon/divasmain.c
drivers/isdn/hardware/mISDN/avmfritz.c
drivers/isdn/hardware/mISDN/hfcmulti.c
drivers/isdn/hardware/mISDN/hfcpci.c
drivers/isdn/hardware/mISDN/netjet.c
drivers/isdn/hardware/mISDN/w6692.c
drivers/isdn/hisax/config.c
drivers/isdn/hisax/hfc4s8s_l1.c
drivers/isdn/hisax/hisax_fcpcipnp.c
drivers/net/bonding/bond_main.c
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
drivers/net/ethernet/broadcom/bgmac-platform.c
drivers/net/ethernet/broadcom/bgmac.c
drivers/net/ethernet/broadcom/bgmac.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmgenet.h
drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
drivers/net/ethernet/mellanox/mlx4/alloc.c
drivers/net/ethernet/qualcomm/emac/emac.c
drivers/net/ethernet/sgi/ioc3-eth.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/sun/niu.c
drivers/net/ethernet/tehuti/tehuti.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/phy/mdio-mux.c
drivers/net/ppp/ppp_generic.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/huawei_cdc_ncm.c
drivers/net/usb/smsc95xx.c
drivers/net/vmxnet3/vmxnet3_int.h
drivers/net/wireless/ralink/rt2x00/rt2800lib.c
include/linux/bpf-cgroup.h
include/linux/bpf_verifier.h
include/linux/jhash.h
include/linux/netfilter.h
include/linux/usb/cdc_ncm.h
include/net/netlink.h
include/net/sctp/sctp.h
kernel/bpf/verifier.c
net/bridge/br_device.c
net/bridge/br_input.c
net/core/dev_ioctl.c
net/core/fib_rules.c
net/core/filter.c
net/core/netpoll.c
net/core/rtnetlink.c
net/dccp/input.c
net/ipv4/fib_frontend.c
net/ipv4/ip_output.c
net/ipv4/netfilter/nf_tables_arp.c
net/ipv4/syncookies.c
net/ipv4/tcp_bbr.c
net/ipv4/udp.c
net/ipv6/output_core.c
net/ipv6/syncookies.c
net/netfilter/core.c
net/netfilter/nf_conntrack_expect.c
net/netfilter/nf_nat_core.c
net/netfilter/nfnetlink.c
net/openvswitch/conntrack.c
net/packet/af_packet.c
net/rds/send.c
net/sched/act_api.c
net/sctp/sm_make_chunk.c
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
tools/testing/selftests/bpf/test_align.c
tools/testing/selftests/bpf/test_verifier.c

index 2fefa1a44afd4472f75a8fd74b73d7ae6c9083b9..ad16c1f481f77fed199e1c24bc3450aa75fbb970 100644 (file)
@@ -11,6 +11,7 @@ Required properties:
  - reg-names:  Names of the registers.
                "amac_base":    Address and length of the GMAC registers
                "idm_base":     Address and length of the GMAC IDM registers
+                               (required for NSP and Northstar2)
                "nicpm_base":   Address and length of the NIC Port Manager
                                registers (required for Northstar2)
  - interrupts: Interrupt number
diff --git a/Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt b/Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt
deleted file mode 100644 (file)
index 022946c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-Broadcom GMAC Ethernet Controller Device Tree Bindings
--------------------------------------------------------------
-
-Required properties:
- - compatible: "brcm,bgmac-nsp"
- - reg:                Address and length of the GMAC registers,
-               Address and length of the GMAC IDM registers
- - reg-names:  Names of the registers.  Must have both "gmac_base" and
-               "idm_base"
- - interrupts: Interrupt number
-
-Optional properties:
-- mac-address: See ethernet.txt file in the same directory
-
-Examples:
-
-gmac0: ethernet@18022000 {
-       compatible = "brcm,bgmac-nsp";
-       reg = <0x18022000 0x1000>,
-             <0x18110000 0x1000>;
-       reg-names = "gmac_base", "idm_base";
-       interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
-       status = "disabled";
-};
index 07590bcdad15a9bb4f66455b29363245ac3039c4..7c04e22a5d6af016fe8198d2d6d955011abc2173 100644 (file)
@@ -1,13 +1,20 @@
-* Broadcom Digital Timing Engine(DTE) based PTP clock driver
+* Broadcom Digital Timing Engine(DTE) based PTP clock
 
 Required properties:
-- compatible: should be "brcm,ptp-dte"
+- compatible: should contain the core compatibility string
+              and the SoC compatibility string. The SoC
+              compatibility string is to handle SoC specific
+              hardware differences.
+              Core compatibility string:
+                 "brcm,ptp-dte"
+              SoC compatibility strings:
+                 "brcm,iproc-ptp-dte" - for iproc based SoC's
 - reg: address and length of the DTE block's NCO registers
 
 Example:
 
-ptp_dte: ptp_dte@180af650 {
-       compatible = "brcm,ptp-dte";
+ptp: ptp-dte@180af650 {
+       compatible = "brcm,iproc-ptp-dte", "brcm,ptp-dte";
        reg = <0x180af650 0x10>;
        status = "okay";
 };
index 292dec18ffb87acf57842f3a0c2490b326488e12..07bdd51b3b9aab2e82e79346f52f6eb1bf4d9cbe 100644 (file)
@@ -1613,7 +1613,7 @@ static int zatm_init_one(struct pci_dev *pci_dev,
 
        ret = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32));
        if (ret < 0)
-               goto out_disable;
+               goto out_release;
 
        zatm_dev->pci_dev = pci_dev;
        dev->dev_data = zatm_dev;
index 060d357f107f8c7720b08e6791dc352893c08fff..6f423bc49d0dcfa0a0bd4ef9321213dbd14de07e 100644 (file)
@@ -485,18 +485,19 @@ static int isdn_divert_icall(isdn_ctrl *ic)
                                cs->deflect_dest[0] = '\0';
                                retval = 4; /* only proceed */
                        }
-                       sprintf(cs->info, "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n",
-                               cs->akt_state,
-                               cs->divert_id,
-                               divert_if.drv_to_name(cs->ics.driver),
-                               (ic->command == ISDN_STAT_ICALLW) ? "1" : "0",
-                               cs->ics.parm.setup.phone,
-                               cs->ics.parm.setup.eazmsn,
-                               cs->ics.parm.setup.si1,
-                               cs->ics.parm.setup.si2,
-                               cs->ics.parm.setup.screen,
-                               dv->rule.waittime,
-                               cs->deflect_dest);
+                       snprintf(cs->info, sizeof(cs->info),
+                                "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n",
+                                cs->akt_state,
+                                cs->divert_id,
+                                divert_if.drv_to_name(cs->ics.driver),
+                                (ic->command == ISDN_STAT_ICALLW) ? "1" : "0",
+                                cs->ics.parm.setup.phone,
+                                cs->ics.parm.setup.eazmsn,
+                                cs->ics.parm.setup.si1,
+                                cs->ics.parm.setup.si2,
+                                cs->ics.parm.setup.screen,
+                                dv->rule.waittime,
+                                cs->deflect_dest);
                        if ((dv->rule.action == DEFLECT_REPORT) ||
                            (dv->rule.action == DEFLECT_REJECT)) {
                                put_info_buffer(cs->info);
index 40c7e2cf423bfeae548c484335cf9916d602fb38..034cabac699dc273d34653e73651ea3189483b62 100644 (file)
@@ -42,7 +42,7 @@ static char *revision = "$Revision: 1.1.2.2 $";
 
 static bool suppress_pollack;
 
-static struct pci_device_id c4_pci_tbl[] = {
+static const struct pci_device_id c4_pci_tbl[] = {
        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C4, 0, 0, (unsigned long)4 },
        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C2, 0, 0, (unsigned long)2 },
        { }                     /* Terminating entry */
index 8b7ad4f1ab0160aec609cdfb587b73c03d7c2b12..b2023e08dcd28b3c85783b7df51a3e3b35c0e2eb 100644 (file)
@@ -110,7 +110,7 @@ typedef struct _diva_os_thread_dpc {
 /*
   This table should be sorted by PCI device ID
 */
-static struct pci_device_id divas_pci_tbl[] = {
+static const struct pci_device_id divas_pci_tbl[] = {
        /* Diva Server BRI-2M PCI 0xE010 */
        { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRA),
          CARDTYPE_MAESTRA_PCI },
index e3fa1cd64470ce48ba32ab797f4f063c62293f4b..dce6632daae1c4b5a0f43be11d80b99d995c5011 100644 (file)
@@ -1142,7 +1142,7 @@ fritz_remove_pci(struct pci_dev *pdev)
                        pr_info("%s: drvdata already removed\n", __func__);
 }
 
-static struct pci_device_id fcpci_ids[] = {
+static const struct pci_device_id fcpci_ids[] = {
        { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID,
          0, 0, (unsigned long) "Fritz!Card PCI"},
        { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID,
index aea0c9616ea51cfac248e50958ac838fcf72f5a9..3cf07b8ced1c067c43c3aeae463e306ae1b22c99 100644 (file)
@@ -5348,7 +5348,7 @@ static const struct hm_map hfcm_map[] = {
 
 #undef H
 #define H(x)   ((unsigned long)&hfcm_map[x])
-static struct pci_device_id hfmultipci_ids[] = {
+static const struct pci_device_id hfmultipci_ids[] = {
 
        /* Cards with HFC-4S Chip */
        { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
index 5dc246d71c167d5a69f449603cbd4a329a85fa9c..d2e401a8090e3dfde6969262a50a55fa0b1b7a9c 100644 (file)
@@ -2161,7 +2161,7 @@ static const struct _hfc_map hfc_map[] =
        {},
 };
 
-static struct pci_device_id hfc_ids[] =
+static const struct pci_device_id hfc_ids[] =
 {
        { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_2BD0),
          (unsigned long) &hfc_map[0] },
index afde4edef9ae895fa009fb5ad7305cc13af2c22e..6a6d848bd18eefc1d7400a49f64c02960a6b4592 100644 (file)
@@ -1137,7 +1137,7 @@ static void nj_remove(struct pci_dev *pdev)
 /* We cannot select cards with PCI_SUB... IDs, since here are cards with
  * SUB IDs set to PCI_ANY_ID, so we need to match all and reject
  * known other cards which not work with this driver - see probe function */
-static struct pci_device_id nj_pci_ids[] = {
+static const struct pci_device_id nj_pci_ids[] = {
        { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        { }
index 3052c836b89f70bc441520e439635a6e91dd2248..d80072fef43415f2812169b2111391b3a6b5281e 100644 (file)
@@ -1398,7 +1398,7 @@ w6692_remove_pci(struct pci_dev *pdev)
                        pr_notice("%s: drvdata already removed\n", __func__);
 }
 
-static struct pci_device_id w6692_ids[] = {
+static const struct pci_device_id w6692_ids[] = {
        { PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, (ulong)&w6692_map[0]},
        { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,
index c7d68675b02874e3661af07d1b8ad22ae8bcb887..7108bdb8742e7a41b5aac61ada26ad212211fe67 100644 (file)
@@ -1909,7 +1909,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
 #ifdef CONFIG_PCI
 #include <linux/pci.h>
 
-static struct pci_device_id hisax_pci_tbl[] __used = {
+static const struct pci_device_id hisax_pci_tbl[] __used = {
 #ifdef CONFIG_HISAX_FRITZPCI
        {PCI_VDEVICE(AVM,      PCI_DEVICE_ID_AVM_A1)                    },
 #endif
index 90f051ce02590f3e70ee2e1227d7aa507441a24c..9090cc1e1f299a8b3a3296fa088b2f2cf33ef342 100644 (file)
@@ -86,7 +86,7 @@ typedef struct {
        char *device_name;
 } hfc4s8s_param;
 
-static struct pci_device_id hfc4s8s_ids[] = {
+static const struct pci_device_id hfc4s8s_ids[] = {
        {.vendor = PCI_VENDOR_ID_CCD,
         .device = PCI_DEVICE_ID_4S,
         .subvendor = 0x1397,
index 5a9f39ed1d5d97da6427e327786053f6f9ab5ecd..e4f7573ba9bf6777c5fcd8548e1fbdb298f3a499 100644 (file)
@@ -52,7 +52,7 @@ module_param(debug, int, 0);
 MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>");
 MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver");
 
-static struct pci_device_id fcpci_ids[] = {
+static const struct pci_device_id fcpci_ids[] = {
        { .vendor      = PCI_VENDOR_ID_AVM,
          .device      = PCI_DEVICE_ID_AVM_A1,
          .subvendor   = PCI_ANY_ID,
index 14ff622190a5b90c827c1be8a0bd9ca54821ec4f..181839d6fbea44a8b6962f94703e4293645cc21c 100644 (file)
@@ -4596,7 +4596,7 @@ static int bond_check_params(struct bond_params *params)
        }
        ad_user_port_key = valptr->value;
 
-       if (bond_mode == BOND_MODE_TLB) {
+       if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) {
                bond_opt_initstr(&newval, "default");
                valptr = bond_opt_parse(bond_opt_get(BOND_OPT_TLB_DYNAMIC_LB),
                                        &newval);
index e68d368e20ac84b636c9d62958c084ad80371787..7f36d3e3c98bc6727e765fef9fbc56bc8e695240 100644 (file)
@@ -1665,6 +1665,7 @@ static const struct b53_chip_data b53_switch_chips[] = {
                .dev_name = "BCM53125",
                .vlans = 4096,
                .enabled_ports = 0xff,
+               .arl_entries = 4,
                .cpu_port = B53_CPU_PORT,
                .vta_regs = B53_VTA_REGS,
                .duplex_reg = B53_DUPLEX_STAT_GE,
index 53b088166c28388d700e80a81df10d828f1edc90..5bcdd33101b00d0b492f87b2a3dc3e67bcf14f09 100644 (file)
@@ -3178,6 +3178,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
        .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
        .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
        .port_pause_limit = mv88e6390_port_pause_limit,
+       .port_set_cmode = mv88e6390x_port_set_cmode,
        .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
        .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
        .stats_snapshot = mv88e6390_g1_stats_snapshot,
index d3906f6b01bd1f7e34f3182ebc14c9bdbbe672b7..86058a9f3417bc59613cb9c019638dc8a85a9731 100644 (file)
@@ -1785,16 +1785,18 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
 
        xgene_enet_gpiod_get(pdata);
 
-       pdata->clk = devm_clk_get(&pdev->dev, NULL);
-       if (IS_ERR(pdata->clk)) {
-               /* Abort if the clock is defined but couldn't be retrived.
-                * Always abort if the clock is missing on DT system as
-                * the driver can't cope with this case.
-                */
-               if (PTR_ERR(pdata->clk) != -ENOENT || dev->of_node)
-                       return PTR_ERR(pdata->clk);
-               /* Firmware may have set up the clock already. */
-               dev_info(dev, "clocks have been setup already\n");
+       if (pdata->phy_mode != PHY_INTERFACE_MODE_SGMII) {
+               pdata->clk = devm_clk_get(&pdev->dev, NULL);
+               if (IS_ERR(pdata->clk)) {
+                       /* Abort if the clock is defined but couldn't be
+                        * retrived. Always abort if the clock is missing on
+                        * DT system as the driver can't cope with this case.
+                        */
+                       if (PTR_ERR(pdata->clk) != -ENOENT || dev->of_node)
+                               return PTR_ERR(pdata->clk);
+                       /* Firmware may have set up the clock already. */
+                       dev_info(dev, "clocks have been setup already\n");
+               }
        }
 
        if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
index 73aca97a96bc70fb1e79f04ec2585589d0616cc5..d937083db9a4af74455156f389b50aee0b0fdf04 100644 (file)
@@ -50,11 +50,14 @@ static u32 platform_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
 
 static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
 {
-       return writel(value, bgmac->plat.idm_base + offset);
+       writel(value, bgmac->plat.idm_base + offset);
 }
 
 static bool platform_bgmac_clk_enabled(struct bgmac *bgmac)
 {
+       if (!bgmac->plat.idm_base)
+               return true;
+
        if ((bgmac_idm_read(bgmac, BCMA_IOCTL) & BGMAC_CLK_EN) != BGMAC_CLK_EN)
                return false;
        if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
@@ -66,6 +69,9 @@ static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
 {
        u32 val;
 
+       if (!bgmac->plat.idm_base)
+               return;
+
        /* The Reset Control register only contains a single bit to show if the
         * controller is currently in reset.  Do a sanity check here, just in
         * case the bootloader happened to leave the device in reset.
@@ -180,6 +186,7 @@ static int bgmac_probe(struct platform_device *pdev)
        bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
        bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
        bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
+       bgmac->feature_flags |= BGMAC_FEAT_IDM_MASK;
 
        bgmac->dev = &pdev->dev;
        bgmac->dma_dev = &pdev->dev;
@@ -207,15 +214,13 @@ static int bgmac_probe(struct platform_device *pdev)
                return PTR_ERR(bgmac->plat.base);
 
        regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
-       if (!regs) {
-               dev_err(&pdev->dev, "Unable to obtain idm resource\n");
-               return -EINVAL;
+       if (regs) {
+               bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
+               if (IS_ERR(bgmac->plat.idm_base))
+                       return PTR_ERR(bgmac->plat.idm_base);
+               bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK;
        }
 
-       bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
-       if (IS_ERR(bgmac->plat.idm_base))
-               return PTR_ERR(bgmac->plat.idm_base);
-
        regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
        if (regs) {
                bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
index ba4d2e145bb9bb81c32ade2e3855743e493c1c59..48d672b204a4847bc113635ed9534d8a3fd53066 100644 (file)
@@ -622,9 +622,11 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
        BUILD_BUG_ON(BGMAC_MAX_TX_RINGS > ARRAY_SIZE(ring_base));
        BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
 
-       if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) {
-               dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
-               return -ENOTSUPP;
+       if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) {
+               if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) {
+                       dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
+                       return -ENOTSUPP;
+               }
        }
 
        for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) {
@@ -855,9 +857,11 @@ static void bgmac_mac_speed(struct bgmac *bgmac)
 static void bgmac_miiconfig(struct bgmac *bgmac)
 {
        if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
-               bgmac_idm_write(bgmac, BCMA_IOCTL,
-                               bgmac_idm_read(bgmac, BCMA_IOCTL) | 0x40 |
-                               BGMAC_BCMA_IOCTL_SW_CLKEN);
+               if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) {
+                       bgmac_idm_write(bgmac, BCMA_IOCTL,
+                                       bgmac_idm_read(bgmac, BCMA_IOCTL) |
+                                       0x40 | BGMAC_BCMA_IOCTL_SW_CLKEN);
+               }
                bgmac->mac_speed = SPEED_2500;
                bgmac->mac_duplex = DUPLEX_FULL;
                bgmac_mac_speed(bgmac);
@@ -874,11 +878,36 @@ static void bgmac_miiconfig(struct bgmac *bgmac)
        }
 }
 
+static void bgmac_chip_reset_idm_config(struct bgmac *bgmac)
+{
+       u32 iost;
+
+       iost = bgmac_idm_read(bgmac, BCMA_IOST);
+       if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
+               iost &= ~BGMAC_BCMA_IOST_ATTACHED;
+
+       /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
+       if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) {
+               u32 flags = 0;
+
+               if (iost & BGMAC_BCMA_IOST_ATTACHED) {
+                       flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
+                       if (!bgmac->has_robosw)
+                               flags |= BGMAC_BCMA_IOCTL_SW_RESET;
+               }
+               bgmac_clk_enable(bgmac, flags);
+       }
+
+       if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
+               bgmac_idm_write(bgmac, BCMA_IOCTL,
+                               bgmac_idm_read(bgmac, BCMA_IOCTL) &
+                               ~BGMAC_BCMA_IOCTL_SW_RESET);
+}
+
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */
 static void bgmac_chip_reset(struct bgmac *bgmac)
 {
        u32 cmdcfg_sr;
-       u32 iost;
        int i;
 
        if (bgmac_clk_enabled(bgmac)) {
@@ -899,20 +928,8 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
                /* TODO: Clear software multicast filter list */
        }
 
-       iost = bgmac_idm_read(bgmac, BCMA_IOST);
-       if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
-               iost &= ~BGMAC_BCMA_IOST_ATTACHED;
-
-       /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
-       if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) {
-               u32 flags = 0;
-               if (iost & BGMAC_BCMA_IOST_ATTACHED) {
-                       flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
-                       if (!bgmac->has_robosw)
-                               flags |= BGMAC_BCMA_IOCTL_SW_RESET;
-               }
-               bgmac_clk_enable(bgmac, flags);
-       }
+       if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK))
+               bgmac_chip_reset_idm_config(bgmac);
 
        /* Request Misc PLL for corerev > 2 */
        if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
@@ -970,11 +987,6 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
                                      BGMAC_CHIPCTL_7_IF_TYPE_RGMII);
        }
 
-       if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
-               bgmac_idm_write(bgmac, BCMA_IOCTL,
-                               bgmac_idm_read(bgmac, BCMA_IOCTL) &
-                               ~BGMAC_BCMA_IOCTL_SW_RESET);
-
        /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_reset
         * Specs don't say about using BGMAC_CMDCFG_SR, but in this routine
         * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to
@@ -1497,8 +1509,10 @@ int bgmac_enet_probe(struct bgmac *bgmac)
        bgmac_clk_enable(bgmac, 0);
 
        /* This seems to be fixing IRQ by assigning OOB #6 to the core */
-       if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
-               bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
+       if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) {
+               if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
+                       bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
+       }
 
        bgmac_chip_reset(bgmac);
 
index c1818766c501f8a33b309495b02566c2c1a1cb5e..443d57b1026417b4feccbc79f562cc5462e90652 100644 (file)
 #define BGMAC_FEAT_CC4_IF_SW_TYPE      BIT(17)
 #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII        BIT(18)
 #define BGMAC_FEAT_CC7_IF_TYPE_RGMII   BIT(19)
+#define BGMAC_FEAT_IDM_MASK            BIT(20)
 
 struct bgmac_slot_info {
        union {
index 43423744fdfa8151b2312bc84b41267965d6c92c..1e33abde4a3e8c833386df176896ad9684c9dc10 100644 (file)
@@ -2886,7 +2886,7 @@ static int bnx2x_test_nvram_tbl(struct bnx2x *bp,
 
 static int bnx2x_test_nvram(struct bnx2x *bp)
 {
-       const struct crc_pair nvram_tbl[] = {
+       static const struct crc_pair nvram_tbl[] = {
                {     0,  0x14 }, /* bootstrap */
                {  0x14,  0xec }, /* dir */
                { 0x100, 0x350 }, /* manuf_info */
@@ -2895,7 +2895,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp)
                { 0x708,  0x70 }, /* manuf_key_info */
                {     0,     0 }
        };
-       const struct crc_pair nvram_tbl2[] = {
+       static const struct crc_pair nvram_tbl2[] = {
                { 0x7e8, 0x350 }, /* manuf_info2 */
                { 0xb38,  0xf0 }, /* feature_info */
                {     0,     0 }
@@ -3162,7 +3162,8 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
                if (is_multi(bp)) {
                        for_each_eth_queue(bp, i) {
                                memset(queue_name, 0, sizeof(queue_name));
-                               sprintf(queue_name, "%d", i);
+                               snprintf(queue_name, sizeof(queue_name),
+                                        "%d", i);
                                for (j = 0; j < BNX2X_NUM_Q_STATS; j++)
                                        snprintf(buf + (k + j)*ETH_GSTRING_LEN,
                                                ETH_GSTRING_LEN,
index daca1c9d254be4b4f2b513f1754c7534c104c757..7b0b399aaedd44778b96a38fe0fc5c7659494da5 100644 (file)
@@ -1202,12 +1202,21 @@ static struct enet_cb *bcmgenet_get_txcb(struct bcmgenet_priv *priv,
        return tx_cb_ptr;
 }
 
-/* Simple helper to free a control block's resources */
-static void bcmgenet_free_cb(struct enet_cb *cb)
+static struct enet_cb *bcmgenet_put_txcb(struct bcmgenet_priv *priv,
+                                        struct bcmgenet_tx_ring *ring)
 {
-       dev_kfree_skb_any(cb->skb);
-       cb->skb = NULL;
-       dma_unmap_addr_set(cb, dma_addr, 0);
+       struct enet_cb *tx_cb_ptr;
+
+       tx_cb_ptr = ring->cbs;
+       tx_cb_ptr += ring->write_ptr - ring->cb_ptr;
+
+       /* Rewinding local write pointer */
+       if (ring->write_ptr == ring->cb_ptr)
+               ring->write_ptr = ring->end_ptr;
+       else
+               ring->write_ptr--;
+
+       return tx_cb_ptr;
 }
 
 static inline void bcmgenet_rx_ring16_int_disable(struct bcmgenet_rx_ring *ring)
@@ -1260,18 +1269,72 @@ static inline void bcmgenet_tx_ring_int_disable(struct bcmgenet_tx_ring *ring)
                                 INTRL2_CPU_MASK_SET);
 }
 
+/* Simple helper to free a transmit control block's resources
+ * Returns an skb when the last transmit control block associated with the
+ * skb is freed.  The skb should be freed by the caller if necessary.
+ */
+static struct sk_buff *bcmgenet_free_tx_cb(struct device *dev,
+                                          struct enet_cb *cb)
+{
+       struct sk_buff *skb;
+
+       skb = cb->skb;
+
+       if (skb) {
+               cb->skb = NULL;
+               if (cb == GENET_CB(skb)->first_cb)
+                       dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr),
+                                        dma_unmap_len(cb, dma_len),
+                                        DMA_TO_DEVICE);
+               else
+                       dma_unmap_page(dev, dma_unmap_addr(cb, dma_addr),
+                                      dma_unmap_len(cb, dma_len),
+                                      DMA_TO_DEVICE);
+               dma_unmap_addr_set(cb, dma_addr, 0);
+
+               if (cb == GENET_CB(skb)->last_cb)
+                       return skb;
+
+       } else if (dma_unmap_addr(cb, dma_addr)) {
+               dma_unmap_page(dev,
+                              dma_unmap_addr(cb, dma_addr),
+                              dma_unmap_len(cb, dma_len),
+                              DMA_TO_DEVICE);
+               dma_unmap_addr_set(cb, dma_addr, 0);
+       }
+
+       return 0;
+}
+
+/* Simple helper to free a receive control block's resources */
+static struct sk_buff *bcmgenet_free_rx_cb(struct device *dev,
+                                          struct enet_cb *cb)
+{
+       struct sk_buff *skb;
+
+       skb = cb->skb;
+       cb->skb = NULL;
+
+       if (dma_unmap_addr(cb, dma_addr)) {
+               dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr),
+                                dma_unmap_len(cb, dma_len), DMA_FROM_DEVICE);
+               dma_unmap_addr_set(cb, dma_addr, 0);
+       }
+
+       return skb;
+}
+
 /* Unlocked version of the reclaim routine */
 static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
                                          struct bcmgenet_tx_ring *ring)
 {
        struct bcmgenet_priv *priv = netdev_priv(dev);
-       struct device *kdev = &priv->pdev->dev;
-       struct enet_cb *tx_cb_ptr;
-       unsigned int pkts_compl = 0;
+       unsigned int txbds_processed = 0;
        unsigned int bytes_compl = 0;
-       unsigned int c_index;
+       unsigned int pkts_compl = 0;
        unsigned int txbds_ready;
-       unsigned int txbds_processed = 0;
+       unsigned int c_index;
+       struct sk_buff *skb;
 
        /* Clear status before servicing to reduce spurious interrupts */
        if (ring->index == DESC_INDEX)
@@ -1292,21 +1355,12 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
 
        /* Reclaim transmitted buffers */
        while (txbds_processed < txbds_ready) {
-               tx_cb_ptr = &priv->tx_cbs[ring->clean_ptr];
-               if (tx_cb_ptr->skb) {
+               skb = bcmgenet_free_tx_cb(&priv->pdev->dev,
+                                         &priv->tx_cbs[ring->clean_ptr]);
+               if (skb) {
                        pkts_compl++;
-                       bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent;
-                       dma_unmap_single(kdev,
-                                        dma_unmap_addr(tx_cb_ptr, dma_addr),
-                                        dma_unmap_len(tx_cb_ptr, dma_len),
-                                        DMA_TO_DEVICE);
-                       bcmgenet_free_cb(tx_cb_ptr);
-               } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
-                       dma_unmap_page(kdev,
-                                      dma_unmap_addr(tx_cb_ptr, dma_addr),
-                                      dma_unmap_len(tx_cb_ptr, dma_len),
-                                      DMA_TO_DEVICE);
-                       dma_unmap_addr_set(tx_cb_ptr, dma_addr, 0);
+                       bytes_compl += GENET_CB(skb)->bytes_sent;
+                       dev_kfree_skb_any(skb);
                }
 
                txbds_processed++;
@@ -1380,95 +1434,6 @@ static void bcmgenet_tx_reclaim_all(struct net_device *dev)
        bcmgenet_tx_reclaim(dev, &priv->tx_rings[DESC_INDEX]);
 }
 
-/* Transmits a single SKB (either head of a fragment or a single SKB)
- * caller must hold priv->lock
- */
-static int bcmgenet_xmit_single(struct net_device *dev,
-                               struct sk_buff *skb,
-                               u16 dma_desc_flags,
-                               struct bcmgenet_tx_ring *ring)
-{
-       struct bcmgenet_priv *priv = netdev_priv(dev);
-       struct device *kdev = &priv->pdev->dev;
-       struct enet_cb *tx_cb_ptr;
-       unsigned int skb_len;
-       dma_addr_t mapping;
-       u32 length_status;
-       int ret;
-
-       tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
-
-       if (unlikely(!tx_cb_ptr))
-               BUG();
-
-       tx_cb_ptr->skb = skb;
-
-       skb_len = skb_headlen(skb);
-
-       mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
-       ret = dma_mapping_error(kdev, mapping);
-       if (ret) {
-               priv->mib.tx_dma_failed++;
-               netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
-               dev_kfree_skb(skb);
-               return ret;
-       }
-
-       dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
-       dma_unmap_len_set(tx_cb_ptr, dma_len, skb_len);
-       length_status = (skb_len << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
-                       (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT) |
-                       DMA_TX_APPEND_CRC;
-
-       if (skb->ip_summed == CHECKSUM_PARTIAL)
-               length_status |= DMA_TX_DO_CSUM;
-
-       dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status);
-
-       return 0;
-}
-
-/* Transmit a SKB fragment */
-static int bcmgenet_xmit_frag(struct net_device *dev,
-                             skb_frag_t *frag,
-                             u16 dma_desc_flags,
-                             struct bcmgenet_tx_ring *ring)
-{
-       struct bcmgenet_priv *priv = netdev_priv(dev);
-       struct device *kdev = &priv->pdev->dev;
-       struct enet_cb *tx_cb_ptr;
-       unsigned int frag_size;
-       dma_addr_t mapping;
-       int ret;
-
-       tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
-
-       if (unlikely(!tx_cb_ptr))
-               BUG();
-
-       tx_cb_ptr->skb = NULL;
-
-       frag_size = skb_frag_size(frag);
-
-       mapping = skb_frag_dma_map(kdev, frag, 0, frag_size, DMA_TO_DEVICE);
-       ret = dma_mapping_error(kdev, mapping);
-       if (ret) {
-               priv->mib.tx_dma_failed++;
-               netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n",
-                         __func__);
-               return ret;
-       }
-
-       dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
-       dma_unmap_len_set(tx_cb_ptr, dma_len, frag_size);
-
-       dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping,
-                   (frag_size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
-                   (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT));
-
-       return 0;
-}
-
 /* Reallocate the SKB to put enough headroom in front of it and insert
  * the transmit checksum offsets in the descriptors
  */
@@ -1535,11 +1500,16 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev,
 static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct bcmgenet_priv *priv = netdev_priv(dev);
+       struct device *kdev = &priv->pdev->dev;
        struct bcmgenet_tx_ring *ring = NULL;
+       struct enet_cb *tx_cb_ptr;
        struct netdev_queue *txq;
        unsigned long flags = 0;
        int nr_frags, index;
-       u16 dma_desc_flags;
+       dma_addr_t mapping;
+       unsigned int size;
+       skb_frag_t *frag;
+       u32 len_stat;
        int ret;
        int i;
 
@@ -1592,29 +1562,53 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
                }
        }
 
-       dma_desc_flags = DMA_SOP;
-       if (nr_frags == 0)
-               dma_desc_flags |= DMA_EOP;
+       for (i = 0; i <= nr_frags; i++) {
+               tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
 
-       /* Transmit single SKB or head of fragment list */
-       ret = bcmgenet_xmit_single(dev, skb, dma_desc_flags, ring);
-       if (ret) {
-               ret = NETDEV_TX_OK;
-               goto out;
-       }
+               if (unlikely(!tx_cb_ptr))
+                       BUG();
+
+               if (!i) {
+                       /* Transmit single SKB or head of fragment list */
+                       GENET_CB(skb)->first_cb = tx_cb_ptr;
+                       size = skb_headlen(skb);
+                       mapping = dma_map_single(kdev, skb->data, size,
+                                                DMA_TO_DEVICE);
+               } else {
+                       /* xmit fragment */
+                       frag = &skb_shinfo(skb)->frags[i - 1];
+                       size = skb_frag_size(frag);
+                       mapping = skb_frag_dma_map(kdev, frag, 0, size,
+                                                  DMA_TO_DEVICE);
+               }
 
-       /* xmit fragment */
-       for (i = 0; i < nr_frags; i++) {
-               ret = bcmgenet_xmit_frag(dev,
-                                        &skb_shinfo(skb)->frags[i],
-                                        (i == nr_frags - 1) ? DMA_EOP : 0,
-                                        ring);
+               ret = dma_mapping_error(kdev, mapping);
                if (ret) {
+                       priv->mib.tx_dma_failed++;
+                       netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
                        ret = NETDEV_TX_OK;
-                       goto out;
+                       goto out_unmap_frags;
+               }
+               dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
+               dma_unmap_len_set(tx_cb_ptr, dma_len, size);
+
+               tx_cb_ptr->skb = skb;
+
+               len_stat = (size << DMA_BUFLENGTH_SHIFT) |
+                          (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT);
+
+               if (!i) {
+                       len_stat |= DMA_TX_APPEND_CRC | DMA_SOP;
+                       if (skb->ip_summed == CHECKSUM_PARTIAL)
+                               len_stat |= DMA_TX_DO_CSUM;
                }
+               if (i == nr_frags)
+                       len_stat |= DMA_EOP;
+
+               dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, len_stat);
        }
 
+       GENET_CB(skb)->last_cb = tx_cb_ptr;
        skb_tx_timestamp(skb);
 
        /* Decrement total BD count and advance our write pointer */
@@ -1635,6 +1629,19 @@ out:
        spin_unlock_irqrestore(&ring->lock, flags);
 
        return ret;
+
+out_unmap_frags:
+       /* Back up for failed control block mapping */
+       bcmgenet_put_txcb(priv, ring);
+
+       /* Unmap successfully mapped control blocks */
+       while (i-- > 0) {
+               tx_cb_ptr = bcmgenet_put_txcb(priv, ring);
+               bcmgenet_free_tx_cb(kdev, tx_cb_ptr);
+       }
+
+       dev_kfree_skb(skb);
+       goto out;
 }
 
 static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv,
@@ -1666,14 +1673,12 @@ static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv,
        }
 
        /* Grab the current Rx skb from the ring and DMA-unmap it */
-       rx_skb = cb->skb;
-       if (likely(rx_skb))
-               dma_unmap_single(kdev, dma_unmap_addr(cb, dma_addr),
-                                priv->rx_buf_len, DMA_FROM_DEVICE);
+       rx_skb = bcmgenet_free_rx_cb(kdev, cb);
 
        /* Put the new Rx skb on the ring */
        cb->skb = skb;
        dma_unmap_addr_set(cb, dma_addr, mapping);
+       dma_unmap_len_set(cb, dma_len, priv->rx_buf_len);
        dmadesc_set_addr(priv, cb->bd_addr, mapping);
 
        /* Return the current Rx skb to caller */
@@ -1880,22 +1885,16 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv,
 
 static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
 {
-       struct device *kdev = &priv->pdev->dev;
+       struct sk_buff *skb;
        struct enet_cb *cb;
        int i;
 
        for (i = 0; i < priv->num_rx_bds; i++) {
                cb = &priv->rx_cbs[i];
 
-               if (dma_unmap_addr(cb, dma_addr)) {
-                       dma_unmap_single(kdev,
-                                        dma_unmap_addr(cb, dma_addr),
-                                        priv->rx_buf_len, DMA_FROM_DEVICE);
-                       dma_unmap_addr_set(cb, dma_addr, 0);
-               }
-
-               if (cb->skb)
-                       bcmgenet_free_cb(cb);
+               skb = bcmgenet_free_rx_cb(&priv->pdev->dev, cb);
+               if (skb)
+                       dev_kfree_skb_any(skb);
        }
 }
 
@@ -2479,8 +2478,10 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
 
 static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
 {
-       int i;
        struct netdev_queue *txq;
+       struct sk_buff *skb;
+       struct enet_cb *cb;
+       int i;
 
        bcmgenet_fini_rx_napi(priv);
        bcmgenet_fini_tx_napi(priv);
@@ -2489,10 +2490,10 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
        bcmgenet_dma_teardown(priv);
 
        for (i = 0; i < priv->num_tx_bds; i++) {
-               if (priv->tx_cbs[i].skb != NULL) {
-                       dev_kfree_skb(priv->tx_cbs[i].skb);
-                       priv->tx_cbs[i].skb = NULL;
-               }
+               cb = priv->tx_cbs + i;
+               skb = bcmgenet_free_tx_cb(&priv->pdev->dev, cb);
+               if (skb)
+                       dev_kfree_skb(skb);
        }
 
        for (i = 0; i < priv->hw_params->tx_queues; i++) {
index efd07020b89fc3a7bd3c68fce1bbd7fe406acfcf..b9344de669f84d2d1fa8e983c704b97ba09c7195 100644 (file)
@@ -544,6 +544,8 @@ struct bcmgenet_hw_params {
 };
 
 struct bcmgenet_skb_cb {
+       struct enet_cb *first_cb;       /* First control block of SKB */
+       struct enet_cb *last_cb;        /* Last control block of SKB */
        unsigned int bytes_sent;        /* bytes on the wire (no TSB) */
 };
 
index 28ecda3d34049342b6e58c108dd22679cb4ad8cc..ebd353bc78ffa1ea6ed3673d95b0cf365d8eb054 100644 (file)
@@ -335,7 +335,7 @@ lio_ethtool_get_channels(struct net_device *dev,
 
 static int lio_get_eeprom_len(struct net_device *netdev)
 {
-       u8 buf[128];
+       u8 buf[192];
        struct lio *lio = GET_LIO(netdev);
        struct octeon_device *oct_dev = lio->oct_dev;
        struct octeon_board_info *board_info;
index a0ca68ce3fbb164ea6e6a2c75a36a8c1ae54172d..79112563a25ae08db35bfb2de214c2b3e84a15a6 100644 (file)
@@ -1008,7 +1008,7 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid)
 {
        struct device *dev = &bgx->pdev->dev;
        struct lmac *lmac;
-       char str[20];
+       char str[27];
 
        if (!bgx->is_dlm && lmacid)
                return;
index 50517cfd9671574c630b676ecec2892eb304b4d9..9f9d6cae39d555057ba63ac6ee874d0884c0c51d 100644 (file)
@@ -441,7 +441,8 @@ void cxgb4_ptp_init(struct adapter *adapter)
 
        adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info,
                                                &adapter->pdev->dev);
-       if (!adapter->ptp_clock) {
+       if (IS_ERR_OR_NULL(adapter->ptp_clock)) {
+               adapter->ptp_clock = NULL;
                dev_err(adapter->pdev_dev,
                        "PTP %s Clock registration has failed\n", __func__);
                return;
index 99987d8e437e2a09c3ddccffae916dd2804a0020..aa28299aef5f64d222f087f33965cf7ce8ffa008 100644 (file)
@@ -174,6 +174,8 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
        CH_PCI_ID_TABLE_FENTRY(0x50a0), /* Custom T540-CR */
        CH_PCI_ID_TABLE_FENTRY(0x50a1), /* Custom T540-CR */
        CH_PCI_ID_TABLE_FENTRY(0x50a2), /* Custom T540-KR4 */
+       CH_PCI_ID_TABLE_FENTRY(0x50a3), /* Custom T580-KR4 */
+       CH_PCI_ID_TABLE_FENTRY(0x50a4), /* Custom 2x T540-CR */
 
        /* T6 adapters:
         */
index ff864a187d5a71fa277f2907659621b9f87ffdcf..a37166ee577b71f4fc2ea07e82d1097c19b4bf66 100644 (file)
@@ -776,8 +776,9 @@ void hns_ae_update_led_status(struct hnae_handle *handle)
 
        assert(handle);
        mac_cb = hns_get_mac_cb(handle);
-       if (!mac_cb->cpld_ctrl)
+       if (mac_cb->media_type != HNAE_MEDIA_TYPE_FIBER)
                return;
+
        hns_set_led_opt(mac_cb);
 }
 
index 7a8addda726e3937d3d8813c08e7555a2b9bb278..408b63faf9a81ac9d4bb3e78af3fbfdeb4dbc407 100644 (file)
@@ -53,6 +53,34 @@ static u32 dsaf_read_sub(struct dsaf_device *dsaf_dev, u32 reg)
        return ret;
 }
 
+static void hns_dsaf_acpi_ledctrl_by_port(struct hns_mac_cb *mac_cb, u8 op_type,
+                                      u32 link, u32 port, u32 act)
+{
+       union acpi_object *obj;
+       union acpi_object obj_args[3], argv4;
+
+       obj_args[0].integer.type = ACPI_TYPE_INTEGER;
+       obj_args[0].integer.value = link;
+       obj_args[1].integer.type = ACPI_TYPE_INTEGER;
+       obj_args[1].integer.value = port;
+       obj_args[2].integer.type = ACPI_TYPE_INTEGER;
+       obj_args[2].integer.value = act;
+
+       argv4.type = ACPI_TYPE_PACKAGE;
+       argv4.package.count = 3;
+       argv4.package.elements = obj_args;
+
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev),
+                               &hns_dsaf_acpi_dsm_guid, 0, op_type, &argv4);
+       if (!obj) {
+               dev_warn(mac_cb->dev, "ledctrl fail, link:%d port:%d act:%d!\n",
+                        link, port, act);
+               return;
+       }
+
+       ACPI_FREE(obj);
+}
+
 static void hns_cpld_set_led(struct hns_mac_cb *mac_cb, int link_status,
                             u16 speed, int data)
 {
@@ -93,6 +121,18 @@ static void hns_cpld_set_led(struct hns_mac_cb *mac_cb, int link_status,
        }
 }
 
+static void hns_cpld_set_led_acpi(struct hns_mac_cb *mac_cb, int link_status,
+                            u16 speed, int data)
+{
+       if (!mac_cb) {
+               pr_err("cpld_led_set mac_cb is null!\n");
+               return;
+       }
+
+       hns_dsaf_acpi_ledctrl_by_port(mac_cb, HNS_OP_LED_SET_FUNC,
+               link_status, mac_cb->mac_id, data);
+}
+
 static void cpld_led_reset(struct hns_mac_cb *mac_cb)
 {
        if (!mac_cb || !mac_cb->cpld_ctrl)
@@ -103,6 +143,20 @@ static void cpld_led_reset(struct hns_mac_cb *mac_cb)
        mac_cb->cpld_led_value = CPLD_LED_DEFAULT_VALUE;
 }
 
+static void cpld_led_reset_acpi(struct hns_mac_cb *mac_cb)
+{
+       if (!mac_cb) {
+               pr_err("cpld_led_reset mac_cb is null!\n");
+               return;
+       }
+
+       if (mac_cb->media_type != HNAE_MEDIA_TYPE_FIBER)
+                return;
+
+       hns_dsaf_acpi_ledctrl_by_port(mac_cb, HNS_OP_LED_SET_FUNC,
+               0, mac_cb->mac_id, 0);
+}
+
 static int cpld_set_led_id(struct hns_mac_cb *mac_cb,
                           enum hnae_led_state status)
 {
@@ -604,8 +658,8 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev)
 
                misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback;
        } else if (is_acpi_node(dsaf_dev->dev->fwnode)) {
-               misc_op->cpld_set_led = hns_cpld_set_led;
-               misc_op->cpld_reset_led = cpld_led_reset;
+               misc_op->cpld_set_led = hns_cpld_set_led_acpi;
+               misc_op->cpld_reset_led = cpld_led_reset_acpi;
                misc_op->cpld_set_led_id = cpld_set_led_id;
 
                misc_op->dsaf_reset = hns_dsaf_rst_acpi;
index d94b3744a5b915c5c972a9ac4ab649f0b00fe9ab..b651c1210555bfe02ec7393486dff9291651afb8 100644 (file)
@@ -283,7 +283,7 @@ int mlx4_zone_add_one(struct mlx4_zone_allocator *zone_alloc,
 }
 
 /* Should be called under a lock */
-static int __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry)
+static void __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry)
 {
        struct mlx4_zone_allocator *zone_alloc = entry->allocator;
 
@@ -315,8 +315,6 @@ static int __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry)
                }
                zone_alloc->mask = mask;
        }
-
-       return 0;
 }
 
 void mlx4_zone_allocator_destroy(struct mlx4_zone_allocator *zone_alloc)
@@ -457,7 +455,7 @@ struct mlx4_bitmap *mlx4_zone_get_bitmap(struct mlx4_zone_allocator *zones, u32
 int mlx4_zone_remove_one(struct mlx4_zone_allocator *zones, u32 uid)
 {
        struct mlx4_zone_entry *zone;
-       int res;
+       int res = 0;
 
        spin_lock(&zones->lock);
 
@@ -468,7 +466,7 @@ int mlx4_zone_remove_one(struct mlx4_zone_allocator *zones, u32 uid)
                goto out;
        }
 
-       res = __mlx4_zone_remove_one_entry(zone);
+       __mlx4_zone_remove_one_entry(zone);
 
 out:
        spin_unlock(&zones->lock);
index 746d94e28470f74a1b0e546fbce0eac6b344a281..60850bfa3d32e5d574bddacda871cb75da2076fd 100644 (file)
@@ -766,11 +766,13 @@ static void emac_shutdown(struct platform_device *pdev)
        struct emac_adapter *adpt = netdev_priv(netdev);
        struct emac_sgmii *sgmii = &adpt->phy;
 
-       /* Closing the SGMII turns off its interrupts */
-       sgmii->close(adpt);
+       if (netdev->flags & IFF_UP) {
+               /* Closing the SGMII turns off its interrupts */
+               sgmii->close(adpt);
 
-       /* Resetting the MAC turns off all DMA and its interrupts */
-       emac_mac_reset(adpt);
+               /* Resetting the MAC turns off all DMA and its interrupts */
+               emac_mac_reset(adpt);
+       }
 }
 
 static struct platform_driver emac_platform_driver = {
index b607936e1b3ec4ae93225106ac0eb53e15c892a6..9c0488e0f08ec2af6e075acd696c54900a648325 100644 (file)
@@ -90,17 +90,13 @@ struct ioc3_private {
        spinlock_t ioc3_lock;
        struct mii_if_info mii;
 
+       struct net_device *dev;
        struct pci_dev *pdev;
 
        /* Members used by autonegotiation  */
        struct timer_list ioc3_timer;
 };
 
-static inline struct net_device *priv_netdev(struct ioc3_private *dev)
-{
-       return (void *)dev - ((sizeof(struct net_device) + 31) & ~31);
-}
-
 static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void ioc3_set_multicast_list(struct net_device *dev);
 static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -427,7 +423,7 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
                nic[i] = nic_read_byte(ioc3);
 
        for (i = 2; i < 8; i++)
-               priv_netdev(ip)->dev_addr[i - 2] = nic[i];
+               ip->dev->dev_addr[i - 2] = nic[i];
 }
 
 /*
@@ -439,7 +435,7 @@ static void ioc3_get_eaddr(struct ioc3_private *ip)
 {
        ioc3_get_eaddr_nic(ip);
 
-       printk("Ethernet address is %pM.\n", priv_netdev(ip)->dev_addr);
+       printk("Ethernet address is %pM.\n", ip->dev->dev_addr);
 }
 
 static void __ioc3_set_mac_address(struct net_device *dev)
@@ -790,13 +786,12 @@ static void ioc3_timer(unsigned long data)
  */
 static int ioc3_mii_init(struct ioc3_private *ip)
 {
-       struct net_device *dev = priv_netdev(ip);
        int i, found = 0, res = 0;
        int ioc3_phy_workaround = 1;
        u16 word;
 
        for (i = 0; i < 32; i++) {
-               word = ioc3_mdio_read(dev, i, MII_PHYSID1);
+               word = ioc3_mdio_read(ip->dev, i, MII_PHYSID1);
 
                if (word != 0xffff && word != 0x0000) {
                        found = 1;
@@ -1276,6 +1271,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        ip = netdev_priv(dev);
+       ip->dev = dev;
 
        dev->irq = pdev->irq;
 
index f233bf8b4ebb844d9b27ca8cf01947f066e5ba03..c4407e8e39a35a523bda481a9cc1787ab24bc608 100644 (file)
@@ -117,7 +117,7 @@ static void dwmac4_tx_queue_routing(struct mac_device_info *hw,
        void __iomem *ioaddr = hw->pcsr;
        u32 value;
 
-       const struct stmmac_rx_routing route_possibilities[] = {
+       static const struct stmmac_rx_routing route_possibilities[] = {
                { GMAC_RXQCTRL_AVCPQ_MASK, GMAC_RXQCTRL_AVCPQ_SHIFT },
                { GMAC_RXQCTRL_PTPQ_MASK, GMAC_RXQCTRL_PTPQ_SHIFT },
                { GMAC_RXQCTRL_DCBCPQ_MASK, GMAC_RXQCTRL_DCBCPQ_SHIFT },
index 1853f7ff6657562cc95e78bdf7954aa8203a7ccd..1763e48c84e2090678f4ffc1b55cf1d7a62382e4 100644 (file)
@@ -4120,8 +4120,15 @@ int stmmac_dvr_probe(struct device *device,
        if ((phyaddr >= 0) && (phyaddr <= 31))
                priv->plat->phy_addr = phyaddr;
 
-       if (priv->plat->stmmac_rst)
+       if (priv->plat->stmmac_rst) {
+               ret = reset_control_assert(priv->plat->stmmac_rst);
                reset_control_deassert(priv->plat->stmmac_rst);
+               /* Some reset controllers have only reset callback instead of
+                * assert + deassert callbacks pair.
+                */
+               if (ret == -ENOTSUPP)
+                       reset_control_reset(priv->plat->stmmac_rst);
+       }
 
        /* Init MAC and get the capabilities */
        ret = stmmac_hw_init(priv);
index 46cb7f8955a22ebf9143f18f993e2bdfd2aaf752..4bb04aaf9650e3c1973dcd85eea57239477b419d 100644 (file)
@@ -9532,7 +9532,7 @@ static struct niu_parent *niu_get_parent(struct niu *np,
                p = niu_new_parent(np, id, ptype);
 
        if (p) {
-               char port_name[6];
+               char port_name[8];
                int err;
 
                sprintf(port_name, "port%d", port);
@@ -9553,7 +9553,7 @@ static void niu_put_parent(struct niu *np)
 {
        struct niu_parent *p = np->parent;
        u8 port = np->port;
-       char port_name[6];
+       char port_name[8];
 
        BUG_ON(!p || p->ports[port] != np);
 
index 711fbbbc4b1f724fcebdaec80eda2eec1eef8551..163d8d16bc245b48a10390d7706b21fd603489a4 100644 (file)
@@ -654,6 +654,8 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
                        RET(-EFAULT);
                }
                DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]);
+       } else {
+               return -EOPNOTSUPP;
        }
 
        if (!capable(CAP_SYS_RAWIO))
index 1850e348f5555b67f253c7a8fc9cb927d9694f16..badd0a8caeb9e85d26a16d48b0eb892123276aaf 100644 (file)
@@ -3089,6 +3089,31 @@ static int cpsw_probe(struct platform_device *pdev)
                        cpsw->quirk_irq = true;
        }
 
+       ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
+
+       ndev->netdev_ops = &cpsw_netdev_ops;
+       ndev->ethtool_ops = &cpsw_ethtool_ops;
+       netif_napi_add(ndev, &cpsw->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT);
+       netif_tx_napi_add(ndev, &cpsw->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT);
+       cpsw_split_res(ndev);
+
+       /* register the network device */
+       SET_NETDEV_DEV(ndev, &pdev->dev);
+       ret = register_netdev(ndev);
+       if (ret) {
+               dev_err(priv->dev, "error registering net device\n");
+               ret = -ENODEV;
+               goto clean_ale_ret;
+       }
+
+       if (cpsw->data.dual_emac) {
+               ret = cpsw_probe_dual_emac(priv);
+               if (ret) {
+                       cpsw_err(priv, probe, "error probe slave 2 emac interface\n");
+                       goto clean_unregister_netdev_ret;
+               }
+       }
+
        /* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and
         * MISC IRQs which are always kept disabled with this driver so
         * we will not request them.
@@ -3127,33 +3152,9 @@ static int cpsw_probe(struct platform_device *pdev)
                goto clean_ale_ret;
        }
 
-       ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
-
-       ndev->netdev_ops = &cpsw_netdev_ops;
-       ndev->ethtool_ops = &cpsw_ethtool_ops;
-       netif_napi_add(ndev, &cpsw->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT);
-       netif_tx_napi_add(ndev, &cpsw->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT);
-       cpsw_split_res(ndev);
-
-       /* register the network device */
-       SET_NETDEV_DEV(ndev, &pdev->dev);
-       ret = register_netdev(ndev);
-       if (ret) {
-               dev_err(priv->dev, "error registering net device\n");
-               ret = -ENODEV;
-               goto clean_ale_ret;
-       }
-
        cpsw_notice(priv, probe,
                    "initialized device (regs %pa, irq %d, pool size %d)\n",
                    &ss_res->start, ndev->irq, dma_params.descs_pool_size);
-       if (cpsw->data.dual_emac) {
-               ret = cpsw_probe_dual_emac(priv);
-               if (ret) {
-                       cpsw_err(priv, probe, "error probe slave 2 emac interface\n");
-                       goto clean_unregister_netdev_ret;
-               }
-       }
 
        pm_runtime_put(&pdev->dev);
 
index 00755b6a42cf1960e0a60bc95b72685afaee987e..c608e1dfaf09745a5ba25aabfbcf7d8c20819e23 100644 (file)
@@ -135,8 +135,8 @@ int mdio_mux_init(struct device *dev,
        for_each_available_child_of_node(dev->of_node, child_bus_node) {
                int v;
 
-               v = of_mdio_parse_addr(dev, child_bus_node);
-               if (v < 0) {
+               r = of_property_read_u32(child_bus_node, "reg", &v);
+               if (r) {
                        dev_err(dev,
                                "Error: Failed to find reg for child %s\n",
                                of_node_full_name(child_bus_node));
index 13028833bee39e26641976dacb879b8ddf34c7a8..bd4303944e4405d543a399f6fc529df9ffd41e02 100644 (file)
@@ -120,6 +120,7 @@ struct ppp {
        int             n_channels;     /* how many channels are attached 54 */
        spinlock_t      rlock;          /* lock for receive side 58 */
        spinlock_t      wlock;          /* lock for transmit side 5c */
+       int             *xmit_recursion __percpu; /* xmit recursion detect */
        int             mru;            /* max receive unit 60 */
        unsigned int    flags;          /* control bits 64 */
        unsigned int    xstate;         /* transmit state bits 68 */
@@ -1025,6 +1026,7 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev,
        struct ppp *ppp = netdev_priv(dev);
        int indx;
        int err;
+       int cpu;
 
        ppp->dev = dev;
        ppp->ppp_net = src_net;
@@ -1039,6 +1041,15 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev,
        INIT_LIST_HEAD(&ppp->channels);
        spin_lock_init(&ppp->rlock);
        spin_lock_init(&ppp->wlock);
+
+       ppp->xmit_recursion = alloc_percpu(int);
+       if (!ppp->xmit_recursion) {
+               err = -ENOMEM;
+               goto err1;
+       }
+       for_each_possible_cpu(cpu)
+               (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0;
+
 #ifdef CONFIG_PPP_MULTILINK
        ppp->minseq = -1;
        skb_queue_head_init(&ppp->mrq);
@@ -1050,11 +1061,15 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev,
 
        err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set);
        if (err < 0)
-               return err;
+               goto err2;
 
        conf->file->private_data = &ppp->file;
 
        return 0;
+err2:
+       free_percpu(ppp->xmit_recursion);
+err1:
+       return err;
 }
 
 static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = {
@@ -1400,18 +1415,16 @@ static void __ppp_xmit_process(struct ppp *ppp)
        ppp_xmit_unlock(ppp);
 }
 
-static DEFINE_PER_CPU(int, ppp_xmit_recursion);
-
 static void ppp_xmit_process(struct ppp *ppp)
 {
        local_bh_disable();
 
-       if (unlikely(__this_cpu_read(ppp_xmit_recursion)))
+       if (unlikely(*this_cpu_ptr(ppp->xmit_recursion)))
                goto err;
 
-       __this_cpu_inc(ppp_xmit_recursion);
+       (*this_cpu_ptr(ppp->xmit_recursion))++;
        __ppp_xmit_process(ppp);
-       __this_cpu_dec(ppp_xmit_recursion);
+       (*this_cpu_ptr(ppp->xmit_recursion))--;
 
        local_bh_enable();
 
@@ -1905,7 +1918,7 @@ static void __ppp_channel_push(struct channel *pch)
                read_lock(&pch->upl);
                ppp = pch->ppp;
                if (ppp)
-                       __ppp_xmit_process(ppp);
+                       ppp_xmit_process(ppp);
                read_unlock(&pch->upl);
        }
 }
@@ -1914,9 +1927,7 @@ static void ppp_channel_push(struct channel *pch)
 {
        local_bh_disable();
 
-       __this_cpu_inc(ppp_xmit_recursion);
        __ppp_channel_push(pch);
-       __this_cpu_dec(ppp_xmit_recursion);
 
        local_bh_enable();
 }
@@ -3057,6 +3068,7 @@ static void ppp_destroy_interface(struct ppp *ppp)
 #endif /* CONFIG_PPP_FILTER */
 
        kfree_skb(ppp->xmit_pending);
+       free_percpu(ppp->xmit_recursion);
 
        free_netdev(ppp->dev);
 }
index d103a1d4fb36713dac529bbc8703dd3023c6ab66..8f572b9f362555b55dc2e3cccfc5761140664616 100644 (file)
@@ -768,8 +768,10 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
        u8 *buf;
        int len;
        int temp;
+       int err;
        u8 iface_no;
        struct usb_cdc_parsed_header hdr;
+       u16 curr_ntb_format;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
@@ -874,6 +876,32 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
                goto error2;
        }
 
+       /*
+        * Some Huawei devices have been observed to come out of reset in NDP32 mode.
+        * Let's check if this is the case, and set the device to NDP16 mode again if
+        * needed.
+       */
+       if (ctx->drvflags & CDC_NCM_FLAG_RESET_NTB16) {
+               err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_FORMAT,
+                                     USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
+                                     0, iface_no, &curr_ntb_format, 2);
+               if (err < 0) {
+                       goto error2;
+               }
+
+               if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) {
+                       dev_info(&intf->dev, "resetting NTB format to 16-bit");
+                       err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
+                                              USB_TYPE_CLASS | USB_DIR_OUT
+                                              | USB_RECIP_INTERFACE,
+                                              USB_CDC_NCM_NTB16_FORMAT,
+                                              iface_no, NULL, 0);
+
+                       if (err < 0)
+                               goto error2;
+               }
+       }
+
        cdc_ncm_find_endpoints(dev, ctx->data);
        cdc_ncm_find_endpoints(dev, ctx->control);
        if (!dev->in || !dev->out || !dev->status) {
index 2680a65cd5e4fde5e333ef1ca1ff5d5ad4091222..63f28908afda78e05dcbcdd27e0a1a037f8b6fcb 100644 (file)
@@ -80,6 +80,12 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
         * be at the end of the frame.
         */
        drvflags |= CDC_NCM_FLAG_NDP_TO_END;
+
+       /* Additionally, it has been reported that some Huawei E3372H devices, with
+        * firmware version 21.318.01.00.541, come out of reset in NTB32 format mode, hence
+        * needing to be set to the NTB16 one again.
+        */
+       drvflags |= CDC_NCM_FLAG_RESET_NTB16;
        ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags);
        if (ret)
                goto err;
index 2dfca96a63b60283b89efab676932a711024a499..340c13484e5cc7dd5001577b7522d5a4318bd5b6 100644 (file)
@@ -898,6 +898,7 @@ static const struct ethtool_ops smsc95xx_ethtool_ops = {
        .set_wol        = smsc95xx_ethtool_set_wol,
        .get_link_ksettings     = smsc95xx_get_link_ksettings,
        .set_link_ksettings     = smsc95xx_set_link_ksettings,
+       .get_ts_info    = ethtool_op_get_ts_info,
 };
 
 static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
index ba1c9f93592b809cddc64b5e2dc68d1ecadf4190..9c51b8be00388adc840c68e38f60952dd1e46896 100644 (file)
@@ -311,7 +311,7 @@ struct vmxnet3_intr {
        u8  num_intrs;                  /* # of intr vectors */
        u8  event_intr_idx;             /* idx of the intr vector for event */
        u8  mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */
-       char    event_msi_vector_name[IFNAMSIZ+11];
+       char    event_msi_vector_name[IFNAMSIZ+17];
 #ifdef CONFIG_PCI_MSI
        struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT];
 #endif
index 6e2e760d98b1b94ce03c7bb74fd034e6e0c9b693..0b75def39c6c4179ae157316f5d2b371775ae48b 100644 (file)
@@ -5704,7 +5704,7 @@ static void rt2800_init_freq_calibration(struct rt2x00_dev *rt2x00dev)
 
 static void rt2800_init_bbp_5592_glrt(struct rt2x00_dev *rt2x00dev)
 {
-       const u8 glrt_table[] = {
+       static const u8 glrt_table[] = {
                0xE0, 0x1F, 0X38, 0x32, 0x08, 0x28, 0x19, 0x0A, 0xFF, 0x00, /* 128 ~ 137 */
                0x16, 0x10, 0x10, 0x0B, 0x36, 0x2C, 0x26, 0x24, 0x42, 0x36, /* 138 ~ 147 */
                0x30, 0x2D, 0x4C, 0x46, 0x3D, 0x40, 0x3E, 0x42, 0x3D, 0x40, /* 148 ~ 157 */
index 360c082e885c7777ef6d9509dec75bbb6ee3fff3..d41d40ac3efdb940bf96391d17ee737456cd24c2 100644 (file)
@@ -85,7 +85,7 @@ int __cgroup_bpf_run_filter_sock_ops(struct sock *sk,
        int __ret = 0;                                                         \
        if (cgroup_bpf_enabled && (sock_ops)->sk) {            \
                typeof(sk) __sk = sk_to_full_sk((sock_ops)->sk);               \
-               if (sk_fullsock(__sk))                                         \
+               if (__sk && sk_fullsock(__sk))                                 \
                        __ret = __cgroup_bpf_run_filter_sock_ops(__sk,         \
                                                                 sock_ops,     \
                                                         BPF_CGROUP_SOCK_OPS); \
index 621076f56251d860f647981b95e2e64cd8e9a5da..8e5d31f6faefd361cee145be654a968123ae5e6a 100644 (file)
@@ -43,6 +43,7 @@ struct bpf_reg_state {
        u32 min_align;
        u32 aux_off;
        u32 aux_off_align;
+       bool value_from_signed;
 };
 
 enum bpf_stack_slot_type {
index 348c6f47e4cc36681e55ff4800a4d2a4e052f954..8037850f31041696a30a046696c99f902d222b03 100644 (file)
@@ -85,19 +85,18 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
                k += 12;
        }
        /* Last block: affect all 32 bits of (c) */
-       /* All the case statements fall through */
        switch (length) {
-       case 12: c += (u32)k[11]<<24;
-       case 11: c += (u32)k[10]<<16;
-       case 10: c += (u32)k[9]<<8;
-       case 9:  c += k[8];
-       case 8:  b += (u32)k[7]<<24;
-       case 7:  b += (u32)k[6]<<16;
-       case 6:  b += (u32)k[5]<<8;
-       case 5:  b += k[4];
-       case 4:  a += (u32)k[3]<<24;
-       case 3:  a += (u32)k[2]<<16;
-       case 2:  a += (u32)k[1]<<8;
+       case 12: c += (u32)k[11]<<24;   /* fall through */
+       case 11: c += (u32)k[10]<<16;   /* fall through */
+       case 10: c += (u32)k[9]<<8;     /* fall through */
+       case 9:  c += k[8];             /* fall through */
+       case 8:  b += (u32)k[7]<<24;    /* fall through */
+       case 7:  b += (u32)k[6]<<16;    /* fall through */
+       case 6:  b += (u32)k[5]<<8;     /* fall through */
+       case 5:  b += k[4];             /* fall through */
+       case 4:  a += (u32)k[3]<<24;    /* fall through */
+       case 3:  a += (u32)k[2]<<16;    /* fall through */
+       case 2:  a += (u32)k[1]<<8;     /* fall through */
        case 1:  a += k[0];
                 __jhash_final(a, b, c);
        case 0: /* Nothing left to add */
@@ -131,10 +130,10 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
                k += 3;
        }
 
-       /* Handle the last 3 u32's: all the case statements fall through */
+       /* Handle the last 3 u32's */
        switch (length) {
-       case 3: c += k[2];
-       case 2: b += k[1];
+       case 3: c += k[2];      /* fall through */
+       case 2: b += k[1];      /* fall through */
        case 1: a += k[0];
                __jhash_final(a, b, c);
        case 0: /* Nothing left to add */
index a4b97be30b28109c4f2987737e1dc532f2b8cf6e..22f081065d4966dbbd3c09bc2b3eea5ecd8c8cf9 100644 (file)
@@ -61,8 +61,6 @@ typedef unsigned int nf_hookfn(void *priv,
                               struct sk_buff *skb,
                               const struct nf_hook_state *state);
 struct nf_hook_ops {
-       struct list_head        list;
-
        /* User fills in from here down. */
        nf_hookfn               *hook;
        struct net_device       *dev;
@@ -160,13 +158,6 @@ int nf_register_net_hooks(struct net *net, const struct nf_hook_ops *reg,
 void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,
                             unsigned int n);
 
-int nf_register_hook(struct nf_hook_ops *reg);
-void nf_unregister_hook(struct nf_hook_ops *reg);
-int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
-void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
-int _nf_register_hooks(struct nf_hook_ops *reg, unsigned int n);
-void _nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
-
 /* Functions to register get/setsockopt ranges (non-inclusive).  You
    need to check permissions yourself! */
 int nf_register_sockopt(struct nf_sockopt_ops *reg);
index 021f7a88f52c929ec804d856a8f6541e1c4c6490..1a59699cf82a90bae208d478092a425d926f4d77 100644 (file)
@@ -83,6 +83,7 @@
 /* Driver flags */
 #define CDC_NCM_FLAG_NDP_TO_END                        0x02    /* NDP is placed at end of frame */
 #define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE  0x04    /* Avoid altsetting toggle during init */
+#define CDC_NCM_FLAG_RESET_NTB16 0x08  /* set NDP16 one more time after altsetting switch */
 
 #define cdc_ncm_comm_intf_is_mbim(x)  ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
                                       (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
index 01709172b3d38455e7e5510228d6b4a0ad6e94a6..ef8e6c3a80a63f6c41f92e82405a5a77c1264ed6 100644 (file)
@@ -98,8 +98,8 @@
  *   nla_put_u8(skb, type, value)      add u8 attribute to skb
  *   nla_put_u16(skb, type, value)     add u16 attribute to skb
  *   nla_put_u32(skb, type, value)     add u32 attribute to skb
- *   nla_put_u64_64bits(skb, type,
- *                     value, padattr) add u64 attribute to skb
+ *   nla_put_u64_64bit(skb, type,
+ *                     value, padattr) add u64 attribute to skb
  *   nla_put_s8(skb, type, value)      add s8 attribute to skb
  *   nla_put_s16(skb, type, value)     add s16 attribute to skb
  *   nla_put_s32(skb, type, value)     add s32 attribute to skb
index a9519a06a23b2083b4eec970eb2d99d98216aa83..980807d7506fe3ae6f5c316da091e126e619ed69 100644 (file)
@@ -469,6 +469,8 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
 
 #define _sctp_walk_params(pos, chunk, end, member)\
 for (pos.v = chunk->member;\
+     (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <\
+      (void *)chunk + end) &&\
      pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
      ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\
      pos.v += SCTP_PAD4(ntohs(pos.p->length)))
@@ -479,6 +481,8 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))
 #define _sctp_walk_errors(err, chunk_hdr, end)\
 for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
            sizeof(struct sctp_chunkhdr));\
+     ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <\
+      (void *)chunk_hdr + end) &&\
      (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
      ntohs(err->length) >= sizeof(sctp_errhdr_t); \
      err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length))))
index 6a86723c5b64bad1534d6519f33e03e9ad4fad99..af9e84a4944e60fdd617c0c69ecbc46d53e230ac 100644 (file)
@@ -504,6 +504,7 @@ static void reset_reg_range_values(struct bpf_reg_state *regs, u32 regno)
 {
        regs[regno].min_value = BPF_REGISTER_MIN_RANGE;
        regs[regno].max_value = BPF_REGISTER_MAX_RANGE;
+       regs[regno].value_from_signed = false;
        regs[regno].min_align = 0;
 }
 
@@ -777,12 +778,13 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,
        return -EACCES;
 }
 
-static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
+static bool __is_pointer_value(bool allow_ptr_leaks,
+                              const struct bpf_reg_state *reg)
 {
-       if (env->allow_ptr_leaks)
+       if (allow_ptr_leaks)
                return false;
 
-       switch (env->cur_state.regs[regno].type) {
+       switch (reg->type) {
        case UNKNOWN_VALUE:
        case CONST_IMM:
                return false;
@@ -791,6 +793,11 @@ static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
        }
 }
 
+static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
+{
+       return __is_pointer_value(env->allow_ptr_leaks, &env->cur_state.regs[regno]);
+}
+
 static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
                                   int off, int size, bool strict)
 {
@@ -1832,10 +1839,24 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
        dst_align = dst_reg->min_align;
 
        /* We don't know anything about what was done to this register, mark it
-        * as unknown.
+        * as unknown. Also, if both derived bounds came from signed/unsigned
+        * mixed compares and one side is unbounded, we cannot really do anything
+        * with them as boundaries cannot be trusted. Thus, arithmetic of two
+        * regs of such kind will get invalidated bounds on the dst side.
         */
-       if (min_val == BPF_REGISTER_MIN_RANGE &&
-           max_val == BPF_REGISTER_MAX_RANGE) {
+       if ((min_val == BPF_REGISTER_MIN_RANGE &&
+            max_val == BPF_REGISTER_MAX_RANGE) ||
+           (BPF_SRC(insn->code) == BPF_X &&
+            ((min_val != BPF_REGISTER_MIN_RANGE &&
+              max_val == BPF_REGISTER_MAX_RANGE) ||
+             (min_val == BPF_REGISTER_MIN_RANGE &&
+              max_val != BPF_REGISTER_MAX_RANGE) ||
+             (dst_reg->min_value != BPF_REGISTER_MIN_RANGE &&
+              dst_reg->max_value == BPF_REGISTER_MAX_RANGE) ||
+             (dst_reg->min_value == BPF_REGISTER_MIN_RANGE &&
+              dst_reg->max_value != BPF_REGISTER_MAX_RANGE)) &&
+            regs[insn->dst_reg].value_from_signed !=
+            regs[insn->src_reg].value_from_signed)) {
                reset_reg_range_values(regs, insn->dst_reg);
                return;
        }
@@ -2023,6 +2044,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
                        regs[insn->dst_reg].max_value = insn->imm;
                        regs[insn->dst_reg].min_value = insn->imm;
                        regs[insn->dst_reg].min_align = calc_align(insn->imm);
+                       regs[insn->dst_reg].value_from_signed = false;
                }
 
        } else if (opcode > BPF_END) {
@@ -2198,40 +2220,63 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
                            struct bpf_reg_state *false_reg, u64 val,
                            u8 opcode)
 {
+       bool value_from_signed = true;
+       bool is_range = true;
+
        switch (opcode) {
        case BPF_JEQ:
                /* If this is false then we know nothing Jon Snow, but if it is
                 * true then we know for sure.
                 */
                true_reg->max_value = true_reg->min_value = val;
+               is_range = false;
                break;
        case BPF_JNE:
                /* If this is true we know nothing Jon Snow, but if it is false
                 * we know the value for sure;
                 */
                false_reg->max_value = false_reg->min_value = val;
+               is_range = false;
                break;
        case BPF_JGT:
-               /* Unsigned comparison, the minimum value is 0. */
-               false_reg->min_value = 0;
+               value_from_signed = false;
                /* fallthrough */
        case BPF_JSGT:
+               if (true_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(true_reg, 0);
+               if (false_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(false_reg, 0);
+               if (opcode == BPF_JGT) {
+                       /* Unsigned comparison, the minimum value is 0. */
+                       false_reg->min_value = 0;
+               }
                /* If this is false then we know the maximum val is val,
                 * otherwise we know the min val is val+1.
                 */
                false_reg->max_value = val;
+               false_reg->value_from_signed = value_from_signed;
                true_reg->min_value = val + 1;
+               true_reg->value_from_signed = value_from_signed;
                break;
        case BPF_JGE:
-               /* Unsigned comparison, the minimum value is 0. */
-               false_reg->min_value = 0;
+               value_from_signed = false;
                /* fallthrough */
        case BPF_JSGE:
+               if (true_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(true_reg, 0);
+               if (false_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(false_reg, 0);
+               if (opcode == BPF_JGE) {
+                       /* Unsigned comparison, the minimum value is 0. */
+                       false_reg->min_value = 0;
+               }
                /* If this is false then we know the maximum value is val - 1,
                 * otherwise we know the mimimum value is val.
                 */
                false_reg->max_value = val - 1;
+               false_reg->value_from_signed = value_from_signed;
                true_reg->min_value = val;
+               true_reg->value_from_signed = value_from_signed;
                break;
        default:
                break;
@@ -2239,6 +2284,12 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
 
        check_reg_overflow(false_reg);
        check_reg_overflow(true_reg);
+       if (is_range) {
+               if (__is_pointer_value(false, false_reg))
+                       reset_reg_range_values(false_reg, 0);
+               if (__is_pointer_value(false, true_reg))
+                       reset_reg_range_values(true_reg, 0);
+       }
 }
 
 /* Same as above, but for the case that dst_reg is a CONST_IMM reg and src_reg
@@ -2248,41 +2299,64 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
                                struct bpf_reg_state *false_reg, u64 val,
                                u8 opcode)
 {
+       bool value_from_signed = true;
+       bool is_range = true;
+
        switch (opcode) {
        case BPF_JEQ:
                /* If this is false then we know nothing Jon Snow, but if it is
                 * true then we know for sure.
                 */
                true_reg->max_value = true_reg->min_value = val;
+               is_range = false;
                break;
        case BPF_JNE:
                /* If this is true we know nothing Jon Snow, but if it is false
                 * we know the value for sure;
                 */
                false_reg->max_value = false_reg->min_value = val;
+               is_range = false;
                break;
        case BPF_JGT:
-               /* Unsigned comparison, the minimum value is 0. */
-               true_reg->min_value = 0;
+               value_from_signed = false;
                /* fallthrough */
        case BPF_JSGT:
+               if (true_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(true_reg, 0);
+               if (false_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(false_reg, 0);
+               if (opcode == BPF_JGT) {
+                       /* Unsigned comparison, the minimum value is 0. */
+                       true_reg->min_value = 0;
+               }
                /*
                 * If this is false, then the val is <= the register, if it is
                 * true the register <= to the val.
                 */
                false_reg->min_value = val;
+               false_reg->value_from_signed = value_from_signed;
                true_reg->max_value = val - 1;
+               true_reg->value_from_signed = value_from_signed;
                break;
        case BPF_JGE:
-               /* Unsigned comparison, the minimum value is 0. */
-               true_reg->min_value = 0;
+               value_from_signed = false;
                /* fallthrough */
        case BPF_JSGE:
+               if (true_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(true_reg, 0);
+               if (false_reg->value_from_signed != value_from_signed)
+                       reset_reg_range_values(false_reg, 0);
+               if (opcode == BPF_JGE) {
+                       /* Unsigned comparison, the minimum value is 0. */
+                       true_reg->min_value = 0;
+               }
                /* If this is false then constant < register, if it is true then
                 * the register < constant.
                 */
                false_reg->min_value = val + 1;
+               false_reg->value_from_signed = value_from_signed;
                true_reg->max_value = val;
+               true_reg->value_from_signed = value_from_signed;
                break;
        default:
                break;
@@ -2290,6 +2364,12 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
 
        check_reg_overflow(false_reg);
        check_reg_overflow(true_reg);
+       if (is_range) {
+               if (__is_pointer_value(false, false_reg))
+                       reset_reg_range_values(false_reg, 0);
+               if (__is_pointer_value(false, true_reg))
+                       reset_reg_range_values(true_reg, 0);
+       }
 }
 
 static void mark_map_reg(struct bpf_reg_state *regs, u32 regno, u32 id,
index f0f3447e8aa48ff02c3f11f6da0e65e79cb28e90..861ae2a165f4dc3271b648794486e6a768590733 100644 (file)
@@ -34,11 +34,11 @@ static struct lock_class_key bridge_netdev_addr_lock_key;
 netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct net_bridge *br = netdev_priv(dev);
-       const unsigned char *dest = skb->data;
        struct net_bridge_fdb_entry *dst;
        struct net_bridge_mdb_entry *mdst;
        struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats);
        const struct nf_br_ops *nf_ops;
+       const unsigned char *dest;
        u16 vid = 0;
 
        rcu_read_lock();
@@ -61,6 +61,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
        if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid))
                goto out;
 
+       dest = eth_hdr(skb)->h_dest;
        if (is_broadcast_ether_addr(dest)) {
                br_flood(br, skb, BR_PKT_BROADCAST, false, true);
        } else if (is_multicast_ether_addr(dest)) {
index 013f2290bfa56df90708879437a762c812dec101..7637f58c12263bae0bc907d01d0838c1fd68cf5c 100644 (file)
@@ -131,11 +131,11 @@ static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br,
 int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct net_bridge_port *p = br_port_get_rcu(skb->dev);
-       const unsigned char *dest = eth_hdr(skb)->h_dest;
        enum br_pkt_type pkt_type = BR_PKT_UNICAST;
        struct net_bridge_fdb_entry *dst = NULL;
        struct net_bridge_mdb_entry *mdst;
        bool local_rcv, mcast_hit = false;
+       const unsigned char *dest;
        struct net_bridge *br;
        u16 vid = 0;
 
@@ -153,6 +153,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
                br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false);
 
        local_rcv = !!(br->dev->flags & IFF_PROMISC);
+       dest = eth_hdr(skb)->h_dest;
        if (is_multicast_ether_addr(dest)) {
                /* by definition the broadcast is also a multicast address */
                if (is_broadcast_ether_addr(dest)) {
index 82fd4c9c4a1bf491f094a17c774c3e611c483690..06b147d7d9e2e7d8d305dd9b173d9bc1a7e9a676 100644 (file)
@@ -28,6 +28,7 @@ static int dev_ifname(struct net *net, struct ifreq __user *arg)
 
        if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
                return -EFAULT;
+       ifr.ifr_name[IFNAMSIZ-1] = 0;
 
        error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex);
        if (error)
@@ -424,6 +425,8 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
                if (copy_from_user(&iwr, arg, sizeof(iwr)))
                        return -EFAULT;
 
+               iwr.ifr_name[sizeof(iwr.ifr_name) - 1] = 0;
+
                return wext_handle_ioctl(net, &iwr, cmd, arg);
        }
 
index a0093e1b0235355db66b980580243dd6619c9aa6..fdcb1bcd2afad5737a2c11fab55a3c214b86388d 100644 (file)
@@ -400,6 +400,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
                err = -ENOMEM;
                goto errout;
        }
+       refcount_set(&rule->refcnt, 1);
        rule->fr_net = net;
 
        rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY])
@@ -517,8 +518,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
                last = r;
        }
 
-       refcount_set(&rule->refcnt, 1);
-
        if (last)
                list_add_rcu(&rule->list, &last->list);
        else
index c7f737058d8964f1bb81c245fd9e5de2648d10e4..f44fc22fd45aca4941c618abf97eb48494a67c16 100644 (file)
@@ -2248,7 +2248,7 @@ static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff)
                       bpf_skb_net_grow(skb, len_diff_abs);
 
        bpf_compute_data_end(skb);
-       return 0;
+       return ret;
 }
 
 BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff,
index d3408a69316622a59de0ce19d5197be56d5a87a4..8357f164c66092b9c99996782d29de246c54dbd6 100644 (file)
@@ -277,7 +277,7 @@ static void zap_completion_queue(void)
                        struct sk_buff *skb = clist;
                        clist = clist->next;
                        if (!skb_irq_freeable(skb)) {
-                               refcount_inc(&skb->users);
+                               refcount_set(&skb->users, 1);
                                dev_kfree_skb_any(skb); /* put this one back */
                        } else {
                                __kfree_skb(skb);
index d1ba90980be1325e86836795a354214cb96a4079..9201e3621351144f1fde497dfa1025d93d0a76f9 100644 (file)
@@ -2031,7 +2031,8 @@ static int do_setlink(const struct sk_buff *skb,
                struct sockaddr *sa;
                int len;
 
-               len = sizeof(sa_family_t) + dev->addr_len;
+               len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len,
+                                                 sizeof(*sa));
                sa = kmalloc(len, GFP_KERNEL);
                if (!sa) {
                        err = -ENOMEM;
@@ -4241,6 +4242,7 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
 
        switch (event) {
        case NETDEV_REBOOT:
+       case NETDEV_CHANGEADDR:
        case NETDEV_CHANGENAME:
        case NETDEV_FEAT_CHANGE:
        case NETDEV_BONDING_FAILOVER:
index 4a05d78768502df69275b4f91cb03bb2ada9f4c3..fa6be9750bb46d9aeee2462fa86ed1a7cfc40cd1 100644 (file)
@@ -126,7 +126,7 @@ static int dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb)
 
 static u16 dccp_reset_code_convert(const u8 code)
 {
-       const u16 error_code[] = {
+       static const u16 error_code[] = {
        [DCCP_RESET_CODE_CLOSED]             = 0,       /* normal termination */
        [DCCP_RESET_CODE_UNSPECIFIED]        = 0,       /* nothing known */
        [DCCP_RESET_CODE_ABORTED]            = ECONNRESET,
index 4e678fa892ddcf1985fb37c3627a660a8f69da9d..044d2a159a3c51bef90acd029067ef047ccaa046 100644 (file)
@@ -1334,13 +1334,14 @@ static struct pernet_operations fib_net_ops = {
 
 void __init ip_fib_init(void)
 {
-       rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
-       rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
-       rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
+       fib_trie_init();
 
        register_pernet_subsys(&fib_net_ops);
+
        register_netdevice_notifier(&fib_netdev_notifier);
        register_inetaddr_notifier(&fib_inetaddr_notifier);
 
-       fib_trie_init();
+       rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
+       rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
+       rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
 }
index 7eb252dceceea31acb84fc0bbc902ca426283154..50c74cd890bc79ed6c85c958c5397d833e9aa74a 100644 (file)
@@ -599,6 +599,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
        hlen = iph->ihl * 4;
        mtu = mtu - hlen;       /* Size of data space */
        IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE;
+       ll_rs = LL_RESERVED_SPACE(rt->dst.dev);
 
        /* When frag_list is given, use it. First, check its validity:
         * some transformers could create wrong frag_list or break existing
@@ -614,14 +615,15 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
                if (first_len - hlen > mtu ||
                    ((first_len - hlen) & 7) ||
                    ip_is_fragment(iph) ||
-                   skb_cloned(skb))
+                   skb_cloned(skb) ||
+                   skb_headroom(skb) < ll_rs)
                        goto slow_path;
 
                skb_walk_frags(skb, frag) {
                        /* Correct geometry. */
                        if (frag->len > mtu ||
                            ((frag->len & 7) && frag->next) ||
-                           skb_headroom(frag) < hlen)
+                           skb_headroom(frag) < hlen + ll_rs)
                                goto slow_path_clean;
 
                        /* Partially cloned skb? */
@@ -711,8 +713,6 @@ slow_path:
        left = skb->len - hlen;         /* Space per frame */
        ptr = hlen;             /* Where to start from */
 
-       ll_rs = LL_RESERVED_SPACE(rt->dst.dev);
-
        /*
         *      Fragment the datagram.
         */
index 805c8ddfe86022e6b47df2026d5c5830c613b0ff..4bbc273b45e871b2c3033bfd31af73f2b8bc9aa4 100644 (file)
@@ -72,8 +72,7 @@ static const struct nf_chain_type filter_arp = {
        .family         = NFPROTO_ARP,
        .owner          = THIS_MODULE,
        .hook_mask      = (1 << NF_ARP_IN) |
-                         (1 << NF_ARP_OUT) |
-                         (1 << NF_ARP_FORWARD),
+                         (1 << NF_ARP_OUT),
 };
 
 static int __init nf_tables_arp_init(void)
index 0905cf04c2a4e41e06a047ab52de6ab95a5afb61..03ad8778c395334ed53a250bccc0b991cd85c2f2 100644 (file)
@@ -335,6 +335,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
        treq->rcv_isn           = ntohl(th->seq) - 1;
        treq->snt_isn           = cookie;
        treq->ts_off            = 0;
+       treq->txhash            = net_tx_rndhash();
        req->mss                = mss;
        ireq->ir_num            = ntohs(th->dest);
        ireq->ir_rmt_port       = th->source;
index dbcc9352a48f07a12484e45f3baf0a733e244f75..69ee877574d08b36bc990f890899037108eafe05 100644 (file)
@@ -112,7 +112,8 @@ struct bbr {
                cwnd_gain:10,   /* current gain for setting cwnd */
                full_bw_cnt:3,  /* number of rounds without large bw gains */
                cycle_idx:3,    /* current index in pacing_gain cycle array */
-               unused_b:6;
+               has_seen_rtt:1, /* have we seen an RTT sample yet? */
+               unused_b:5;
        u32     prior_cwnd;     /* prior cwnd upon entering loss recovery */
        u32     full_bw;        /* recent bw, to estimate if pipe is full */
 };
@@ -211,6 +212,35 @@ static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain)
        return rate >> BW_SCALE;
 }
 
+/* Convert a BBR bw and gain factor to a pacing rate in bytes per second. */
+static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain)
+{
+       u64 rate = bw;
+
+       rate = bbr_rate_bytes_per_sec(sk, rate, gain);
+       rate = min_t(u64, rate, sk->sk_max_pacing_rate);
+       return rate;
+}
+
+/* Initialize pacing rate to: high_gain * init_cwnd / RTT. */
+static void bbr_init_pacing_rate_from_rtt(struct sock *sk)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct bbr *bbr = inet_csk_ca(sk);
+       u64 bw;
+       u32 rtt_us;
+
+       if (tp->srtt_us) {              /* any RTT sample yet? */
+               rtt_us = max(tp->srtt_us >> 3, 1U);
+               bbr->has_seen_rtt = 1;
+       } else {                         /* no RTT sample yet */
+               rtt_us = USEC_PER_MSEC;  /* use nominal default RTT */
+       }
+       bw = (u64)tp->snd_cwnd * BW_UNIT;
+       do_div(bw, rtt_us);
+       sk->sk_pacing_rate = bbr_bw_to_pacing_rate(sk, bw, bbr_high_gain);
+}
+
 /* Pace using current bw estimate and a gain factor. In order to help drive the
  * network toward lower queues while maintaining high utilization and low
  * latency, the average pacing rate aims to be slightly (~1%) lower than the
@@ -220,12 +250,13 @@ static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain)
  */
 static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain)
 {
+       struct tcp_sock *tp = tcp_sk(sk);
        struct bbr *bbr = inet_csk_ca(sk);
-       u64 rate = bw;
+       u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain);
 
-       rate = bbr_rate_bytes_per_sec(sk, rate, gain);
-       rate = min_t(u64, rate, sk->sk_max_pacing_rate);
-       if (bbr->mode != BBR_STARTUP || rate > sk->sk_pacing_rate)
+       if (unlikely(!bbr->has_seen_rtt && tp->srtt_us))
+               bbr_init_pacing_rate_from_rtt(sk);
+       if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate)
                sk->sk_pacing_rate = rate;
 }
 
@@ -798,7 +829,6 @@ static void bbr_init(struct sock *sk)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct bbr *bbr = inet_csk_ca(sk);
-       u64 bw;
 
        bbr->prior_cwnd = 0;
        bbr->tso_segs_goal = 0;  /* default segs per skb until first ACK */
@@ -814,11 +844,8 @@ static void bbr_init(struct sock *sk)
 
        minmax_reset(&bbr->bw, bbr->rtt_cnt, 0);  /* init max bw to 0 */
 
-       /* Initialize pacing rate to: high_gain * init_cwnd / RTT. */
-       bw = (u64)tp->snd_cwnd * BW_UNIT;
-       do_div(bw, (tp->srtt_us >> 3) ? : USEC_PER_MSEC);
-       sk->sk_pacing_rate = 0;         /* force an update of sk_pacing_rate */
-       bbr_set_pacing_rate(sk, bw, bbr_high_gain);
+       bbr->has_seen_rtt = 0;
+       bbr_init_pacing_rate_from_rtt(sk);
 
        bbr->restore_cwnd = 0;
        bbr->round_start = 0;
index 25294d43e1470757e4631a8ac2af7fda7e810008..b057653ceca9208d1e1765525e5492876c0b651e 100644 (file)
@@ -1388,6 +1388,11 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len)
                unlock_sock_fast(sk, slow);
        }
 
+       /* we cleared the head states previously only if the skb lacks any IP
+        * options, see __udp_queue_rcv_skb().
+        */
+       if (unlikely(IPCB(skb)->opt.optlen > 0))
+               skb_release_head_state(skb);
        consume_stateless_skb(skb);
 }
 EXPORT_SYMBOL_GPL(skb_consume_udp);
@@ -1779,8 +1784,12 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
                sk_mark_napi_id_once(sk, skb);
        }
 
-       /* clear all pending head states while they are hot in the cache */
-       skb_release_head_state(skb);
+       /* At recvmsg() time we need skb->dst to process IP options-related
+        * cmsg, elsewhere can we clear all pending head states while they are
+        * hot in the cache
+        */
+       if (likely(IPCB(skb)->opt.optlen == 0))
+               skb_release_head_state(skb);
 
        rc = __udp_enqueue_schedule_skb(sk, skb);
        if (rc < 0) {
index e9065b8d3af852c6e9a7359667f68a5ad00bfe75..abb2c307fbe8337ce1714e7392072c945ed5af51 100644 (file)
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(ipv6_select_ident);
 
 int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 {
-       u16 offset = sizeof(struct ipv6hdr);
+       unsigned int offset = sizeof(struct ipv6hdr);
        unsigned int packet_len = skb_tail_pointer(skb) -
                skb_network_header(skb);
        int found_rhdr = 0;
@@ -86,6 +86,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 
        while (offset <= packet_len) {
                struct ipv6_opt_hdr *exthdr;
+               unsigned int len;
 
                switch (**nexthdr) {
 
@@ -111,7 +112,10 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 
                exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
                                                 offset);
-               offset += ipv6_optlen(exthdr);
+               len = ipv6_optlen(exthdr);
+               if (len + offset >= IPV6_MAXPLEN)
+                       return -EINVAL;
+               offset += len;
                *nexthdr = &exthdr->nexthdr;
        }
 
index 7b75b062073087b7b715629de839dcc107144402..4e7817abc0b934fbff21ba481c3f6773475c7a63 100644 (file)
@@ -216,6 +216,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        treq->rcv_isn = ntohl(th->seq) - 1;
        treq->snt_isn = cookie;
        treq->ts_off = 0;
+       treq->txhash = net_tx_rndhash();
 
        /*
         * We need to lookup the dst_entry to get the correct window size.
index 552d606e57ca4aac6bfe5ad26c42c385a431ab68..974cf2a3795aaa8ea68a17d60349d4b1cfad9496 100644 (file)
@@ -227,114 +227,6 @@ void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,
 }
 EXPORT_SYMBOL(nf_unregister_net_hooks);
 
-static LIST_HEAD(nf_hook_list);
-
-static int _nf_register_hook(struct nf_hook_ops *reg)
-{
-       struct net *net, *last;
-       int ret;
-
-       for_each_net(net) {
-               ret = nf_register_net_hook(net, reg);
-               if (ret && ret != -ENOENT)
-                       goto rollback;
-       }
-       list_add_tail(&reg->list, &nf_hook_list);
-
-       return 0;
-rollback:
-       last = net;
-       for_each_net(net) {
-               if (net == last)
-                       break;
-               nf_unregister_net_hook(net, reg);
-       }
-       return ret;
-}
-
-int nf_register_hook(struct nf_hook_ops *reg)
-{
-       int ret;
-
-       rtnl_lock();
-       ret = _nf_register_hook(reg);
-       rtnl_unlock();
-
-       return ret;
-}
-EXPORT_SYMBOL(nf_register_hook);
-
-static void _nf_unregister_hook(struct nf_hook_ops *reg)
-{
-       struct net *net;
-
-       list_del(&reg->list);
-       for_each_net(net)
-               nf_unregister_net_hook(net, reg);
-}
-
-void nf_unregister_hook(struct nf_hook_ops *reg)
-{
-       rtnl_lock();
-       _nf_unregister_hook(reg);
-       rtnl_unlock();
-}
-EXPORT_SYMBOL(nf_unregister_hook);
-
-int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n)
-{
-       unsigned int i;
-       int err = 0;
-
-       for (i = 0; i < n; i++) {
-               err = nf_register_hook(&reg[i]);
-               if (err)
-                       goto err;
-       }
-       return err;
-
-err:
-       if (i > 0)
-               nf_unregister_hooks(reg, i);
-       return err;
-}
-EXPORT_SYMBOL(nf_register_hooks);
-
-/* Caller MUST take rtnl_lock() */
-int _nf_register_hooks(struct nf_hook_ops *reg, unsigned int n)
-{
-       unsigned int i;
-       int err = 0;
-
-       for (i = 0; i < n; i++) {
-               err = _nf_register_hook(&reg[i]);
-               if (err)
-                       goto err;
-       }
-       return err;
-
-err:
-       if (i > 0)
-               _nf_unregister_hooks(reg, i);
-       return err;
-}
-EXPORT_SYMBOL(_nf_register_hooks);
-
-void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n)
-{
-       while (n-- > 0)
-               nf_unregister_hook(&reg[n]);
-}
-EXPORT_SYMBOL(nf_unregister_hooks);
-
-/* Caller MUST take rtnl_lock */
-void _nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n)
-{
-       while (n-- > 0)
-               _nf_unregister_hook(&reg[n]);
-}
-EXPORT_SYMBOL(_nf_unregister_hooks);
-
 /* Returns 1 if okfn() needs to be executed by the caller,
  * -EPERM for NF_DROP, 0 otherwise.  Caller must hold rcu_read_lock. */
 int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
@@ -450,40 +342,9 @@ void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
 EXPORT_SYMBOL(nf_nat_decode_session_hook);
 #endif
 
-static int nf_register_hook_list(struct net *net)
-{
-       struct nf_hook_ops *elem;
-       int ret;
-
-       rtnl_lock();
-       list_for_each_entry(elem, &nf_hook_list, list) {
-               ret = nf_register_net_hook(net, elem);
-               if (ret && ret != -ENOENT)
-                       goto out_undo;
-       }
-       rtnl_unlock();
-       return 0;
-
-out_undo:
-       list_for_each_entry_continue_reverse(elem, &nf_hook_list, list)
-               nf_unregister_net_hook(net, elem);
-       rtnl_unlock();
-       return ret;
-}
-
-static void nf_unregister_hook_list(struct net *net)
-{
-       struct nf_hook_ops *elem;
-
-       rtnl_lock();
-       list_for_each_entry(elem, &nf_hook_list, list)
-               nf_unregister_net_hook(net, elem);
-       rtnl_unlock();
-}
-
 static int __net_init netfilter_net_init(struct net *net)
 {
-       int i, h, ret;
+       int i, h;
 
        for (i = 0; i < ARRAY_SIZE(net->nf.hooks); i++) {
                for (h = 0; h < NF_MAX_HOOKS; h++)
@@ -500,16 +361,12 @@ static int __net_init netfilter_net_init(struct net *net)
                return -ENOMEM;
        }
 #endif
-       ret = nf_register_hook_list(net);
-       if (ret)
-               remove_proc_entry("netfilter", net->proc_net);
 
-       return ret;
+       return 0;
 }
 
 static void __net_exit netfilter_net_exit(struct net *net)
 {
-       nf_unregister_hook_list(net);
        remove_proc_entry("netfilter", net->proc_net);
 }
 
index e03d16ed550d6bf07a537f4b150148a3cd967f59..899c2c36da136fe3e7268e44437a8d49d73789e2 100644 (file)
@@ -422,7 +422,7 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect)
        h = nf_ct_expect_dst_hash(net, &expect->tuple);
        hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) {
                if (expect_matches(i, expect)) {
-                       if (nf_ct_remove_expect(expect))
+                       if (nf_ct_remove_expect(i))
                                break;
                } else if (expect_clash(i, expect)) {
                        ret = -EBUSY;
index 832c5a08d9a58f216f61008ebdb6636e2384f5e3..eb541786ccb7c79b3498477dfefc2927368f1a6f 100644 (file)
@@ -222,20 +222,21 @@ find_appropriate_src(struct net *net,
                .tuple = tuple,
                .zone = zone
        };
-       struct rhlist_head *hl;
+       struct rhlist_head *hl, *h;
 
        hl = rhltable_lookup(&nf_nat_bysource_table, &key,
                             nf_nat_bysource_params);
-       if (!hl)
-               return 0;
 
-       ct = container_of(hl, typeof(*ct), nat_bysource);
+       rhl_for_each_entry_rcu(ct, h, hl, nat_bysource) {
+               nf_ct_invert_tuplepr(result,
+                                    &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+               result->dst = tuple->dst;
 
-       nf_ct_invert_tuplepr(result,
-                            &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
-       result->dst = tuple->dst;
+               if (in_range(l3proto, l4proto, result, range))
+                       return 1;
+       }
 
-       return in_range(l3proto, l4proto, result, range);
+       return 0;
 }
 
 /* For [FUTURE] fragmentation handling, we want the least-used
index 92b05e188fd1f8adac7e363f59998ce8310ed9ed..733d3e4a30d85d0bfe5656c1e99a24c01b0fabec 100644 (file)
@@ -472,8 +472,7 @@ static void nfnetlink_rcv_skb_batch(struct sk_buff *skb, struct nlmsghdr *nlh)
        if (msglen > skb->len)
                msglen = skb->len;
 
-       if (nlh->nlmsg_len < NLMSG_HDRLEN ||
-           skb->len < NLMSG_HDRLEN + sizeof(struct nfgenmsg))
+       if (skb->len < NLMSG_HDRLEN + sizeof(struct nfgenmsg))
                return;
 
        err = nla_parse(cda, NFNL_BATCH_MAX, attr, attrlen, nfnl_batch_policy,
@@ -500,7 +499,8 @@ static void nfnetlink_rcv(struct sk_buff *skb)
 {
        struct nlmsghdr *nlh = nlmsg_hdr(skb);
 
-       if (nlh->nlmsg_len < NLMSG_HDRLEN ||
+       if (skb->len < NLMSG_HDRLEN ||
+           nlh->nlmsg_len < NLMSG_HDRLEN ||
            skb->len < nlh->nlmsg_len)
                return;
 
index 08679ebb3068298a58a081926c6a7dd5a2a73d17..e3c4c6c3fef7f274aef72cda0d21fc00c72de24a 100644 (file)
@@ -629,6 +629,34 @@ ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone,
        return ct;
 }
 
+static
+struct nf_conn *ovs_ct_executed(struct net *net,
+                               const struct sw_flow_key *key,
+                               const struct ovs_conntrack_info *info,
+                               struct sk_buff *skb,
+                               bool *ct_executed)
+{
+       struct nf_conn *ct = NULL;
+
+       /* If no ct, check if we have evidence that an existing conntrack entry
+        * might be found for this skb.  This happens when we lose a skb->_nfct
+        * due to an upcall, or if the direction is being forced.  If the
+        * connection was not confirmed, it is not cached and needs to be run
+        * through conntrack again.
+        */
+       *ct_executed = (key->ct_state & OVS_CS_F_TRACKED) &&
+                      !(key->ct_state & OVS_CS_F_INVALID) &&
+                      (key->ct_zone == info->zone.id);
+
+       if (*ct_executed || (!key->ct_state && info->force)) {
+               ct = ovs_ct_find_existing(net, &info->zone, info->family, skb,
+                                         !!(key->ct_state &
+                                         OVS_CS_F_NAT_MASK));
+       }
+
+       return ct;
+}
+
 /* Determine whether skb->_nfct is equal to the result of conntrack lookup. */
 static bool skb_nfct_cached(struct net *net,
                            const struct sw_flow_key *key,
@@ -637,24 +665,17 @@ static bool skb_nfct_cached(struct net *net,
 {
        enum ip_conntrack_info ctinfo;
        struct nf_conn *ct;
+       bool ct_executed = true;
 
        ct = nf_ct_get(skb, &ctinfo);
-       /* If no ct, check if we have evidence that an existing conntrack entry
-        * might be found for this skb.  This happens when we lose a skb->_nfct
-        * due to an upcall.  If the connection was not confirmed, it is not
-        * cached and needs to be run through conntrack again.
-        */
-       if (!ct && key->ct_state & OVS_CS_F_TRACKED &&
-           !(key->ct_state & OVS_CS_F_INVALID) &&
-           key->ct_zone == info->zone.id) {
-               ct = ovs_ct_find_existing(net, &info->zone, info->family, skb,
-                                         !!(key->ct_state
-                                            & OVS_CS_F_NAT_MASK));
-               if (ct)
-                       nf_ct_get(skb, &ctinfo);
-       }
        if (!ct)
+               ct = ovs_ct_executed(net, key, info, skb, &ct_executed);
+
+       if (ct)
+               nf_ct_get(skb, &ctinfo);
+       else
                return false;
+
        if (!net_eq(net, read_pnet(&ct->ct_net)))
                return false;
        if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct)))
@@ -679,7 +700,7 @@ static bool skb_nfct_cached(struct net *net,
                return false;
        }
 
-       return true;
+       return ct_executed;
 }
 
 #ifdef CONFIG_NF_NAT_NEEDED
index e3beb28203ebe06a4192ff80d4d0eb3b3741cf41..008bb34ee3240495ecb0ed65bf55d5edd20e1186 100644 (file)
@@ -214,6 +214,7 @@ static void prb_clear_rxhash(struct tpacket_kbdq_core *,
 static void prb_fill_vlan_info(struct tpacket_kbdq_core *,
                struct tpacket3_hdr *);
 static void packet_flush_mclist(struct sock *sk);
+static void packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb);
 
 struct packet_skb_cb {
        union {
@@ -260,6 +261,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
        if (skb != orig_skb)
                goto drop;
 
+       packet_pick_tx_queue(dev, skb);
        txq = skb_get_tx_queue(dev, skb);
 
        local_bh_disable();
@@ -2747,8 +2749,6 @@ tpacket_error:
                        goto tpacket_error;
                }
 
-               packet_pick_tx_queue(dev, skb);
-
                skb->destructor = tpacket_destruct_skb;
                __packet_set_status(po, ph, TP_STATUS_SENDING);
                packet_inc_pending(&po->tx_ring);
@@ -2931,8 +2931,6 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
        skb->priority = sk->sk_priority;
        skb->mark = sockc.mark;
 
-       packet_pick_tx_queue(dev, skb);
-
        if (po->has_vnet_hdr) {
                err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le());
                if (err)
index e81aa176f4e2c3f42a6ba75769b5d42142c7e3c4..41b9f0f5bb9c7fac6f23efb8fe535dfa8b2f4530 100644 (file)
@@ -170,8 +170,8 @@ restart:
         * The acquire_in_xmit() check above ensures that only one
         * caller can increment c_send_gen at any time.
         */
-       cp->cp_send_gen++;
-       send_gen = cp->cp_send_gen;
+       send_gen = READ_ONCE(cp->cp_send_gen) + 1;
+       WRITE_ONCE(cp->cp_send_gen, send_gen);
 
        /*
         * rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT,
@@ -431,7 +431,7 @@ over_batch:
                smp_mb();
                if ((test_bit(0, &conn->c_map_queued) ||
                     !list_empty(&cp->cp_send_queue)) &&
-                   send_gen == cp->cp_send_gen) {
+                       send_gen == READ_ONCE(cp->cp_send_gen)) {
                        rds_stats_inc(s_send_lock_queue_raced);
                        if (batch_count < send_batch_count)
                                goto restart;
index aed6cf2e9fd87792e5124838466a98045fd60ce4..f2e9ed34a963e1a06dbefb792836919d92bf6733 100644 (file)
@@ -835,7 +835,7 @@ out_nlmsg_trim:
 }
 
 static int
-act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
+tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
               struct list_head *actions, int event)
 {
        struct sk_buff *skb;
@@ -1018,7 +1018,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
        }
 
        if (event == RTM_GETACTION)
-               ret = act_get_notify(net, portid, n, &actions, event);
+               ret = tcf_get_notify(net, portid, n, &actions, event);
        else { /* delete */
                ret = tcf_del_notify(net, n, &actions, portid);
                if (ret)
index 4e16b02ed8321fcbd022cee0ed2c9d9c90d422a6..6110447fe51dcbd206cf0e3bf78d4746f0854d3e 100644 (file)
@@ -228,7 +228,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
        sctp_adaptation_ind_param_t aiparam;
        sctp_supported_ext_param_t ext_param;
        int num_ext = 0;
-       __u8 extensions[3];
+       __u8 extensions[4];
        struct sctp_paramhdr *auth_chunks = NULL,
                        *auth_hmacs = NULL;
 
@@ -396,7 +396,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
        sctp_adaptation_ind_param_t aiparam;
        sctp_supported_ext_param_t ext_param;
        int num_ext = 0;
-       __u8 extensions[3];
+       __u8 extensions[4];
        struct sctp_paramhdr *auth_chunks = NULL,
                        *auth_hmacs = NULL,
                        *auth_random = NULL;
index 7e0405e1651d23ea80b2f000495e199a561eca72..412a7c82995ae1cb595f6eb1637703ae8a1a359b 100644 (file)
@@ -120,7 +120,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
 int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
                       size_t insns_cnt, int strict_alignment,
                       const char *license, __u32 kern_version,
-                      char *log_buf, size_t log_buf_sz)
+                      char *log_buf, size_t log_buf_sz, int log_level)
 {
        union bpf_attr attr;
 
@@ -131,7 +131,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
        attr.license = ptr_to_u64(license);
        attr.log_buf = ptr_to_u64(log_buf);
        attr.log_size = log_buf_sz;
-       attr.log_level = 2;
+       attr.log_level = log_level;
        log_buf[0] = 0;
        attr.kern_version = kern_version;
        attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
index 16de44a14b48706886ef77e37abed2bafa8e8fc1..418c86e69bcbfae71d93d07c7054afa08b149c18 100644 (file)
@@ -38,7 +38,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
 int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
                       size_t insns_cnt, int strict_alignment,
                       const char *license, __u32 kern_version,
-                      char *log_buf, size_t log_buf_sz);
+                      char *log_buf, size_t log_buf_sz, int log_level);
 
 int bpf_map_update_elem(int fd, const void *key, const void *value,
                        __u64 flags);
index bccebd935907a894afbe835f6ea480131559b9ea..29793694cbc79c3efeb100fed07df8930ec5e62c 100644 (file)
@@ -380,7 +380,7 @@ static int do_test_single(struct bpf_align_test *test)
        prog_len = probe_filter_length(prog);
        fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
                                     prog, prog_len, 1, "GPL", 0,
-                                    bpf_vlog, sizeof(bpf_vlog));
+                                    bpf_vlog, sizeof(bpf_vlog), 2);
        if (fd_prog < 0) {
                printf("Failed to load program.\n");
                printf("%s", bpf_vlog);
index 404aec5208128101812f6c9189ed046d1ec6eb24..af7d173910f4b71023badb38011a27179f92fdf9 100644 (file)
@@ -4969,7 +4969,7 @@ static struct bpf_test tests[] = {
                        BPF_JMP_IMM(BPF_JSGT, BPF_REG_2,
                                sizeof(struct test_val), 4),
                        BPF_MOV64_IMM(BPF_REG_4, 0),
-                       BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2),
                        BPF_MOV64_IMM(BPF_REG_3, 0),
                        BPF_EMIT_CALL(BPF_FUNC_probe_read),
                        BPF_MOV64_IMM(BPF_REG_0, 0),
@@ -4995,7 +4995,7 @@ static struct bpf_test tests[] = {
                        BPF_JMP_IMM(BPF_JSGT, BPF_REG_2,
                                sizeof(struct test_val) + 1, 4),
                        BPF_MOV64_IMM(BPF_REG_4, 0),
-                       BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2),
                        BPF_MOV64_IMM(BPF_REG_3, 0),
                        BPF_EMIT_CALL(BPF_FUNC_probe_read),
                        BPF_MOV64_IMM(BPF_REG_0, 0),
@@ -5023,7 +5023,7 @@ static struct bpf_test tests[] = {
                        BPF_JMP_IMM(BPF_JSGT, BPF_REG_2,
                                sizeof(struct test_val) - 20, 4),
                        BPF_MOV64_IMM(BPF_REG_4, 0),
-                       BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2),
                        BPF_MOV64_IMM(BPF_REG_3, 0),
                        BPF_EMIT_CALL(BPF_FUNC_probe_read),
                        BPF_MOV64_IMM(BPF_REG_0, 0),
@@ -5050,7 +5050,7 @@ static struct bpf_test tests[] = {
                        BPF_JMP_IMM(BPF_JSGT, BPF_REG_2,
                                sizeof(struct test_val) - 19, 4),
                        BPF_MOV64_IMM(BPF_REG_4, 0),
-                       BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2),
                        BPF_MOV64_IMM(BPF_REG_3, 0),
                        BPF_EMIT_CALL(BPF_FUNC_probe_read),
                        BPF_MOV64_IMM(BPF_REG_0, 0),
@@ -5510,6 +5510,476 @@ static struct bpf_test tests[] = {
                .errstr = "invalid bpf_context access",
                .prog_type = BPF_PROG_TYPE_LWT_IN,
        },
+       {
+               "bounds checks mixing signed and unsigned, positive bounds",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 3),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 4, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 2",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5),
+                       BPF_MOV64_IMM(BPF_REG_8, 0),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_1),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8),
+                       BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R8 invalid mem access 'inv'",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 3",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 4),
+                       BPF_MOV64_REG(BPF_REG_8, BPF_REG_1),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8),
+                       BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R8 invalid mem access 'inv'",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 4",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 1),
+                       BPF_ALU64_REG(BPF_AND, BPF_REG_1, BPF_REG_2),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 5",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 4),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 4),
+                       BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 invalid mem access",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 6",
+               .insns = {
+                       BPF_MOV64_IMM(BPF_REG_2, 0),
+                       BPF_MOV64_REG(BPF_REG_3, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -512),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_6, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_4, BPF_REG_6, 5),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_4, 1, 4),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 1),
+                       BPF_MOV64_IMM(BPF_REG_5, 0),
+                       BPF_ST_MEM(BPF_H, BPF_REG_10, -512, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_skb_load_bytes),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .errstr_unpriv = "R4 min value is negative, either use unsigned",
+               .errstr = "R4 min value is negative, either use unsigned",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 7",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 8",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024 + 1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 9",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 10",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_LD_IMM64(BPF_REG_2, -9223372036854775808ULL),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 11",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 0),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 12",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2),
+                       /* Dead branch. */
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 13",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -6),
+                       BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 14",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, 2),
+                       BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_7, 1),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 0, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_7, BPF_REG_1),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 4, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_7),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 15",
+               .insns = {
+                       BPF_LDX_MEM(BPF_W, BPF_REG_9, BPF_REG_1,
+                                   offsetof(struct __sk_buff, mark)),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -1),
+                       BPF_MOV64_IMM(BPF_REG_8, 2),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_9, 42, 6),
+                       BPF_JMP_REG(BPF_JSGT, BPF_REG_8, BPF_REG_1, 3),
+                       BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, -3),
+                       BPF_JMP_IMM(BPF_JA, 0, 0, -7),
+               },
+               .fixup_map1 = { 4 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
+       {
+               "bounds checks mixing signed and unsigned, variant 16",
+               .insns = {
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+                       BPF_LD_MAP_FD(BPF_REG_1, 0),
+                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+                                    BPF_FUNC_map_lookup_elem),
+                       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
+                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8),
+                       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16),
+                       BPF_MOV64_IMM(BPF_REG_2, -6),
+                       BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
+                       BPF_JMP_IMM(BPF_JGT, BPF_REG_0, 1, 2),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+                       BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0),
+                       BPF_MOV64_IMM(BPF_REG_0, 0),
+                       BPF_EXIT_INSN(),
+               },
+               .fixup_map1 = { 3 },
+               .errstr_unpriv = "R0 pointer arithmetic prohibited",
+               .errstr = "R0 min value is negative",
+               .result = REJECT,
+               .result_unpriv = REJECT,
+       },
 };
 
 static int probe_filter_length(const struct bpf_insn *fp)
@@ -5633,7 +6103,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 
        fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
                                     prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT,
-                                    "GPL", 0, bpf_vlog, sizeof(bpf_vlog));
+                                    "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1);
 
        expected_ret = unpriv && test->result_unpriv != UNDEF ?
                       test->result_unpriv : test->result;