Re: [PATCH][rds-next] rds: make functions rds_info_from_znotifier and rds_message_zcopy_from_user static

2018-03-12 Thread santosh.shilim...@oracle.com

On 3/11/18 11:54 PM, santosh.shilim...@oracle.com wrote:

On 3/11/18 10:03 AM, Colin King wrote:

From: Colin Ian King 

Functions rds_info_from_znotifier and rds_message_zcopy_from_user are
local to the source and do not need to be in global scope, so make them
static.

Cleans up sparse warnins:
net/rds/message.c:70:27: warning: symbol 'rds_info_from_znotifier' was
not declared. Should it be static?
net/rds/message.c:358:5: warning: symbol 'rds_message_zcopy_from_user'
was not declared. Should it be static?

Signed-off-by: Colin Ian King 
---
  net/rds/message.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)


Acked-by: Santosh Shilimkar 


This was fixed by kbuild robot and the fix is already in net-next.

Regards,
Santosh


Re: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

2018-03-12 Thread santosh.shilim...@oracle.com

On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:

Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca 
---

Thanks for both VLA fixes Salvatore.

FWIW, Acked-by: Santosh Shilimkar 


Re: [PATCH 2/2] net: rds: drop VLA in rds_walk_conn_path_info()

2018-03-12 Thread santosh.shilim...@oracle.com

On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:

Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca 
---

Acked-by: Santosh Shilimkar 


Re: [pci PATCH v4 1/4] pci-iov: Add support for unmanaged SR-IOV

2018-03-12 Thread Christoph Hellwig
On Sun, Mar 11, 2018 at 09:59:09PM -0600, Alex Williamson wrote:
> I still struggle to understand why we need this "unmanaged"
> complication and how a user of the sysfs API is expected to have any
> idea whether a PF is managed or unmanaged and why they should care.
> Can't we just have a pci_simple_sriov_configure() helper and ignore
> this unmanaged business?  Thanks,

Just a pci_simple_sriov_configure is exactly what I envisioned originally.


Re: KASAN: use-after-free Read in sctp_association_free (2)

2018-03-12 Thread Xin Long
On Sun, Mar 11, 2018 at 3:04 AM, Neil Horman  wrote:
> On Sun, Mar 11, 2018 at 12:22:32AM +0800, Xin Long wrote:
>> On Sat, Mar 10, 2018 at 9:13 PM, Neil Horman  wrote:
>> > On Sat, Mar 10, 2018 at 03:58:04PM +0800, Xin Long wrote:
>> >> On Sat, Mar 10, 2018 at 6:08 AM, Neil Horman  
>> >> wrote:
>> >> > On Fri, Mar 09, 2018 at 12:59:06PM -0800, syzbot wrote:
>> >> >> Hello,
>> >> >>
>> >> >> syzbot hit the following crash on net-next commit
>> >> >> fd372a7a9e5e9d8011a0222d10edd3523abcd3b1 (Thu Mar 8 19:43:48 2018 
>> >> >> +)
>> >> >> Merge tag 'mlx5-updates-2018-02-28-2' of
>> >> >> git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux
>> >> >>
>> >> >> So far this crash happened 2 times on net-next.
>> >> >> C reproducer is attached.
>> >> >> syzkaller reproducer is attached.
>> >> >> Raw console output is attached.
>> >> >> compiler: gcc (GCC) 7.1.1 20170620
>> >> >> .config is attached.
>> >> >>
>> >> >> IMPORTANT: if you fix the bug, please add the following tag to the 
>> >> >> commit:
>> >> >> Reported-by: syzbot+a4e4112c3aff00c8c...@syzkaller.appspotmail.com
>> >> >> It will help syzbot understand when the bug is fixed. See footer for
>> >> >> details.
>> >> >> If you forward the report, please keep this part and the footer.
>> >> >>
>> >> >> IPVS: ftp: loaded support on port[0] = 21
>> >> >> IPVS: ftp: loaded support on port[0] = 21
>> >> >> IPVS: ftp: loaded support on port[0] = 21
>> >> >> IPVS: ftp: loaded support on port[0] = 21
>> >> >> ==
>> >> >> BUG: KASAN: use-after-free in sctp_association_free+0x7b7/0x930
>> >> >> net/sctp/associola.c:332
>> >> >> Read of size 8 at addr 8801d8006ae0 by task syzkaller914861/4202
>> >> >>
>> >> >> CPU: 1 PID: 4202 Comm: syzkaller914861 Not tainted 4.16.0-rc4+ #258
>> >> >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
>> >> >> Google 01/01/2011
>> >> >> Call Trace:
>> >> >>  __dump_stack lib/dump_stack.c:17 [inline]
>> >> >>  dump_stack+0x194/0x24d lib/dump_stack.c:53
>> >> >>  print_address_description+0x73/0x250 mm/kasan/report.c:256
>> >> >>  kasan_report_error mm/kasan/report.c:354 [inline]
>> >> >>  kasan_report+0x23c/0x360 mm/kasan/report.c:412
>> >> >>  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
>> >> >>  sctp_association_free+0x7b7/0x930 net/sctp/associola.c:332
>> >> >>  sctp_sendmsg+0xc67/0x1a80 net/sctp/socket.c:2075
>> >> >>  inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763
>> >> >>  sock_sendmsg_nosec net/socket.c:629 [inline]
>> >> >>  sock_sendmsg+0xca/0x110 net/socket.c:639
>> >> >>  SYSC_sendto+0x361/0x5c0 net/socket.c:1748
>> >> >>  SyS_sendto+0x40/0x50 net/socket.c:1716
>> >> >>  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
>> >> >>  entry_SYSCALL_64_after_hwframe+0x42/0xb7
>> >> >> RIP: 0033:0x446d09
>> >> >> RSP: 002b:7f5dbac21da8 EFLAGS: 0216 ORIG_RAX: 002c
>> >> >> RAX: ffda RBX: 006e29fc RCX: 00446d09
>> >> >> RDX: 0001 RSI: 2340 RDI: 0003
>> >> >> RBP: 006e29f8 R08: 204d9000 R09: 001c
>> >> >> R10:  R11: 0216 R12: 
>> >> >> R13: 7fff7b26fb1f R14: 7f5dbac229c0 R15: 006e2b60
>> >> >>
>> >> > I think we have a corner case with 
>> >> > a0ff660058b88d12625a783ce9e5c1371c87951f
>> >> > here.  If a peeloff event happens during a wait for sendbuf space, 
>> >> > EPIPE will be
>> >> > returned, and the code path appears to call sctp_association_put twice, 
>> >> > leading
>> >> > to the use after free situation.  I'll write a patch this weekend
>> >> Hi, Neil, you're right.
>> >>
>> >> I didn't expect peeloff can be done on a NEW asoc, as peeloff needs
>> >> assoc_id, which can only be set when connecting has started.
>> >>
>> >> But I realized that:
>> >> f84af33 sctp: factor out sctp_sendmsg_to_asoc from sctp_sendmsg
>> >>
>> >> moved sctp_primitive_ASSOCIATE(connecting) before sctp_wait_for_sndbuf
>> >> (snd buffer waiting). It means peeloff can be done on a NEW asoc.
>> >> So you may want to move it back.
>> >>
>> > I agree with the root cause, but I'm not sure I agree with just moving the
>> > wait_for_sndbuf call back above the call to associate.  I'm not sure I like
>> > relying on placing a call in a spcific order solely to avoid an error 
>> > condition
>> > that might legitimately occur.  I think would rather check the return code 
>> > at
>> > the call site for the complete set of conditions for which we should not 
>> > free
>> > the association.  Something like this:
>> >
>> > diff --git a/net/sctp/socket.c b/net/sctp/socket.c
>> > index 7d3476a4860d..a68846d2b0ef 100644
>> > --- a/net/sctp/socket.c
>> > +++ b/net/sctp/socket.c
>> > @@ -2071,8 +2071,9 @@ static int sctp_sendmsg(struct sock *sk, struct 
>> > msghdr *msg, size_t msg_len)
>> >
>> > /* Send msg to the asoc */
>> > err = sctp_sendmsg_to_asoc(asoc, ms

Re: [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'

2018-03-12 Thread Tariq Toukan



On 12/03/2018 12:45 AM, Christophe JAILLET wrote:

If 'kzalloc' fails, we must free some memory before returning.

Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET 
---
  drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 8fc51bc29003..f9db018e858f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
if (!priv->tx_cq[t]) {
kfree(priv->tx_ring[t]);
err = -ENOMEM;
-   goto out;
+   goto err_free_tx;
}
}
priv->rx_ring_num = prof->rx_ring_num;



Hi Christophe, thanks for spotting this.

However, I think these err_free_tx label and loop are redundant.
Both tx_ring/tx_cq flows should just goto out, as resources are freed 
later in mlx4_en_destroy_netdev() -> mlx4_en_free_resources().


[PATCH v4 5/6] staging: fsl-dpaa2/ethsw: Add README

2018-03-12 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1



[PATCH v4 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2018-03-12 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- remove fsl-mc bus driver dependency as it is out of staging

 drivers/staging/fsl-dpaa2/ethsw/TODO | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d186875
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,13 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+dpio driver is moved to drivers/soc (this is required for I/O).
+
-- 
1.9.1



[PATCH v4 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index c3c2b75..20d7bf2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4410,6 +4410,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.9.1



[PATCH v4 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2018-03-12 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- fix sparse warnings

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1116 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2069 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..36edef6
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE 

[PATCH v4 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2018-03-12 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- no changes
 v3:
- removed driver version
 v4:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 206 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   1 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   2 +
 7 files changed, 287 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 36edef6..c45f001 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 8e52d74..e63531d 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, &cmd);
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index d13970c..5a0c7ad 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure representing DPSW link state
  * @rate: Rate
  * @

[PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean 
Signed-off-by: Razvan Stefanescu 
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- support adding/deleting multicast entries to/from FDB
- selectively discard benign MC errors for calling add/delete fdb entries
  multiple times to avoid spamming console with stack traces
- refactor setting TCI to avoid code duplication
- clean probe code error path

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1515 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1604 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..b992434
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1515 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, &vcfg);
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
+ struct dpsw_tci_cfg *tci_cfg)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   bool is_oper;
+   int err, ret;
+
+   /* Interface needs to be down to change PVID */
+   is_ope

Re: [PATCH net v2 2/2] l2tp: fix races with ipv4-mapped ipv6 addresses

2018-03-12 Thread Paolo Abeni
On Fri, 2018-03-09 at 19:26 +0100, Guillaume Nault wrote:
> On Fri, Mar 09, 2018 at 06:58:00PM +0100, Paolo Abeni wrote:
> > The single threaded reproducer does not trigger anymore after 1/2,
> > _but_ if ask syzbot to test 1/2 that will trigger another splat,
> > because syzbot will do also multi threaded tests and we will hit the
> > race between connect(tunnel->fd) and l2tp_tunnel_create(),
> > 
> 
> Ok, and this case is handled by the sk_state test in l2tp_xmit_skb(),
> right?

We need both such test and checking for v4mapped address in
l2tp_xmit_skb()

> I just want to be sure that I didn't miss anything and that patch 1/2
> combined with the socket state check in l2tp_xmit_skb() are enough to
> fix the bug. And that overriding ->inet_*addr can be removed entirely
> (and safely!).

I tested the above in vs the repro and in some real use case, but any
additinal pair of eyes are welcome!

I'll send v3 soon.

Cheers,

Paolo


[PATCH] can: m_can: select pinctrl state in each suspend/resume function

2018-03-12 Thread Bich HEMON
Make sure to apply the correct pin state in suspend/resume callbacks.
Putting pins in sleep state saves power.

Signed-off-by: Bich Hemon 
---
 drivers/net/can/m_can/m_can.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 2594f77..a86ef69 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1700,6 +1700,8 @@ static __maybe_unused int m_can_suspend(struct device 
*dev)
m_can_clk_stop(priv);
}
 
+   pinctrl_pm_select_sleep_state(dev);
+
priv->can.state = CAN_STATE_SLEEPING;
 
return 0;
@@ -1710,6 +1712,8 @@ static __maybe_unused int m_can_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct m_can_priv *priv = netdev_priv(ndev);
 
+   pinctrl_pm_select_default_state(dev);
+
m_can_init_ram(priv);
 
priv->can.state = CAN_STATE_ERROR_ACTIVE;
-- 
1.9.1


[PATCH v4 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.

 v3: addressed comments from Andrew L. (patch 3/6 updated)

 v4: adjust to moving MC-bus out of staging
 support adding/deleting multicast entries to/from FDB
 avoid triggering console stack traces due to benign MC errors
 refactor TCI setting code to avoid code duplication
 fix sparse warning

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1148 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  206 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1516 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   90 ++
 12 files changed, 4083 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1



Re: [PATCH net-next] net: stmmac: remove superfluous wmb() memory barriers

2018-03-12 Thread Niklas Cassel
On Fri, Mar 09, 2018 at 10:15:20AM -0500, David Miller wrote:
> From: Jose Abreu 
> Date: Fri, 9 Mar 2018 10:26:11 +
> 
> > Sorry but I know at least two architectures which don't do a
> > wmb() upon an writel [1] [2]. This can be critical if if we are
> > accessing the device through some slow or filled bus which will
> > delay accesses to the device IO. Notice that writel and then
> > readl to the same address will force CPU to wait for writel
> > completion before readl, but in this case we are using DMA and
> > then writel so I think a wmb() before the writel is a safe measure.
> 
> Wait a second.
> 
> This is not about whether there is an explicit memory barrier
> instruction placed in the writel() implementation.
> 
> Are you saying that the cpu(s) in question will reorder stores in
> their store buffers, even if they are to real memory vs. IOMEM?
> 
> That's really dangerous.

Hello David,

Jose is simply responding to the commit message description of this patch.

You explained that there is an implicit memory barrier between physical memory
writes and those to MMIO register space, as long as you used writel().

I assumed that you meant writel() vs writel_relaxed(), where there latter
does not do an implicit barrier.

I also found this from you:
https://lwn.net/Articles/198995/

If my assumption was incorrect, please correct me.

As you seem to possess knowledge regarding this, you are probably the most
suited person to know if this patch simply needs a commit message rewrite,
or if it should be dropped completely.


Best regards,
Niklas


Re: [PATCH] can: m_can: select pinctrl state in each suspend/resume function

2018-03-12 Thread Marc Kleine-Budde
On 03/12/2018 09:52 AM, Bich HEMON wrote:
> Make sure to apply the correct pin state in suspend/resume callbacks.
> Putting pins in sleep state saves power.
> 
> Signed-off-by: Bich Hemon 
> ---

Doesn't compile:

>   CHECK   /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1703:9: 
> error: undefined identifier 'pinctrl_pm_select_sleep_state'
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1715:9: 
> error: undefined identifier 'pinctrl_pm_select_default_state'
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1703:38: 
> warning: call with no type!
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1715:40: 
> warning: call with no type!
>   CC [M]  drivers/net/can/m_can/m_can.o
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c: In function 
> 'm_can_suspend':
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1703:2: 
> error: implicit declaration of function 'pinctrl_pm_select_sleep_state' 
> [-Werror=implicit-function-declaration]
>   pinctrl_pm_select_sleep_state(dev);
>   ^
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c: In function 
> 'm_can_resume':
> /srv/work/frogger/socketcan/linux/drivers/net/can/m_can/m_can.c:1715:2: 
> error: implicit declaration of function 'pinctrl_pm_select_default_state' 
> [-Werror=implicit-function-declaration]
>   pinctrl_pm_select_default_state(dev);
>   ^

Fixed while applying the patch.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [RESEND] rsi: Remove stack VLA usage

2018-03-12 Thread Kalle Valo
tcharding  wrote:

> The kernel would like to have all stack VLA usage removed[1].  rsi uses
> a VLA based on 'blksize'.  Elsewhere in the SDIO code maximum block size
> is defined using a magic number.  We can use a pre-processor defined
> constant and declare the array to maximum size.  We add a check before
> accessing the array in case of programmer error.
> 
> [1]: https://lkml.org/lkml/2018/3/7/621
> 
> Signed-off-by: Tobin C. Harding 

Tobin, your name in patchwork.kernel.org is just "tcharding" then it should be
"Tobin C. Harding". Patchwork is braindead in a way as it takes the name from
it's database instead of the From header of the patch in question.

I can fix that manually but it would be helpful if you could register to
patchwork and fix your name during registration. You have only one chance to
fix your name (another braindead feature!) so be careful :)

-- 
https://patchwork.kernel.org/patch/10274983/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw

2018-03-12 Thread Rafał Miłecki
On 27 February 2018 at 18:05, Stephen Hemminger
 wrote:
> On Tue, 27 Feb 2018 11:08:20 +0100
> Rafał Miłecki  wrote:
>
>> I've problem when using OpenWrt/LEDE on a home router with Broadcom's
>> FullMAC WiFi chipset.
>>
>>
>> First of all OpenWrt/LEDE uses bridge interface for LAN network with:
>> 1) IFLA_BRPORT_MCAST_TO_UCAST
>> 2) Clients isolation in hostapd
>> 3) Hairpin mode enabled
>>
>> For more details please see Linus's patch description:
>> https://patchwork.kernel.org/patch/9530669/
>> and maybe hairpin mode patch:
>> https://lwn.net/Articles/347344/
>>
>> Short version: in that setup packets received from a bridged wireless
>> interface can be handled back to it for transmission.
>>
>>
>> Now, Broadcom's firmware for their FullMAC chipsets in AP mode
>> supports an obsoleted 802.11f AKA IAPP standard. It's a roaming
>> standard that was replaced by 802.11r.
>>
>> Whenever a new station associates, firmware generates a packet like:
>> ff ff ff ff  ff ff ec 10  7b 5f ?? ??  00 06 00 01  af 81 01 00
>> (just masked 2 bytes of my MAC)
>>
>> For mode details you can see discussion in my brcmfmac patch thread:
>> https://patchwork.kernel.org/patch/10191451/
>>
>>
>> The problem is that bridge (in setup as above) handles such a packet
>> back to the device.
>>
>> That makes Broadcom's FullMAC firmware believe that a given station
>> just connected to another AP in a network (which doesn't even exist).
>> As a result firmware immediately disassociates that station. It's
>> simply impossible to connect to the router. Every association is
>> followed by immediate disassociation.
>>
>>
>> Can you see any solution for this problem? Is that an option to stop
>> multicast-to-unicast from touching 802.11f packets? Some other ideas?
>> Obviously I can't modify Broadcom's firmware and drop that obsoleted
>> standard.
>>
>
> ebtables is your friend in dealing with weird and broken devices.

It may be weird, not sure if actually broken. Anyway I'd like to have
some generic solution instead of telling every user to use ebtables to
workaround the problem.

-- 
Rafał


Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw

2018-03-12 Thread Rafał Miłecki
On 28 February 2018 at 12:31, Arend van Spriel
 wrote:
> On 2/27/2018 11:14 AM, Rafał Miłecki wrote:
>>
>> Sending with a fixed linux-wireless ML address. Please kindly send your
>> replies using linux-wireless@
>>
>> On 02/27/2018 11:08 AM, Rafał Miłecki wrote:
>>>
>>> I've problem when using OpenWrt/LEDE on a home router with Broadcom's
>>> FullMAC WiFi chipset.
>>>
>>>
>>> First of all OpenWrt/LEDE uses bridge interface for LAN network with:
>>> 1) IFLA_BRPORT_MCAST_TO_UCAST
>>> 2) Clients isolation in hostapd
>>> 3) Hairpin mode enabled
>>>
>>> For more details please see Linus's patch description:
>>> https://patchwork.kernel.org/patch/9530669/
>>> and maybe hairpin mode patch:
>>> https://lwn.net/Articles/347344/
>>>
>>> Short version: in that setup packets received from a bridged wireless
>>> interface can be handled back to it for transmission.
>>>
>>>
>>> Now, Broadcom's firmware for their FullMAC chipsets in AP mode
>>> supports an obsoleted 802.11f AKA IAPP standard. It's a roaming
>>> standard that was replaced by 802.11r.
>>>
>>> Whenever a new station associates, firmware generates a packet like:
>>> ff ff ff ff  ff ff ec 10  7b 5f ?? ??  00 06 00 01  af 81 01 00
>>> (just masked 2 bytes of my MAC)
>>>
>>> For mode details you can see discussion in my brcmfmac patch thread:
>>> https://patchwork.kernel.org/patch/10191451/
>>>
>>>
>>> The problem is that bridge (in setup as above) handles such a packet
>>> back to the device.
>
>
> From reading the referenced links I understand the hairpin mode is causing
> the packet to be sent back to the device, and the hairpin mode is required
> for MCAST_TO_UCAST, right?
>
>>> That makes Broadcom's FullMAC firmware believe that a given station
>>> just connected to another AP in a network (which doesn't even exist).
>>> As a result firmware immediately disassociates that station. It's
>>> simply impossible to connect to the router. Every association is
>>> followed by immediate disassociation.
>>>
>>>
>>> Can you see any solution for this problem? Is that an option to stop
>>> multicast-to-unicast from touching 802.11f packets? Some other ideas?
>>> Obviously I can't modify Broadcom's firmware and drop that obsoleted
>>> standard.
>
>
> As far as I can tell you are correct that the 802.11f amendment was never
> adopted into the 802.11 standard. I will ask internally if we still have a
> reason for carrying it in our firmware.

Thanks! Having at least a way to disable it would be nice.

That said I think we still should look for a solution for existing
firmwares. I guess it may takes months to years to never to release
new firmwares for all supported chipsets.

-- 
Rafał


[PATCH net-next] net: Make RX-FCS and HW GRO mutually exclusive

2018-03-12 Thread Gal Pressman
Same as LRO, hardware GRO cannot be enabled with RX-FCS.
When both are requested, hardware GRO will be dropped.

Suggested-by: David Miller 
Signed-off-by: Gal Pressman 
---
 net/core/dev.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 1bc3792..fd87c2c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7542,10 +7542,17 @@ static netdev_features_t netdev_fix_features(struct 
net_device *dev,
}
}
 
-   /* LRO feature cannot be combined with RX-FCS */
-   if ((features & NETIF_F_LRO) && (features & NETIF_F_RXFCS)) {
-   netdev_dbg(dev, "Dropping LRO feature since RX-FCS is 
requested.\n");
-   features &= ~NETIF_F_LRO;
+   /* LRO/HW-GRO features cannot be combined with RX-FCS */
+   if (features & NETIF_F_RXFCS) {
+   if (features & NETIF_F_LRO) {
+   netdev_dbg(dev, "Dropping LRO feature since RX-FCS is 
requested.\n");
+   features &= ~NETIF_F_LRO;
+   }
+
+   if (features & NETIF_F_GRO_HW) {
+   netdev_dbg(dev, "Dropping HW-GRO feature since RX-FCS 
is requested.\n");
+   features &= ~NETIF_F_GRO_HW;
+   }
}
 
return features;
-- 
2.7.4



[BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
Since the kprobe which was optimized by jump can not change
the execution path, the kprobe for error-injection must not
be optimized. To prohibit it, set a dummy post-handler as
officially stated in Documentation/kprobes.txt.

Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
Signed-off-by: Masami Hiramatsu 
---
 kernel/fail_function.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index 21b0122cb39c..1d5632d8bbcc 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -14,6 +14,15 @@
 
 static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
 
+static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs,
+unsigned long flags)
+{
+   /*
+* A dummy post handler is required to prohibit optimizing, because
+* jump optimization does not support execution path overriding.
+*/
+}
+
 struct fei_attr {
struct list_head list;
struct kprobe kp;
@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, 
unsigned long addr)
return NULL;
}
attr->kp.pre_handler = fei_kprobe_handler;
+   attr->kp.post_handler = fei_post_handler;
attr->retval = adjust_error_retval(addr, 0);
INIT_LIST_HEAD(&attr->list);
}



pull-request: can 2018-03-12

2018-03-12 Thread Marc Kleine-Budde
Hello David,

this is a pull reqeust of 6 patches for net/master.

The first patch is by Wolfram Sang and fixes a bitshift vs. comparison mistake
in the m_can driver. Two patches of Marek Vasut repair the error handling in
the ifi driver. The two patches by Stephane Grosjean fix a "echo_skb is
occupied!" bug in the peak/pcie_fd driver. Bich HEMON's patch adds pinctrl
select state calls to the m_can's driver to further improve power saving during
suspend.

regards,
Marc

---

The following changes since commit ddc502dfed600bff0b61d899f70d95b76223fdfc:

  openvswitch: meter: fix the incorrect calculation of max delta_t (2018-03-11 
22:48:59 -0400)

are available in the Git repository at:

  ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git 
tags/linux-can-fixes-for-4.16-20180312

for you to fetch changes up to c9b3bce18da4a0aebc27853052dea39aa64b7d75:

  can: m_can: select pinctrl state in each suspend/resume function (2018-03-12 
10:38:20 +0100)


linux-can-fixes-for-4.16-20180312


Bich HEMON (1):
  can: m_can: select pinctrl state in each suspend/resume function

Marek Vasut (2):
  can: ifi: Check core revision upon probe
  can: ifi: Repair the error handling

Stephane Grosjean (2):
  can: peak/pcie_fd: fix echo_skb is occupied! bug
  can: peak/pcie_fd: remove useless code when interface starts

Wolfram Sang (1):
  can: m_can: change comparison to bitshift when dealing with a mask

 drivers/net/can/ifi_canfd/ifi_canfd.c | 75 +--
 drivers/net/can/m_can/m_can.c |  7 ++-
 drivers/net/can/peak_canfd/peak_canfd.c   | 25 +++--
 drivers/net/can/peak_canfd/peak_pciefd_main.c |  8 ++-
 4 files changed, 67 insertions(+), 48 deletions(-)



[PATCH 1/6] can: m_can: change comparison to bitshift when dealing with a mask

2018-03-12 Thread Marc Kleine-Budde
From: Wolfram Sang 

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Reported-by: Geert Uytterhoeven 
Signed-off-by: Wolfram Sang 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/m_can/m_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 2594f7779c6f..74170b0d23cf 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -253,7 +253,7 @@ enum m_can_mram_cfg {
 
 /* Rx FIFO 0/1 Configuration (RXF0C/RXF1C) */
 #define RXFC_FWM_SHIFT 24
-#define RXFC_FWM_MASK  (0x7f < RXFC_FWM_SHIFT)
+#define RXFC_FWM_MASK  (0x7f << RXFC_FWM_SHIFT)
 #define RXFC_FS_SHIFT  16
 #define RXFC_FS_MASK   (0x7f << RXFC_FS_SHIFT)
 
-- 
2.16.1



[PATCH 3/6] can: ifi: Repair the error handling

2018-03-12 Thread Marc Kleine-Budde
From: Marek Vasut 

The new version of the IFI CANFD core has significantly less complex
error state indication logic. In particular, the warning/error state
bits are no longer all over the place, but are all present in the
STATUS register. Moreover, there is a new IRQ register bit indicating
transition between error states (active/warning/passive/busoff).

This patch makes use of this bit to weed out the obscure selective
INTERRUPT register clearing, which was used to carry over the error
state indication into the poll function. While at it, this patch
fixes the handling of the ACTIVE state, since the hardware provides
indication of the core being in ACTIVE state and that in turn fixes
the state transition indication toward userspace. Finally, register
reads in the poll function are moved to the matching subfunctions
since those are also no longer needed in the poll function.

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Markus Marb 
Cc: Marc Kleine-Budde 
Cc: linux-stable 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 64 ---
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 9fd396c3569a..fedd927ba6ed 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -30,6 +30,7 @@
 #define IFI_CANFD_STCMD_ERROR_ACTIVE   BIT(2)
 #define IFI_CANFD_STCMD_ERROR_PASSIVE  BIT(3)
 #define IFI_CANFD_STCMD_BUSOFF BIT(4)
+#define IFI_CANFD_STCMD_ERROR_WARNING  BIT(5)
 #define IFI_CANFD_STCMD_BUSMONITOR BIT(16)
 #define IFI_CANFD_STCMD_LOOPBACK   BIT(18)
 #define IFI_CANFD_STCMD_DISABLE_CANFD  BIT(24)
@@ -52,7 +53,10 @@
 #define IFI_CANFD_TXSTCMD_OVERFLOW BIT(13)
 
 #define IFI_CANFD_INTERRUPT0xc
+#define IFI_CANFD_INTERRUPT_ERROR_BUSOFF   BIT(0)
 #define IFI_CANFD_INTERRUPT_ERROR_WARNING  BIT(1)
+#define IFI_CANFD_INTERRUPT_ERROR_STATE_CHGBIT(2)
+#define IFI_CANFD_INTERRUPT_ERROR_REC_TEC_INC  BIT(3)
 #define IFI_CANFD_INTERRUPT_ERROR_COUNTER  BIT(10)
 #define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY   BIT(16)
 #define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE  BIT(22)
@@ -61,6 +65,10 @@
 #define IFI_CANFD_INTERRUPT_SET_IRQ((u32)BIT(31))
 
 #define IFI_CANFD_IRQMASK  0x10
+#define IFI_CANFD_IRQMASK_ERROR_BUSOFF BIT(0)
+#define IFI_CANFD_IRQMASK_ERROR_WARNINGBIT(1)
+#define IFI_CANFD_IRQMASK_ERROR_STATE_CHG  BIT(2)
+#define IFI_CANFD_IRQMASK_ERROR_REC_TEC_INCBIT(3)
 #define IFI_CANFD_IRQMASK_SET_ERR  BIT(7)
 #define IFI_CANFD_IRQMASK_SET_TS   BIT(15)
 #define IFI_CANFD_IRQMASK_TXFIFO_EMPTY BIT(16)
@@ -222,7 +230,10 @@ static void ifi_canfd_irq_enable(struct net_device *ndev, 
bool enable)
 
if (enable) {
enirq = IFI_CANFD_IRQMASK_TXFIFO_EMPTY |
-   IFI_CANFD_IRQMASK_RXFIFO_NEMPTY;
+   IFI_CANFD_IRQMASK_RXFIFO_NEMPTY |
+   IFI_CANFD_IRQMASK_ERROR_STATE_CHG |
+   IFI_CANFD_IRQMASK_ERROR_WARNING |
+   IFI_CANFD_IRQMASK_ERROR_BUSOFF;
if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
enirq |= IFI_CANFD_INTERRUPT_ERROR_COUNTER;
}
@@ -363,12 +374,13 @@ static int ifi_canfd_handle_lost_msg(struct net_device 
*ndev)
return 1;
 }
 
-static int ifi_canfd_handle_lec_err(struct net_device *ndev, const u32 errctr)
+static int ifi_canfd_handle_lec_err(struct net_device *ndev)
 {
struct ifi_canfd_priv *priv = netdev_priv(ndev);
struct net_device_stats *stats = &ndev->stats;
struct can_frame *cf;
struct sk_buff *skb;
+   u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
const u32 errmask = IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST |
IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST |
IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST |
@@ -451,6 +463,11 @@ static int ifi_canfd_handle_state_change(struct net_device 
*ndev,
 
switch (new_state) {
case CAN_STATE_ERROR_ACTIVE:
+   /* error active state */
+   priv->can.can_stats.error_warning++;
+   priv->can.state = CAN_STATE_ERROR_ACTIVE;
+   break;
+   case CAN_STATE_ERROR_WARNING:
/* error warning state */
priv->can.can_stats.error_warning++;
priv->can.state = CAN_STATE_ERROR_WARNING;
@@ -479,7 +496,7 @@ static int ifi_canfd_handle_state_change(struct net_device 
*ndev,
ifi_canfd_get_berr_counter(ndev, &bec);
 
switch (new_state) {
-   case CAN_STATE_ERROR_ACTIVE:
+   case CAN_STATE_ERROR_WARNING:
/* error warning state */
cf->can_id |= CAN_ERR_CRTL;

[PATCH 4/6] can: peak/pcie_fd: fix echo_skb is occupied! bug

2018-03-12 Thread Marc Kleine-Budde
From: Stephane Grosjean 

This patch makes atomic the handling of the linux-can echo_skb array and
the network tx queue. This prevents from the "BUG! echo_skb is occupied!"
message to be printed by the linux-can core, in SMP environments.

Reported-by: Diana Burgess 
Signed-off-by: Stephane Grosjean 
Cc: linux-stable 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/peak_canfd/peak_canfd.c   | 12 ++--
 drivers/net/can/peak_canfd/peak_pciefd_main.c |  8 ++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c 
b/drivers/net/can/peak_canfd/peak_canfd.c
index 55513411a82e..6fa66231ed8e 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -262,7 +262,6 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
 
spin_lock_irqsave(&priv->echo_lock, flags);
can_get_echo_skb(priv->ndev, msg->client);
-   spin_unlock_irqrestore(&priv->echo_lock, flags);
 
/* count bytes of the echo instead of skb */
stats->tx_bytes += cf_len;
@@ -271,6 +270,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
/* restart tx queue (a slot is free) */
netif_wake_queue(priv->ndev);
 
+   spin_unlock_irqrestore(&priv->echo_lock, flags);
return 0;
}
 
@@ -726,11 +726,6 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff 
*skb,
 */
should_stop_tx_queue = !!(priv->can.echo_skb[priv->echo_idx]);
 
-   spin_unlock_irqrestore(&priv->echo_lock, flags);
-
-   /* write the skb on the interface */
-   priv->write_tx_msg(priv, msg);
-
/* stop network tx queue if not enough room to save one more msg too */
if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
should_stop_tx_queue |= (room_left <
@@ -742,6 +737,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff 
*skb,
if (should_stop_tx_queue)
netif_stop_queue(ndev);
 
+   spin_unlock_irqrestore(&priv->echo_lock, flags);
+
+   /* write the skb on the interface */
+   priv->write_tx_msg(priv, msg);
+
return NETDEV_TX_OK;
 }
 
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c 
b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index 788c3464a3b0..3c51a884db87 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -349,8 +349,12 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg)
priv->tx_pages_free++;
spin_unlock_irqrestore(&priv->tx_lock, flags);
 
-   /* wake producer up */
-   netif_wake_queue(priv->ucan.ndev);
+   /* wake producer up (only if enough room in echo_skb array) */
+   spin_lock_irqsave(&priv->ucan.echo_lock, flags);
+   if (!priv->ucan.can.echo_skb[priv->ucan.echo_idx])
+   netif_wake_queue(priv->ucan.ndev);
+
+   spin_unlock_irqrestore(&priv->ucan.echo_lock, flags);
}
 
/* re-enable Rx DMA transfer for this CAN */
-- 
2.16.1



[PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function

2018-03-12 Thread Marc Kleine-Budde
From: Bich HEMON 

Make sure to apply the correct pin state in suspend/resume callbacks.
Putting pins in sleep state saves power.

Signed-off-by: Bich Hemon 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/m_can/m_can.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 74170b0d23cf..b397a33f3d32 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* napi related */
 #define M_CAN_NAPI_WEIGHT  64
@@ -1700,6 +1701,8 @@ static __maybe_unused int m_can_suspend(struct device 
*dev)
m_can_clk_stop(priv);
}
 
+   pinctrl_pm_select_sleep_state(dev);
+
priv->can.state = CAN_STATE_SLEEPING;
 
return 0;
@@ -1710,6 +1713,8 @@ static __maybe_unused int m_can_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct m_can_priv *priv = netdev_priv(ndev);
 
+   pinctrl_pm_select_default_state(dev);
+
m_can_init_ram(priv);
 
priv->can.state = CAN_STATE_ERROR_ACTIVE;
-- 
2.16.1



[PATCH 2/6] can: ifi: Check core revision upon probe

2018-03-12 Thread Marc Kleine-Budde
From: Marek Vasut 

Older versions of the core are not compatible with the driver due
to various intrusive fixes of the core. Read out the VER register,
check the core revision bitfield and verify if the core in use is
new enough (rev 2.1 or newer) to work correctly with this driver.

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Markus Marb 
Cc: Marc Kleine-Budde 
Cc: linux-stable 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 2772d05ff11c..9fd396c3569a 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -136,6 +136,8 @@
 #define IFI_CANFD_SYSCLOCK 0x50
 
 #define IFI_CANFD_VER  0x54
+#define IFI_CANFD_VER_REV_MASK 0xff
+#define IFI_CANFD_VER_REV_MIN_SUPPORTED0x15
 
 #define IFI_CANFD_IP_ID0x58
 #define IFI_CANFD_IP_ID_VALUE  0xD073CAFD
@@ -933,7 +935,7 @@ static int ifi_canfd_plat_probe(struct platform_device 
*pdev)
struct resource *res;
void __iomem *addr;
int irq, ret;
-   u32 id;
+   u32 id, rev;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
addr = devm_ioremap_resource(dev, res);
@@ -947,6 +949,13 @@ static int ifi_canfd_plat_probe(struct platform_device 
*pdev)
return -EINVAL;
}
 
+   rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK;
+   if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) {
+   dev_err(dev, "This block is too old (rev %i), minimum supported 
is rev %i\n",
+   rev, IFI_CANFD_VER_REV_MIN_SUPPORTED);
+   return -EINVAL;
+   }
+
ndev = alloc_candev(sizeof(*priv), 1);
if (!ndev)
return -ENOMEM;
-- 
2.16.1



[PATCH 5/6] can: peak/pcie_fd: remove useless code when interface starts

2018-03-12 Thread Marc Kleine-Budde
From: Stephane Grosjean 

When an interface starts, the echo_skb array is empty and the network
queue should be started only. This patch replaces useless code and locks
when the internal RX_BARRIER message is received from the IP core, telling
the driver that tx may start.

Signed-off-by: Stephane Grosjean 
Cc: linux-stable 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/net/can/peak_canfd/peak_canfd.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/peak_canfd/peak_canfd.c 
b/drivers/net/can/peak_canfd/peak_canfd.c
index 6fa66231ed8e..ed8561d4a90f 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -333,7 +333,6 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
 
/* this STATUS is the CNF of the RX_BARRIER: Tx path can be setup */
if (pucan_status_is_rx_barrier(msg)) {
-   unsigned long flags;
 
if (priv->enable_tx_path) {
int err = priv->enable_tx_path(priv);
@@ -342,16 +341,8 @@ static int pucan_handle_status(struct peak_canfd_priv 
*priv,
return err;
}
 
-   /* restart network queue only if echo skb array is free */
-   spin_lock_irqsave(&priv->echo_lock, flags);
-
-   if (!priv->can.echo_skb[priv->echo_idx]) {
-   spin_unlock_irqrestore(&priv->echo_lock, flags);
-
-   netif_wake_queue(ndev);
-   } else {
-   spin_unlock_irqrestore(&priv->echo_lock, flags);
-   }
+   /* start network queue (echo_skb array is empty) */
+   netif_start_queue(ndev);
 
return 0;
}
-- 
2.16.1



Re: [bpf-next V3 PATCH 13/15] mlx5: use page_pool for xdp_return_frame call

2018-03-12 Thread Tariq Toukan



On 09/03/2018 10:56 PM, Jesper Dangaard Brouer wrote:

This patch shows how it is possible to have both the driver local page
cache, which uses elevated refcnt for "catching"/avoiding SKB
put_page.  And at the same time, have pages getting returned to the
page_pool from ndp_xdp_xmit DMA completion.

Performance is surprisingly good. Tested DMA-TX completion on ixgbe,
that calls "xdp_return_frame", which call page_pool_put_page().
Stats show DMA-TX-completion runs on CPU#9 and mlx5 RX runs on CPU#5.
(Internally page_pool uses ptr_ring, which is what gives the good
cross CPU performance).

Show adapter(s) (ixgbe2 mlx5p2) statistics (ONLY that changed!)
Ethtool(ixgbe2  ) stat:732863573 (732,863,573) <= tx_bytes /sec
Ethtool(ixgbe2  ) stat:781724427 (781,724,427) <= tx_bytes_nic /sec
Ethtool(ixgbe2  ) stat: 12214393 ( 12,214,393) <= tx_packets /sec
Ethtool(ixgbe2  ) stat: 12214435 ( 12,214,435) <= tx_pkts_nic /sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= rx3_cache_empty /sec
Ethtool(mlx5p2  ) stat: 36506736 ( 36,506,736) <= rx_64_bytes_phy /sec
Ethtool(mlx5p2  ) stat:   2336430575 (  2,336,430,575) <= rx_bytes_phy /sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= rx_cache_empty /sec
Ethtool(mlx5p2  ) stat: 22823073 ( 22,823,073) <= rx_discards_phy /sec
Ethtool(mlx5p2  ) stat:  1471860 (  1,471,860) <= rx_out_of_buffer /sec
Ethtool(mlx5p2  ) stat: 36506715 ( 36,506,715) <= rx_packets_phy /sec
Ethtool(mlx5p2  ) stat:   2336542282 (  2,336,542,282) <= rx_prio0_bytes /sec
Ethtool(mlx5p2  ) stat: 13683921 ( 13,683,921) <= rx_prio0_packets /sec
Ethtool(mlx5p2  ) stat:821015537 (821,015,537) <= 
rx_vport_unicast_bytes /sec
Ethtool(mlx5p2  ) stat: 13683608 ( 13,683,608) <= 
rx_vport_unicast_packets /sec

Before this patch: single flow performance was 6Mpps, and if I started
two flows the collective performance drop to 4Mpps, because we hit the
page allocator lock (further negative scaling occurs).

V2: Adjustments requested by Tariq
  - Changed page_pool_create return codes not return NULL, only
ERR_PTR, as this simplifies err handling in drivers.
  - Save a branch in mlx5e_page_release
  - Correct page_pool size calc for MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ

Signed-off-by: Jesper Dangaard Brouer 
---


I am running perf tests with your series. I sense a drastic degradation 
in regular TCP flows, I'm double checking the numbers now...


Re: [PATCH 2/2] net/usb/ax88179_178a: Delete three unnecessary variables in ax88179_chk_eee()

2018-03-12 Thread Oliver Neukum
Am Samstag, den 10.03.2018, 19:26 +0100 schrieb SF Markus Elfring:
> From: Markus Elfring 
> Date: Sat, 10 Mar 2018 18:53:28 +0100
> 
> Use three values directly for a condition check without assigning them
> to intermediate variables.

Hi,

what is the benefit of this? It looks like needless code churn to me.

Regards
Oliver



Re: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

2018-03-12 Thread Salvatore Mesoraca
2018-03-12 8:06 GMT+01:00 santosh.shilim...@oracle.com
:
> On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:
>>
>> Avoid VLA[1] by using an already allocated buffer passed
>> by the caller.
>>
>> [1] https://lkml.org/lkml/2018/3/7/621
>>
>> Signed-off-by: Salvatore Mesoraca 
>> ---
>
> Thanks for both VLA fixes Salvatore.
>
> FWIW, Acked-by: Santosh Shilimkar 

Thank you very much for your time,

Salvatore


Re: [bpf-next V3 PATCH 13/15] mlx5: use page_pool for xdp_return_frame call

2018-03-12 Thread Tariq Toukan



On 12/03/2018 12:08 PM, Tariq Toukan wrote:



On 09/03/2018 10:56 PM, Jesper Dangaard Brouer wrote:

This patch shows how it is possible to have both the driver local page
cache, which uses elevated refcnt for "catching"/avoiding SKB
put_page.  And at the same time, have pages getting returned to the
page_pool from ndp_xdp_xmit DMA completion.

Performance is surprisingly good. Tested DMA-TX completion on ixgbe,
that calls "xdp_return_frame", which call page_pool_put_page().
Stats show DMA-TX-completion runs on CPU#9 and mlx5 RX runs on CPU#5.
(Internally page_pool uses ptr_ring, which is what gives the good
cross CPU performance).

Show adapter(s) (ixgbe2 mlx5p2) statistics (ONLY that changed!)
Ethtool(ixgbe2  ) stat:    732863573 (    732,863,573) <= tx_bytes /sec
Ethtool(ixgbe2  ) stat:    781724427 (    781,724,427) <= tx_bytes_nic 
/sec

Ethtool(ixgbe2  ) stat: 12214393 ( 12,214,393) <= tx_packets /sec
Ethtool(ixgbe2  ) stat: 12214435 ( 12,214,435) <= tx_pkts_nic 
/sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= 
rx3_cache_empty /sec
Ethtool(mlx5p2  ) stat: 36506736 ( 36,506,736) <= 
rx_64_bytes_phy /sec
Ethtool(mlx5p2  ) stat:   2336430575 (  2,336,430,575) <= rx_bytes_phy 
/sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= 
rx_cache_empty /sec
Ethtool(mlx5p2  ) stat: 22823073 ( 22,823,073) <= 
rx_discards_phy /sec
Ethtool(mlx5p2  ) stat:  1471860 (  1,471,860) <= 
rx_out_of_buffer /sec
Ethtool(mlx5p2  ) stat: 36506715 ( 36,506,715) <= 
rx_packets_phy /sec
Ethtool(mlx5p2  ) stat:   2336542282 (  2,336,542,282) <= 
rx_prio0_bytes /sec
Ethtool(mlx5p2  ) stat: 13683921 ( 13,683,921) <= 
rx_prio0_packets /sec
Ethtool(mlx5p2  ) stat:    821015537 (    821,015,537) <= 
rx_vport_unicast_bytes /sec
Ethtool(mlx5p2  ) stat: 13683608 ( 13,683,608) <= 
rx_vport_unicast_packets /sec


Before this patch: single flow performance was 6Mpps, and if I started
two flows the collective performance drop to 4Mpps, because we hit the
page allocator lock (further negative scaling occurs).

V2: Adjustments requested by Tariq
  - Changed page_pool_create return codes not return NULL, only
    ERR_PTR, as this simplifies err handling in drivers.
  - Save a branch in mlx5e_page_release
  - Correct page_pool size calc for MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ

Signed-off-by: Jesper Dangaard Brouer 
---


I am running perf tests with your series. I sense a drastic degradation 
in regular TCP flows, I'm double checking the numbers now...


Well, there's a huge performance degradation indeed, whenever the 
regular flows (non-XDP) use the new page pool. Cannot merge before 
fixing this.


If I disable the local page-cache, numbers get as low as 100's of Mbps 
in TCP stream tests.


Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
On Mon, 12 Mar 2018 19:00:49 +0900
Masami Hiramatsu  wrote:

> Since the kprobe which was optimized by jump can not change
> the execution path, the kprobe for error-injection must not
> be optimized. To prohibit it, set a dummy post-handler as
> officially stated in Documentation/kprobes.txt.

Note that trace-probe based BPF is not affected, because it
ensures the trace-probe is based on ftrace, which is not
jump optimized.

Thanks,

> 
> Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
> Signed-off-by: Masami Hiramatsu 
> ---
>  kernel/fail_function.c |   10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/kernel/fail_function.c b/kernel/fail_function.c
> index 21b0122cb39c..1d5632d8bbcc 100644
> --- a/kernel/fail_function.c
> +++ b/kernel/fail_function.c
> @@ -14,6 +14,15 @@
>  
>  static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
>  
> +static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs,
> +  unsigned long flags)
> +{
> + /*
> +  * A dummy post handler is required to prohibit optimizing, because
> +  * jump optimization does not support execution path overriding.
> +  */
> +}
> +
>  struct fei_attr {
>   struct list_head list;
>   struct kprobe kp;
> @@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, 
> unsigned long addr)
>   return NULL;
>   }
>   attr->kp.pre_handler = fei_kprobe_handler;
> + attr->kp.post_handler = fei_post_handler;
>   attr->retval = adjust_error_retval(addr, 0);
>   INIT_LIST_HEAD(&attr->list);
>   }
> 


-- 
Masami Hiramatsu 


Re: [PATCH 6/6] can: m_can: select pinctrl state in each suspend/resume function

2018-03-12 Thread Bich HEMON
Hi Mark,

Thanks for the fix.

On 03/12/2018 11:04 AM, Marc Kleine-Budde wrote:
> From: Bich HEMON 
> 
> Make sure to apply the correct pin state in suspend/resume callbacks.
> Putting pins in sleep state saves power.
> 
> Signed-off-by: Bich Hemon 
> Signed-off-by: Marc Kleine-Budde 
> ---
>   drivers/net/can/m_can/m_can.c | 5 +
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 74170b0d23cf..b397a33f3d32 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -26,6 +26,7 @@
>   #include 
>   #include 
>   #include 
> +#include 
>   
>   /* napi related */
>   #define M_CAN_NAPI_WEIGHT   64
> @@ -1700,6 +1701,8 @@ static __maybe_unused int m_can_suspend(struct device 
> *dev)
>   m_can_clk_stop(priv);
>   }
>   
> + pinctrl_pm_select_sleep_state(dev);
> +
>   priv->can.state = CAN_STATE_SLEEPING;
>   
>   return 0;
> @@ -1710,6 +1713,8 @@ static __maybe_unused int m_can_resume(struct device 
> *dev)
>   struct net_device *ndev = dev_get_drvdata(dev);
>   struct m_can_priv *priv = netdev_priv(ndev);
>   
> + pinctrl_pm_select_default_state(dev);
> +
>   m_can_init_ram(priv);
>   
>   priv->can.state = CAN_STATE_ERROR_ACTIVE;
> 

Acked-by: Bich Hemon 

Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Daniel Borkmann
Hi Masami,

On 03/12/2018 11:27 AM, Masami Hiramatsu wrote:
> On Mon, 12 Mar 2018 19:00:49 +0900
> Masami Hiramatsu  wrote:
> 
>> Since the kprobe which was optimized by jump can not change
>> the execution path, the kprobe for error-injection must not
>> be optimized. To prohibit it, set a dummy post-handler as
>> officially stated in Documentation/kprobes.txt.
> 
> Note that trace-probe based BPF is not affected, because it
> ensures the trace-probe is based on ftrace, which is not
> jump optimized.

Thanks for the fix! I presume this should go via bpf instead of bpf-next
tree since 4b1a29a7f542 ("error-injection: Support fault injection framework")
is in Linus' tree as well. Unless there are objection I would rather route
it that way so it would be for 4.16.

Thanks,
Daniel

> Thanks,
> 
>>
>> Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
>> Signed-off-by: Masami Hiramatsu 
>> ---
>>  kernel/fail_function.c |   10 ++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/kernel/fail_function.c b/kernel/fail_function.c
>> index 21b0122cb39c..1d5632d8bbcc 100644
>> --- a/kernel/fail_function.c
>> +++ b/kernel/fail_function.c
>> @@ -14,6 +14,15 @@
>>  
>>  static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
>>  
>> +static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs,
>> + unsigned long flags)
>> +{
>> +/*
>> + * A dummy post handler is required to prohibit optimizing, because
>> + * jump optimization does not support execution path overriding.
>> + */
>> +}
>> +
>>  struct fei_attr {
>>  struct list_head list;
>>  struct kprobe kp;
>> @@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, 
>> unsigned long addr)
>>  return NULL;
>>  }
>>  attr->kp.pre_handler = fei_kprobe_handler;
>> +attr->kp.post_handler = fei_post_handler;
>>  attr->retval = adjust_error_retval(addr, 0);
>>  INIT_LIST_HEAD(&attr->list);
>>  }
>>
> 
> 



Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw

2018-03-12 Thread Linus Lüssing
On Tue, Feb 27, 2018 at 11:08:20AM +0100, Rafał Miłecki wrote:
> I've problem when using OpenWrt/LEDE on a home router with Broadcom's
> FullMAC WiFi chipset.

Hi Rafał,

Thanks for reporting this issue!

> Can you see any solution for this problem? Is that an option to stop
> multicast-to-unicast from touching 802.11f packets? Some other ideas?
> Obviously I can't modify Broadcom's firmware and drop that obsoleted
> standard.

Just to avoid some potential confusion: This is more an issue of
hairpinning than it is an issue of multicast-to-unicast per se,
right?

That is, if you set this to 0 manually:
/sys/class/net//brport/multicast_to_unicast
Then the issue still occurs, right?

Regards, Linus


Re: KASAN: use-after-free Read in sctp_association_free (2)

2018-03-12 Thread Neil Horman
On Mon, Mar 12, 2018 at 04:16:27PM +0800, Xin Long wrote:
> On Sun, Mar 11, 2018 at 3:04 AM, Neil Horman  wrote:
> > On Sun, Mar 11, 2018 at 12:22:32AM +0800, Xin Long wrote:
> >> On Sat, Mar 10, 2018 at 9:13 PM, Neil Horman  wrote:
> >> > On Sat, Mar 10, 2018 at 03:58:04PM +0800, Xin Long wrote:
> >> >> On Sat, Mar 10, 2018 at 6:08 AM, Neil Horman  
> >> >> wrote:
> >> >> > On Fri, Mar 09, 2018 at 12:59:06PM -0800, syzbot wrote:
> >> >> >> Hello,
> >> >> >>
> >> >> >> syzbot hit the following crash on net-next commit
> >> >> >> fd372a7a9e5e9d8011a0222d10edd3523abcd3b1 (Thu Mar 8 19:43:48 2018 
> >> >> >> +)
> >> >> >> Merge tag 'mlx5-updates-2018-02-28-2' of
> >> >> >> git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux
> >> >> >>
> >> >> >> So far this crash happened 2 times on net-next.
> >> >> >> C reproducer is attached.
> >> >> >> syzkaller reproducer is attached.
> >> >> >> Raw console output is attached.
> >> >> >> compiler: gcc (GCC) 7.1.1 20170620
> >> >> >> .config is attached.
> >> >> >>
> >> >> >> IMPORTANT: if you fix the bug, please add the following tag to the 
> >> >> >> commit:
> >> >> >> Reported-by: syzbot+a4e4112c3aff00c8c...@syzkaller.appspotmail.com
> >> >> >> It will help syzbot understand when the bug is fixed. See footer for
> >> >> >> details.
> >> >> >> If you forward the report, please keep this part and the footer.
> >> >> >>
> >> >> >> IPVS: ftp: loaded support on port[0] = 21
> >> >> >> IPVS: ftp: loaded support on port[0] = 21
> >> >> >> IPVS: ftp: loaded support on port[0] = 21
> >> >> >> IPVS: ftp: loaded support on port[0] = 21
> >> >> >> ==
> >> >> >> BUG: KASAN: use-after-free in sctp_association_free+0x7b7/0x930
> >> >> >> net/sctp/associola.c:332
> >> >> >> Read of size 8 at addr 8801d8006ae0 by task syzkaller914861/4202
> >> >> >>
> >> >> >> CPU: 1 PID: 4202 Comm: syzkaller914861 Not tainted 4.16.0-rc4+ #258
> >> >> >> Hardware name: Google Google Compute Engine/Google Compute Engine, 
> >> >> >> BIOS
> >> >> >> Google 01/01/2011
> >> >> >> Call Trace:
> >> >> >>  __dump_stack lib/dump_stack.c:17 [inline]
> >> >> >>  dump_stack+0x194/0x24d lib/dump_stack.c:53
> >> >> >>  print_address_description+0x73/0x250 mm/kasan/report.c:256
> >> >> >>  kasan_report_error mm/kasan/report.c:354 [inline]
> >> >> >>  kasan_report+0x23c/0x360 mm/kasan/report.c:412
> >> >> >>  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
> >> >> >>  sctp_association_free+0x7b7/0x930 net/sctp/associola.c:332
> >> >> >>  sctp_sendmsg+0xc67/0x1a80 net/sctp/socket.c:2075
> >> >> >>  inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763
> >> >> >>  sock_sendmsg_nosec net/socket.c:629 [inline]
> >> >> >>  sock_sendmsg+0xca/0x110 net/socket.c:639
> >> >> >>  SYSC_sendto+0x361/0x5c0 net/socket.c:1748
> >> >> >>  SyS_sendto+0x40/0x50 net/socket.c:1716
> >> >> >>  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
> >> >> >>  entry_SYSCALL_64_after_hwframe+0x42/0xb7
> >> >> >> RIP: 0033:0x446d09
> >> >> >> RSP: 002b:7f5dbac21da8 EFLAGS: 0216 ORIG_RAX: 
> >> >> >> 002c
> >> >> >> RAX: ffda RBX: 006e29fc RCX: 00446d09
> >> >> >> RDX: 0001 RSI: 2340 RDI: 0003
> >> >> >> RBP: 006e29f8 R08: 204d9000 R09: 001c
> >> >> >> R10:  R11: 0216 R12: 
> >> >> >> R13: 7fff7b26fb1f R14: 7f5dbac229c0 R15: 006e2b60
> >> >> >>
> >> >> > I think we have a corner case with 
> >> >> > a0ff660058b88d12625a783ce9e5c1371c87951f
> >> >> > here.  If a peeloff event happens during a wait for sendbuf space, 
> >> >> > EPIPE will be
> >> >> > returned, and the code path appears to call sctp_association_put 
> >> >> > twice, leading
> >> >> > to the use after free situation.  I'll write a patch this weekend
> >> >> Hi, Neil, you're right.
> >> >>
> >> >> I didn't expect peeloff can be done on a NEW asoc, as peeloff needs
> >> >> assoc_id, which can only be set when connecting has started.
> >> >>
> >> >> But I realized that:
> >> >> f84af33 sctp: factor out sctp_sendmsg_to_asoc from sctp_sendmsg
> >> >>
> >> >> moved sctp_primitive_ASSOCIATE(connecting) before sctp_wait_for_sndbuf
> >> >> (snd buffer waiting). It means peeloff can be done on a NEW asoc.
> >> >> So you may want to move it back.
> >> >>
> >> > I agree with the root cause, but I'm not sure I agree with just moving 
> >> > the
> >> > wait_for_sndbuf call back above the call to associate.  I'm not sure I 
> >> > like
> >> > relying on placing a call in a spcific order solely to avoid an error 
> >> > condition
> >> > that might legitimately occur.  I think would rather check the return 
> >> > code at
> >> > the call site for the complete set of conditions for which we should not 
> >> > free
> >> > the association.  Something like this:
> >> >
> >> > diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> >> > index 7d347

Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw

2018-03-12 Thread Linus Lüssing
On Mon, Mar 12, 2018 at 10:46:45AM +0100, Rafał Miłecki wrote:
> On 27 February 2018 at 18:05, Stephen Hemminger
[...]
> > ebtables is your friend in dealing with weird and broken devices.
> 
> It may be weird, not sure if actually broken. Anyway I'd like to have
> some generic solution instead of telling every user to use ebtables to
> workaround the problem.

I agree that a "broken by default" in OpenWRT/LEDE for a variety
of Broadcom devices is not really acceptable.

Technically we could teach netifd in OpenWRT/LEDE to configure
ebtables accordingly, at least for a list of affected devices,
so that users would not have to. However, as ebtables is not
managed by the fw3 in OpenWRT/LEDE, that would probably interfer
with user provided ebtables rules and scripts...


> That said I think we still should look for a solution for existing
> firmwares. I guess it may takes months to years to never to release
> new firmwares for all supported chipsets.

Hm, we could change the default in OpenWRT/LEDE for
multicast-to-unicast (or more precisely bridge hairpinning) to
disabled again for now.


Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw

2018-03-12 Thread Linus Lüssing
On Mon, Mar 12, 2018 at 12:08:56PM +0100, Linus Lüssing wrote:
> On Tue, Feb 27, 2018 at 11:08:20AM +0100, Rafał Miłecki wrote:
> > I've problem when using OpenWrt/LEDE on a home router with Broadcom's
> > FullMAC WiFi chipset.
> 
> Hi Rafał,
> 
> Thanks for reporting this issue!
> 
> > Can you see any solution for this problem? Is that an option to stop
> > multicast-to-unicast from touching 802.11f packets? Some other ideas?
> > Obviously I can't modify Broadcom's firmware and drop that obsoleted
> > standard.
> 
> Just to avoid some potential confusion: This is more an issue of
> hairpinning than it is an issue of multicast-to-unicast per se,
> right?
> 
> That is, if you set this to 0 manually:
> /sys/class/net//brport/multicast_to_unicast
> Then the issue still occurs, right?

Btw., if in OpenWRT/LEDE you set 'option multicast_to_unicast 0'
in /etc/config/network for the bridge (and not bridge port)
then netifd should refrain from setting the bridge hairpinning and
AP isolation on wireless devices, too, if I remember correctly.

Can you confirm that the issue disappears for you then?


Re: [PATCH net-next] modules: allow modprobe load regular elf binaries

2018-03-12 Thread Edward Cree
On 09/03/18 18:58, Alexei Starovoitov wrote:
> It's not waiting for the whole thing, because once bpfilter starts it
> stays running/sleeping because it's stateful.
So, this has been bugging me a bit.
If bpfilter takes a signal and crashes, all that state goes away.
Does that mean your iptables/netfilter config just got forgotten and next
 time you run iptables it disappears, so you have to re-apply it all again?
> It needs normal
> malloc-ed memory to keep the state of iptable->bpf translation that
> it will use later during subsequent translation calls.
> Theoretically it can use bpf maps pinned in kernel memory to keep
> this state, but then it's non-swappable. It's better to keep bpfilter
> state in its own user memory.
Perhaps the state should live in swappable kernel memory (e.g. a tmpfs
 thing, which bpfilter could access through a mount).  It'd be read-only
 to userspace, listing the existing rules (in untranslated form), and be
 updated to reflect the new rule after bpfilter has supplied the updated
 translation.
Then bpfilter can cache things if it wants, but the kernel remains the
 ultimate arbiter of the state and maintains it over a bpfilter crash.

Sound reasonable?

-Ed


[PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Wei Yongjun
Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
sendmsg")
Signed-off-by: Wei Yongjun 
---
 net/sctp/socket.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..5e7bfc2 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 
sflags,
memset(daddr, 0, sizeof(*daddr));
dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
-   if (dlen < sizeof(struct in_addr))
+   if (dlen < sizeof(struct in_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in_addr);
daddr->v4.sin_family = AF_INET;
daddr->v4.sin_port = htons(asoc->peer.port);
memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
} else {
-   if (dlen < sizeof(struct in6_addr))
+   if (dlen < sizeof(struct in6_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in6_addr);
daddr->v6.sin6_family = AF_INET6;



[PATCH net-next] mlxsw: spectrum_kvdl: Make some functions static

2018-03-12 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:371:5: warning:
 symbol 'mlxsw_sp_kvdl_single_occ_get' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:384:5: warning:
 symbol 'mlxsw_sp_kvdl_chunks_occ_get' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:397:5: warning:
 symbol 'mlxsw_sp_kvdl_large_chunks_occ_get' was not declared. Should it be 
static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
index 059eb32..4c9bff2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
@@ -368,7 +368,7 @@ u64 mlxsw_sp_kvdl_occ_get(const struct mlxsw_sp *mlxsw_sp)
return occ;
 }
 
-u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
@@ -381,7 +381,7 @@ u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
return mlxsw_sp_kvdl_part_occ(part);
 }
 
-u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
@@ -394,7 +394,7 @@ u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
return mlxsw_sp_kvdl_part_occ(part);
 }
 
-u64 mlxsw_sp_kvdl_large_chunks_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_large_chunks_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);



Re: [PATCH v2] net: ipv6: xfrm6_state: remove VLA usage

2018-03-12 Thread Steffen Klassert
On Sat, Mar 10, 2018 at 07:26:44PM +0100, Stefano Brivio wrote:
> On Sat, 10 Mar 2018 09:18:46 -0800
> Kees Cook  wrote:
> 
> > On Sat, Mar 10, 2018 at 12:43 AM, Stefano Brivio  wrote:
> > > On Sat, 10 Mar 2018 09:40:44 +0200
> > > Andreas Christoforou  wrote:
> > >  
> > >> diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
> > >> index b15075a..270a53a 100644
> > >> --- a/net/ipv6/xfrm6_state.c
> > >> +++ b/net/ipv6/xfrm6_state.c
> > >> @@ -62,7 +62,7 @@ __xfrm6_sort(void **dst, void **src, int n, int 
> > >> (*cmp)(void *p), int maxclass)
> > >>  {
> > >>   int i;
> > >>   int class[XFRM_MAX_DEPTH];
> > >> - int count[maxclass];
> > >> + int count[XFRM_MAX_DEPTH];
> > >>
> > >>   memset(count, 0, sizeof(count));  
> > >
> > > Can you perhaps initialize 'count' instead of calling memset(), now?  
> > 
> > Do you mean:
> > 
> > int count[XFRM_MAX_DEPTH] = { };
> > 
> > instead of the memset()?
> 
> Yep.
> 
> > I thought the compiler would resolve these both to the same thing?
> 
> Yes, for all practical purposes. With gcc 7.3.0 for x86_64, starting
> from -O1, it's exactly the same. With e.g. gcc 4.4.7, even with -O3,
> they can be a bit different depending on context.
> 
> > The former looks better though! :)
> 
> Yep! :)

If Andreas does a v3 anyway, please also consider to trim the subject
line to something like:

xfrm: remove VLA usage in __xfrm6_sort()



Re: [PATCH net-next] mlxsw: spectrum_kvdl: Make some functions static

2018-03-12 Thread Jiri Pirko
Mon, Mar 12, 2018 at 01:25:24PM CET, weiyongj...@huawei.com wrote:
>Fixes the following sparse warnings:
>
>drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:371:5: warning:
> symbol 'mlxsw_sp_kvdl_single_occ_get' was not declared. Should it be static?
>drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:384:5: warning:
> symbol 'mlxsw_sp_kvdl_chunks_occ_get' was not declared. Should it be static?
>drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:397:5: warning:
> symbol 'mlxsw_sp_kvdl_large_chunks_occ_get' was not declared. Should it be 
> static?
>
>Signed-off-by: Wei Yongjun 

Acked-by: Jiri Pirko 

Thanks!


Re: [bpf-next V3 PATCH 13/15] mlx5: use page_pool for xdp_return_frame call

2018-03-12 Thread Tariq Toukan



On 12/03/2018 12:16 PM, Tariq Toukan wrote:



On 12/03/2018 12:08 PM, Tariq Toukan wrote:



On 09/03/2018 10:56 PM, Jesper Dangaard Brouer wrote:

This patch shows how it is possible to have both the driver local page
cache, which uses elevated refcnt for "catching"/avoiding SKB
put_page.  And at the same time, have pages getting returned to the
page_pool from ndp_xdp_xmit DMA completion.

Performance is surprisingly good. Tested DMA-TX completion on ixgbe,
that calls "xdp_return_frame", which call page_pool_put_page().
Stats show DMA-TX-completion runs on CPU#9 and mlx5 RX runs on CPU#5.
(Internally page_pool uses ptr_ring, which is what gives the good
cross CPU performance).

Show adapter(s) (ixgbe2 mlx5p2) statistics (ONLY that changed!)
Ethtool(ixgbe2  ) stat:    732863573 (    732,863,573) <= tx_bytes /sec
Ethtool(ixgbe2  ) stat:    781724427 (    781,724,427) <= 
tx_bytes_nic /sec
Ethtool(ixgbe2  ) stat: 12214393 ( 12,214,393) <= tx_packets 
/sec
Ethtool(ixgbe2  ) stat: 12214435 ( 12,214,435) <= tx_pkts_nic 
/sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= 
rx3_cache_empty /sec
Ethtool(mlx5p2  ) stat: 36506736 ( 36,506,736) <= 
rx_64_bytes_phy /sec
Ethtool(mlx5p2  ) stat:   2336430575 (  2,336,430,575) <= 
rx_bytes_phy /sec
Ethtool(mlx5p2  ) stat: 12211786 ( 12,211,786) <= 
rx_cache_empty /sec
Ethtool(mlx5p2  ) stat: 22823073 ( 22,823,073) <= 
rx_discards_phy /sec
Ethtool(mlx5p2  ) stat:  1471860 (  1,471,860) <= 
rx_out_of_buffer /sec
Ethtool(mlx5p2  ) stat: 36506715 ( 36,506,715) <= 
rx_packets_phy /sec
Ethtool(mlx5p2  ) stat:   2336542282 (  2,336,542,282) <= 
rx_prio0_bytes /sec
Ethtool(mlx5p2  ) stat: 13683921 ( 13,683,921) <= 
rx_prio0_packets /sec
Ethtool(mlx5p2  ) stat:    821015537 (    821,015,537) <= 
rx_vport_unicast_bytes /sec
Ethtool(mlx5p2  ) stat: 13683608 ( 13,683,608) <= 
rx_vport_unicast_packets /sec


Before this patch: single flow performance was 6Mpps, and if I started
two flows the collective performance drop to 4Mpps, because we hit the
page allocator lock (further negative scaling occurs).

V2: Adjustments requested by Tariq
  - Changed page_pool_create return codes not return NULL, only
    ERR_PTR, as this simplifies err handling in drivers.
  - Save a branch in mlx5e_page_release
  - Correct page_pool size calc for MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ

Signed-off-by: Jesper Dangaard Brouer 
---


I am running perf tests with your series. I sense a drastic 
degradation in regular TCP flows, I'm double checking the numbers now...


Well, there's a huge performance degradation indeed, whenever the 
regular flows (non-XDP) use the new page pool. Cannot merge before 
fixing this.


If I disable the local page-cache, numbers get as low as 100's of Mbps 
in TCP stream tests.


It seems that the page-pool doesn't fit as a general fallback (when page 
in local rx cache is busy), as the refcnt is elevated/changing:


[ 7343.086102] [ cut here ]
[ 7343.086103] __page_pool_put_page() violating page_pool invariance 
refcnt:0
[ 7343.086114] WARNING: CPU: 1 PID: 17 at net/core/page_pool.c:291 
__page_pool_put_page+0x7c/0xa0
[ 7343.086114] Modules linked in: mlx5_core(OE) netconsole nfsv3 nfs 
fscache rpcrdma ib_isert iscsi_target_mod ib_iser libiscsi 
scsi_transport_iscsi ib_srpt target_core_mod ib_srp scsi_transport_srp 
ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm mlx4_ib 
dm_mirror ib_core dm_region_hash dm_log dm_mod dax sb_edac 
x86_pkg_temp_thermal coretemp kvm ipmi_si ipmi_devintf iTCO_wdt 
irqbypass crc32_pclmul iTCO_vendor_support ipmi_msghandler 
ghash_clmulni_intel dcdbas acpi_power_meter sg wmi pcspkr lpc_ich 
mfd_core shpchp nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables 
mlx4_en sr_mod cdrom sd_mod mgag200 i2c_algo_bit drm_kms_helper 
syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ahci drm mlx4_core 
libahci libata crc32c_intel megaraid_sas tg3 i2c_core [last unloaded: 
mlx5_core]
[ 7343.086137] CPU: 1 PID: 17 Comm: ksoftirqd/1 Tainted: GW  OE 
  4.16.0-rc4+ #7
[ 7343.086138] Hardware name: Dell Inc. PowerEdge R730/0H21J3, BIOS 
1.5.4 10/002/2015

[ 7343.086139] RIP: 0010:__page_pool_put_page+0x7c/0xa0
[ 7343.086140] RSP: 0018:c9000653fcc8 EFLAGS: 00010292
[ 7343.086141] RAX: 003e RBX: ea0080d582c0 RCX: 

[ 7343.086141] RDX:  RSI: 0002 RDI: 
0246
[ 7343.086142] RBP: 882033ffe000 R08: 003e R09: 
8282f8b6
[ 7343.086142] R10: 50ee R11: 0001 R12: 
881fc857c000
[ 7343.086143] R13: 881fc49cc800 R14: 0040 R15: 
881fc857c140
[ 7343.086143] FS:  () GS:88203f00() 
knlGS:

[ 7343.086144] CS:  0010 DS:  ES:  CR0: 80050033
[ 7343.086145] CR2: 7f0aee0dc8b0 CR3: 0200a006 CR4: 
001606e0

[ 7343.086156] Call Trace:

Re: [PATCH v10 crypto 09/11] chtls: Inline TLS request Tx/Rx

2018-03-12 Thread Stefano Brivio
On Sat, 10 Mar 2018 00:40:14 +0530
Atul Gupta  wrote:

> TLS handler for record transmit and receive.
> Create Inline TLS work request and post to FW.
> Create Inline TLS record CPLs for hardware
> 
> Signed-off-by: Atul Gupta 
> ---
>  drivers/crypto/chelsio/chtls/chtls_io.c | 1863 
> +++
>  1 file changed, 1863 insertions(+)
>  create mode 100644 drivers/crypto/chelsio/chtls/chtls_io.c
> 
> diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c 
> b/drivers/crypto/chelsio/chtls/chtls_io.c
> new file mode 100644
> index 000..f7f5826
> --- /dev/null
> +++ b/drivers/crypto/chelsio/chtls/chtls_io.c
> @@ -0,0 +1,1863 @@
> +/*
> + * Copyright (c) 2017 Chelsio Communications, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Written by: Atul Gupta (atul.gu...@chelsio.com)
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "chtls.h"
> +#include "chtls_cm.h"
> +
> +static bool is_tls_hw(struct chtls_sock *csk)
> +{
> + return csk->tlshws.ofld;
> +}

Do you actually need this function?

> +static bool is_tls_rx(struct chtls_sock *csk)
> +{
> + return (csk->tlshws.rxkey >= 0);
> +}

You can drop the ().

> +
> +static bool is_tls_tx(struct chtls_sock *csk)
> +{
> + return (csk->tlshws.txkey >= 0);
> +}

You can drop the ().

> +static bool is_tls_skb(struct chtls_sock *csk, const struct sk_buff *skb)
> +{
> + return (is_tls_hw(csk) && skb_ulp_tls_skb_flags(skb));
> +}

You can drop the ().

> +static int key_size(void *sk)
> +{
> + return 16; /* Key on DDR */
> +}

Do you actually need this function? Can't you turn that into a #define?

> +
> +#define ceil(x, y) \
> + ({ unsigned long __x = (x), __y = (y); (__x + __y - 1) / __y; })

This doesn't look like a ceiling function, could you perhaps name it
more descriptively?

> +static int data_sgl_len(const struct sk_buff *skb)
> +{
> + unsigned int cnt;
> +
> + cnt = skb_shinfo(skb)->nr_frags;
> + return (sgl_len(cnt) * 8);

You can drop the ().

> +}
> +
> +static int nos_ivs(struct sock *sk, unsigned int size)
> +{
> + struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
> +
> + return ceil(size, csk->tlshws.mfs);
> +}
> +
> +#define TLS_WR_CPL_LEN \
> + (sizeof(struct fw_tlstx_data_wr) + \
> + sizeof(struct cpl_tx_tls_sfo))
> +
> +static int is_ivs_imm(struct sock *sk, const struct sk_buff *skb)

Shouldn't this be a bool?

> +{
> + int ivs_size = nos_ivs(sk, skb->len) * CIPHER_BLOCK_SIZE;
> + int hlen = TLS_WR_CPL_LEN + data_sgl_len(skb);
> +
> + if ((hlen + key_size(sk) + ivs_size) <
> + MAX_IMM_OFLD_TX_DATA_WR_LEN) {
> + ULP_SKB_CB(skb)->ulp.tls.iv = 1;
> + return 1;
> + }
> + ULP_SKB_CB(skb)->ulp.tls.iv = 0;

Are these assignments intended? They don't seem to fit with the name of
the function.

> + return 0;
> +}
> +
> +static int max_ivs_size(struct sock *sk, int size)
> +{
> + return (nos_ivs(sk, size) * CIPHER_BLOCK_SIZE);
> +}

You can drop the ().

> +
> +static int ivs_size(struct sock *sk, const struct sk_buff *skb)
> +{
> + return (is_ivs_imm(sk, skb) ? (nos_ivs(sk, skb->len) *
> +  CIPHER_BLOCK_SIZE) : 0);
> +}

You can drop the ().

> [...]
>
> +static u64 tls_sequence_number(struct chtls_hws *hws)
> +{
> + return (hws->tx_seq_no++);
> +}

You can drop the (), and I find the name of this function a bit misleading
as you are actually increasing the sequence number, not just returning
it.

> +
> +static int is_sg_request(const struct sk_buff *skb)
> +{
> + return (skb->peeked ||
> + (skb->len > MAX_IMM_ULPTX_WR_LEN));
> +}

You can drop the (). This should be a bool.

> +
> +/*
> + * Returns true if an sk_buff carries urgent data.
> + */
> +static int skb_urgent(struct sk_buff *skb)
> +{
> + return (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_URG) != 0;
> +}

This should be a bool, you can drop the (), and avoid that != 0
comparison.

-- 
Stefano


Re: [PATCH v10 crypto 08/11] chtls: CPL handler definition

2018-03-12 Thread Stefano Brivio
On Sat, 10 Mar 2018 00:40:13 +0530
Atul Gupta  wrote:

> Exchange CPL messages with hardware to program the TLS session
> CPL handlers defined to process messages received from chip.
> 
> Signed-off-by: Atul Gupta 
> ---
>  drivers/crypto/chelsio/chtls/chtls_cm.c | 2041 
> +++
>  net/ipv4/tcp_minisocks.c|1 +
>  2 files changed, 2042 insertions(+)
>  create mode 100644 drivers/crypto/chelsio/chtls/chtls_cm.c
> 
> diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c 
> b/drivers/crypto/chelsio/chtls/chtls_cm.c
>
> [...]
>
> +static void send_defer_abort_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
> +{
> + struct cpl_abort_req_rss *req = cplhdr(skb);
> + struct sk_buff *reply_skb;
> +
> + reply_skb = alloc_skb(sizeof(struct cpl_abort_rpl),
> +   GFP_KERNEL | __GFP_NOFAIL);
> + if (!reply_skb)
> + return;

This will never happen. By the way, is there really no way to handle a
failure here?

-- 
Stefano


Re: [PATCH v10 crypto 07/11] chtls: Program the TLS Key

2018-03-12 Thread Stefano Brivio
On Sat, 10 Mar 2018 00:40:12 +0530
Atul Gupta  wrote:

> Initialize the space reserved for storing the TLS keys
> get and free the location where key is stored for the TLS
> connection
> Program the tx and rx key as received from user in
> struct tls12_crypto_info_aes_gcm_128 and understood by hardware.
> 
> Signed-off-by: Atul Gupta 
> ---
>  drivers/crypto/chelsio/chtls/chtls_hw.c | 371 
> 
>  1 file changed, 371 insertions(+)
>  create mode 100644 drivers/crypto/chelsio/chtls/chtls_hw.c
> 
> diff --git a/drivers/crypto/chelsio/chtls/chtls_hw.c 
> b/drivers/crypto/chelsio/chtls/chtls_hw.c
> new file mode 100644
> index 000..40cf84f
> --- /dev/null
> +++ b/drivers/crypto/chelsio/chtls/chtls_hw.c
> @@ -0,0 +1,371 @@
> +/*
> + * Copyright (c) 2017 Chelsio Communications, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Written by: Atul Gupta (atul.gu...@chelsio.com)
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "chtls.h"
> +#include "chtls_cm.h"
> +
> +static void __set_tcb_field_direct(struct chtls_sock *csk,
> +struct cpl_set_tcb_field *req, u16 word,
> +u64 mask, u64 val, u8 cookie, int no_reply)
> +{
> + struct ulptx_idata *sc;
> +
> + INIT_TP_WR_CPL(req, CPL_SET_TCB_FIELD, csk->tid);
> + req->wr.wr_mid |= htonl(FW_WR_FLOWID_V(csk->tid));
> + req->reply_ctrl = htons(NO_REPLY_V(no_reply) |
> + QUEUENO_V(csk->rss_qid));
> + req->word_cookie = htons(TCB_WORD_V(word) | TCB_COOKIE_V(cookie));
> + req->mask = cpu_to_be64(mask);
> + req->val = cpu_to_be64(val);
> + sc = (struct ulptx_idata *)(req + 1);
> + sc->cmd_more = htonl(ULPTX_CMD_V(ULP_TX_SC_NOOP));
> + sc->len = htonl(0);
> +}
> +
> +static void __set_tcb_field(struct sock *sk, struct sk_buff *skb, u16 word,
> + u64 mask, u64 val, u8 cookie, int no_reply)
> +{
> + struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
> + struct cpl_set_tcb_field *req;
> + struct ulptx_idata *sc;
> + unsigned int wrlen = roundup(sizeof(*req) + sizeof(*sc), 16);
> +
> + req = (struct cpl_set_tcb_field *)__skb_put(skb, wrlen);
> + __set_tcb_field_direct(csk, req, word, mask, val, cookie, no_reply);
> + set_wr_txq(skb, CPL_PRIORITY_CONTROL, csk->port_id);
> +}
> +
> +/*
> + * Send control message to HW, message go as immediate data and packet
> + * is freed immediately.
> + */
> +static void chtls_set_tcb_field(struct sock *sk, u16 word, u64 mask, u64 val)
> +{
> + struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);
> + struct cpl_set_tcb_field *req;
> + struct ulptx_idata *sc;
> + struct sk_buff *skb;
> + unsigned int wrlen = roundup(sizeof(*req) + sizeof(*sc), 16);
> + unsigned int credits_needed = DIV_ROUND_UP(wrlen, 16);
> +
> + skb = alloc_skb(wrlen, GFP_ATOMIC);
> + if (!skb)
> + return;
> +
> + __set_tcb_field(sk, skb, word, mask, val, 0, 1);
> + set_queue(skb, (csk->txq_idx << 1) | CPL_PRIORITY_DATA, sk);
> + csk->wr_credits -= credits_needed;
> + csk->wr_unacked += credits_needed;
> + enqueue_wr(csk, skb);
> + cxgb4_ofld_send(csk->egress_dev, skb);
> +}

What happens if e.g. alloc_skb() fails here? Is it fine to ignore the
error altogether?

> +
> +/*
> + * Set one of the t_flags bits in the TCB.
> + */
> +void chtls_set_tcb_tflag(struct sock *sk, unsigned int bit_pos, int val)
> +{
> + return chtls_set_tcb_field(sk, 1, 1ULL << bit_pos,
> + val << bit_pos);
> +}
> +
> +static void chtls_set_tcb_keyid(struct sock *sk, int keyid)
> +{
> + return chtls_set_tcb_field(sk, 31, 0xULL, keyid);
> +}
> +
> +static void chtls_set_tcb_seqno(struct sock *sk)
> +{
> + return chtls_set_tcb_field(sk, 28, ~0ULL, 0);
> +}
> +
> +static void chtls_set_tcb_quiesce(struct sock *sk, int val)
> +{
> + return chtls_set_tcb_field(sk, 1, (1ULL << TF_RX_QUIESCE_S),
> +TF_RX_QUIESCE_V(val));
> +}

Why would you return from a void function?

IMHO, it would be more productive if you could address the comments you
are receiving a bit more carefully instead of patching them up quickly
and race to re-post, because this doesn't seem to gain any time.

-- 
Stefano


Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Xin Long
On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun  wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
>
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
> sendmsg")
> Signed-off-by: Wei Yongjun 
> ---
>  net/sctp/socket.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, 
> __u16 sflags,
> memset(daddr, 0, sizeof(*daddr));
> dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
> if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> -   if (dlen < sizeof(struct in_addr))
> +   if (dlen < sizeof(struct in_addr)) {
> +   err = -EINVAL;
> goto free;
> +   }
>
> dlen = sizeof(struct in_addr);
> daddr->v4.sin_family = AF_INET;
> daddr->v4.sin_port = htons(asoc->peer.port);
> memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
> } else {
> -   if (dlen < sizeof(struct in6_addr))
> +   if (dlen < sizeof(struct in6_addr)) {
> +   err = -EINVAL;
> goto free;
> +   }
>
> dlen = sizeof(struct in6_addr);
> daddr->v6.sin6_family = AF_INET6;
>
Unfortunately, this can't be fixed right now, because of
https://lkml.org/lkml/2018/3/7/1175
Pls hold it until net-next merges linus tree.

Btw, the 'err' initialization can also be removed in your patch.

Thanks.


[PATCH net v3 2/2] l2tp: fix races with ipv4-mapped ipv6 addresses

2018-03-12 Thread Paolo Abeni
The l2tp_tunnel_create() function checks for v4mapped ipv6
sockets and cache that flag, so that l2tp core code can
reusing it at xmit time.

If the socket is provided by the userspace, the connection
status of the tunnel sockets can change between the tunnel
creation and the xmit call, so that syzbot is able to
trigger the following splat:

BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:192
[inline]
BUG: KASAN: use-after-free in ip6_xmit+0x1f76/0x2260
net/ipv6/ip6_output.c:264
Read of size 8 at addr 8801bd949318 by task syz-executor4/23448

CPU: 0 PID: 23448 Comm: syz-executor4 Not tainted 4.16.0-rc4+ #65
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:17 [inline]
  dump_stack+0x194/0x24d lib/dump_stack.c:53
  print_address_description+0x73/0x250 mm/kasan/report.c:256
  kasan_report_error mm/kasan/report.c:354 [inline]
  kasan_report+0x23c/0x360 mm/kasan/report.c:412
  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
  ip6_dst_idev include/net/ip6_fib.h:192 [inline]
  ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264
  inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139
  l2tp_xmit_core net/l2tp/l2tp_core.c:1053 [inline]
  l2tp_xmit_skb+0x105f/0x1410 net/l2tp/l2tp_core.c:1148
  pppol2tp_sendmsg+0x470/0x670 net/l2tp/l2tp_ppp.c:341
  sock_sendmsg_nosec net/socket.c:630 [inline]
  sock_sendmsg+0xca/0x110 net/socket.c:640
  ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046
  __sys_sendmsg+0xe5/0x210 net/socket.c:2080
  SYSC_sendmsg net/socket.c:2091 [inline]
  SyS_sendmsg+0x2d/0x50 net/socket.c:2087
  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
  entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x453e69
RSP: 002b:7f819593cc68 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 7f819593d6d4 RCX: 00453e69
RDX: 0081 RSI: 2037ffc8 RDI: 0004
RBP: 0072bea0 R08:  R09: 
R10:  R11: 0246 R12: 
R13: 04c3 R14: 006f72e8 R15: 

This change addresses the issues:
* explicitly checking for TCP_ESTABLISHED for user space provided sockets
* dropping the v4mapped flag usage - it can become outdated - and
  explicitly invoking ipv6_addr_v4mapped() instead

The issue is apparently there since ancient times.

v1 -> v2: (many thanks to Guillaume)
 - with csum issue introduced in v1
 - replace pr_err with pr_debug
 - fix build issue with IPV6 disabled
 - move l2tp_sk_is_v4mapped in l2tp_core.c

v2 -> v3:
 - don't update inet_daddr for v4mapped address, unneeded
 - drop rendundant check at creation time

Reported-and-tested-by: syzbot+92fa328176eb07e4a...@syzkaller.appspotmail.com
Fixes: 3557baabf280 ("[L2TP]: PPP over L2TP driver core")
Signed-off-by: Paolo Abeni 
---
 net/l2tp/l2tp_core.c | 38 ++
 net/l2tp/l2tp_core.h |  3 ---
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index e22512e32827..14b67dfacc4b 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -111,6 +111,13 @@ struct l2tp_net {
spinlock_t l2tp_session_hlist_lock;
 };
 
+#if IS_ENABLED(CONFIG_IPV6)
+static bool l2tp_sk_is_v6(struct sock *sk)
+{
+   return sk->sk_family == PF_INET6 &&
+  !ipv6_addr_v4mapped(&sk->sk_v6_daddr);
+}
+#endif
 
 static inline struct l2tp_tunnel *l2tp_tunnel(struct sock *sk)
 {
@@ -1049,7 +1056,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, 
struct sk_buff *skb,
/* Queue the packet to IP for output */
skb->ignore_df = 1;
 #if IS_ENABLED(CONFIG_IPV6)
-   if (tunnel->sock->sk_family == PF_INET6 && !tunnel->v4mapped)
+   if (l2tp_sk_is_v6(tunnel->sock))
error = inet6_csk_xmit(tunnel->sock, skb, NULL);
else
 #endif
@@ -1112,6 +1119,15 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct 
sk_buff *skb, int hdr_len
goto out_unlock;
}
 
+   /* The user-space may change the connection status for the user-space
+* provided socket at run time: we must check it under the socket lock
+*/
+   if (tunnel->fd >= 0 && sk->sk_state != TCP_ESTABLISHED) {
+   kfree_skb(skb);
+   ret = NET_XMIT_DROP;
+   goto out_unlock;
+   }
+
/* Get routing info from the tunnel socket */
skb_dst_drop(skb);
skb_dst_set(skb, dst_clone(__sk_dst_check(sk, 0)));
@@ -1131,7 +1147,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct 
sk_buff *skb, int hdr_len
 
/* Calculate UDP checksum if configured to do so */
 #if IS_ENABLED(CONFIG_IPV6)
-   if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
+   if (l2tp_sk_is_v6(sk))
udp6_set_csum(udp_get_no_check6_tx(sk),
 

[PATCH net v3 0/2] l2tp: fix races with ipv4-mapped ipv6 addresses

2018-03-12 Thread Paolo Abeni
The syzbot reported an l2tp oops that uncovered some races in the l2tp xmit
path and a partially related issue in the generic ipv6 code.

We need to address them separately.

v1 -> v2:
 - add missing fixes tag in patch 1
 - fix several issues in patch 2

v2 -> v3:
 - dropped some unneeded chunks in patch 2

Paolo Abeni (2):
  net: ipv6: keep sk status consistent after datagram connect failure
  l2tp: fix races with ipv4-mapped ipv6 addresses

 net/ipv6/datagram.c  | 21 ++---
 net/l2tp/l2tp_core.c | 38 ++
 net/l2tp/l2tp_core.h |  3 ---
 3 files changed, 32 insertions(+), 30 deletions(-)

-- 
2.14.3



[PATCH net v3 1/2] net: ipv6: keep sk status consistent after datagram connect failure

2018-03-12 Thread Paolo Abeni
On unsuccesful ip6_datagram_connect(), if the failure is caused by
ip6_datagram_dst_update(), the sk peer information are cleared, but
the sk->sk_state is preserved.

If the socket was already in an established status, the overall sk
status is inconsistent and fouls later checks in datagram code.

Fix this saving the old peer information and restoring them in
case of failure. This also aligns ipv6 datagram connect() behavior
with ipv4.

v1 -> v2:
 - added missing Fixes tag

Fixes: 85cb73ff9b74 ("net: ipv6: reset daddr and dport in sk if connect() 
fails")
Signed-off-by: Paolo Abeni 
---
 net/ipv6/datagram.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index fbf08ce3f5ab..8a9ac2d0f5d3 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -146,10 +146,12 @@ int __ip6_datagram_connect(struct sock *sk, struct 
sockaddr *uaddr,
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
struct inet_sock*inet = inet_sk(sk);
struct ipv6_pinfo   *np = inet6_sk(sk);
-   struct in6_addr *daddr;
+   struct in6_addr *daddr, old_daddr;
+   __be32  fl6_flowlabel = 0;
+   __be32  old_fl6_flowlabel;
+   __be32  old_dport;
int addr_type;
int err;
-   __be32  fl6_flowlabel = 0;
 
if (usin->sin6_family == AF_INET) {
if (__ipv6_only_sock(sk))
@@ -238,9 +240,13 @@ int __ip6_datagram_connect(struct sock *sk, struct 
sockaddr *uaddr,
}
}
 
+   /* save the current peer information before updating it */
+   old_daddr = sk->sk_v6_daddr;
+   old_fl6_flowlabel = np->flow_label;
+   old_dport = inet->inet_dport;
+
sk->sk_v6_daddr = *daddr;
np->flow_label = fl6_flowlabel;
-
inet->inet_dport = usin->sin6_port;
 
/*
@@ -250,11 +256,12 @@ int __ip6_datagram_connect(struct sock *sk, struct 
sockaddr *uaddr,
 
err = ip6_datagram_dst_update(sk, true);
if (err) {
-   /* Reset daddr and dport so that udp_v6_early_demux()
-* fails to find this socket
+   /* Restore the socket peer info, to keep it consistent with
+* the old socket state
 */
-   memset(&sk->sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr));
-   inet->inet_dport = 0;
+   sk->sk_v6_daddr = old_daddr;
+   np->flow_label = old_fl6_flowlabel;
+   inet->inet_dport = old_dport;
goto out;
}
 
-- 
2.14.3



Re: [PATCH 1/1] qed: Add firmware 8.33.11.0

2018-03-12 Thread Josh Boyer
On Feb 28, Rahul Verma wrote:
> This patch add a new qed firmware with fixes and added
> support for new features.
> -Support VLAN remove action in steering flow.
> -Optimized the FW flow and several bug fixes.
> -Allow VXLAN steering.
> -Supports T10DIF and SRQ.
> -Support for port redirection for RDMA bonding
>
> Signed-off-by: Rahul Verma 
> ---
>  WHENCE   |   1 +
>  qed/qed_init_values_zipped-8.33.11.0.bin | Bin 0 -> 852456 bytes
>  2 files changed, 1 insertion(+)
>  create mode 100755 qed/qed_init_values_zipped-8.33.11.0.bin

I had to fixup a small conflict in WHENCE, but no big deal.  Applied
and pushed out.

josh


Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Masami Hiramatsu
On Mon, 12 Mar 2018 11:44:21 +0100
Daniel Borkmann  wrote:

> Hi Masami,
> 
> On 03/12/2018 11:27 AM, Masami Hiramatsu wrote:
> > On Mon, 12 Mar 2018 19:00:49 +0900
> > Masami Hiramatsu  wrote:
> > 
> >> Since the kprobe which was optimized by jump can not change
> >> the execution path, the kprobe for error-injection must not
> >> be optimized. To prohibit it, set a dummy post-handler as
> >> officially stated in Documentation/kprobes.txt.
> > 
> > Note that trace-probe based BPF is not affected, because it
> > ensures the trace-probe is based on ftrace, which is not
> > jump optimized.
> 
> Thanks for the fix! I presume this should go via bpf instead of bpf-next
> tree since 4b1a29a7f542 ("error-injection: Support fault injection framework")
> is in Linus' tree as well. Unless there are objection I would rather route
> it that way so it would be for 4.16.

Ah, right! It should go into 4.16. It should be applicable cleanly either tree
since there is only the above commit on kernel/fail_function.c :)

Thanks,

> 
> Thanks,
> Daniel
> 
> > Thanks,
> > 
> >>
> >> Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
> >> Signed-off-by: Masami Hiramatsu 
> >> ---
> >>  kernel/fail_function.c |   10 ++
> >>  1 file changed, 10 insertions(+)
> >>
> >> diff --git a/kernel/fail_function.c b/kernel/fail_function.c
> >> index 21b0122cb39c..1d5632d8bbcc 100644
> >> --- a/kernel/fail_function.c
> >> +++ b/kernel/fail_function.c
> >> @@ -14,6 +14,15 @@
> >>  
> >>  static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
> >>  
> >> +static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs,
> >> +   unsigned long flags)
> >> +{
> >> +  /*
> >> +   * A dummy post handler is required to prohibit optimizing, because
> >> +   * jump optimization does not support execution path overriding.
> >> +   */
> >> +}
> >> +
> >>  struct fei_attr {
> >>struct list_head list;
> >>struct kprobe kp;
> >> @@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, 
> >> unsigned long addr)
> >>return NULL;
> >>}
> >>attr->kp.pre_handler = fei_kprobe_handler;
> >> +  attr->kp.post_handler = fei_post_handler;
> >>attr->retval = adjust_error_retval(addr, 0);
> >>INIT_LIST_HEAD(&attr->list);
> >>}
> >>
> > 
> > 
> 


-- 
Masami Hiramatsu 


Re: [PATCH linux-firmware] Mellanox: Add new mlxsw_spectrum firmware 13.1620.192

2018-03-12 Thread Josh Boyer
On Tue, Feb 27, 2018 at 3:51 AM, Tal Bar  wrote:
> This new firmware contains:
> - Support for auto-neg disable mode
>
> Signed-off-by: Tal Bar 
> ---
>  WHENCE   |   1 +
>  mellanox/mlxsw_spectrum-13.1620.192.mfa2 | Bin 0 -> 1091848 bytes
>  2 files changed, 1 insertion(+)
>  create mode 100644 mellanox/mlxsw_spectrum-13.1620.192.mfa2

Applied and pushed out.  Thanks.

josh


Re: [PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-12 Thread Andrew Lunn
On Mon, Mar 12, 2018 at 03:49:51AM -0500, Razvan Stefanescu wrote:

> +static irqreturn_t ethsw_irq0_handler(int irq_num, void *arg)
> +{
> + return IRQ_WAKE_THREAD;
> +}
> +

> +static int ethsw_setup_irqs(struct fsl_mc_device *sw_dev)
> +{
> + struct device *dev = &sw_dev->dev;
> + struct ethsw_core *ethsw = dev_get_drvdata(dev);
> + u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED;
> + struct fsl_mc_device_irq *irq;
> + int err;
> +
> + err = fsl_mc_allocate_irqs(sw_dev);
> + if (err) {
> + dev_err(dev, "MC irqs allocation failed\n");
> + return err;
> + }
> +
> + if (WARN_ON(sw_dev->obj_desc.irq_count != DPSW_IRQ_NUM)) {
> + err = -EINVAL;
> + goto free_irq;
> + }
> +
> + err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle,
> +   DPSW_IRQ_INDEX_IF, 0);
> + if (err) {
> + dev_err(dev, "dpsw_set_irq_enable err %d\n", err);
> + goto free_irq;
> + }
> +
> + irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF];
> +
> + err = devm_request_threaded_irq(dev, irq->msi_desc->irq,
> + ethsw_irq0_handler,
> + ethsw_irq0_handler_thread,
> + IRQF_NO_SUSPEND | IRQF_ONESHOT,
> + dev_name(dev), dev);

Hi Razvan

You can pass NULL instead of ethsw_irq0_handler.

Andrew


Re: [PATCH net v3] net: phy: Tell caller result of phy_change()

2018-03-12 Thread David Miller
From: Brad Mouring 
Date: Thu, 8 Mar 2018 16:23:03 -0600

> In 664fcf123a30e (net: phy: Threaded interrupts allow some simplification)
> the phy_interrupt system was changed to use a traditional threaded
> interrupt scheme instead of a workqueue approach.
> 
> With this change, the phy status check moved into phy_change, which
> did not report back to the caller whether or not the interrupt was
> handled. This means that, in the case of a shared phy interrupt,
> only the first phydev's interrupt registers are checked (since
> phy_interrupt() would always return IRQ_HANDLED). This leads to
> interrupt storms when it is a secondary device that's actually the
> interrupt source.
> 
> Signed-off-by: Brad Mouring 

Applied and queued up for -stable, thanks.


Re: [PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-12 Thread Andrew Lunn
> +static int port_netdevice_event(struct notifier_block *unused,
> + unsigned long event, void *ptr)
> +{
> + struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> + struct netdev_notifier_changeupper_info *info = ptr;
> + struct net_device *upper_dev;
> + int err = 0;
> +
> + if (netdev->netdev_ops != ðsw_port_ops)
> + return NOTIFY_DONE;
> +
> + /* Handle just upper dev link/unlink for the moment */
> + if (event == NETDEV_CHANGEUPPER) {
> + upper_dev = info->upper_dev;
> + if (netif_is_bridge_master(upper_dev)) {
> + if (info->linking)
> + err = port_bridge_join(netdev);
> + else
> + err = port_bridge_leave(netdev);
> + }
> + }
> +
> + return notifier_from_errno(err);
> +}

I could be missing something here, but don't you need to pass to
port_bridge_join() which bridge the port is joining. There can be
multiple bridges, so you need to ensure the port joins the correct
bridge.

Andrew


Re: [PATCH] net: hns: use put_device() if device_register fail

2018-03-12 Thread David Miller
From: Arvind Yadav 
Date: Fri,  9 Mar 2018 16:11:17 +0530

> if device_register() returned an error! Always use put_device()
> to give up the reference initialized.
> 
> Signed-off-by: Arvind Yadav 

I do not see anything giving cls_dev an initial non-zero reference
count before this device_register() call.

And I have no idea why you use a "!" when saying 'error' you this
commit log message.



chelsio inline tls patches

2018-03-12 Thread David Miller

Atul, starting with patch #5 there are functions which need to be
adjusted to order function local variables from longest to shortest
line (reverse christmas tree order).

Please fix this up for all of those patches and resubmit your
series.

Thank you.


Re: [PATCH net-next 1/1] tc-testing: updated gact tests with batch test cases

2018-03-12 Thread David Miller
From: Roman Mashak 
Date: Fri,  9 Mar 2018 17:16:12 -0500

> Add test cases to exercise code paths responsible for adding or deleting
> batch of TC actions.
> 
> Signed-off-by: Roman Mashak 

You submitted this patch twice.

You didn't indicate if this is a new version of the patch or something
like this.

Please resubmit your tc-testing changes, all of them, with this
sorted out.


Re: [PATCH net 0/8] bnxt_en: Bug fixes.

2018-03-12 Thread David Miller
From: Michael Chan 
Date: Fri,  9 Mar 2018 23:46:02 -0500

> There are 3 bug fixes in this series to fix regressions recently
> introduced when adding the new ring reservations scheme.  2 minor
> fixes in the TC Flower code to return standard errno values and
> to elide some unnecessary warning dmesg.  One Fixes the VLAN TCI
> value passed to the stack by including the entire 16-bit VLAN TCI,
> and the last fix is to check for valid VNIC ID before setting up or
> shutting down LRO/GRO.

Series applied, thanks Michael.


Re: [PATCH V2 net-next] liquidio: fix ndo_change_mtu to always return correct status to the caller

2018-03-12 Thread David Miller
From: Felix Manlunas 
Date: Sat, 10 Mar 2018 00:17:35 -0800

> From: Veerasenareddy Burru 
> 
> In a scenario where the command queued to firmware get dropped or times
> out, MTU change from host will not propagate to firmware. So, it is
> required for host driver to wait for response from firmware or timeout
> and then return correct status to caller of ndo_change_mtu.
> 
> Also moved the common code for MTU change from PF and VF driver files to
> common file lio_core.c
> 
> Signed-off-by: Veerasenareddy Burru 
> Signed-off-by: Felix Manlunas 
> ---
> Patch Change Log:
>   V1 -> V2:
> Remove unnecessary log message "MTU changed from %d to %d\n" as
> suggested by David Miller

Applied, thank you.


Re: [PATCHv3 net] sock_diag: request _diag module only when the family or proto has been registered

2018-03-12 Thread David Miller
From: Xin Long 
Date: Sat, 10 Mar 2018 18:57:50 +0800

> Now when using 'ss' in iproute, kernel would try to load all _diag
> modules, which also causes corresponding family and proto modules
> to be loaded as well due to module dependencies.
> 
> Like after running 'ss', sctp, dccp, af_packet (if it works as a module)
> would be loaded.
> 
> For example:
> 
>   $ lsmod|grep sctp
>   $ ss
>   $ lsmod|grep sctp
>   sctp_diag  16384  0
>   sctp  323584  5 sctp_diag
>   inet_diag  24576  4 raw_diag,tcp_diag,sctp_diag,udp_diag
>   libcrc32c  16384  3 nf_conntrack,nf_nat,sctp
> 
> As these family and proto modules are loaded unintentionally, it
> could cause some problems, like:
> 
> - Some debug tools use 'ss' to collect the socket info, which loads all
>   those diag and family and protocol modules. It's noisy for identifying
>   issues.
> 
> - Users usually expect to drop sctp init packet silently when they
>   have no sense of sctp protocol instead of sending abort back.
> 
> - It wastes resources (especially with multiple netns), and SCTP module
>   can't be unloaded once it's loaded.
> 
> ...
> 
> In short, it's really inappropriate to have these family and proto
> modules loaded unexpectedly when just doing debugging with inet_diag.
> 
> This patch is to introduce sock_load_diag_module() where it loads
> the _diag module only when it's corresponding family or proto has
> been already registered.
> 
> Note that we can't just load _diag module without the family or
> proto loaded, as some symbols used in _diag module are from the
> family or proto module.
> 
> v1->v2:
>   - move inet proto check to inet_diag to avoid a compiling err.
> v2->v3:
>   - define sock_load_diag_module in sock.c and export one symbol
> only.
>   - improve the changelog.
> 
> Reported-by: Sabrina Dubroca 
> Acked-by: Marcelo Ricardo Leitner 
> Acked-by: Phil Sutter 
> Acked-by: Sabrina Dubroca 
> Signed-off-by: Xin Long 

Ok, applied and queued up for -stable, thanks.


Re: [PATCH net-next] cxgb4: do not display 50Gbps as unsupported speed

2018-03-12 Thread David Miller
From: Ganesh Goudar 
Date: Sat, 10 Mar 2018 17:34:50 +0530

> 50Gbps is a supported speed, Stop reporting it as
> unsupported speed.
> 
> Signed-off-by: Ganesh Goudar 

Applied.


Re: [PATCH net-next] cxgb4/cxgb4vf: check fw caps to set link mode mask

2018-03-12 Thread David Miller
From: Ganesh Goudar 
Date: Sat, 10 Mar 2018 19:27:52 +0530

> check firmware capabilities before setting ethtool
> link mode mask, also add few missing speeds.
> 
> Signed-off-by: Ganesh Goudar 

Applied.


[PATCH] net: drivers/net: Remove unnecessary skb_copy_expand OOM messages

2018-03-12 Thread Joe Perches
skb_copy_expand without __GFP_NOWARN already does a dump_stack
on OOM so these messages are redundant.

Signed-off-by: Joe Perches 
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 1 -
 drivers/net/usb/lg-vl600.c  | 6 +-
 drivers/net/wimax/i2400m/usb-rx.c   | 3 ---
 drivers/net/wireless/ti/wl1251/tx.c | 4 +---
 drivers/usb/gadget/function/f_eem.c | 1 -
 net/mac80211/rx.c   | 5 +
 net/netfilter/nfnetlink_queue.c | 5 +
 7 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c 
b/drivers/net/ethernet/qualcomm/qca_spi.c
index 9c236298fe21..5803cd6db406 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -705,7 +705,6 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device 
*dev)
tskb = skb_copy_expand(skb, QCAFRM_HEADER_LEN,
   QCAFRM_FOOTER_LEN + pad_len, GFP_ATOMIC);
if (!tskb) {
-   netdev_dbg(qca->net_dev, "could not allocate 
tx_buff\n");
qca->stats.out_of_mem++;
return NETDEV_TX_BUSY;
}
diff --git a/drivers/net/usb/lg-vl600.c b/drivers/net/usb/lg-vl600.c
index dbabd7ca5268..257916f172cd 100644
--- a/drivers/net/usb/lg-vl600.c
+++ b/drivers/net/usb/lg-vl600.c
@@ -157,12 +157,8 @@ static int vl600_rx_fixup(struct usbnet *dev, struct 
sk_buff *skb)
 
s->current_rx_buf = skb_copy_expand(skb, 0,
le32_to_cpup(&frame->len), GFP_ATOMIC);
-   if (!s->current_rx_buf) {
-   netif_err(dev, ifup, dev->net, "Reserving %i bytes "
-   "for packet assembly failed.\n",
-   le32_to_cpup(&frame->len));
+   if (!s->current_rx_buf)
dev->net->stats.rx_errors++;
-   }
 
return 0;
}
diff --git a/drivers/net/wimax/i2400m/usb-rx.c 
b/drivers/net/wimax/i2400m/usb-rx.c
index b78ee676e102..5b64bda7d9e7 100644
--- a/drivers/net/wimax/i2400m/usb-rx.c
+++ b/drivers/net/wimax/i2400m/usb-rx.c
@@ -263,9 +263,6 @@ struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct 
sk_buff *rx_skb)
new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
  GFP_KERNEL);
if (new_skb == NULL) {
-   if (printk_ratelimit())
-   dev_err(dev, "RX: Can't reallocate skb to %d; "
-   "RX dropped\n", rx_size);
kfree_skb(rx_skb);
rx_skb = NULL;
goto out;   /* drop it...*/
diff --git a/drivers/net/wireless/ti/wl1251/tx.c 
b/drivers/net/wireless/ti/wl1251/tx.c
index de2fa6705574..12ed14ebc307 100644
--- a/drivers/net/wireless/ti/wl1251/tx.c
+++ b/drivers/net/wireless/ti/wl1251/tx.c
@@ -221,10 +221,8 @@ static int wl1251_tx_send_packet(struct wl1251 *wl, struct 
sk_buff *skb,
struct sk_buff *newskb = skb_copy_expand(skb, 0, 3,
 GFP_KERNEL);
 
-   if (unlikely(newskb == NULL)) {
-   wl1251_error("Can't allocate skb!");
+   if (unlikely(newskb == NULL))
return -EINVAL;
-   }
 
tx_hdr = (struct tx_double_buffer_desc *) newskb->data;
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index 37557651b600..c13befa31110 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -507,7 +507,6 @@ static int eem_unwrap(struct gether *port,
0,
GFP_ATOMIC);
if (unlikely(!skb3)) {
-   DBG(cdev, "unable to realign EEM packet\n");
dev_kfree_skb_any(skb2);
continue;
}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index d01743234cf6..9c898a3688c6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2549,11 +2549,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 
fwd_skb = skb_copy_expand(skb, local->tx_headroom +
   sdata->encrypt_headroom, 0, GFP_ATOMIC);
-   if (!fwd_skb) {
-   net_info_ratelimited("%s: failed to clone mesh frame\n",
-   sdata->name);
+   if (!fwd_skb)
goto out;
-   }
 
fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY);
diff --git a/net/netfilter/nfnetlink_q

Re: [PATCH net-next 0/3] mlxsw: Removing dependency of mlxsw on GRE

2018-03-12 Thread David Miller
From: Ido Schimmel 
Date: Sun, 11 Mar 2018 09:44:39 +0200

> Petr says:
> 
> mlxsw_spectrum supports offloading of a tc action mirred egress mirror
> to a gretap or ip6gretap netdevice, which necessitates calls to
> functions defined in ip_gre, ip6_gre and ip6_tunnel modules. Previously
> this was enabled by introducing a hard dependency of MLXSW_SPECTRUM on
> NET_IPGRE and IPV6_GRE. However the rest of mlxsw is careful about
> picking which modules are absolutely required, and therefore the better
> approach is to make mlxsw_spectrum tolerant of absence of one or both of
> the GRE flavors.
> 
> One way this might be resolved is by keeping the code in mlxsw_spectrum
> intact, and defining defaults for functions that mlxsw_spectrum depends
> on. The downsides are that other modules end up littered with these
> do-nothing defaults; that the driver ends up carrying quite a bit of
> dead code; and that the driver ends up having to explicitly depend on
> IPV6_TUNNEL to prevent configurations where mlxsw_spectrum is compiled
> in and and ip6_tunnel is a module, something that it currently can treat
> as an implementation detail of the IPV6_GRE dependency.
> 
> Alternatively, the driver should just bite the bullet and ifdef-out the
> code that handles configurations that are not supported. Since that's
> what we are doing for IPv6 dependency, let's do the same for the GRE
> flavors.
> 
> Patch #1 introduces a wrapper function for determining the value of
> ipv6.sysctl.multipath_hash_policy, which defaults to 0 on non-IPv6
> builds. That function is then used from spectrum_router.c, instead of
> the direct variable reference that was introduced there during the short
> window when the Spectrum driver had a hard dependency on IPv6.
> 
> Patch #2 moves one function to keep together in one block all the
> callbacks for handling (IPv4) gretap mirroring.
> 
> Patch #3 then introduces the ifdefs to hide the irrelevant code.

Series applied.


[PATCH] ipv6: Use ip6_multipath_hash_policy() in rt6_multipath_hash().

2018-03-12 Thread David Miller

Make use of the new helper.

Suggested-by: David Ahern 
Signed-off-by: David S. Miller 
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f0ae58424c45..81711e3e2604 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1846,7 +1846,7 @@ u32 rt6_multipath_hash(const struct net *net, const 
struct flowi6 *fl6,
struct flow_keys hash_keys;
u32 mhash;
 
-   switch (net->ipv6.sysctl.multipath_hash_policy) {
+   switch (ip6_multipath_hash_policy(net)) {
case 0:
memset(&hash_keys, 0, sizeof(hash_keys));
hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
-- 
2.14.3



Re: [PATCH][next] lan743x: make functions lan743x_csr_read and lan743x_csr_read static

2018-03-12 Thread David Miller
From: Colin King 
Date: Sun, 11 Mar 2018 17:55:47 +0100

> From: Colin Ian King 
> 
> Functions lan743x_csr_read and lan743x_csr_read are local to the source
> and do not need to be in global scope, so make them static.
> 
> Cleans up sparse warning:
> drivers/net/ethernet/microchip/lan743x_main.c:56:5: warning: symbol
> lan743x_csr_read' was not declared. Should it be static?
> drivers/net/ethernet/microchip/lan743x_main.c:61:6: warning: symbol
> 'lan743x_csr_write' was not declared. Should it be static?
> 
> Signed-off-by: Colin Ian King 

Applied.


Re: [PATCH][rds-next] rds: remove redundant variable 'sg_off'

2018-03-12 Thread David Miller
From: Colin King 
Date: Sun, 11 Mar 2018 17:27:56 +0100

> From: Colin Ian King 
> 
> Variable sg_off is assigned a value but it is never read, hence it is
> redundant and can be removed.
> 
> Cleans up clang warning:
> net/rds/message.c:373:2: warning: Value stored to 'sg_off' is never read
> 
> Signed-off-by: Colin Ian King 

Applied.


Re: [PATCH][next] lan743x: remove some redundant variables and assignments

2018-03-12 Thread David Miller
From: Colin King 
Date: Sun, 11 Mar 2018 17:42:33 +0100

> From: Colin Ian King 
> 
> Function lan743x_phy_init assigns pointer 'netdev' but this is never read
> and hence it can be removed. The return error code handling can also be
> cleaned up to remove the variable 'ret'.
> 
> Function lan743x_phy_link_status_change assigns pointer 'phy' twice and
> this is never read, so it also can be removed.
> 
> Finally, function lan743x_tx_napi_poll initializes pointer 'adapter'
> and then re-assigns the same value into this pointer a little later on
> so this second assignment is redundant and can be also removed.
> 
> Cleans up clang warnings:
> drivers/net/ethernet/microchip/lan743x_main.c:951:2: warning: Value
> stored to 'netdev' is never read
> drivers/net/ethernet/microchip/lan743x_main.c:971:3: warning: Value
> stored to 'phy' is never read
> drivers/net/ethernet/microchip/lan743x_main.c:1583:26: warning: Value
> stored to 'adapter' during its initialization is never read
> 
> Signed-off-by: Colin Ian King 

Applied.


Re: [PATCH] net: llc: drop VLA in llc_sap_mcast()

2018-03-12 Thread David Miller
From: Salvatore Mesoraca 
Date: Sun, 11 Mar 2018 22:12:04 +0100

> Avoid a VLA[1] by using a real constant expression instead of a variable.
> The compiler should be able to optimize the original code and avoid using
> an actual VLA. Anyway this change is useful because it will avoid a false
> positive with -Wvla, it might also help the compiler generating better
> code.
> 
> [1] https://lkml.org/lkml/2018/3/7/621
> 
> Signed-off-by: Salvatore Mesoraca 

Applied.


Re: [PATCH net-next] net: Make RX-FCS and HW GRO mutually exclusive

2018-03-12 Thread David Miller
From: Gal Pressman 
Date: Mon, 12 Mar 2018 11:48:49 +0200

> Same as LRO, hardware GRO cannot be enabled with RX-FCS.
> When both are requested, hardware GRO will be dropped.
> 
> Suggested-by: David Miller 
> Signed-off-by: Gal Pressman 

Applied, thank you.


RE: [PATCH v2 iproute2-next 0/6] cm_id, cq, mr, and pd resource tracking

2018-03-12 Thread Steve Wise
Hey all,

The kernel side of this series has been merged for rdma-next [1].  Let me
know if this iproute2 series can be merged, of if it needs more changes.

Thanks,

Steve.

[1] https://www.spinics.net/lists/linux-rdma/msg61720.html



> -Original Message-
> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma-
> ow...@vger.kernel.org] On Behalf Of Steve Wise
> Sent: Friday, March 02, 2018 1:56 PM
> To: dsah...@gmail.com
> Cc: l...@kernel.org; step...@networkplumber.org; netdev@vger.kernel.org;
> linux-r...@vger.kernel.org
> Subject: [PATCH v2 iproute2-next 0/6] cm_id, cq, mr, and pd resource
tracking
> 
> Hello,
> 
> This series enhances the iproute2 rdma tool to include dumping of
> connection manager id (cm_id), completion queue (cq), memory region (mr),
> and protection domain (pd) rdma resources.  It is the user-space part of
> the resource tracking series under review now on the linux-rdma list [1].
> 
> Changes since v1/RFC:
> - removed RFC tag
> - initialize rd properly to avoid passing a garbage port number
> - revert accidental change to qp_valid_filters
> - removed cm_id dev/network/transport types
> - cm_id ip addrs now passed up as __kernel_sockaddr_storage
> - cm_id ip address ports printed as "address:port" strings
> - only parse/display memory keys and iova if available
> - filter on "users" for cqs and pds
> - fixed memory leaks
> - removed PD_FLAGS attribute
> - filter on "mrlen" for mrs
> - filter on "poll-ctx" for cqs
> - don't require addrs or qp_type for parsing cm_ids
> - only filter optional attrs if they are present
> - remove PGSIZE MR attr to match kernel
> 
> [1] https://www.spinics.net/lists/linux-rdma/msg61400.html
> 
> Thanks,
> 
> Steve.
> ---
> 
> Steve Wise (6):
>   rdma: update rdma_netlink.h
>   rdma: initialize the rd struct
>   rdma: Add CM_ID resource tracking information
>   rdma: Add CQ resource tracking information
>   rdma: Add MR resource tracking information
>   rdma: Add PD resource tracking information
> 
>  include/json_writer.h|   2 +
>  include/uapi/rdma/rdma_netlink.h |  44 ++-
>  lib/json_writer.c|  11 +
>  rdma/rdma.c  |   2 +-
>  rdma/rdma.h  |   2 +
>  rdma/res.c   | 611
++-
>  rdma/utils.c |  16 +
>  7 files changed, 683 insertions(+), 5 deletions(-)
> 
> --
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: pull-request: can 2018-03-12

2018-03-12 Thread David Miller
From: Marc Kleine-Budde 
Date: Mon, 12 Mar 2018 11:04:04 +0100

> this is a pull reqeust of 6 patches for net/master.
> 
> The first patch is by Wolfram Sang and fixes a bitshift vs. comparison mistake
> in the m_can driver. Two patches of Marek Vasut repair the error handling in
> the ifi driver. The two patches by Stephane Grosjean fix a "echo_skb is
> occupied!" bug in the peak/pcie_fd driver. Bich HEMON's patch adds pinctrl
> select state calls to the m_can's driver to further improve power saving 
> during
> suspend.

Pulled, thank you.


Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread David Miller
From: Wei Yongjun 
Date: Mon, 12 Mar 2018 12:16:04 +

> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
> sendmsg")
> Signed-off-by: Wei Yongjun 

Xin, I do not want to have a bug fix like this blocked because of that
SCTP options merge nightmare which is of no fault of our own.


Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization

2018-03-12 Thread Daniel Borkmann
On 03/12/2018 03:06 PM, Masami Hiramatsu wrote:
> On Mon, 12 Mar 2018 11:44:21 +0100
> Daniel Borkmann  wrote:
>> On 03/12/2018 11:27 AM, Masami Hiramatsu wrote:
>>> On Mon, 12 Mar 2018 19:00:49 +0900
>>> Masami Hiramatsu  wrote:
>>>
 Since the kprobe which was optimized by jump can not change
 the execution path, the kprobe for error-injection must not
 be optimized. To prohibit it, set a dummy post-handler as
 officially stated in Documentation/kprobes.txt.
>>>
>>> Note that trace-probe based BPF is not affected, because it
>>> ensures the trace-probe is based on ftrace, which is not
>>> jump optimized.
>>
>> Thanks for the fix! I presume this should go via bpf instead of bpf-next
>> tree since 4b1a29a7f542 ("error-injection: Support fault injection 
>> framework")
>> is in Linus' tree as well. Unless there are objection I would rather route
>> it that way so it would be for 4.16.
> 
> Ah, right! It should go into 4.16. It should be applicable cleanly either tree
> since there is only the above commit on kernel/fail_function.c :)

Applied to bpf tree, thanks Masami!


Re: [PATCH 3/4 net-next] ibmvnic: Pad small packets to minimum MTU size

2018-03-12 Thread Thomas Falcon
On 03/11/2018 09:56 PM, David Miller wrote:
> From: Thomas Falcon 
> Date: Fri,  9 Mar 2018 13:23:56 -0600
>
>> +/* For some backing devices, mishandling of small packets
>> + * can result in a loss of connection or TX stall. Device
>> + * architects recommend that no packet should be smaller
>> + * than the minimum MTU value provided to the driver, so
>> + * pad any packets to that length
>> + */
>> +if (skb->len < netdev->min_mtu) {
>> +return skb_put_padto(skb, netdev->min_mtu);
>> +}
> Please do not use curly braces for a single statement
> basic block.
>
> Thank you.
>
Oops, sorry about that. I'll fix that and resend.

Thanks.



Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Neil Horman
On Mon, Mar 12, 2018 at 12:16:04PM +, Wei Yongjun wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
> sendmsg")
> Signed-off-by: Wei Yongjun 
> ---
>  net/sctp/socket.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, 
> __u16 sflags,
>   memset(daddr, 0, sizeof(*daddr));
>   dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>   if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> - if (dlen < sizeof(struct in_addr))
> + if (dlen < sizeof(struct in_addr)) {
> + err = -EINVAL;
>   goto free;
> + }
>  
>   dlen = sizeof(struct in_addr);
>   daddr->v4.sin_family = AF_INET;
>   daddr->v4.sin_port = htons(asoc->peer.port);
>   memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>   } else {
> - if (dlen < sizeof(struct in6_addr))
> + if (dlen < sizeof(struct in6_addr)) {
> + err = -EINVAL;
>   goto free;
> + }
>  
>   dlen = sizeof(struct in6_addr);
>   daddr->v6.sin6_family = AF_INET6;
> 
> 
Acked-by: Neil Horman 



Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Marcelo Ricardo Leitner
On Mon, Mar 12, 2018 at 09:38:53PM +0800, Xin Long wrote:
> On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun  wrote:
...
> Btw, the 'err' initialization can also be removed in your patch.
 
I second this.



Re: [pci PATCH v4 1/4] pci-iov: Add support for unmanaged SR-IOV

2018-03-12 Thread Alexander Duyck
On Mon, Mar 12, 2018 at 12:59 AM, Christoph Hellwig  wrote:
> On Sun, Mar 11, 2018 at 09:59:09PM -0600, Alex Williamson wrote:
>> I still struggle to understand why we need this "unmanaged"
>> complication and how a user of the sysfs API is expected to have any
>> idea whether a PF is managed or unmanaged and why they should care.
>> Can't we just have a pci_simple_sriov_configure() helper and ignore
>> this unmanaged business?  Thanks,
>
> Just a pci_simple_sriov_configure is exactly what I envisioned originally.

I can drop the "unmanaged" bits if that is what is wanted, but based
on previous conversations I thought there was some concern about the
kernel loading VFs when there was some foreign entity managing the VFs
other than the kernel.

Thanks.

- Alex


Re: [PATCH net] ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu

2018-03-12 Thread Sabrina Dubroca
2018-03-09, 16:06:19 -0500, David Miller wrote:
> From: Sabrina Dubroca 
> Date: Fri,  9 Mar 2018 17:43:21 +0100
> 
> > diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
> > index f80524396c06..77d0a78cf7d2 100644
> > --- a/include/net/ip_fib.h
> > +++ b/include/net/ip_fib.h
> > @@ -59,6 +59,7 @@ struct fib_nh_exception {
> > int fnhe_genid;
> > __be32  fnhe_daddr;
> > u32 fnhe_pmtu;
> > +   boolfnhe_mtu_locked;
> > __be32  fnhe_gw;
> > unsigned long   fnhe_expires;
> > struct rtable __rcu *fnhe_rth_input;
> > diff --git a/include/net/route.h b/include/net/route.h
> > index 1eb9ce470e25..729bb5e61e9a 100644
> > --- a/include/net/route.h
> > +++ b/include/net/route.h
> > @@ -64,6 +64,7 @@ struct rtable {
> >  
> > /* Miscellaneous cached information */
> > u32 rt_pmtu;
> > +   boolrt_mtu_locked;
> >  
> > u32 rt_table_id;
> >  
> 
> Please use a flag bit for this, we've worked hard to shrink these
> datastructures as much as possible.

Oops, sorry.

> I think if you just choose an unused RTCF_* bit (f.e. 0x0200) for
> the state, you can use that because values propagate into the
> rtable->rt_flags, and do not propagate out.  So you should be able to
> use it in this way privately inside the kernel.

What about a bitfield?

-   u32 rt_pmtu;
+   u32 rt_mtu_locked:1,
+   rt_pmtu:31;

Since it's going to be private to the kernel, I'd rather not use a
value that's in uapi, especially considering that they're almost all
used (unless we start recycling).

-- 
Sabrina


[PATCH 3/5] netfilter: x_tables: add and use xt_check_proc_name

2018-03-12 Thread Pablo Neira Ayuso
From: Florian Westphal 

recent and hashlimit both create /proc files, but only check that
name is 0 terminated.

This can trigger WARN() from procfs when name is "" or "/".
Add helper for this and then use it for both.

Cc: Eric Dumazet 
Reported-by: Eric Dumazet 
Reported-by: 
Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
---
 include/linux/netfilter/x_tables.h |  2 ++
 net/netfilter/x_tables.c   | 30 ++
 net/netfilter/xt_hashlimit.c   | 16 ++--
 net/netfilter/xt_recent.c  |  6 +++---
 4 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/include/linux/netfilter/x_tables.h 
b/include/linux/netfilter/x_tables.h
index 1313b35c3ab7..14529511c4b8 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -285,6 +285,8 @@ unsigned int *xt_alloc_entry_offsets(unsigned int size);
 bool xt_find_jump_offset(const unsigned int *offsets,
 unsigned int target, unsigned int size);
 
+int xt_check_proc_name(const char *name, unsigned int size);
+
 int xt_check_match(struct xt_mtchk_param *, unsigned int size, u_int8_t proto,
   bool inv_proto);
 int xt_check_target(struct xt_tgchk_param *, unsigned int size, u_int8_t proto,
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index fa1655aff8d3..4aa01c90e9d1 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -423,6 +423,36 @@ textify_hooks(char *buf, size_t size, unsigned int mask, 
uint8_t nfproto)
return buf;
 }
 
+/**
+ * xt_check_proc_name - check that name is suitable for /proc file creation
+ *
+ * @name: file name candidate
+ * @size: length of buffer
+ *
+ * some x_tables modules wish to create a file in /proc.
+ * This function makes sure that the name is suitable for this
+ * purpose, it checks that name is NUL terminated and isn't a 'special'
+ * name, like "..".
+ *
+ * returns negative number on error or 0 if name is useable.
+ */
+int xt_check_proc_name(const char *name, unsigned int size)
+{
+   if (name[0] == '\0')
+   return -EINVAL;
+
+   if (strnlen(name, size) == size)
+   return -ENAMETOOLONG;
+
+   if (strcmp(name, ".") == 0 ||
+   strcmp(name, "..") == 0 ||
+   strchr(name, '/'))
+   return -EINVAL;
+
+   return 0;
+}
+EXPORT_SYMBOL(xt_check_proc_name);
+
 int xt_check_match(struct xt_mtchk_param *par,
   unsigned int size, u_int8_t proto, bool inv_proto)
 {
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 66f5aca62a08..3360f13dc208 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -917,8 +917,9 @@ static int hashlimit_mt_check_v1(const struct 
xt_mtchk_param *par)
struct hashlimit_cfg3 cfg = {};
int ret;
 
-   if (info->name[sizeof(info->name) - 1] != '\0')
-   return -EINVAL;
+   ret = xt_check_proc_name(info->name, sizeof(info->name));
+   if (ret)
+   return ret;
 
ret = cfg_copy(&cfg, (void *)&info->cfg, 1);
 
@@ -935,8 +936,9 @@ static int hashlimit_mt_check_v2(const struct 
xt_mtchk_param *par)
struct hashlimit_cfg3 cfg = {};
int ret;
 
-   if (info->name[sizeof(info->name) - 1] != '\0')
-   return -EINVAL;
+   ret = xt_check_proc_name(info->name, sizeof(info->name));
+   if (ret)
+   return ret;
 
ret = cfg_copy(&cfg, (void *)&info->cfg, 2);
 
@@ -950,9 +952,11 @@ static int hashlimit_mt_check_v2(const struct 
xt_mtchk_param *par)
 static int hashlimit_mt_check(const struct xt_mtchk_param *par)
 {
struct xt_hashlimit_mtinfo3 *info = par->matchinfo;
+   int ret;
 
-   if (info->name[sizeof(info->name) - 1] != '\0')
-   return -EINVAL;
+   ret = xt_check_proc_name(info->name, sizeof(info->name));
+   if (ret)
+   return ret;
 
return hashlimit_mt_check_common(par, &info->hinfo, &info->cfg,
 info->name, 3);
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 6d232d18faff..81ee1d6543b2 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -361,9 +361,9 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
info->hit_count, XT_RECENT_MAX_NSTAMPS - 1);
return -EINVAL;
}
-   if (info->name[0] == '\0' ||
-   strnlen(info->name, XT_RECENT_NAME_LEN) == XT_RECENT_NAME_LEN)
-   return -EINVAL;
+   ret = xt_check_proc_name(info->name, sizeof(info->name));
+   if (ret)
+   return ret;
 
if (ip_pkt_list_tot && info->hit_count < ip_pkt_list_tot)
nstamp_mask = roundup_pow_of_two(ip_pkt_list_tot) - 1;
-- 
2.11.0



[PATCH 5/5] netfilter: nf_tables: release flowtable hooks

2018-03-12 Thread Pablo Neira Ayuso
Otherwise we leak this array.

Signed-off-by: Pablo Neira Ayuso 
---
 net/netfilter/nf_tables_api.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 558593e6a0a3..c4acc7340eb1 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -5423,6 +5423,7 @@ static void nf_tables_flowtable_notify(struct nft_ctx 
*ctx,
 static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable)
 {
cancel_delayed_work_sync(&flowtable->data.gc_work);
+   kfree(flowtable->ops);
kfree(flowtable->name);
flowtable->data.type->free(&flowtable->data);
rhashtable_destroy(&flowtable->data.rhashtable);
-- 
2.11.0



[PATCH 4/5] netfilter: bridge: ebt_among: add more missing match size checks

2018-03-12 Thread Pablo Neira Ayuso
From: Florian Westphal 

ebt_among is special, it has a dynamic match size and is exempt
from the central size checks.

commit c4585a2823edf ("bridge: ebt_among: add missing match size checks")
added validation for pool size, but missed fact that the macros
ebt_among_wh_src/dst can already return out-of-bound result because
they do not check value of wh_src/dst_ofs (an offset) vs. the size
of the match that userspace gave to us.

v2:
check that offset has correct alignment.
Paolo Abeni points out that we should also check that src/dst
wormhash arrays do not overlap, and src + length lines up with
start of dst (or vice versa).
v3: compact wormhash_sizes_valid() part

NB: Fixes tag is intentionally wrong, this bug exists from day
one when match was added for 2.6 kernel. Tag is there so stable
maintainers will notice this one too.

Tested with same rules from the earlier patch.

Fixes: c4585a2823edf ("bridge: ebt_among: add missing match size checks")
Reported-by: 
Signed-off-by: Florian Westphal 
Reviewed-by: Eric Dumazet 
Signed-off-by: Pablo Neira Ayuso 
---
 net/bridge/netfilter/ebt_among.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c
index c5afb4232ecb..620e54f08296 100644
--- a/net/bridge/netfilter/ebt_among.c
+++ b/net/bridge/netfilter/ebt_among.c
@@ -177,6 +177,28 @@ static bool poolsize_invalid(const struct ebt_mac_wormhash 
*w)
return w && w->poolsize >= (INT_MAX / sizeof(struct 
ebt_mac_wormhash_tuple));
 }
 
+static bool wormhash_offset_invalid(int off, unsigned int len)
+{
+   if (off == 0) /* not present */
+   return false;
+
+   if (off < (int)sizeof(struct ebt_among_info) ||
+   off % __alignof__(struct ebt_mac_wormhash))
+   return true;
+
+   off += sizeof(struct ebt_mac_wormhash);
+
+   return off > len;
+}
+
+static bool wormhash_sizes_valid(const struct ebt_mac_wormhash *wh, int a, int 
b)
+{
+   if (a == 0)
+   a = sizeof(struct ebt_among_info);
+
+   return ebt_mac_wormhash_size(wh) + a == b;
+}
+
 static int ebt_among_mt_check(const struct xt_mtchk_param *par)
 {
const struct ebt_among_info *info = par->matchinfo;
@@ -189,6 +211,10 @@ static int ebt_among_mt_check(const struct xt_mtchk_param 
*par)
if (expected_length > em->match_size)
return -EINVAL;
 
+   if (wormhash_offset_invalid(info->wh_dst_ofs, em->match_size) ||
+   wormhash_offset_invalid(info->wh_src_ofs, em->match_size))
+   return -EINVAL;
+
wh_dst = ebt_among_wh_dst(info);
if (poolsize_invalid(wh_dst))
return -EINVAL;
@@ -201,6 +227,14 @@ static int ebt_among_mt_check(const struct xt_mtchk_param 
*par)
if (poolsize_invalid(wh_src))
return -EINVAL;
 
+   if (info->wh_src_ofs < info->wh_dst_ofs) {
+   if (!wormhash_sizes_valid(wh_src, info->wh_src_ofs, 
info->wh_dst_ofs))
+   return -EINVAL;
+   } else {
+   if (!wormhash_sizes_valid(wh_dst, info->wh_dst_ofs, 
info->wh_src_ofs))
+   return -EINVAL;
+   }
+
expected_length += ebt_mac_wormhash_size(wh_src);
 
if (em->match_size != EBT_ALIGN(expected_length)) {
-- 
2.11.0



[PATCH 1/5] netfilter: nft_set_hash: skip fixed hash if timeout is specified

2018-03-12 Thread Pablo Neira Ayuso
Fixed hash supports to timeouts, so skip it. Otherwise, userspace hits
EOPNOTSUPP.

Fixes: 6c03ae210ce3 ("netfilter: nft_set_hash: add non-resizable hashtable 
implementation")
Signed-off-by: Pablo Neira Ayuso 
---
 net/netfilter/nft_set_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c
index 3f1624ee056f..d40591fe1b2f 100644
--- a/net/netfilter/nft_set_hash.c
+++ b/net/netfilter/nft_set_hash.c
@@ -674,7 +674,7 @@ static const struct nft_set_ops *
 nft_hash_select_ops(const struct nft_ctx *ctx, const struct nft_set_desc *desc,
u32 flags)
 {
-   if (desc->size) {
+   if (desc->size && !(flags & NFT_SET_TIMEOUT)) {
switch (desc->klen) {
case 4:
return &nft_hash_fast_ops;
-- 
2.11.0



[PATCH 2/5] netfilter: ebtables: fix erroneous reject of last rule

2018-03-12 Thread Pablo Neira Ayuso
From: Florian Westphal 

The last rule in the blob has next_entry offset that is same as total size.
This made "ebtables32 -A OUTPUT -d de:ad:be:ef:01:02" fail on 64 bit kernel.

Fixes: b71812168571fa ("netfilter: ebtables: CONFIG_COMPAT: don't trust 
userland offsets")
Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
---
 net/bridge/netfilter/ebtables.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 254ef9f49567..a94d23b0a9af 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -2119,8 +2119,12 @@ static int size_entry_mwt(struct ebt_entry *entry, const 
unsigned char *base,
 * offsets are relative to beginning of struct ebt_entry (i.e., 0).
 */
for (i = 0; i < 4 ; ++i) {
-   if (offsets[i] >= *total)
+   if (offsets[i] > *total)
return -EINVAL;
+
+   if (i < 3 && offsets[i] == *total)
+   return -EINVAL;
+
if (i == 0)
continue;
if (offsets[i-1] > offsets[i])
-- 
2.11.0



[PATCH 0/5] Netfilter fixes for net

2018-03-12 Thread Pablo Neira Ayuso
Hi David,

The following patchset contains Netfilter fixes for your net tree, they are:

1) Fixed hashtable representation doesn't support timeout flag, skip it
   otherwise rules to add elements from the packet fail bogusly fail with
   EOPNOTSUPP.

2) Fix bogus error with 32-bits ebtables userspace and 64-bits kernel,
   patch from Florian Westphal.

3) Sanitize proc names in several x_tables extensions, also from Florian.

4) Add sanitization to ebt_among wormhash logic, from Florian.

5) Missing release of hook array in flowtable.


You can pull these changes from:

  git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git

Thanks!



The following changes since commit ce380619fab99036f5e745c7a865b21c59f005f6:

  Merge tag 'please-pull-ia64_misc' of 
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux (2018-03-05 20:31:14 
-0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD

for you to fetch changes up to c04a3f730021c304c7cc4bc30ee57ee70ad98d57:

  netfilter: nf_tables: release flowtable hooks (2018-03-11 21:24:56 +0100)


Florian Westphal (3):
  netfilter: ebtables: fix erroneous reject of last rule
  netfilter: x_tables: add and use xt_check_proc_name
  netfilter: bridge: ebt_among: add more missing match size checks

Pablo Neira Ayuso (2):
  netfilter: nft_set_hash: skip fixed hash if timeout is specified
  netfilter: nf_tables: release flowtable hooks

 include/linux/netfilter/x_tables.h |  2 ++
 net/bridge/netfilter/ebt_among.c   | 34 ++
 net/bridge/netfilter/ebtables.c|  6 +-
 net/netfilter/nf_tables_api.c  |  1 +
 net/netfilter/nft_set_hash.c   |  2 +-
 net/netfilter/x_tables.c   | 30 ++
 net/netfilter/xt_hashlimit.c   | 16 ++--
 net/netfilter/xt_recent.c  |  6 +++---
 8 files changed, 86 insertions(+), 11 deletions(-)


Re: [PATCH net] ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu

2018-03-12 Thread David Miller
From: Sabrina Dubroca 
Date: Mon, 12 Mar 2018 17:05:28 +0100

> 2018-03-09, 16:06:19 -0500, David Miller wrote:
>> From: Sabrina Dubroca 
>> Date: Fri,  9 Mar 2018 17:43:21 +0100
>> 
>> I think if you just choose an unused RTCF_* bit (f.e. 0x0200) for
>> the state, you can use that because values propagate into the
>> rtable->rt_flags, and do not propagate out.  So you should be able to
>> use it in this way privately inside the kernel.
> 
> What about a bitfield?
> 
> - u32 rt_pmtu;
> + u32 rt_mtu_locked:1,
> + rt_pmtu:31;

I guess that's fine.


Re: [PATCH] net: hns: use put_device() if device_register fail

2018-03-12 Thread arvindY



On Monday 12 March 2018 08:13 PM, David Miller wrote:

From: Arvind Yadav 
Date: Fri,  9 Mar 2018 16:11:17 +0530


if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav 

I do not see anything giving cls_dev an initial non-zero reference
count before this device_register() call.

Yes,  you are correct there is nothing to release (hnae_release).


And I have no idea why you use a "!" when saying 'error' you this
commit log message.


Sorry for that. next time I will take care.

~arvind


Re: [pci PATCH v4 1/4] pci-iov: Add support for unmanaged SR-IOV

2018-03-12 Thread Alex Williamson
On Mon, 12 Mar 2018 09:01:54 -0700
Alexander Duyck  wrote:

> On Mon, Mar 12, 2018 at 12:59 AM, Christoph Hellwig  wrote:
> > On Sun, Mar 11, 2018 at 09:59:09PM -0600, Alex Williamson wrote:  
> >> I still struggle to understand why we need this "unmanaged"
> >> complication and how a user of the sysfs API is expected to have any
> >> idea whether a PF is managed or unmanaged and why they should care.
> >> Can't we just have a pci_simple_sriov_configure() helper and ignore
> >> this unmanaged business?  Thanks,  
> >
> > Just a pci_simple_sriov_configure is exactly what I envisioned originally.  
> 
> I can drop the "unmanaged" bits if that is what is wanted, but based
> on previous conversations I thought there was some concern about the
> kernel loading VFs when there was some foreign entity managing the VFs
> other than the kernel.

My concern has always been whether the PF driver is trusted and by
dropping the vfio bits, the remaining drivers here are native, trusted,
host drivers, so I don't see that we have any reason to consider the
VFs as anything other than trusted as well.  It's VFs where the PF
driver is untrusted, such as a userspace driver, which needs some kind
of quarantine, imo.  Thanks,

Alex


Re: [PATCH net-next 1/1] tc-testing: updated gact tests with batch test cases

2018-03-12 Thread Roman Mashak
David Miller  writes:

> From: Roman Mashak 
> Date: Fri,  9 Mar 2018 17:16:12 -0500
>
>> Add test cases to exercise code paths responsible for adding or deleting
>> batch of TC actions.
>> 
>> Signed-off-by: Roman Mashak 
>
> You submitted this patch twice.
>
> You didn't indicate if this is a new version of the patch or something
> like this.
>

Sorry for that glitch, I've just resent the patch.

> Please resubmit your tc-testing changes, all of them, with this
> sorted out.


[RESEND PATCH net-next 1/1] tc-testing: updated gact tests with batch test cases

2018-03-12 Thread Roman Mashak
Add test cases to exercise code paths responsible for adding or deleting
batch of TC actions.

Signed-off-by: Roman Mashak 
---
 .../tc-testing/tc-tests/actions/gact.json  | 73 +-
 1 file changed, 72 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json 
b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
index e2187b6e0b7a..ae96d0350d7e 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
@@ -465,5 +465,76 @@
 "teardown": [
 "$TC actions flush action gact"
 ]
+},
+{
+"id": "1021",
+"name": "Add batch of 32 gact pass actions",
+"category": [
+"actions",
+"gact"
+],
+"setup": [
+[
+"$TC actions flush action gact",
+0,
+1,
+255
+]
+],
+"cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action pass index $i 
\"; args=\"$args$cmd\"; done && $TC actions add $args",
+"expExitCode": "0",
+"verifyCmd": "$TC actions list action gact",
+"matchPattern": "^[ \t]+index [0-9]+ ref",
+"matchCount": "32",
+"teardown": [
+"$TC actions flush action gact"
+]
+},
+{
+"id": "da7a",
+"name": "Add batch of 32 gact continue actions with cookie",
+"category": [
+"actions",
+"gact"
+],
+"setup": [
+[
+"$TC actions flush action gact",
+0,
+1,
+255
+]
+],
+"cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action continue index 
$i cookie aabbccddeeff112233445566778800a1 \"; args=\"$args$cmd\"; done && $TC 
actions add $args",
+"expExitCode": "0",
+"verifyCmd": "$TC actions list action gact",
+"matchPattern": "^[ \t]+index [0-9]+ ref",
+"matchCount": "32",
+"teardown": [
+"$TC actions flush action gact"
+]
+},
+{
+"id": "8aa3",
+"name": "Delete batch of 32 gact continue actions",
+"category": [
+"actions",
+"gact"
+],
+"setup": [
+[
+"$TC actions flush action gact",
+0,
+1,
+255
+],
+"for i in `seq 1 32`; do cmd=\"action continue index $i \"; 
args=\"$args$cmd\"; done && $TC actions add $args"
+],
+"cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action gact index $i 
\"; args=\"$args$cmd\"; done && $TC actions del $args",
+"expExitCode": "0",
+"verifyCmd": "$TC actions list action gact",
+"matchPattern": "^[ \t]+index [0-9]+ ref",
+"matchCount": "0",
+"teardown": []
 }
-]
+]
\ No newline at end of file
-- 
2.7.4



Re: [PATCH net-next 1/1] tc-testing: updated gact tests with batch test cases

2018-03-12 Thread David Miller
From: Roman Mashak 
Date: Mon, 12 Mar 2018 12:39:57 -0400

> David Miller  writes:
> 
>> From: Roman Mashak 
>> Date: Fri,  9 Mar 2018 17:16:12 -0500
>>
>>> Add test cases to exercise code paths responsible for adding or deleting
>>> batch of TC actions.
>>> 
>>> Signed-off-by: Roman Mashak 
>>
>> You submitted this patch twice.
>>
>> You didn't indicate if this is a new version of the patch or something
>> like this.
>>
> 
> Sorry for that glitch, I've just resent the patch.
> 
>> Please resubmit your tc-testing changes, all of them, with this
>> sorted out.

I said "all of your tc-testing changes" not just this one.


Re: [PATCH] net: llc: drop VLA in llc_sap_mcast()

2018-03-12 Thread Salvatore Mesoraca
2018-03-12 16:14 GMT+01:00 David Miller :
> From: Salvatore Mesoraca 
> Date: Sun, 11 Mar 2018 22:12:04 +0100
>
>> Avoid a VLA[1] by using a real constant expression instead of a variable.
>> The compiler should be able to optimize the original code and avoid using
>> an actual VLA. Anyway this change is useful because it will avoid a false
>> positive with -Wvla, it might also help the compiler generating better
>> code.
>>
>> [1] https://lkml.org/lkml/2018/3/7/621
>>
>> Signed-off-by: Salvatore Mesoraca 
>
> Applied.

Thank you.


Re: [PATCH 0/5] Netfilter fixes for net

2018-03-12 Thread David Miller
From: Pablo Neira Ayuso 
Date: Mon, 12 Mar 2018 17:15:59 +0100

> The following patchset contains Netfilter fixes for your net tree, they are:
> 
> 1) Fixed hashtable representation doesn't support timeout flag, skip it
>otherwise rules to add elements from the packet fail bogusly fail with
>EOPNOTSUPP.
> 
> 2) Fix bogus error with 32-bits ebtables userspace and 64-bits kernel,
>patch from Florian Westphal.
> 
> 3) Sanitize proc names in several x_tables extensions, also from Florian.
> 
> 4) Add sanitization to ebt_among wormhash logic, from Florian.
> 
> 5) Missing release of hook array in flowtable.

Pulled, thank you.


[PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata

2018-03-12 Thread Thomas Falcon
This patch series contains fixes for VLAN and other backing hardware
errata. The VLAN fixes are mostly to account for the additional four
bytes VLAN header in TX descriptors and buffers, when applicable.

The other fixes for device errata are to pad small packets to avoid a
possible connection error that can occur when some devices attempt to
transmit small packets. The other fixes are GSO related. Some devices
cannot handle a smaller MSS or a packet with a single segment, so
disable GSO in those cases.

v2: Fix style mistake (unneeded brackets) in patch 3/4

Thomas Falcon (4):
  ibmvnic: Account for VLAN tag in L2 Header descriptor
  ibmvnic: Account for VLAN header length in TX buffers
  ibmvnic: Pad small packets to minimum MTU size
  ibmvnic: Handle TSO backing device errata

 drivers/net/ethernet/ibm/ibmvnic.c | 50 +++---
 1 file changed, 46 insertions(+), 4 deletions(-)

-- 
2.12.3



[PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size

2018-03-12 Thread Thomas Falcon
Some backing devices cannot handle small packets well,
so pad any small packets to avoid that. It was recommended
that the VNIC driver should not send packets smaller than the
minimum MTU value provided by firmware, so pad small packets
to be at least that long.

Signed-off-by: Thomas Falcon 
---
v2: Fix up unneeded brackets
 drivers/net/ethernet/ibm/ibmvnic.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
index 14f0081..7ed87fb 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1340,6 +1340,19 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff 
*txbuff,
 txbuff->indir_arr + 1);
 }
 
+static int ibmvnic_xmit_workarounds(struct sk_buff *skb,
+   struct net_device *netdev)
+{
+   /* For some backing devices, mishandling of small packets
+* can result in a loss of connection or TX stall. Device
+* architects recommend that no packet should be smaller
+* than the minimum MTU value provided to the driver, so
+* pad any packets to that length
+*/
+   if (skb->len < netdev->min_mtu)
+   return skb_put_padto(skb, netdev->min_mtu);
+}
+
 static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -1377,6 +1390,13 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct 
net_device *netdev)
goto out;
}
 
+   if (ibmvnic_xmit_workarounds(skb, adapter)) {
+   tx_dropped++;
+   tx_send_failed++;
+   ret = NETDEV_TX_OK;
+   goto out;
+   }
+
tx_pool = &adapter->tx_pool[queue_num];
tx_scrq = adapter->tx_scrq[queue_num];
txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));
-- 
2.7.5



  1   2   3   4   >