Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next v10 0/5] Avoiding stack overflow in skb_to_sgvec
From: David Miller @ 2017-06-05  3:03 UTC (permalink / raw)
  To: Jason; +Cc: netdev, linux-kernel, kernel-hardening
In-Reply-To: <20170604021626.11968-1-Jason@zx2c4.com>

From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun,  4 Jun 2017 04:16:21 +0200

> Changes v9->v10:
>    - Spaces to tabs on one line.
>    - Added some acked-by, reviewed-by lines.

I wish in the future you would retain the entire change history, and
keep it in it's entirety here in the header postings.  That list of
adjustments is important and might be useful to someone in the future
("why didn't they do this, oh they decided to not do that
intentionally I can see that in the Change list").

> The recent bug with macsec and historical one with virtio have
> indicated that letting skb_to_sgvec trounce all over an sglist
> without checking the length is probably a bad idea. And it's not
> necessary either: an sglist already explicitly marks its last
> item, and the initialization functions are diligent in doing so.
> Thus there's a clear way of avoiding future overflows.
> 
> So, this patchset, from a high level, makes skb_to_sgvec return
> a potential error code, and then adjusts all callers to check
> for the error code. There are two situations in which skb_to_sgvec
> might return such an error:
> 
>    1) When the passed in sglist is too small; and
>    2) When the passed in skbuff is too deeply nested.
> 
> So, the first patch in this series handles the issues with
> skb_to_sgvec directly, and the remaining ones then handle the call
> sites.

Applied to net-next.

^ permalink raw reply

* Re: [PATCH] sit: reload iphdr in ipip6_rcv
From: David Miller @ 2017-06-05  3:05 UTC (permalink / raw)
  To: yanhaishuang
  Cc: jesse, kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel
In-Reply-To: <1496558623-11437-1-git-send-email-yanhaishuang@cmss.chinamobile.com>

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Sun,  4 Jun 2017 14:43:43 +0800

> Since iptunnel_pull_header() can call pskb_may_pull(),
> we must reload any pointer that was related to skb->head.
> 
> Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Applied and queued up for -stable, thank you.

^ permalink raw reply

* [PATCH net-next 00/11] qed*: Support VF XDP attachment
From: David Miller @ 2017-06-05  3:09 UTC (permalink / raw)
  To: Yuval.Mintz; +Cc: netdev
In-Reply-To: <20170604103109.3082-1-Yuval.Mintz@cavium.com>


Please no empty primary subject lines next time, thank you.

Series applied.

^ permalink raw reply

* Re: [PATCH net V4] net/mlx4: Fix the check in attaching steering rules
From: David Miller @ 2017-06-05  3:14 UTC (permalink / raw)
  To: tariqt; +Cc: netdev, eranbe, ogerlitz, talatb
In-Reply-To: <1496575807-27979-1-git-send-email-tariqt@mellanox.com>

From: Tariq Toukan <tariqt@mellanox.com>
Date: Sun,  4 Jun 2017 14:30:07 +0300

> From: Talat Batheesh <talatb@mellanox.com>
> 
> Our previous patch (cited below) introduced a regression
> for RAW Eth QPs.
> 
> Fix it by checking if the QP number provided by user-space
> exists, hence allowing steering rules to be added for valid
> QPs only.
> 
> Fixes: 89c557687a32 ("net/mlx4_en: Avoid adding steering rules with invalid ring")
> Reported-by: Or Gerlitz <gerlitz.or@gmail.com>
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> Acked-by: Or Gerlitz <ogerlitz@mellanox.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Applied, thanks.

^ permalink raw reply

* Re: [patch net-next] mlxsw: spectrum: Rename the firmware file
From: David Miller @ 2017-06-05  3:48 UTC (permalink / raw)
  To: jiri; +Cc: netdev, idosch, yotamg, mlxsw
In-Reply-To: <20170604144958.14358-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Sun,  4 Jun 2017 16:49:58 +0200

> From: Yotam Gigi <yotamg@mellanox.com>
> 
> Change the firmware file name to be in "mellanox" directory.
> 
> This commit is a followup to the linux-firmware commit a4c72696f5f4
> ("Mellanox: Add firmware for mlxsw_spectrum")
> 
> Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
> Reviewed-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied.

^ permalink raw reply

* Re: [patch net-next 0/3] mlxsw: Minor cleanup
From: David Miller @ 2017-06-05  3:50 UTC (permalink / raw)
  To: jiri; +Cc: netdev, idosch, petrm, mlxsw
In-Reply-To: <20170604145340.14447-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Sun,  4 Jun 2017 16:53:37 +0200

> Fix small issues I noticed during the refactoring.
> 
> First patch adds file name comments in the header file to make it clear
> what goes where. Second patch fixes a typo and third patch simply aligns
> RIF index allocation with similar allocations in the driver.

Series applied.

^ permalink raw reply

* Re: [PATCH] net: sched: fix mips build failure
From: Jiri Pirko @ 2017-06-05  4:50 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Jamal Hadi Salim, Cong Wang, David S. Miller, Ralf Baechle,
	linux-kernel, netdev, linux-mips
In-Reply-To: <1496612653-12419-1-git-send-email-sudipm.mukherjee@gmail.com>

Sun, Jun 04, 2017 at 11:44:13PM CEST, sudipm.mukherjee@gmail.com wrote:
>The build of mips ar7_defconfig was failing with the error:
>../net/sched/act_api.c: In function 'tcf_action_goto_chain_init':
>../net/sched/act_api.c:37:18: error:
>	implicit declaration of function 'tcf_chain_get'
>	[-Werror=implicit-function-declaration]
>
>../net/sched/act_api.c: In function 'tcf_action_goto_chain_fini':
>../net/sched/act_api.c:45:2: error:
>	implicit declaration of function 'tcf_chain_put'
>	[-Werror=implicit-function-declaration]
>
>Add two inline helpers for the case where CONFIG_NET_CLS is not enabled.
>
>Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

I already sent a fix for this:

http://patchwork.ozlabs.org/project/netdev/list/

^ permalink raw reply

* Re: [PATCH v2] devlink: fix potential memort leak
From: Jiri Pirko @ 2017-06-05  4:51 UTC (permalink / raw)
  To: Haishuang Yan
  Cc: David S. Miller, Arkadi Sharshevsky, Jiri Pirko, netdev,
	linux-kernel
In-Reply-To: <1496624241-25794-1-git-send-email-yanhaishuang@cmss.chinamobile.com>

Mon, Jun 05, 2017 at 02:57:21AM CEST, yanhaishuang@cmss.chinamobile.com wrote:
>We must free allocated skb when genlmsg_put() return fails.
>
>Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
>Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>

Thanks.

^ permalink raw reply

* Re: [Intel-wired-lan] [PATCH v2 1/1] e1000e: Undo e1000e_pm_freeze if __e1000_shutdown fails
From: Neftin, Sasha @ 2017-06-05  5:20 UTC (permalink / raw)
  To: Jani Nikula, David Miller, daniel.vetter
  Cc: netdev, intel-gfx, linux-kernel, intel-wired-lan, dri-devel,
	Dave Ertman
In-Reply-To: <20170531155043.3596-2-jani.nikula@intel.com>

On 5/31/2017 18:50, Jani Nikula wrote:
> From: Chris Wilson <chris@chris-wilson.co.uk>
>
> An error during suspend (e100e_pm_suspend),
>
> [  429.994338] ACPI : EC: event blocked
> [  429.994633] e1000e: EEE TX LPI TIMER: 00000011
> [  430.955451] pci_pm_suspend(): e1000e_pm_suspend+0x0/0x30 [e1000e] returns -2
> [  430.955454] dpm_run_callback(): pci_pm_suspend+0x0/0x140 returns -2
> [  430.955458] PM: Device 0000:00:19.0 failed to suspend async: error -2
> [  430.955581] PM: Some devices failed to suspend, or early wake event detected
> [  430.957709] ACPI : EC: event unblocked
>
> lead to complete failure:
>
> [  432.585002] ------------[ cut here ]------------
> [  432.585013] WARNING: CPU: 3 PID: 8372 at kernel/irq/manage.c:1478 __free_irq+0x9f/0x280
> [  432.585015] Trying to free already-free IRQ 20
> [  432.585016] Modules linked in: cdc_ncm usbnet x86_pkg_temp_thermal intel_powerclamp coretemp mii crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep lpc_ich snd_hda_core snd_pcm mei_me mei sdhci_pci sdhci i915 mmc_core e1000e ptp pps_core prime_numbers
> [  432.585042] CPU: 3 PID: 8372 Comm: kworker/u16:40 Tainted: G     U          4.10.0-rc8-CI-Patchwork_3870+ #1
> [  432.585044] Hardware name: LENOVO 2356GCG/2356GCG, BIOS G7ET31WW (1.13 ) 07/02/2012
> [  432.585050] Workqueue: events_unbound async_run_entry_fn
> [  432.585051] Call Trace:
> [  432.585058]  dump_stack+0x67/0x92
> [  432.585062]  __warn+0xc6/0xe0
> [  432.585065]  warn_slowpath_fmt+0x4a/0x50
> [  432.585070]  ? _raw_spin_lock_irqsave+0x49/0x60
> [  432.585072]  __free_irq+0x9f/0x280
> [  432.585075]  free_irq+0x34/0x80
> [  432.585089]  e1000_free_irq+0x65/0x70 [e1000e]
> [  432.585098]  e1000e_pm_freeze+0x7a/0xb0 [e1000e]
> [  432.585106]  e1000e_pm_suspend+0x21/0x30 [e1000e]
> [  432.585113]  pci_pm_suspend+0x71/0x140
> [  432.585118]  dpm_run_callback+0x6f/0x330
> [  432.585122]  ? pci_pm_freeze+0xe0/0xe0
> [  432.585125]  __device_suspend+0xea/0x330
> [  432.585128]  async_suspend+0x1a/0x90
> [  432.585132]  async_run_entry_fn+0x34/0x160
> [  432.585137]  process_one_work+0x1f4/0x6d0
> [  432.585140]  ? process_one_work+0x16e/0x6d0
> [  432.585143]  worker_thread+0x49/0x4a0
> [  432.585145]  kthread+0x107/0x140
> [  432.585148]  ? process_one_work+0x6d0/0x6d0
> [  432.585150]  ? kthread_create_on_node+0x40/0x40
> [  432.585154]  ret_from_fork+0x2e/0x40
> [  432.585156] ---[ end trace 6712df7f8c4b9124 ]---
>
> The unwind failures stems from commit 2800209994f8 ("e1000e: Refactor PM
> flows"), but it may be a later patch that introduced the non-recoverable
> behaviour.
>
> Fixes: 2800209994f8 ("e1000e: Refactor PM flows")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99847
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Cc: Dave Ertman <davidx.m.ertman@intel.com>
> Cc: Bruce Allan <bruce.w.allan@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> [Jani: bikeshed repainted]
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>   drivers/net/ethernet/intel/e1000e/netdev.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
> index b3679728caac..5cad688be609 100644
> --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> @@ -6630,12 +6630,17 @@ static int e1000e_pm_thaw(struct device *dev)
>   static int e1000e_pm_suspend(struct device *dev)
>   {
>   	struct pci_dev *pdev = to_pci_dev(dev);
> +	int rc;
>   
>   	e1000e_flush_lpic(pdev);
>   
>   	e1000e_pm_freeze(dev);
>   
> -	return __e1000_shutdown(pdev, false);
> +	rc = __e1000_shutdown(pdev, false);
> +	if (rc)
> +		e1000e_pm_thaw(dev);
> +
> +	return rc;
>   }
>   
>   static int e1000e_pm_resume(struct device *dev)

Good. Let's pick up this patch.

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply

* Re: More BPF verifier questions
From: Y Song via iovisor-dev @ 2017-06-05  7:06 UTC (permalink / raw)
  To: Edward Cree; +Cc: Alexei Starovoitov, netdev, iovisor-dev, David Miller
In-Reply-To: <24a519bc-d403-f429-5d72-2a1d31edfbe7-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>

On Fri, Jun 2, 2017 at 7:42 AM, Edward Cree <ecree-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org> wrote:
> A couple of the tests in tools/testing/selftests/bpf/test_verifier.c seem to be bogus: Test "multiple registers share map_lookup_elem bad reg type" is supposed to
>  error with "R3 invalid mem access 'inv'", but from my reading of it, R3 gets
>  loaded with a map_value_or_null, that later gets null-checked (both directly
>  and - through R0 - indirectly), and finally stored through.  I don't see
>  what's supposed to make R3 become a bad pointer.

You are right. In this case,
r0 = bpf_map_lookup
r2 = r0
r3 = r0
r4 = r0
r5 = r0
if (r0 != 0)  <=== condition 1
  r1 = 1
if (r0 != 0)
  r1 = 2
if (r3 != 0)
  *r3 = 0
...

If (r0 != 0) if false, the current verifier marks r2/r3/r4/r5 as unknown value.
I guess here what you did to have precise value 0 helps and make verifier
complaint go away correctly.

> Test "helper access to variable memory: stack, bitwise AND + JMP, correct
>  bounds" is listed as expected to pass, but it passes zero in the 'size'
>  argument, an ARG_CONST_SIZE, to bpf_probe_read; I believe this should fail
>  (and with my WIP patch it does).

Probably a typo or mis-statement. "size" is not passed in with "zero", but
with an unknown value. Hence, it probably should fail.

      BPF_MOV64_IMM(BPF_REG_2, 16),
      BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_2, -128),
      BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_1, -128),
      BPF_ALU64_IMM(BPF_AND, BPF_REG_2, 64),
      BPF_MOV64_IMM(BPF_REG_4, 0),
      BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2),
      BPF_MOV64_IMM(BPF_REG_3, 0),
      BPF_EMIT_CALL(BPF_FUNC_probe_read),


In kernel/bpf/verifier.c,

  } else if (arg_type == ARG_CONST_SIZE ||
       arg_type == ARG_CONST_SIZE_OR_ZERO) {
    expected_type = CONST_IMM;
    /* One exception. Allow UNKNOWN_VALUE registers when the
     * boundaries are known and don't cause unsafe memory accesses
     */
    if (type != UNKNOWN_VALUE && type != expected_type)
      goto err_type;

Maybe somebody can provide some historical context for this relaxation.

^ permalink raw reply

* [PATCH v1] net: phy: Delete unused function phy_ethtool_gset
From: Yuval Shaia @ 2017-06-05  7:18 UTC (permalink / raw)
  To: f.fainelli, andrew, corbet, netdev, linux-doc, yuval.shaia

It's unused, so remove it.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
v0 -> v1:
	* Add commit message
	* Update Documentation/networking/phy.txt
	* Modify commit header message
---
 Documentation/networking/phy.txt |  1 -
 drivers/net/phy/phy.c            | 24 ------------------------
 include/linux/phy.h              |  1 -
 3 files changed, 26 deletions(-)

diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index 16f90d8..bdec0f7 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -295,7 +295,6 @@ Doing it all yourself
    settings in the PHY.
 
  int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
- int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
 
    Ethtool convenience functions.
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9c372bf..8e26af5 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -484,30 +484,6 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
 }
 EXPORT_SYMBOL(phy_ethtool_ksettings_set);
 
-int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
-{
-	cmd->supported = phydev->supported;
-
-	cmd->advertising = phydev->advertising;
-	cmd->lp_advertising = phydev->lp_advertising;
-
-	ethtool_cmd_speed_set(cmd, phydev->speed);
-	cmd->duplex = phydev->duplex;
-	if (phydev->interface == PHY_INTERFACE_MODE_MOCA)
-		cmd->port = PORT_BNC;
-	else
-		cmd->port = PORT_MII;
-	cmd->phy_address = phydev->mdio.addr;
-	cmd->transceiver = phy_is_internal(phydev) ?
-		XCVR_INTERNAL : XCVR_EXTERNAL;
-	cmd->autoneg = phydev->autoneg;
-	cmd->eth_tp_mdix_ctrl = phydev->mdix_ctrl;
-	cmd->eth_tp_mdix = phydev->mdix;
-
-	return 0;
-}
-EXPORT_SYMBOL(phy_ethtool_gset);
-
 void phy_ethtool_ksettings_get(struct phy_device *phydev,
 			       struct ethtool_link_ksettings *cmd)
 {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 4ec07a6..804851c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -843,7 +843,6 @@ void phy_start_machine(struct phy_device *phydev);
 void phy_stop_machine(struct phy_device *phydev);
 void phy_trigger_machine(struct phy_device *phydev, bool sync);
 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
-int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
 void phy_ethtool_ksettings_get(struct phy_device *phydev,
 			       struct ethtool_link_ksettings *cmd);
 int phy_ethtool_ksettings_set(struct phy_device *phydev,
-- 
2.9.4

^ permalink raw reply related

* [PATCH net] net/mlx4: Check if Granular QoS per VF has been enabled before updating QP qos_vport
From: Tariq Toukan @ 2017-06-05  7:44 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Eran Ben Elisha, Ido Shamay, Jack Morgenstein,
	Tariq Toukan

From: Ido Shamay <idos@mellanox.com>

The Granular QoS per VF feature must be enabled in FW before it can be
used.

Thus, the driver cannot modify a QP's qos_vport value (via the UPDATE_QP FW
command) if the feature has not been enabled -- the FW returns an error if
this is attempted.

Fixes: 08068cd5683f ("net/mlx4: Added qos_vport QP configuration in VST mode")
Signed-off-by: Ido Shamay <idos@mellanox.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/qp.c               |  6 ++++++
 drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 16 +++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index ad92d2311478..5a310d313e94 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -484,6 +484,12 @@ int mlx4_update_qp(struct mlx4_dev *dev, u32 qpn,
 	}
 
 	if (attr & MLX4_UPDATE_QP_QOS_VPORT) {
+		if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_QOS_VPP)) {
+			mlx4_warn(dev, "Granular QoS per VF is not enabled\n");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
 		qp_mask |= 1ULL << MLX4_UPD_QP_MASK_QOS_VPP;
 		cmd->qp_context.qos_vport = params->qos_vport;
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 07516545474f..812783865205 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -5255,6 +5255,13 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave)
 	mutex_unlock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex);
 }
 
+static void update_qos_vpp(struct mlx4_update_qp_context *ctx,
+			   struct mlx4_vf_immed_vlan_work *work)
+{
+	ctx->qp_mask |= cpu_to_be64(1ULL << MLX4_UPD_QP_MASK_QOS_VPP);
+	ctx->qp_context.qos_vport = work->qos_vport;
+}
+
 void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work)
 {
 	struct mlx4_vf_immed_vlan_work *work =
@@ -5369,11 +5376,10 @@ void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work)
 					qp->sched_queue & 0xC7;
 				upd_context->qp_context.pri_path.sched_queue |=
 					((work->qos & 0x7) << 3);
-				upd_context->qp_mask |=
-					cpu_to_be64(1ULL <<
-						    MLX4_UPD_QP_MASK_QOS_VPP);
-				upd_context->qp_context.qos_vport =
-					work->qos_vport;
+
+				if (dev->caps.flags2 &
+				    MLX4_DEV_CAP_FLAG2_QOS_VPP)
+					update_qos_vpp(upd_context, work);
 			}
 
 			err = mlx4_cmd(dev, mailbox->dma,
-- 
1.8.3.1

^ permalink raw reply related

* Re:  [PATCH][-next] mwifiex: make function mwifiex_ret_pkt_aggr_ctrl static
From: Xinming Hu @ 2017-06-05  8:23 UTC (permalink / raw)
  To: Colin King, Amitkumar Karwar, Nishant Sarmukadam, Ganapathi Bhat,
	Kalle Valo, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org
  Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	Cathy Luo
In-Reply-To: <20170602085639.29338-1-colin.king@canonical.com>

Hi Colin,

> -----Original Message-----
> From: Colin King [mailto:colin.king@canonical.com]
> Sent: 2017年6月2日 16:57
> To: Amitkumar Karwar; Nishant Sarmukadam; Ganapathi Bhat; Xinming Hu;
> Kalle Valo; linux-wireless@vger.kernel.org; netdev@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [EXT] [PATCH][-next] mwifiex: make function
> mwifiex_ret_pkt_aggr_ctrl static
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Colin Ian King <colin.king@canonical.com>
> 
> function mwifiex_ret_pkt_aggr_ctrl can be made static as it does not need to
> be in global scope.
> 
> Cleans up sparse warning: "symbol 'mwifiex_ret_pkt_aggr_ctrl' was not
> declared. Should it be static?"

Yes, it should be static, Thanks,

Regards,
Simon
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> index 3348fb3a7514..2945775e83c5 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
> @@ -1154,8 +1154,8 @@ static int mwifiex_ret_chan_region_cfg(struct
> mwifiex_private *priv,
>  	return 0;
>  }
> 
> -int mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private *priv,
> -			      struct host_cmd_ds_command *resp)
> +static int mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private *priv,
> +				     struct host_cmd_ds_command *resp)
>  {
>  	struct host_cmd_ds_pkt_aggr_ctrl *pkt_aggr_ctrl =
>  					&resp->params.pkt_aggr_ctrl;
> --
> 2.11.0


^ permalink raw reply

* [PATCH iproute2 net-next] ip neigh: allow flush FAILED neighbour entry
From: Hangbin Liu @ 2017-06-05  8:31 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Hangbin Liu

After upstream commit 5071034e4af7 ('neigh: Really delete an arp/neigh entry
on "ip neigh delete" or "arp -d"'), we could delete a single FAILED neighbour
entry now. But `ip neigh flush` still skip the FAILED entry.

Let's remove this filter so we can also flush FAILED entry.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 ip/ipneigh.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index 4d8fc85..8082fa8 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -445,7 +445,6 @@ static int do_show_or_flush(int argc, char **argv, int flush)
 		filter.flushb = flushb;
 		filter.flushp = 0;
 		filter.flushe = sizeof(flushb);
-		filter.state &= ~NUD_FAILED;
 
 		while (round < MAX_ROUNDS) {
 			if (rtnl_dump_request_n(&rth, &req.n) < 0) {
-- 
2.5.5

^ permalink raw reply related

* Re: [PATCH net] netlink: don't send unknown nsid
From: Nicolas Dichtel @ 2017-06-05  8:40 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: davem, netdev
In-Reply-To: <20170601224454.GG2673@x240.lan>

Le 02/06/2017 à 00:44, Flavio Leitner a écrit :
> On Thu, Jun 01, 2017 at 10:42:13PM +0200, Nicolas Dichtel wrote:
>> Le 01/06/2017 à 19:02, Flavio Leitner a écrit :
[snip]
>>> On the other hand, with the original patch, if the socket and the
>>> device are in the same netns, we don't need to report any ID.  Previous
>>> kernels did that, so we are not breaking anything.  When the netns
>>> differs, then we either should report the real ID or an error.
>>>
>> I don't understand. With or without my last patch, the kernel sends netlink
>> messages of other netns than the netns where the socket is opened, only if an
>> nsid is assigned.
> 
> "only if an nsid is assigned" that's the issue.
It was design like that because it's not legitimate to unconditionally listen
all netns of the system. Isolation between namespaces must be respected
(scenarii with containers, etc.).
When a nsid is assigned to a peer netns, it's a way to say "ok, I know this
netns and I have access to it".

> 
> Let me ask this instead: How do you think userspace should behave when
> netnsid allocation fails?
> 
There is two ways to assign a nsid:
 - manually with netlink ('ip netns set'). In this case, the error is reported
   to userspace via netlink.
 - automatically when a x-netns interface is created. The link-nsid is also
   reported to userspace. If the allocation failed, NETNSA_NSID_NOT_ASSIGNED is
   reported. And if you were able to create this x-netns interface, it means
   that you have access to this peer netns, thus you can try to assign the nsid
   manually.
So, in both cases, userland knows that something went wrong.

Do you have another scenario in mind?


Nicolas

^ permalink raw reply

* [PATCH][V2] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value
From: Colin King @ 2017-06-05  9:04 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The current comparison of entry < 0 will never be true since entry is an
unsigned integer. Make entry an int to ensure -ve error return values
from the call to jumbo_frm are correctly being caught.

Detected by CoverityScan, CID#1238760 ("Macro compares unsigned to 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 68a188e74c54..3346a99ce4c4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2945,7 +2945,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	int i, csum_insertion = 0, is_jumbo = 0;
 	u32 queue = skb_get_queue_mapping(skb);
 	int nfrags = skb_shinfo(skb)->nr_frags;
-	unsigned int entry, first_entry;
+	int entry;
+	unsigned int first_entry;
 	struct dma_desc *desc, *first;
 	struct stmmac_tx_queue *tx_q;
 	unsigned int enh_desc;
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH][V2] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value
From: Julia Lawall @ 2017-06-05  9:20 UTC (permalink / raw)
  To: Colin King
  Cc: Giuseppe Cavallaro, Alexandre Torgue, netdev, kernel-janitors,
	linux-kernel
In-Reply-To: <20170605090452.30688-1-colin.king@canonical.com>



On Mon, 5 Jun 2017, Colin King wrote:

> From: Colin Ian King <colin.king@canonical.com>
>
> The current comparison of entry < 0 will never be true since entry is an
> unsigned integer. Make entry an int to ensure -ve error return values
> from the call to jumbo_frm are correctly being caught.

Perhaps it would be good to mention that the return value of jumbo_frm
is an int and that the subsequent computations on entry are all on small
values so there is no need for unsigned.

julia

>
> Detected by CoverityScan, CID#1238760 ("Macro compares unsigned to 0")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 68a188e74c54..3346a99ce4c4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2945,7 +2945,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>  	int i, csum_insertion = 0, is_jumbo = 0;
>  	u32 queue = skb_get_queue_mapping(skb);
>  	int nfrags = skb_shinfo(skb)->nr_frags;
> -	unsigned int entry, first_entry;
> +	int entry;
> +	unsigned int first_entry;
>  	struct dma_desc *desc, *first;
>  	struct stmmac_tx_queue *tx_q;
>  	unsigned int enh_desc;
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply

* [patch net-next 00/19] Remove support from bridge bypass for mlxsw/rocker drivers
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera

From: Jiri Pirko <jiri@mellanox.com>

Currently setting bridge port attributes and adding FDBs are done via
setting the SELF flag which implies unconsistent offloading model. This
patch-set fixes this behavior by making the bridge and drivers which are
using it to be totally in sync.

This implies several changes:
- Offloading bridge flags from the bridge code.
- Sending notification about FDB add/del to the software bridge in a
  similiar way it is done for the hardware externally learned FDBs.

By making the offloading model more consistent a cleanup is done in
the drivers supporting it. This is done in order to remove un-needed
logic related to dump operation which is redundant.

First add missing functionality to bridge, then clean up the mlxsw/rocker
drivers.

Arkadi Sharshevsky (19):
  net: switchdev: Add support for querying supported bridge flags by
    hardware
  net: bridge: Add support for offloading port attributes
  net: bridge: Add support for calling FDB external learning under rcu
  net: switchdev: Change notifier chain to be atomic
  net: bridge: Add support for notifying devices about FDB add/del
  net: bridge: Receive notification about successful FDB offload
  mlxsw: spectrum: Remove support for bridge FDB learning sync
  mlxsw: spectrum_switchdev: Add support for querying supported bridge
    flags
  mlxsw: spectrum: Remove support for bypass bridge port attributes/vlan
    set
  mlxsw: spectrum_switchdev: Change switchdev notifier API
  mlxsw: spectrum_switchdev: Add support for learning FDB through
    notification
  mlxsw: spectrum: Remove support for bridge bypass FDB add/del
  net: Remove support for bridge bypass ndos from stacked devices
  rocker: Remove support for bridge FDB learning sync
  rocker: Add support for querying supported bridge flags
  rocker: Change world_ops API and implementation to be switchdev
    independant
  rocker: Add support for learning FDB through notification
  rocker: Remove support for bypass bridge port attributes/vlan set
  rocker: Remove support bridge bypass FDB

 drivers/net/bonding/bond_main.c                    |   6 -
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     |   8 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |   1 +
 .../ethernet/mellanox/mlxsw/spectrum_switchdev.c   | 360 +++++-------
 drivers/net/ethernet/rocker/rocker.h               |  21 +-
 drivers/net/ethernet/rocker/rocker_main.c          | 235 +++++---
 drivers/net/ethernet/rocker/rocker_ofdpa.c         | 610 ++++++++-------------
 drivers/net/team/team.c                            |   6 -
 include/net/switchdev.h                            |   9 +-
 include/uapi/linux/neighbour.h                     |   1 +
 net/8021q/vlan_dev.c                               |   6 -
 net/bridge/br.c                                    |  19 +-
 net/bridge/br_fdb.c                                |  46 +-
 net/bridge/br_netlink.c                            | 112 +++-
 net/bridge/br_private.h                            |  23 +-
 net/bridge/br_switchdev.c                          |  13 +
 net/switchdev/switchdev.c                          |  30 +-
 17 files changed, 714 insertions(+), 792 deletions(-)

-- 
2.9.3

^ permalink raw reply

* [patch net-next 01/19] net: switchdev: Add support for querying supported bridge flags by hardware
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

This is done as a preparation stage before setting the bridge port flags
from the bridge code. Currently the device can be queried for the bridge
flags state, but the querier cannot distinguish if the flag is disabled
or if it is not supported at all. Thus, add new attr and a bit-mask which
include information regarding the support on a per-flag basis.

Drivers that support bridge offload but not support bridge flags should
return zeroed bitmask.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 include/net/switchdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 929d6af..63a754d 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -46,6 +46,7 @@ enum switchdev_attr_id {
 	SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
 	SWITCHDEV_ATTR_ID_PORT_STP_STATE,
 	SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
+	SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
 	SWITCHDEV_ATTR_ID_PORT_MROUTER,
 	SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
 	SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
@@ -62,6 +63,7 @@ struct switchdev_attr {
 		struct netdev_phys_item_id ppid;	/* PORT_PARENT_ID */
 		u8 stp_state;				/* PORT_STP_STATE */
 		unsigned long brport_flags;		/* PORT_BRIDGE_FLAGS */
+		unsigned long brport_flags_support;	/* PORT_BRIDGE_FLAGS_SUPPORT */
 		bool mrouter;				/* PORT_MROUTER */
 		clock_t ageing_time;			/* BRIDGE_AGEING_TIME */
 		bool vlan_filtering;			/* BRIDGE_VLAN_FILTERING */
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 02/19] net: bridge: Add support for offloading port attributes
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

Currently the flood, learning and learning_sync port attributes are
offloaded by setting the SELF flag. Add support for offloading the
flood and learning attribute through the bridge code. In case of
setting an unsupported flag on a offloded port the operation will
fail.

The learning_sync attribute doesn't have any software representation
and cannot be offloaded through the bridge code.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/bridge/br_netlink.c | 112 +++++++++++++++++++++++++++++++++++++++---------
 net/bridge/br_private.h |   4 ++
 2 files changed, 96 insertions(+), 20 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 1e63ec4..1afafb7 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -17,6 +17,7 @@
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <uapi/linux/if_bridge.h>
+#include <net/switchdev.h>
 
 #include "br_private.h"
 #include "br_private_stp.h"
@@ -662,16 +663,52 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state)
 }
 
 /* Set/clear or port flags based on attribute */
-static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[],
-			   int attrtype, unsigned long mask)
+static int br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[],
+			    int attrtype, unsigned long mask)
 {
-	if (tb[attrtype]) {
-		u8 flag = nla_get_u8(tb[attrtype]);
-		if (flag)
-			p->flags |= mask;
-		else
-			p->flags &= ~mask;
+	struct switchdev_attr attr = {
+		.orig_dev = p->dev,
+		.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
+	};
+	unsigned long flags;
+	int err;
+
+	if (!tb[attrtype])
+		return 0;
+
+	if (nla_get_u8(tb[attrtype]))
+		flags = p->flags | mask;
+	else
+		flags = p->flags & ~mask;
+
+	if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD)
+		goto out;
+
+	err = switchdev_port_attr_get(p->dev, &attr);
+	if (err == -EOPNOTSUPP)
+		goto out;
+	if (err)
+		return err;
+
+	/* Check if specific bridge flag attribute offload is supported */
+	if (!(attr.u.brport_flags_support & mask)) {
+		br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
+			(unsigned int)p->port_no, p->dev->name);
+		return -EOPNOTSUPP;
+	}
+
+	attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
+	attr.flags = SWITCHDEV_F_DEFER;
+	attr.u.brport_flags = flags;
+	err = switchdev_port_attr_set(p->dev, &attr);
+	if (err) {
+		br_warn(p->br, "error setting offload FLAG on port %u(%s)\n",
+			(unsigned int)p->port_no, p->dev->name);
+		return err;
 	}
+out:
+	p->flags = flags;
+	return 0;
 }
 
 /* Process bridge protocol info on port */
@@ -681,20 +718,55 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])
 	bool br_vlan_tunnel_old = false;
 	int err;
 
-	br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE);
-	br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD);
-	br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, BR_MULTICAST_FAST_LEAVE);
-	br_set_port_flag(p, tb, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK);
-	br_set_port_flag(p, tb, IFLA_BRPORT_LEARNING, BR_LEARNING);
-	br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD);
-	br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD);
-	br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, BR_MULTICAST_TO_UNICAST);
-	br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD);
-	br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP);
-	br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI);
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, BR_MULTICAST_FAST_LEAVE);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_LEARNING, BR_LEARNING);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, BR_MULTICAST_TO_UNICAST);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP);
+	if (err)
+		return err;
+
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI);
+	if (err)
+		return err;
 
 	br_vlan_tunnel_old = (p->flags & BR_VLAN_TUNNEL) ? true : false;
-	br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL);
+	err = br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL);
+	if (err)
+		return err;
+
 	if (br_vlan_tunnel_old && !(p->flags & BR_VLAN_TUNNEL))
 		nbp_vlan_tunnel_info_flush(p);
 
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 2062692..5dc30ed 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -42,6 +42,10 @@
 /* Path to usermode spanning tree program */
 #define BR_STP_PROG	"/sbin/bridge-stp"
 
+/* Flags that can be offloaded to hardware */
+#define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+
 typedef struct bridge_id bridge_id;
 typedef struct mac_addr mac_addr;
 typedef __u16 port_id;
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 06/19] net: bridge: Receive notification about successful FDB offload
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

When a new static FDB is added to the bridge a notification is sent to
the driver for offload. In case of successful offload the driver should
notify the bridge back, which in turn should mark the FDB as offloaded.

Currently, externally learned is equivalent for being offloaded which is
not correct due to the fact that FDBs which are added from user-space are
also marked as externally learned. In order to specify if an FDB was
successfully offloaded a new flag is introduced.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 include/net/switchdev.h        |  1 +
 include/uapi/linux/neighbour.h |  1 +
 net/bridge/br.c                | 11 ++++++++++-
 net/bridge/br_fdb.c            | 22 +++++++++++++++++++++-
 net/bridge/br_private.h        |  5 ++++-
 5 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 8165ed9..c784a6a 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -159,6 +159,7 @@ enum switchdev_notifier_type {
 	SWITCHDEV_FDB_DEL_TO_BRIDGE,
 	SWITCHDEV_FDB_ADD_TO_DEVICE,
 	SWITCHDEV_FDB_DEL_TO_DEVICE,
+	SWITCHDEV_FDB_OFFLOADED,
 };
 
 struct switchdev_notifier_info {
diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h
index f3d16db..3199d28 100644
--- a/include/uapi/linux/neighbour.h
+++ b/include/uapi/linux/neighbour.h
@@ -41,6 +41,7 @@ enum {
 #define NTF_MASTER	0x04
 #define NTF_PROXY	0x08	/* == ATF_PUBL */
 #define NTF_EXT_LEARNED	0x10
+#define NTF_OFFLOADED   0x20
 #define NTF_ROUTER	0x80
 
 /*
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 96d209c..1407d1b 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -142,8 +142,12 @@ static int br_switchdev_event(struct notifier_block *unused,
 		fdb_info = ptr;
 		err = br_fdb_external_learn_add(br, p, fdb_info->addr,
 						fdb_info->vid);
-		if (err)
+		if (err) {
 			err = notifier_from_errno(err);
+			break;
+		}
+		br_fdb_offloaded_set(br, p, fdb_info->addr,
+				     fdb_info->vid);
 		break;
 	case SWITCHDEV_FDB_DEL_TO_BRIDGE:
 		fdb_info = ptr;
@@ -152,6 +156,11 @@ static int br_switchdev_event(struct notifier_block *unused,
 		if (err)
 			err = notifier_from_errno(err);
 		break;
+	case SWITCHDEV_FDB_OFFLOADED:
+		fdb_info = ptr;
+		br_fdb_offloaded_set(br, p, fdb_info->addr,
+				     fdb_info->vid);
+		break;
 	}
 
 out:
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 21bf9d2..1bd3d84 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -511,6 +511,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
 		fdb->is_static = is_static;
 		fdb->added_by_user = 0;
 		fdb->added_by_external_learn = 0;
+		fdb->offloaded = 0;
 		fdb->updated = fdb->used = jiffies;
 		hlist_add_head_rcu(&fdb->hlist, head);
 	}
@@ -647,11 +648,16 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
 	ndm->ndm_family	 = AF_BRIDGE;
 	ndm->ndm_pad1    = 0;
 	ndm->ndm_pad2    = 0;
-	ndm->ndm_flags	 = fdb->added_by_external_learn ? NTF_EXT_LEARNED : 0;
+	ndm->ndm_flags	 = 0;
 	ndm->ndm_type	 = 0;
 	ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex;
 	ndm->ndm_state   = fdb_to_nud(br, fdb);
 
+	if (fdb->offloaded)
+		ndm->ndm_flags |= NTF_OFFLOADED;
+	if (fdb->added_by_external_learn)
+		ndm->ndm_flags |= NTF_EXT_LEARNED;
+
 	if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->addr))
 		goto nla_put_failure;
 	if (nla_put_u32(skb, NDA_MASTER, br->dev->ifindex))
@@ -1143,3 +1149,17 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
 
 	return err;
 }
+
+void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
+			  const unsigned char *addr, u16 vid)
+{
+	struct net_bridge_fdb_entry *fdb;
+
+	spin_lock_bh(&br->hash_lock);
+
+	fdb = br_fdb_find(br, addr, vid);
+	if (fdb)
+		fdb->offloaded = 1;
+
+	spin_unlock_bh(&br->hash_lock);
+}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 5e944e9..a5db2e1 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -173,7 +173,8 @@ struct net_bridge_fdb_entry {
 	unsigned char			is_local:1,
 					is_static:1,
 					added_by_user:1,
-					added_by_external_learn:1;
+					added_by_external_learn:1,
+					offloaded:1;
 
 	/* write-heavy members should not affect lookups */
 	unsigned long			updated ____cacheline_aligned_in_smp;
@@ -540,6 +541,8 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid);
 int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid);
+void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
+			  const unsigned char *addr, u16 vid);
 
 /* br_forward.c */
 enum br_pkt_type {
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 03/19] net: bridge: Add support for calling FDB external learning under rcu
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

This is done as a preparation to moving the switchdev notifier chain
to be atomic. The FDB external learning should be called under rtnl
or rcu.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/bridge/br.c         | 4 ++--
 net/bridge/br_fdb.c     | 2 --
 net/bridge/br_private.h | 6 ++++++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/bridge/br.c b/net/bridge/br.c
index 889e564..e962fff 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -121,7 +121,7 @@ static struct notifier_block br_device_notifier = {
 	.notifier_call = br_device_event
 };
 
-/* called with RTNL */
+/* called with RTNL or RCU */
 static int br_switchdev_event(struct notifier_block *unused,
 			      unsigned long event, void *ptr)
 {
@@ -131,7 +131,7 @@ static int br_switchdev_event(struct notifier_block *unused,
 	struct switchdev_notifier_fdb_info *fdb_info;
 	int err = NOTIFY_DONE;
 
-	p = br_port_get_rtnl(dev);
+	p = br_port_get_rtnl_rcu(dev);
 	if (!p)
 		goto out;
 
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index ab0c7cc..5c780cd 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1075,7 +1075,6 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 	struct net_bridge_fdb_entry *fdb;
 	int err = 0;
 
-	ASSERT_RTNL();
 	spin_lock_bh(&br->hash_lock);
 
 	head = &br->hash[br_mac_hash(addr, vid)];
@@ -1110,7 +1109,6 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
 	struct net_bridge_fdb_entry *fdb;
 	int err = 0;
 
-	ASSERT_RTNL();
 	spin_lock_bh(&br->hash_lock);
 
 	fdb = br_fdb_find(br, addr, vid);
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 5dc30ed..69ba3ba 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -288,6 +288,12 @@ static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *
 		rtnl_dereference(dev->rx_handler_data) : NULL;
 }
 
+static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_device *dev)
+{
+	return br_port_exists(dev) ?
+		rcu_dereference_rtnl(dev->rx_handler_data) : NULL;
+}
+
 struct net_bridge {
 	spinlock_t			lock;
 	spinlock_t			hash_lock;
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 07/19] mlxsw: spectrum: Remove support for bridge FDB learning sync
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

Currently the mlxsw driver supports an option for disabling syncing
the hardware learned FDBs with the software bridge. This behavior
breaks the bridge offload model and thus it is removed.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 0111a77..eb88b72 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1857,19 +1857,17 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
 	mlxsw_sp_bridge_port_put(mlxsw_sp->bridge, bridge_port);
 }
 
-static void mlxsw_sp_fdb_call_notifiers(bool learning_sync, bool adding,
+static void mlxsw_sp_fdb_call_notifiers(bool adding,
 					char *mac, u16 vid,
 					struct net_device *dev)
 {
 	struct switchdev_notifier_fdb_info info;
 	unsigned long notifier_type;
 
-	if (learning_sync) {
-		info.addr = mac;
-		info.vid = vid;
-		notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE;
-		call_switchdev_notifiers(notifier_type, dev, &info.info);
-	}
+	info.addr = mac;
+	info.vid = vid;
+	notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE;
+	call_switchdev_notifiers(notifier_type, dev, &info.info);
 }
 
 static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
@@ -1918,8 +1916,8 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
 
 	if (!do_notification)
 		return;
-	mlxsw_sp_fdb_call_notifiers(bridge_port->flags & BR_LEARNING_SYNC,
-				    adding, mac, vid, bridge_port->dev);
+	mlxsw_sp_fdb_call_notifiers(adding, mac, vid, bridge_port->dev);
+
 	return;
 
 just_remove:
@@ -1976,8 +1974,8 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,
 
 	if (!do_notification)
 		return;
-	mlxsw_sp_fdb_call_notifiers(bridge_port->flags & BR_LEARNING_SYNC,
-				    adding, mac, vid, bridge_port->dev);
+	mlxsw_sp_fdb_call_notifiers(adding, mac, vid, bridge_port->dev);
+
 	return;
 
 just_remove:
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 04/19] net: switchdev: Change notifier chain to be atomic
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

In order to use the switchdev notifier chain for FDB sync with the
device it has to be changed to atomic. The is done because the bridge
can learn new FDBs in atomic context.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/switchdev/switchdev.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 8d40a7d..25dc67e 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj,
 }
 EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);
 
-static RAW_NOTIFIER_HEAD(switchdev_notif_chain);
+static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain);
 
 /**
  *	register_switchdev_notifier - Register notifier
  *	@nb: notifier_block
  *
- *	Register switch device notifier. This should be used by code
- *	which needs to monitor events happening in particular device.
- *	Return values are same as for atomic_notifier_chain_register().
+ *	Register switch device notifier.
  */
 int register_switchdev_notifier(struct notifier_block *nb)
 {
-	int err;
-
-	rtnl_lock();
-	err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
-	rtnl_unlock();
-	return err;
+	return atomic_notifier_chain_register(&switchdev_notif_chain, nb);
 }
 EXPORT_SYMBOL_GPL(register_switchdev_notifier);
 
@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier);
  *	@nb: notifier_block
  *
  *	Unregister switch device notifier.
- *	Return values are same as for atomic_notifier_chain_unregister().
  */
 int unregister_switchdev_notifier(struct notifier_block *nb)
 {
-	int err;
-
-	rtnl_lock();
-	err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
-	rtnl_unlock();
-	return err;
+	return atomic_notifier_chain_unregister(&switchdev_notif_chain, nb);
 }
 EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
 
@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
  *	@dev: port device
  *	@info: notifier information data
  *
- *	Call all network notifier blocks. This should be called by driver
- *	when it needs to propagate hardware event.
- *	Return values are same as for atomic_notifier_call_chain().
- *	rtnl_lock must be held.
+ *	Call all network notifier blocks.
  */
 int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
 			     struct switchdev_notifier_info *info)
 {
-	ASSERT_RTNL();
-
 	info->dev = dev;
-	return raw_notifier_call_chain(&switchdev_notif_chain, val, info);
+	return atomic_notifier_call_chain(&switchdev_notif_chain, val, info);
 }
 EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
 
-- 
2.9.3

^ permalink raw reply related

* [patch net-next 08/19] mlxsw: spectrum_switchdev: Add support for querying supported bridge flags
From: Jiri Pirko @ 2017-06-05  9:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, arkadis, mlxsw, roopa, stephen, ivecera
In-Reply-To: <20170605092043.3523-1-jiri@resnulli.us>

From: Arkadi Sharshevsky <arkadis@mellanox.com>

Add support for querying supported bridge flags.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index eb88b72..0333493 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -456,6 +456,9 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
 		mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
 					       &attr->u.brport_flags);
 		break;
+	case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
+		attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD;
+		break;
 	default:
 		return -EOPNOTSUPP;
 	}
-- 
2.9.3

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox