Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net,v2] ipv4: use new_gw for redirect neigh lookup
From: David Miller @ 2016-11-13 17:25 UTC (permalink / raw)
  To: stephen.suryaputra.lin; +Cc: netdev, ssurya
In-Reply-To: <1478794575-28748-1-git-send-email-ssurya@ieee.org>

From: Stephen Suryaputra Lin <stephen.suryaputra.lin@gmail.com>
Date: Thu, 10 Nov 2016 11:16:15 -0500

> In v2.6, ip_rt_redirect() calls arp_bind_neighbour() which returns 0
> and then the state of the neigh for the new_gw is checked. If the state
> isn't valid then the redirected route is deleted. This behavior is
> maintained up to v3.5.7 by check_peer_redirect() because rt->rt_gateway
> is assigned to peer->redirect_learned.a4 before calling
> ipv4_neigh_lookup().
> 
> After commit 5943634fc559 ("ipv4: Maintain redirect and PMTU info in
> struct rtable again."), ipv4_neigh_lookup() is performed without the
> rt_gateway assigned to the new_gw. In the case when rt_gateway (old_gw)
> isn't zero, the function uses it as the key. The neigh is most likely
> valid since the old_gw is the one that sends the ICMP redirect message.
> Then the new_gw is assigned to fib_nh_exception. The problem is: the
> new_gw ARP may never gets resolved and the traffic is blackholed.
> 
> So, use the new_gw for neigh lookup.
> 
> Changes from v1:
>  - use __ipv4_neigh_lookup instead (per Eric Dumazet).
> 
> Fixes: 5943634fc559 ("ipv4: Maintain redirect and PMTU info in struct rtable again.")
> Signed-off-by: Stephen Suryaputra Lin <ssurya@ieee.org>

Looks good, applied and queued up for -stable.

Thanks.

^ permalink raw reply

* Re: [mm PATCH v3 17/23] arch/sparc: Add option to skip DMA sync as a part of map and unmap
From: David Miller @ 2016-11-13 17:27 UTC (permalink / raw)
  To: alexander.h.duyck; +Cc: linux-mm, akpm, sparclinux, netdev, linux-kernel
In-Reply-To: <20161110113544.76501.40008.stgit@ahduyck-blue-test.jf.intel.com>

From: Alexander Duyck <alexander.h.duyck@intel.com>
Date: Thu, 10 Nov 2016 06:35:45 -0500

> This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
> avoid invoking cache line invalidation if the driver will just handle it
> via a sync_for_cpu or sync_for_device call.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH v2 net] tcp: take care of truncations done by sk_filter()
From: David Miller @ 2016-11-13 17:30 UTC (permalink / raw)
  To: eric.dumazet; +Cc: vdronov, netdev, marco.gra
In-Reply-To: <1478812355.8455.39.camel@edumazet-glaptop3.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 10 Nov 2016 13:12:35 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> With syzkaller help, Marco Grassi found a bug in TCP stack,
> crashing in tcp_collapse()
> 
> Root cause is that sk_filter() can truncate the incoming skb,
> but TCP stack was not really expecting this to happen.
> It probably was expecting a simple DROP or ACCEPT behavior.
> 
> We first need to make sure no part of TCP header could be removed.
> Then we need to adjust TCP_SKB_CB(skb)->end_seq
> 
> Many thanks to syzkaller team and Marco for giving us a reproducer.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Marco Grassi <marco.gra@gmail.com>
> Reported-by: Vladis Dronov <vdronov@redhat.com>
> ---
> v2: reload both th/iph in case skb->head changed.

Applied and queued up for -stable, thanks Eric.

^ permalink raw reply

* [PATCH] net: atheros: atl1: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2016-11-13 17:35 UTC (permalink / raw)
  To: jcliburn, chris.snook, davem, jarod; +Cc: netdev, linux-kernel, Philippe Reynes

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

The previous implementation of set_settings was modifying
the value of advertising, but with the new API, it's not
possible. The structure ethtool_link_ksettings is defined
as const.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/net/ethernet/atheros/atlx/atl1.c |   66 ++++++++++++++++-------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 9aede18..7dad8e4 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -3214,66 +3214,72 @@ static int atl1_get_sset_count(struct net_device *netdev, int sset)
 	}
 }
 
-static int atl1_get_settings(struct net_device *netdev,
-	struct ethtool_cmd *ecmd)
+static int atl1_get_link_ksettings(struct net_device *netdev,
+				   struct ethtool_link_ksettings *cmd)
 {
 	struct atl1_adapter *adapter = netdev_priv(netdev);
 	struct atl1_hw *hw = &adapter->hw;
+	u32 supported, advertising;
 
-	ecmd->supported = (SUPPORTED_10baseT_Half |
+	supported = (SUPPORTED_10baseT_Half |
 			   SUPPORTED_10baseT_Full |
 			   SUPPORTED_100baseT_Half |
 			   SUPPORTED_100baseT_Full |
 			   SUPPORTED_1000baseT_Full |
 			   SUPPORTED_Autoneg | SUPPORTED_TP);
-	ecmd->advertising = ADVERTISED_TP;
+	advertising = ADVERTISED_TP;
 	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
 	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
-		ecmd->advertising |= ADVERTISED_Autoneg;
+		advertising |= ADVERTISED_Autoneg;
 		if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
-			ecmd->advertising |= ADVERTISED_Autoneg;
-			ecmd->advertising |=
+			advertising |= ADVERTISED_Autoneg;
+			advertising |=
 			    (ADVERTISED_10baseT_Half |
 			     ADVERTISED_10baseT_Full |
 			     ADVERTISED_100baseT_Half |
 			     ADVERTISED_100baseT_Full |
 			     ADVERTISED_1000baseT_Full);
 		} else
-			ecmd->advertising |= (ADVERTISED_1000baseT_Full);
+			advertising |= (ADVERTISED_1000baseT_Full);
 	}
-	ecmd->port = PORT_TP;
-	ecmd->phy_address = 0;
-	ecmd->transceiver = XCVR_INTERNAL;
+	cmd->base.port = PORT_TP;
+	cmd->base.phy_address = 0;
 
 	if (netif_carrier_ok(adapter->netdev)) {
 		u16 link_speed, link_duplex;
 		atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
-		ethtool_cmd_speed_set(ecmd, link_speed);
+		cmd->base.speed = link_speed;
 		if (link_duplex == FULL_DUPLEX)
-			ecmd->duplex = DUPLEX_FULL;
+			cmd->base.duplex = DUPLEX_FULL;
 		else
-			ecmd->duplex = DUPLEX_HALF;
+			cmd->base.duplex = DUPLEX_HALF;
 	} else {
-		ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
-		ecmd->duplex = DUPLEX_UNKNOWN;
+		cmd->base.speed = SPEED_UNKNOWN;
+		cmd->base.duplex = DUPLEX_UNKNOWN;
 	}
 	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
 	    hw->media_type == MEDIA_TYPE_1000M_FULL)
-		ecmd->autoneg = AUTONEG_ENABLE;
+		cmd->base.autoneg = AUTONEG_ENABLE;
 	else
-		ecmd->autoneg = AUTONEG_DISABLE;
+		cmd->base.autoneg = AUTONEG_DISABLE;
+
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+						supported);
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+						advertising);
 
 	return 0;
 }
 
-static int atl1_set_settings(struct net_device *netdev,
-	struct ethtool_cmd *ecmd)
+static int atl1_set_link_ksettings(struct net_device *netdev,
+				   const struct ethtool_link_ksettings *cmd)
 {
 	struct atl1_adapter *adapter = netdev_priv(netdev);
 	struct atl1_hw *hw = &adapter->hw;
 	u16 phy_data;
 	int ret_val = 0;
 	u16 old_media_type = hw->media_type;
+	u32 advertising;
 
 	if (netif_running(adapter->netdev)) {
 		if (netif_msg_link(adapter))
@@ -3282,12 +3288,12 @@ static int atl1_set_settings(struct net_device *netdev,
 		atl1_down(adapter);
 	}
 
-	if (ecmd->autoneg == AUTONEG_ENABLE)
+	if (cmd->base.autoneg == AUTONEG_ENABLE)
 		hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
 	else {
-		u32 speed = ethtool_cmd_speed(ecmd);
+		u32 speed = cmd->base.speed;
 		if (speed == SPEED_1000) {
-			if (ecmd->duplex != DUPLEX_FULL) {
+			if (cmd->base.duplex != DUPLEX_FULL) {
 				if (netif_msg_link(adapter))
 					dev_warn(&adapter->pdev->dev,
 						"1000M half is invalid\n");
@@ -3296,12 +3302,12 @@ static int atl1_set_settings(struct net_device *netdev,
 			}
 			hw->media_type = MEDIA_TYPE_1000M_FULL;
 		} else if (speed == SPEED_100) {
-			if (ecmd->duplex == DUPLEX_FULL)
+			if (cmd->base.duplex == DUPLEX_FULL)
 				hw->media_type = MEDIA_TYPE_100M_FULL;
 			else
 				hw->media_type = MEDIA_TYPE_100M_HALF;
 		} else {
-			if (ecmd->duplex == DUPLEX_FULL)
+			if (cmd->base.duplex == DUPLEX_FULL)
 				hw->media_type = MEDIA_TYPE_10M_FULL;
 			else
 				hw->media_type = MEDIA_TYPE_10M_HALF;
@@ -3309,7 +3315,7 @@ static int atl1_set_settings(struct net_device *netdev,
 	}
 	switch (hw->media_type) {
 	case MEDIA_TYPE_AUTO_SENSOR:
-		ecmd->advertising =
+		advertising =
 		    ADVERTISED_10baseT_Half |
 		    ADVERTISED_10baseT_Full |
 		    ADVERTISED_100baseT_Half |
@@ -3318,12 +3324,12 @@ static int atl1_set_settings(struct net_device *netdev,
 		    ADVERTISED_Autoneg | ADVERTISED_TP;
 		break;
 	case MEDIA_TYPE_1000M_FULL:
-		ecmd->advertising =
+		advertising =
 		    ADVERTISED_1000baseT_Full |
 		    ADVERTISED_Autoneg | ADVERTISED_TP;
 		break;
 	default:
-		ecmd->advertising = 0;
+		advertising = 0;
 		break;
 	}
 	if (atl1_phy_setup_autoneg_adv(hw)) {
@@ -3663,8 +3669,6 @@ static int atl1_nway_reset(struct net_device *netdev)
 }
 
 static const struct ethtool_ops atl1_ethtool_ops = {
-	.get_settings		= atl1_get_settings,
-	.set_settings		= atl1_set_settings,
 	.get_drvinfo		= atl1_get_drvinfo,
 	.get_wol		= atl1_get_wol,
 	.set_wol		= atl1_set_wol,
@@ -3681,6 +3685,8 @@ static int atl1_nway_reset(struct net_device *netdev)
 	.nway_reset		= atl1_nway_reset,
 	.get_ethtool_stats	= atl1_get_ethtool_stats,
 	.get_sset_count		= atl1_get_sset_count,
+	.get_link_ksettings	= atl1_get_link_ksettings,
+	.set_link_ksettings	= atl1_set_link_ksettings,
 };
 
 module_pci_driver(atl1_driver);
-- 
1.7.4.4

^ permalink raw reply related

* Re: [PATCH net 0/2] bnxt_en: 2 bug fixes.
From: David Miller @ 2016-11-13 17:37 UTC (permalink / raw)
  To: michael.chan; +Cc: netdev
In-Reply-To: <1478841103-22413-1-git-send-email-michael.chan@broadcom.com>

From: Michael Chan <michael.chan@broadcom.com>
Date: Fri, 11 Nov 2016 00:11:41 -0500

> Bug fixes in bnxt_setup_tc() and VF vitual link state.

Series applied, thanks Michael.

^ permalink raw reply

* Re: [RFC v4 00/18] Landlock LSM: Unprivileged sandboxing
From: Alexei Starovoitov @ 2016-11-13 17:38 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: linux-kernel@vger.kernel.org, Alexei Starovoitov, Andy Lutomirski,
	Daniel Borkmann, Daniel Mack, David Drysdale, David S . Miller,
	Eric W . Biederman, James Morris, Jann Horn, Kees Cook,
	Paul Moore, Sargun Dhillon, Serge E . Hallyn, Tejun Heo,
	Thomas Graf, Will Drewry, kernel-hardening, Linux API, LSM List,
	netdev@vger.kernel.org, open list:CONTROL GROUP (CGROUP)

On Sun, Nov 13, 2016 at 6:23 AM, Mickaël Salaün <mic@digikod.net> wrote:
> Hi,
>
> After the BoF at LPC last week, we came to a multi-step roadmap to
> upstream Landlock.
>
> A first patch series containing the basic properties needed for a
> "minimum viable product", which means being able to test it, without
> full features. The idea is to set in place the main components which
> include the LSM part (some hooks with the manager logic) and the new
> eBPF type. To have a minimum amount of code, the first userland entry
> point will be the seccomp syscall. This doesn't imply non-upstream
> patches and should be more simple. For the sake of simplicity and to
> ease the review, this first series will only be dedicated to privileged
> processes (i.e. with CAP_SYS_ADMIN). We may want to only allow one level
> of rules at first, instead of dealing with more complex rule inheritance
> (like seccomp-bpf can do).
>
> The second series will focus on the cgroup manager. It will follow the
> same rules of inheritance as the Daniel Mack's patches does.
>
> The third series will try to bring a BPF map of handles for Landlock and
> the dedicated BPF helpers.
>
> Finally, the fourth series will bring back the unprivileged mode (with
> no_new_privs), at least for process hierarchies (via seccomp). This also
> imply to handle multi-level of rules.
>
> Right now, an important point of attention is the userland ABI. We don't
> want LSM hooks to be exposed "as is" to userland. This may have some
> future implications if their semantic and/or enforcement point(s)
> change. In the next series, I will propose a new abstraction over the
> currently used LSM hooks. I'll also propose a new way to deal with
> resource accountability. Finally, I plan to create a minimal (kernel)
> developer documentation and a test suite.

Thanks for the summary.
That's exactly what we discussed and agreed upon.

^ permalink raw reply

* Re: [PATCH net 2/2] r8152: rx descriptor check
From: David Miller @ 2016-11-13 17:39 UTC (permalink / raw)
  To: hayeswang-Rasf1IRRPZFBDgjK7y7TUQ
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, nic_swsd-Rasf1IRRPZFBDgjK7y7TUQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, mlord-e+AXbWqSrlAAvxtiuMwx3w
In-Reply-To: <1394712342-15778-228-Taiwan-albertk-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>

From: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
Date: Fri, 11 Nov 2016 15:15:41 +0800

> For some platforms, the data in memory is not the same with the one
> from the device. That is, the data of memory is unbelievable. The
> check is used to find out this situation.
> 
> Signed-off-by: Hayes Wang <hayeswang-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>

I'm all for adding consistency checks, but I disagree with proceeding
in this manner for this.

If you add this patch now, there is a much smaller likelyhood that you
will work with a high priority to figure out _why_ this is happening.

For all we know this could be a platform bug in the DMA API for the
systems in question.

It could also be a bug elsewhere in the driver, either in setting up
the descriptor DMA mappings or how the chip is programmed.

Either way the true cause must be found before we start throwing
changes like this into the driver.

I'm not applying this series, sorry.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH net-next v7 03/10] dpaa_eth: add option to use one buffer pool set
From: David Miller @ 2016-11-13 17:46 UTC (permalink / raw)
  To: madalin.bucur
  Cc: netdev, linuxppc-dev, linux-kernel, oss, ppc, joe, pebolle,
	joakim.tjernlund
In-Reply-To: <1478852407-27420-4-git-send-email-madalin.bucur@nxp.com>

From: Madalin Bucur <madalin.bucur@nxp.com>
Date: Fri, 11 Nov 2016 10:20:00 +0200

> @@ -8,3 +8,12 @@ menuconfig FSL_DPAA_ETH
>  	  supporting the Freescale QorIQ chips.
>  	  Depends on Freescale Buffer Manager and Queue Manager
>  	  driver and Frame Manager Driver.
> +
> +if FSL_DPAA_ETH
> +config FSL_DPAA_ETH_COMMON_BPOOL
> +	bool "Use a common buffer pool set for all the interfaces"
> +	---help---
> +	  The DPAA Ethernet netdevices require buffer pools for storing the buffers
> +	  used by the FMan hardware for reception. One can use a single buffer pool
> +	  set for all interfaces or a dedicated buffer pool set for each interface.
> +endif # FSL_DPAA_ETH

This in no way belongs in Kconfig.  If you want to support this,
support it wit a run time configuration choice via ethtool flags
or similar.  Do not use debugfs, do not use sysfs, do not use
module options.

If you put it in Kconfig, distributions will have to pick one way or
another which means that users who want the other choice lose.  This
never works.

^ permalink raw reply

* Re: [PATCH] Revert "include/uapi/linux/atm_zatm.h: include linux/time.h"
From: David Miller @ 2016-11-13 17:35 UTC (permalink / raw)
  To: vapier; +Cc: netdev, mikko.rapeli
In-Reply-To: <20161111000839.23267-1-vapier@gentoo.org>

From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 10 Nov 2016 19:08:39 -0500

> This reverts commit cf00713a655d ("include/uapi/linux/atm_zatm.h: include
> linux/time.h").
> 
> This attempted to fix userspace breakage that no longer existed when
> the patch was merged.  Almost one year earlier, commit 70ba07b675b5
> ("atm: remove 'struct zatm_t_hist'") deleted the struct in question.
> 
> After this patch was merged, we now have to deal with people being
> unable to include this header in conjunction with standard C library
> headers like stdlib.h (which linux-atm does).  Example breakage:
> x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../.. -I./../q2931 -I./../saal \
> 	-I.  -DCPPFLAGS_TEST  -I../../src/include -O2 -march=native -pipe -g \
> 	-frecord-gcc-switches -freport-bug -Wimplicit-function-declaration \
> 	-Wnonnull -Wstrict-aliasing -Wparentheses -Warray-bounds \
> 	-Wfree-nonheap-object -Wreturn-local-addr -fno-strict-aliasing -Wall \
> 	-Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -c zntune.c
> In file included from /usr/include/linux/atm_zatm.h:17:0,
>                  from zntune.c:17:
> /usr/include/linux/time.h:9:8: error: redefinition of ‘struct timespec’
>  struct timespec {
>         ^
> In file included from /usr/include/sys/select.h:43:0,
>                  from /usr/include/sys/types.h:219,
>                  from /usr/include/stdlib.h:314,
>                  from zntune.c:9:
> /usr/include/time.h:120:8: note: originally defined here
>  struct timespec
>         ^
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [patch net 0/2] mlxsw: Couple of fixes
From: David Miller @ 2016-11-13 17:48 UTC (permalink / raw)
  To: jiri; +Cc: netdev, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478859642-2918-1-git-send-email-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 11 Nov 2016 11:20:40 +0100

> Please, queue-up both for stable. Thanks!

Series applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [patch net v2 0/2] mlxsw: Couple of fixes
From: David Miller @ 2016-11-13 17:51 UTC (permalink / raw)
  To: jiri; +Cc: netdev, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478878466-3141-1-git-send-email-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 11 Nov 2016 16:34:24 +0100

> From: Jiri Pirko <jiri@mellanox.com>
> 
> Please, queue-up both for stable. Thanks!

Just to be clear I did make sure to take v2 rather than
v1.

^ permalink raw reply

* [PATCH] net: atheros: atl2: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2016-11-13 17:53 UTC (permalink / raw)
  To: jcliburn, chris.snook, davem, jarod, ben
  Cc: netdev, linux-kernel, Philippe Reynes

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

The previous implementation of set_settings was modifying
the value of advertising, but with the new API, it's not
possible. The structure ethtool_link_ksettings is defined
as const.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/net/ethernet/atheros/atlx/atl2.c |   66 ++++++++++++++++-------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index 6911394..63f2dee 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -1737,81 +1737,87 @@ static void atl2_write_pci_cfg(struct atl2_hw *hw, u32 reg, u16 *value)
 	pci_write_config_word(adapter->pdev, reg, *value);
 }
 
-static int atl2_get_settings(struct net_device *netdev,
-	struct ethtool_cmd *ecmd)
+static int atl2_get_link_ksettings(struct net_device *netdev,
+				   struct ethtool_link_ksettings *cmd)
 {
 	struct atl2_adapter *adapter = netdev_priv(netdev);
 	struct atl2_hw *hw = &adapter->hw;
+	u32 supported, advertising;
 
-	ecmd->supported = (SUPPORTED_10baseT_Half |
+	supported = (SUPPORTED_10baseT_Half |
 		SUPPORTED_10baseT_Full |
 		SUPPORTED_100baseT_Half |
 		SUPPORTED_100baseT_Full |
 		SUPPORTED_Autoneg |
 		SUPPORTED_TP);
-	ecmd->advertising = ADVERTISED_TP;
+	advertising = ADVERTISED_TP;
 
-	ecmd->advertising |= ADVERTISED_Autoneg;
-	ecmd->advertising |= hw->autoneg_advertised;
+	advertising |= ADVERTISED_Autoneg;
+	advertising |= hw->autoneg_advertised;
 
-	ecmd->port = PORT_TP;
-	ecmd->phy_address = 0;
-	ecmd->transceiver = XCVR_INTERNAL;
+	cmd->base.port = PORT_TP;
+	cmd->base.phy_address = 0;
 
 	if (adapter->link_speed != SPEED_0) {
-		ethtool_cmd_speed_set(ecmd, adapter->link_speed);
+		cmd->base.speed = adapter->link_speed;
 		if (adapter->link_duplex == FULL_DUPLEX)
-			ecmd->duplex = DUPLEX_FULL;
+			cmd->base.duplex = DUPLEX_FULL;
 		else
-			ecmd->duplex = DUPLEX_HALF;
+			cmd->base.duplex = DUPLEX_HALF;
 	} else {
-		ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
-		ecmd->duplex = DUPLEX_UNKNOWN;
+		cmd->base.speed = SPEED_UNKNOWN;
+		cmd->base.duplex = DUPLEX_UNKNOWN;
 	}
 
-	ecmd->autoneg = AUTONEG_ENABLE;
+	cmd->base.autoneg = AUTONEG_ENABLE;
+
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+						supported);
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+						advertising);
+
 	return 0;
 }
 
-static int atl2_set_settings(struct net_device *netdev,
-	struct ethtool_cmd *ecmd)
+static int atl2_set_link_ksettings(struct net_device *netdev,
+				   const struct ethtool_link_ksettings *cmd)
 {
 	struct atl2_adapter *adapter = netdev_priv(netdev);
 	struct atl2_hw *hw = &adapter->hw;
+	u32 advertising;
+
+	ethtool_convert_link_mode_to_legacy_u32(&advertising,
+						cmd->link_modes.advertising);
 
 	while (test_and_set_bit(__ATL2_RESETTING, &adapter->flags))
 		msleep(1);
 
-	if (ecmd->autoneg == AUTONEG_ENABLE) {
+	if (cmd->base.autoneg == AUTONEG_ENABLE) {
 #define MY_ADV_MASK	(ADVERTISE_10_HALF | \
 			 ADVERTISE_10_FULL | \
 			 ADVERTISE_100_HALF| \
 			 ADVERTISE_100_FULL)
 
-		if ((ecmd->advertising & MY_ADV_MASK) == MY_ADV_MASK) {
+		if ((advertising & MY_ADV_MASK) == MY_ADV_MASK) {
 			hw->MediaType = MEDIA_TYPE_AUTO_SENSOR;
 			hw->autoneg_advertised =  MY_ADV_MASK;
-		} else if ((ecmd->advertising & MY_ADV_MASK) ==
-				ADVERTISE_100_FULL) {
+		} else if ((advertising & MY_ADV_MASK) == ADVERTISE_100_FULL) {
 			hw->MediaType = MEDIA_TYPE_100M_FULL;
 			hw->autoneg_advertised = ADVERTISE_100_FULL;
-		} else if ((ecmd->advertising & MY_ADV_MASK) ==
-				ADVERTISE_100_HALF) {
+		} else if ((advertising & MY_ADV_MASK) == ADVERTISE_100_HALF) {
 			hw->MediaType = MEDIA_TYPE_100M_HALF;
 			hw->autoneg_advertised = ADVERTISE_100_HALF;
-		} else if ((ecmd->advertising & MY_ADV_MASK) ==
-				ADVERTISE_10_FULL) {
+		} else if ((advertising & MY_ADV_MASK) == ADVERTISE_10_FULL) {
 			hw->MediaType = MEDIA_TYPE_10M_FULL;
 			hw->autoneg_advertised = ADVERTISE_10_FULL;
-		}  else if ((ecmd->advertising & MY_ADV_MASK) ==
-				ADVERTISE_10_HALF) {
+		}  else if ((advertising & MY_ADV_MASK) == ADVERTISE_10_HALF) {
 			hw->MediaType = MEDIA_TYPE_10M_HALF;
 			hw->autoneg_advertised = ADVERTISE_10_HALF;
 		} else {
 			clear_bit(__ATL2_RESETTING, &adapter->flags);
 			return -EINVAL;
 		}
-		ecmd->advertising = hw->autoneg_advertised |
+		advertising = hw->autoneg_advertised |
 			ADVERTISED_TP | ADVERTISED_Autoneg;
 	} else {
 		clear_bit(__ATL2_RESETTING, &adapter->flags);
@@ -2080,8 +2086,6 @@ static int atl2_nway_reset(struct net_device *netdev)
 }
 
 static const struct ethtool_ops atl2_ethtool_ops = {
-	.get_settings		= atl2_get_settings,
-	.set_settings		= atl2_set_settings,
 	.get_drvinfo		= atl2_get_drvinfo,
 	.get_regs_len		= atl2_get_regs_len,
 	.get_regs		= atl2_get_regs,
@@ -2094,6 +2098,8 @@ static int atl2_nway_reset(struct net_device *netdev)
 	.get_eeprom_len		= atl2_get_eeprom_len,
 	.get_eeprom		= atl2_get_eeprom,
 	.set_eeprom		= atl2_set_eeprom,
+	.get_link_ksettings	= atl2_get_link_ksettings,
+	.set_link_ksettings	= atl2_set_link_ksettings,
 };
 
 #define LBYTESWAP(a)  ((((a) & 0x00ff00ff) << 8) | \
-- 
1.7.4.4

^ permalink raw reply related

* Re: [patch net-next] mlxsw: reg: Fix pwm_frequency field size in MFCR register
From: David Miller @ 2016-11-13 17:52 UTC (permalink / raw)
  To: jiri; +Cc: netdev, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
In-Reply-To: <1478859773-3013-1-git-send-email-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 11 Nov 2016 11:22:53 +0100

> From: Jiri Pirko <jiri@mellanox.com>
> 
> The field is 7bit long. Fix it.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied.

^ permalink raw reply

* [net-next:master 664/670] drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1421:7-9: WARNING: possible condition with no effect (if == else)
From: Julia Lawall @ 2016-11-13 18:12 UTC (permalink / raw)
  To: Lendacky, Thomas; +Cc: netdev, kbuild-all

It looks like the code on lines 1422 and 1424 is the same, so either the
test may be unnecessary, or one of the branches is wrong.

Coccinelle is also comparing about a comparison on an unsigned value in
line 1900, but the code for that is not listed in the report below.

julia

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   f7ad3d4b83e694347cddc96d956143068bef32c9
commit: abf0a1c2b26ad964d19b143ce46735e1b0667f29 [664/670] amd-xgbe: Add support for SFP+ modules
:::::: branch date: 16 minutes ago
:::::: commit date: 12 hours ago

>> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1421:7-9: WARNING: possible condition with no effect (if == else)
--
>> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1900:6-9: WARNING: Unsigned expression compared with zero: ret < 0

git remote add net-next https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
git remote update net-next
git checkout abf0a1c2b26ad964d19b143ce46735e1b0667f29
vim +1421 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c

abf0a1c2 Lendacky, Thomas 2016-11-10  1405  {
abf0a1c2 Lendacky, Thomas 2016-11-10  1406  	struct xgbe_phy_data *phy_data = pdata->phy_data;
abf0a1c2 Lendacky, Thomas 2016-11-10  1407  	unsigned int s0;
abf0a1c2 Lendacky, Thomas 2016-11-10  1408
abf0a1c2 Lendacky, Thomas 2016-11-10  1409  	xgbe_phy_start_ratechange(pdata);
abf0a1c2 Lendacky, Thomas 2016-11-10  1410
abf0a1c2 Lendacky, Thomas 2016-11-10  1411  	/* 10G/SFI */
abf0a1c2 Lendacky, Thomas 2016-11-10  1412  	s0 = 0;
abf0a1c2 Lendacky, Thomas 2016-11-10  1413  	XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 3);
abf0a1c2 Lendacky, Thomas 2016-11-10  1414  	if (phy_data->sfp_cable != XGBE_SFP_CABLE_PASSIVE) {
abf0a1c2 Lendacky, Thomas 2016-11-10  1415  		XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0);
abf0a1c2 Lendacky, Thomas 2016-11-10  1416  	} else {
abf0a1c2 Lendacky, Thomas 2016-11-10  1417  		if (phy_data->sfp_cable_len <= 1)
abf0a1c2 Lendacky, Thomas 2016-11-10  1418  			XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 1);
abf0a1c2 Lendacky, Thomas 2016-11-10  1419  		else if (phy_data->sfp_cable_len <= 3)
abf0a1c2 Lendacky, Thomas 2016-11-10  1420  			XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 2);
abf0a1c2 Lendacky, Thomas 2016-11-10 @1421  		else if (phy_data->sfp_cable_len <= 5)
abf0a1c2 Lendacky, Thomas 2016-11-10  1422  			XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 3);
abf0a1c2 Lendacky, Thomas 2016-11-10  1423  		else
abf0a1c2 Lendacky, Thomas 2016-11-10  1424  			XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 3);
abf0a1c2 Lendacky, Thomas 2016-11-10  1425  	}
abf0a1c2 Lendacky, Thomas 2016-11-10  1426
abf0a1c2 Lendacky, Thomas 2016-11-10  1427  	/* Call FW to make the change */
abf0a1c2 Lendacky, Thomas 2016-11-10  1428  	XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0);
abf0a1c2 Lendacky, Thomas 2016-11-10  1429  	XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply

* Re: [PATCH] net: ioctl SIOCSIFADDR minor cleanup
From: David Miller @ 2016-11-13 18:38 UTC (permalink / raw)
  To: cugyly; +Cc: netdev
In-Reply-To: <1478877393.3705.3.camel@163.com>


Your patch was mangled by your email client, chopping up long lines
and turning TAB characters into spaces.

Please fix this, email a test patch to yourself, and do not resubmit
your change until you can successfully apply the patch you receive
in a test email.  Also, do not try using attachments to fix this
problem, patches must be inline.

^ permalink raw reply

* Re: [PATCH v2] net: ethernet: ti: davinci_cpdma: fix fixed prio cpdma ctlr configuration
From: David Miller @ 2016-11-13 18:40 UTC (permalink / raw)
  To: ivan.khoronzhuk
  Cc: mugunthanvnm, grygorii.strashko, netdev, linux-omap, linux-kernel
In-Reply-To: <1478871924-20985-1-git-send-email-ivan.khoronzhuk@linaro.org>

From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Date: Fri, 11 Nov 2016 15:45:24 +0200

> The dma ctlr is reseted to 0 while cpdma soft reset, thus cpdma ctlr
> cannot be configured after cpdma is stopped. So restoring content
> of cpdma ctlr while off/on procedure is needed. The cpdma ctlr off/on
> procedure is present while interface down/up and while changing number
> of channels with ethtool. In order to not restore content in many
> places, move it to cpdma_ctlr_start().
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Applied.

^ permalink raw reply

* Re: [PATCH] net: ethernet: ti: davinci_cpdma: don't stop ctlr if it was stopped
From: David Miller @ 2016-11-13 18:40 UTC (permalink / raw)
  To: ivan.khoronzhuk
  Cc: mugunthanvnm, grygorii.strashko, netdev, linux-omap, linux-kernel
In-Reply-To: <1478873447-1309-1-git-send-email-ivan.khoronzhuk@linaro.org>

From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Date: Fri, 11 Nov 2016 16:10:47 +0200

> No need to stop ctlr if it was already stopped. It can cause timeout
> warns. Steps:
> - ifconfig eth0 down
> - ethtool -l eth0 rx 8 tx 8
> - ethtool -l eth0 rx 1 tx 1
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Applied.

^ permalink raw reply

* Re: [PATCH net-next] sfc: clear napi_hash state when copying channels
From: David Miller @ 2016-11-13 18:41 UTC (permalink / raw)
  To: bkenward; +Cc: netdev, linux-net-drivers
In-Reply-To: <80535661-f88f-3dc5-9b40-111358707ffd@solarflare.com>

From: Bert Kenward <bkenward@solarflare.com>
Date: Fri, 11 Nov 2016 15:56:51 +0000

> efx_copy_channel() doesn't correctly clear the napi_hash related state.
> This means that when napi_hash_add is called for that channel nothing is
> done, and we are left with a copy of the napi_hash_node from the old
> channel. When we later call napi_hash_del() on this channel we have a
> stale napi_hash_node.
> 
> Corruption is only seen when there are multiple entries in one of the
> napi_hash lists. This is made more likely by having a very large number
> of channels. Testing was carried out with 512 channels - 32 channels on
> each of 16 ports.
> 
> This failure typically appears as protection faults within napi_by_id()
> or napi_hash_add(). efx_copy_channel() is only used when tx or rx ring
> sizes are changed (ethtool -G).
> 
> Fixes: 36763266bbe8 ("sfc: Add support for busy polling")
> Signed-off-by: Bert Kenward <bkenward@solarflare.com>

Applied to net.

^ permalink raw reply

* [PATCH net-next v1] bpf: Use u64_to_user_ptr()
From: Mickaël Salaün @ 2016-11-13 18:44 UTC (permalink / raw)
  To: netdev
  Cc: Mickaël Salaün, Alexei Starovoitov, Arnd Bergmann,
	Daniel Borkmann

Replace the custom u64_to_ptr() function with the u64_to_user_ptr()
macro.

Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
---
 kernel/bpf/syscall.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 237f3d6a7ddc..4281a9560c05 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -17,6 +17,7 @@
 #include <linux/license.h>
 #include <linux/filter.h>
 #include <linux/version.h>
+#include <linux/kernel.h>
 
 DEFINE_PER_CPU(int, bpf_prog_active);
 
@@ -254,12 +255,6 @@ struct bpf_map *bpf_map_get_with_uref(u32 ufd)
 	return map;
 }
 
-/* helper to convert user pointers passed inside __aligned_u64 fields */
-static void __user *u64_to_ptr(__u64 val)
-{
-	return (void __user *) (unsigned long) val;
-}
-
 int __weak bpf_stackmap_copy(struct bpf_map *map, void *key, void *value)
 {
 	return -ENOTSUPP;
@@ -270,8 +265,8 @@ int __weak bpf_stackmap_copy(struct bpf_map *map, void *key, void *value)
 
 static int map_lookup_elem(union bpf_attr *attr)
 {
-	void __user *ukey = u64_to_ptr(attr->key);
-	void __user *uvalue = u64_to_ptr(attr->value);
+	void __user *ukey = u64_to_user_ptr(attr->key);
+	void __user *uvalue = u64_to_user_ptr(attr->value);
 	int ufd = attr->map_fd;
 	struct bpf_map *map;
 	void *key, *value, *ptr;
@@ -344,8 +339,8 @@ static int map_lookup_elem(union bpf_attr *attr)
 
 static int map_update_elem(union bpf_attr *attr)
 {
-	void __user *ukey = u64_to_ptr(attr->key);
-	void __user *uvalue = u64_to_ptr(attr->value);
+	void __user *ukey = u64_to_user_ptr(attr->key);
+	void __user *uvalue = u64_to_user_ptr(attr->value);
 	int ufd = attr->map_fd;
 	struct bpf_map *map;
 	void *key, *value;
@@ -422,7 +417,7 @@ static int map_update_elem(union bpf_attr *attr)
 
 static int map_delete_elem(union bpf_attr *attr)
 {
-	void __user *ukey = u64_to_ptr(attr->key);
+	void __user *ukey = u64_to_user_ptr(attr->key);
 	int ufd = attr->map_fd;
 	struct bpf_map *map;
 	struct fd f;
@@ -466,8 +461,8 @@ static int map_delete_elem(union bpf_attr *attr)
 
 static int map_get_next_key(union bpf_attr *attr)
 {
-	void __user *ukey = u64_to_ptr(attr->key);
-	void __user *unext_key = u64_to_ptr(attr->next_key);
+	void __user *ukey = u64_to_user_ptr(attr->key);
+	void __user *unext_key = u64_to_user_ptr(attr->next_key);
 	int ufd = attr->map_fd;
 	struct bpf_map *map;
 	void *key, *next_key;
@@ -732,7 +727,7 @@ static int bpf_prog_load(union bpf_attr *attr)
 		return -EINVAL;
 
 	/* copy eBPF program license from user space */
-	if (strncpy_from_user(license, u64_to_ptr(attr->license),
+	if (strncpy_from_user(license, u64_to_user_ptr(attr->license),
 			      sizeof(license) - 1) < 0)
 		return -EFAULT;
 	license[sizeof(license) - 1] = 0;
@@ -762,7 +757,7 @@ static int bpf_prog_load(union bpf_attr *attr)
 	prog->len = attr->insn_cnt;
 
 	err = -EFAULT;
-	if (copy_from_user(prog->insns, u64_to_ptr(attr->insns),
+	if (copy_from_user(prog->insns, u64_to_user_ptr(attr->insns),
 			   prog->len * sizeof(struct bpf_insn)) != 0)
 		goto free_prog;
 
@@ -813,7 +808,7 @@ static int bpf_obj_pin(const union bpf_attr *attr)
 	if (CHECK_ATTR(BPF_OBJ))
 		return -EINVAL;
 
-	return bpf_obj_pin_user(attr->bpf_fd, u64_to_ptr(attr->pathname));
+	return bpf_obj_pin_user(attr->bpf_fd, u64_to_user_ptr(attr->pathname));
 }
 
 static int bpf_obj_get(const union bpf_attr *attr)
@@ -821,7 +816,7 @@ static int bpf_obj_get(const union bpf_attr *attr)
 	if (CHECK_ATTR(BPF_OBJ) || attr->bpf_fd != 0)
 		return -EINVAL;
 
-	return bpf_obj_get_user(u64_to_ptr(attr->pathname));
+	return bpf_obj_get_user(u64_to_user_ptr(attr->pathname));
 }
 
 SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
-- 
2.10.2

^ permalink raw reply related

* Re: [PATCH] net: ethernet: ixp4xx_eth: fix spelling mistake in debug message
From: David Miller @ 2016-11-13 18:49 UTC (permalink / raw)
  To: colin.king; +Cc: khalasa, netdev, linux-kernel
In-Reply-To: <20161112174406.8368-1-colin.king@canonical.com>

From: Colin King <colin.king@canonical.com>
Date: Sat, 12 Nov 2016 17:44:06 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> Trivial fix to spelling mistake "successed" to "succeeded"
> in debug message.  Also unwrap multi-line literal string.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply

* Re: [PATCH] net: atheros: atl1e: use new api ethtool_{get|set}_link_ksettings
From: David Miller @ 2016-11-13 18:49 UTC (permalink / raw)
  To: tremyfr; +Cc: jcliburn, chris.snook, netdev, linux-kernel
In-Reply-To: <1478989011-11078-1-git-send-email-tremyfr@gmail.com>

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat, 12 Nov 2016 23:16:51 +0100

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> The previous implementation of set_settings was modifying
> the value of advertising, but with the new API, it's not
> possible. The structure ethtool_link_ksettings is defined
> as const.
> 
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>

Applied.

^ permalink raw reply

* Re: [PATCH net 1/2] ibmvnic: Unmap ibmvnic_statistics structure
From: David Miller @ 2016-11-13 18:42 UTC (permalink / raw)
  To: tlfalcon; +Cc: netdev, mwb
In-Reply-To: <1478883646-10760-1-git-send-email-tlfalcon@linux.vnet.ibm.com>

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Fri, 11 Nov 2016 11:00:45 -0600

> This structure was mapped but never subsequently unmapped.
> 
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Applied.

^ permalink raw reply

* Re: [PATCH net 2/2] ibmvnic: Fix size of debugfs name buffer
From: David Miller @ 2016-11-13 18:42 UTC (permalink / raw)
  To: tlfalcon; +Cc: netdev, mwb
In-Reply-To: <1478883646-10760-2-git-send-email-tlfalcon@linux.vnet.ibm.com>

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Fri, 11 Nov 2016 11:00:46 -0600

> This mistake was causing debugfs directory creation
> failures when multiple ibmvnic devices were probed.
> 
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Applied.

^ permalink raw reply

* Re: [PATCH v2 2/2] bnx2: Wait for in-flight DMA to complete at probe stage
From: Michael Chan @ 2016-11-13 19:02 UTC (permalink / raw)
  To: Baoquan He
  Cc: Netdev, David Miller, open list, Dept-GELinuxNICDev, rasesh.mody,
	harish.patil, frank, jsr, pmenzel, jroedel, dyoung
In-Reply-To: <1479013293-21001-3-git-send-email-bhe@redhat.com>

On Sat, Nov 12, 2016 at 9:01 PM, Baoquan He <bhe@redhat.com> wrote:
> In-flight DMA from 1st kernel could continue going in kdump kernel.
> New io-page table has been created before bnx2 does reset at open stage.
> We have to wait for the in-flight DMA to complete to avoid it look up
> into the newly created io-page table at probe stage.
>
> Suggested-by: Michael Chan <michael.chan@broadcom.com>
> Signed-off-by: Baoquan He <bhe@redhat.com>

Acked-by: Michael Chan <michael.chan@broadcom.com>

^ permalink raw reply

* [PATCH v2] ip6_output: ensure flow saddr actually belongs to device
From: Jason A. Donenfeld @ 2016-11-13 19:02 UTC (permalink / raw)
  To: David Ahern, Netdev, WireGuard mailing list, LKML,
	YOSHIFUJI Hideaki, Hannes Frederic Sowa
In-Reply-To: <405b2e79-854d-4c30-07b0-bd524137d2f6@cumulusnetworks.com>

This puts the IPv6 routing functions in parity with the IPv4 routing
functions. Namely, we now check in v6 that if a flowi6 requests an
saddr, the returned dst actually corresponds to a net device that has
that saddr. This mirrors the v4 logic with __ip_dev_find in
__ip_route_output_key_hash. In the event that the returned dst is not
for a dst with a dev that has the saddr, we return -EINVAL, just like
v4; this makes it easy to use the same error handlers for both cases.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: David Ahern <dsa@cumulusnetworks.com>
---
Changes from v1:
   This moves the check to the top and now sees if it's a valid address
   on _any_ device, not just the one in dst.

 include/net/ipv6.h    |  2 ++
 net/ipv6/ip6_output.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 8fed1cd..e5dc14f 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -914,6 +914,8 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
 					 const struct in6_addr *final_dst);
 struct dst_entry *ip6_blackhole_route(struct net *net,
 				      struct dst_entry *orig_dst);
+struct net_device *__ip6_dev_find(struct net *net, struct in6_addr *addr,
+				  bool devref);
 
 /*
  *	skb processing functions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 6001e78..371170b 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -916,6 +916,30 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
 	return dst;
 }
 
+/**
+ * __ip6_dev_find - find the first device with a given source address.
+ * @net: the net namespace
+ * @addr: the source address
+ * @devref: if true, take a reference on the found device
+ *
+ * If a caller uses devref=false, it should be protected by RCU, or RTNL
+ */
+struct net_device *__ip6_dev_find(struct net *net, struct in6_addr *addr, bool devref)
+{
+	struct net_device *result;
+
+	rcu_read_lock();
+	for_each_netdev_rcu(net, result) {
+		if (ipv6_chk_addr(net, addr, result, 1))
+			break;
+	}
+	if (result && devref)
+		dev_hold(result);
+	rcu_read_unlock();
+	return result;
+}
+EXPORT_SYMBOL(__ip6_dev_find);
+
 static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
 			       struct dst_entry **dst, struct flowi6 *fl6)
 {
@@ -926,6 +950,10 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
 	int err;
 	int flags = 0;
 
+	if (!ipv6_addr_any(&fl6->saddr) &&
+	    !__ip6_dev_find(net, &fl6->saddr, false))
+		return -EINVAL;
+
 	/* The correct way to handle this would be to do
 	 * ip6_route_get_saddr, and then ip6_route_output; however,
 	 * the route-specific preferred source forces the
-- 
2.10.2

^ 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