Re: [PATCH net-next v2 0/6] bpf: Fix bugs in sock_ops samples

2017-11-10 Thread David Miller
From: Lawrence Brakmo 
Date: Fri, 10 Nov 2017 22:19:49 -0800

> The programs were returning -1 in some cases when they should
> only return 0 or 1. Changes in the verifier now catch this
> issue and the programs fail to load. This is now fixed.

Series applied, thanks Lawrence.


Re: [PATCH net-next 0/6] net: dsa: simplify switchdev prepare phase

2017-11-10 Thread David Miller
From: Vivien Didelot 
Date: Wed,  8 Nov 2017 12:19:11 -0500

> This patch series brings no functional changes.
> 
> It removes the unused switchdev_trans arguments from the dsa_switch_ops
> for both MDB and VLAN operations, and provides function to prepare and
> add these objects for a given bitmap of ports.

This series doesn't apply to net-next and it also seems to duplicate
some fixes that went into 'net'.

Please don't do things this way.

When a fix has to go to 'net' fix, _wait_ until it propagates to
'net-next' if you must use it as a dependency.

Thank you.


Re: [PATCH net] net: dsa: return after mdb prepare phase

2017-11-10 Thread David Miller
From: Vivien Didelot 
Date: Wed,  8 Nov 2017 10:49:56 -0500

> The current code does not return after successfully preparing the MDB
> addition on every ports member of a multicast group. Fix this.
> 
> Fixes: a1a6b7ea7f2d ("net: dsa: add cross-chip multicast support")
> Reported-by: Egil Hjelmeland 
> Signed-off-by: Vivien Didelot 

Applied.


Re: [PATCH net] net: dsa: return after vlan prepare phase

2017-11-10 Thread David Miller
From: Vivien Didelot 
Date: Wed,  8 Nov 2017 10:50:10 -0500

> The current code does not return after successfully preparing the VLAN
> addition on every ports member of a it. Fix this.
> 
> Fixes: 1ca4aa9cd4cc ("net: dsa: check VLAN capability of every switch")
> Signed-off-by: Vivien Didelot 

Applied.


Re: [net-next v2 1/1] tipc: improve link resiliency when rps is activated

2017-11-10 Thread David Miller
From: Jon Maloy 
Date: Wed, 8 Nov 2017 09:59:26 +0100

> Currently, the TIPC RPS dissector is based only on the incoming packets'
> source node address, hence steering all traffic from a node to the same
> core. We have seen that this makes the links vulnerable to starvation
> and unnecessary resets when we turn down the link tolerance to very low
> values.
> 
> To reduce the risk of this happening, we exempt probe and probe replies
> packets from the convergence to one core per source node. Instead, we do
> the opposite, - we try to diverge those packets across as many cores as
> possible, by randomizing the flow selector key.
> 
> To make such packets identifiable to the dissector, we add a new
> 'is_keepalive' bit to word 0 of the LINK_PROTOCOL header. This bit is
> set both for PROBE and PROBE_REPLY messages, and only for those.
> 
> It should be noted that these packets are not part of any flow anyway,
> and only constitute a minuscule fraction of all packets sent across a
> link. Hence, there is no risk that this will affect overall performance.
> 
> Acked-by: Ying Xue 
> Signed-off-by: Jon Maloy 

Applied, thanks.


Re: [PATCH v2 0/2] net: macb: add error handling on probe and

2017-11-10 Thread David Miller
From: Michael Grzeschik 
Date: Wed,  8 Nov 2017 09:56:33 +0100

> This series adds more error handling to the macb driver.

Series applied to net-next, thanks.


[PATCH net v3 04/12] net/sonic: Clean up and modernize log messages

2017-11-10 Thread Finn Thain
Add missing printk severity levels by adopting pr_foo() calls for the
platform_driver and dev_foo() calls for the nubus_driver.
Avoid KERN_CONT usage as per advice from checkpatch.
Avoid #ifdef around printk calls.

Cc: Thomas Bogendoerfer 
Cc: Chris Zankel 
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
Only the macsonic.c changes have been tested. The other changes
are similar but untested.
---
 drivers/net/ethernet/natsemi/jazzsonic.c | 13 
 drivers/net/ethernet/natsemi/macsonic.c  | 54 ++--
 drivers/net/ethernet/natsemi/xtsonic.c   | 11 ---
 3 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c 
b/drivers/net/ethernet/natsemi/jazzsonic.c
index a6caeb567c0d..2cd88b4b5eac 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -141,17 +141,14 @@ static int sonic_probe1(struct net_device *dev)
i++;
 
if (known_revisions[i] == 0x) {
-   printk("SONIC ethernet controller not found (0x%4x)\n",
-  silicon_revision);
+   pr_info("SONIC ethernet controller not found (0x%4x)\n",
+   silicon_revision);
goto out;
}
 
if (sonic_debug  &&  version_printed++ == 0)
printk(version);
 
-   printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ",
-  dev_name(lp->device), dev->base_addr);
-
/*
 * Put the sonic into software reset, then
 * retrieve and print the ethernet address.
@@ -244,12 +241,14 @@ static int jazz_sonic_probe(struct platform_device *pdev)
err = sonic_probe1(dev);
if (err)
goto out;
+
+   pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
+   dev->base_addr, dev->dev_addr, dev->irq);
+
err = register_netdev(dev);
if (err)
goto out1;
 
-   printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
-
return 0;
 
 out1:
diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index 8a135abe136f..c8c40e4708f3 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -313,8 +313,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
if (!MACH_IS_MAC)
return -ENODEV;
 
-   printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
-
/* Bogus probing, on the models which may or may not have
   Ethernet (BTW, the Ethernet *is* always at the same
   address, and nothing else lives there, at least if Apple's
@@ -324,13 +322,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
 
card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
if (!card_present) {
-   printk("none.\n");
+   pr_info("Onboard/comm-slot SONIC not found\n");
return -ENODEV;
}
}
 
-   printk("yes\n");
-
/* Danger!  My arms are flailing wildly!  You *must* set lp->reg_offset
 * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
dev->base_addr = ONBOARD_SONIC_REGISTERS;
@@ -343,14 +339,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
printk(KERN_INFO "%s", version);
sonic_version_printed = 1;
}
-   printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
-  dev_name(lp->device), dev->base_addr);
 
/* The PowerBook's SONIC is 16 bit always. */
if (macintosh_config->ident == MAC_MODEL_PB520) {
lp->reg_offset = 0;
lp->dma_bitmode = SONIC_BITMODE16;
-   sr = SONIC_READ(SONIC_SR);
} else if (commslot) {
/* Some of the comm-slot cards are 16 bit.  But some
   of them are not.  The 32-bit cards use offset 2 and
@@ -367,22 +360,21 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else {
lp->dma_bitmode = SONIC_BITMODE16;
lp->reg_offset = 0;
-   sr = SONIC_READ(SONIC_SR);
}
} else {
/* All onboard cards are at offset 2 with 32 bit DMA. */
lp->reg_offset = 2;
lp->dma_bitmode = SONIC_BITMODE32;
-   sr = SONIC_READ(SONIC_SR);
}
-   printk(KERN_INFO
-  "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
-  dev_name(lp->device), sr, lp->dma_bitmode?32:16, lp->reg_offset);
 
-#if 0 /* This is sometimes useful to find out how MacOS configured the card. */
-   printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", 

[PATCH net v3 03/12] net/mac8390: Convert to nubus_driver

2017-11-10 Thread Finn Thain
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/Space.c |   3 --
 drivers/net/ethernet/8390/mac8390.c | 105 ++--
 include/net/Space.h |   1 -
 3 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index fe123808c6b8..3afda6561434 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -114,9 +114,6 @@ static struct devprobe2 m68k_probes[] __initdata = {
 #ifdef CONFIG_MVME147_NET  /* MVME147 internal Ethernet */
{mvme147lance_probe, 0},
 #endif
-#ifdef CONFIG_MAC8390   /* NuBus NS8390-based cards */
-   {mac8390_probe, 0},
-#endif
{NULL, 0},
 };
 
diff --git a/drivers/net/ethernet/8390/mac8390.c 
b/drivers/net/ethernet/8390/mac8390.c
index 0367c9ada7c6..80bbaa3c7241 100644
--- a/drivers/net/ethernet/8390/mac8390.c
+++ b/drivers/net/ethernet/8390/mac8390.c
@@ -123,8 +123,7 @@ enum mac8390_access {
 };
 
 extern int mac8390_memtest(struct net_device *dev);
-static int mac8390_initdev(struct net_device *dev,
-  struct nubus_functional_resource *ndev,
+static int mac8390_initdev(struct net_device *dev, struct nubus_board *board,
   enum mac8390_type type);
 
 static int mac8390_open(struct net_device *dev);
@@ -170,7 +169,7 @@ static void word_memcpy_tocard(unsigned long tp, const void 
*fp, int count);
 static void word_memcpy_fromcard(void *tp, unsigned long fp, int count);
 static u32 mac8390_msg_enable;
 
-static enum mac8390_type __init mac8390_ident(struct nubus_functional_resource 
*dev)
+static enum mac8390_type mac8390_ident(struct nubus_functional_resource *dev)
 {
switch (dev->dr_sw) {
case NUBUS_DRSW_3COM:
@@ -236,7 +235,7 @@ static enum mac8390_type __init mac8390_ident(struct 
nubus_functional_resource *
return MAC8390_NONE;
 }
 
-static enum mac8390_access __init mac8390_testio(volatile unsigned long 
membase)
+static enum mac8390_access mac8390_testio(unsigned long membase)
 {
unsigned long outdata = 0xA5A0B5B0;
unsigned long indata =  0x;
@@ -254,7 +253,7 @@ static enum mac8390_access __init mac8390_testio(volatile 
unsigned long membase)
return ACCESS_UNKNOWN;
 }
 
-static int __init mac8390_memsize(unsigned long membase)
+static int mac8390_memsize(unsigned long membase)
 {
unsigned long flags;
int i, j;
@@ -290,9 +289,9 @@ static int __init mac8390_memsize(unsigned long membase)
return i * 0x1000;
 }
 
-static bool __init mac8390_init(struct net_device *dev,
-   struct nubus_functional_resource *ndev,
-   enum mac8390_type cardtype)
+static bool mac8390_rsrc_init(struct net_device *dev,
+ struct nubus_functional_resource *ndev,
+ enum mac8390_type cardtype)
 {
struct nubus_dir dir;
struct nubus_dirent ent;
@@ -393,49 +392,40 @@ static bool __init mac8390_init(struct net_device *dev,
return true;
 }
 
-struct net_device * __init mac8390_probe(int unit)
+static int mac8390_device_probe(struct nubus_board *board)
 {
struct net_device *dev;
-   struct nubus_functional_resource *ndev = NULL;
int err = -ENODEV;
struct ei_device *ei_local;
-
-   static unsigned int slots;
-
-   enum mac8390_type cardtype;
-
-   /* probably should check for Nubus instead */
+   struct nubus_functional_resource *fres;
+   enum mac8390_type cardtype = MAC8390_NONE;
 
if (!MACH_IS_MAC)
-   return ERR_PTR(-ENODEV);
+   return -ENODEV;
 
dev = alloc_ei_netdev(0);
if (!dev)
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
 
-   if (unit >= 0)
-   sprintf(dev->name, "eth%d", unit);
+   SET_NETDEV_DEV(dev, >dev);
 
-   while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET,
-  ndev))) {
-   /* Have we seen it already? */
-   if (slots & (1 << ndev->board->slot))
+   for_each_board_func_rsrc(board, fres) {
+   if (fres->category != NUBUS_CAT_NETWORK ||
+   fres->type != NUBUS_TYPE_ETHERNET)
continue;
-   slots |= 1 << ndev->board->slot;
 
-   cardtype = mac8390_ident(ndev);
+   cardtype = mac8390_ident(fres);
if (cardtype == MAC8390_NONE)
continue;
 
-   if (!mac8390_init(dev, ndev, cardtype))
-   continue;
-
-   /* Do the nasty 8390 stuff */
-   if (!mac8390_initdev(dev, ndev, cardtype))
+   if (mac8390_rsrc_init(dev, fres, cardtype))
break;
}
+   if (!fres)
+   goto out;
 
-   

[PATCH net v3 02/12] net/mac89x0: Convert to platform_driver

2017-11-10 Thread Finn Thain
Apparently these Dayna cards don't have a pseudoslot declaration ROM
which means they can't be probed like NuBus cards.

Cc: Geert Uytterhoeven 
Signed-off-by: Finn Thain 
---
 arch/m68k/mac/config.c|  4 +++
 drivers/net/Space.c   |  3 --
 drivers/net/ethernet/cirrus/mac89x0.c | 64 +++
 include/net/Space.h   |  1 -
 4 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index d3d435248a24..c73eb8209555 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -1088,6 +1088,10 @@ int __init mac_platform_init(void)
macintosh_config->expansion_type == MAC_EXP_PDS_COMM)
platform_device_register_simple("macsonic", -1, NULL, 0);
 
+   if (macintosh_config->expansion_type == MAC_EXP_PDS ||
+   macintosh_config->expansion_type == MAC_EXP_PDS_COMM)
+   platform_device_register_simple("mac89x0", -1, NULL, 0);
+
if (macintosh_config->ether_type == MAC_ETHER_MACE)
platform_device_register_simple("macmace", -1, NULL, 0);
 
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index 11fe71278f40..fe123808c6b8 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -117,9 +117,6 @@ static struct devprobe2 m68k_probes[] __initdata = {
 #ifdef CONFIG_MAC8390   /* NuBus NS8390-based cards */
{mac8390_probe, 0},
 #endif
-#ifdef CONFIG_MAC89x0
-   {mac89x0_probe, 0},
-#endif
{NULL, 0},
 };
 
diff --git a/drivers/net/ethernet/cirrus/mac89x0.c 
b/drivers/net/ethernet/cirrus/mac89x0.c
index f910f0f386d6..8a23d2fc0e28 100644
--- a/drivers/net/ethernet/cirrus/mac89x0.c
+++ b/drivers/net/ethernet/cirrus/mac89x0.c
@@ -93,6 +93,7 @@ static const char version[] =
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -105,6 +106,7 @@ static const char version[] =
 
 #include "cs89x0.h"
 
+static int debug;
 static unsigned int net_debug = NET_DEBUG;
 
 /* Information that need to be kept for each board. */
@@ -176,10 +178,9 @@ static const struct net_device_ops mac89x0_netdev_ops = {
 
 /* Probe for the CS8900 card in slot E.  We won't bother looking
anywhere else until we have a really good reason to do so. */
-struct net_device * __init mac89x0_probe(int unit)
+static int mac89x0_device_probe(struct platform_device *pdev)
 {
struct net_device *dev;
-   static int once_is_enough;
struct net_local *lp;
static unsigned version_printed;
int i, slot;
@@ -189,20 +190,13 @@ struct net_device * __init mac89x0_probe(int unit)
int err = -ENODEV;
 
if (!MACH_IS_MAC)
-   return ERR_PTR(-ENODEV);
+   return -ENODEV;
+
+   net_debug = debug;
 
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
-   return ERR_PTR(-ENOMEM);
-
-   if (unit >= 0) {
-   sprintf(dev->name, "eth%d", unit);
-   netdev_boot_setup_check(dev);
-   }
-
-   if (once_is_enough)
-   goto out;
-   once_is_enough = 1;
+   return -ENOMEM;
 
/* We might have to parameterize this later */
slot = 0xE;
@@ -228,6 +222,8 @@ struct net_device * __init mac89x0_probe(int unit)
if (sig != swab16(CHIP_EISA_ID_SIG))
goto out;
 
+   SET_NETDEV_DEV(dev, >dev);
+
/* Initialize the net_device structure. */
lp = netdev_priv(dev);
 
@@ -287,12 +283,14 @@ struct net_device * __init mac89x0_probe(int unit)
err = register_netdev(dev);
if (err)
goto out1;
-   return NULL;
+
+   platform_set_drvdata(pdev, dev);
+   return 0;
 out1:
nubus_writew(0, dev->base_addr + ADD_PORT);
 out:
free_netdev(dev);
-   return ERR_PTR(err);
+   return err;
 }
 
 #if 0
@@ -601,32 +599,26 @@ static int set_mac_address(struct net_device *dev, void 
*addr)
return 0;
 }
 
-#ifdef MODULE
-
-static struct net_device *dev_cs89x0;
-static int debug;
-
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
 MODULE_LICENSE("GPL");
 
-int __init
-init_module(void)
+static int mac89x0_device_remove(struct platform_device *pdev)
 {
-   net_debug = debug;
-dev_cs89x0 = mac89x0_probe(-1);
-   if (IS_ERR(dev_cs89x0)) {
-printk(KERN_WARNING "mac89x0.c: No card found\n");
-   return PTR_ERR(dev_cs89x0);
-   }
+   struct net_device *dev = platform_get_drvdata(pdev);
+
+   unregister_netdev(dev);
+   nubus_writew(0, dev->base_addr + ADD_PORT);
+   free_netdev(dev);
return 0;
 }
 
-void
-cleanup_module(void)
-{
-   unregister_netdev(dev_cs89x0);
-   nubus_writew(0, dev_cs89x0->base_addr + ADD_PORT);
-   free_netdev(dev_cs89x0);
-}
-#endif /* MODULE */
+static struct platform_driver 

[PATCH net v3 00/12] Fixes, cleanup and modernization for some legacy ethernet NIC drivers

2017-11-10 Thread Finn Thain
This patch series adds support for the Linux Driver Model for Mac NIC
drivers, fixes some logging bugs, removes dead code, and adopts netif_*
calls to reduce code duplication.

All up, about 100 lines of code are eliminated.

This patch series has been tested on a variety of Macs, with coverage
for the changes to lib8390.c, mac8390.c, macsonic.c, sonic.[ch] and
macmace.c.

This patch series should be applied after the NuBus subsystem
modernization patch series.

Changes since v1:
- Keep the once_is_enough test in mac89x0.c.
- Add tested-by tags.
- Move netdev_info() call to correct branch in macmace.c.

Changes since v2:
- Modernize NuBus drivers by adopting the Linux Driver Model.
- Use dev_foo() in NuBus drivers.
- Don't log any probe messages after register_netdev().


Finn Thain (12):
  net/macsonic: Convert to nubus_driver
  net/mac89x0: Convert to platform_driver
  net/mac8390: Convert to nubus_driver
  net/sonic: Clean up and modernize log messages
  net/sonic: Replace custom debug logging with netif_* calls
  net/mac89x0: Remove dead or unreachable code
  net/mac89x0: Fix and modernize log messages
  net/mac89x0: Replace custom debug logging with netif_* calls
  net/8390: Fix redundant code
  net/mac8390: Fix log messages
  net/macmace: Fix and clean up log messages
  net/smc9194: Remove bogus CONFIG_MAC reference

 arch/m68k/mac/config.c   |   4 +
 drivers/net/Space.c  |   6 -
 drivers/net/ethernet/8390/ax88796.c  |   3 -
 drivers/net/ethernet/8390/axnet_cs.c |   2 -
 drivers/net/ethernet/8390/etherh.c   |  17 ---
 drivers/net/ethernet/8390/hydra.c|   4 -
 drivers/net/ethernet/8390/lib8390.c  |   2 +
 drivers/net/ethernet/8390/mac8390.c  | 144 +--
 drivers/net/ethernet/8390/mcf8390.c  |   4 -
 drivers/net/ethernet/8390/pcnet_cs.c |   4 -
 drivers/net/ethernet/8390/zorro8390.c|   5 -
 drivers/net/ethernet/apple/macmace.c |   9 +-
 drivers/net/ethernet/cirrus/mac89x0.c| 160 +++--
 drivers/net/ethernet/natsemi/jazzsonic.c |  32 ++---
 drivers/net/ethernet/natsemi/macsonic.c  | 239 ++-
 drivers/net/ethernet/natsemi/sonic.c |  92 ++--
 drivers/net/ethernet/natsemi/sonic.h |   2 +
 drivers/net/ethernet/natsemi/xtsonic.c   |  30 ++--
 drivers/net/ethernet/smsc/Kconfig|   2 +-
 include/net/Space.h  |   2 -
 20 files changed, 333 insertions(+), 430 deletions(-)

-- 
2.13.6



[PATCH net v3 06/12] net/mac89x0: Remove dead or unreachable code

2017-11-10 Thread Finn Thain
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/cirrus/mac89x0.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/mac89x0.c 
b/drivers/net/ethernet/cirrus/mac89x0.c
index 8a23d2fc0e28..c1a3d1aed037 100644
--- a/drivers/net/ethernet/cirrus/mac89x0.c
+++ b/drivers/net/ethernet/cirrus/mac89x0.c
@@ -121,10 +121,6 @@ struct net_local {
 };
 
 /* Index to functions, as function prototypes. */
-
-#if 0
-extern void reset_chip(struct net_device *dev);
-#endif
 static int net_open(struct net_device *dev);
 static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
 static irqreturn_t net_interrupt(int irq, void *dev_id);
@@ -134,10 +130,6 @@ static int net_close(struct net_device *dev);
 static struct net_device_stats *net_get_stats(struct net_device *dev);
 static int set_mac_address(struct net_device *dev, void *addr);
 
-
-/* Example routines you must write ;->. */
-#define tx_done(dev) 1
-
 /* For reading/writing registers ISA-style */
 static inline int
 readreg_io(struct net_device *dev, int portno)
@@ -293,24 +285,6 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
return err;
 }
 
-#if 0
-/* This is useful for something, but I don't know what yet. */
-void __init reset_chip(struct net_device *dev)
-{
-   int reset_start_time;
-
-   writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
-
-   /* wait 30 ms */
-   msleep_interruptible(30);
-
-   /* Wait until the chip is reset */
-   reset_start_time = jiffies;
-   while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - 
reset_start_time < 2)
-   ;
-}
-#endif
-
 /* Open/initialize the board.  This is called (in the current kernel)
sometime after booting when the 'ifconfig' program is run.
 
@@ -412,11 +386,6 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
struct net_local *lp;
int ioaddr, status;
 
-   if (dev == NULL) {
-   printk ("net_interrupt(): irq %d for unknown device.\n", irq);
-   return IRQ_NONE;
-   }
-
ioaddr = dev->base_addr;
lp = netdev_priv(dev);
 
-- 
2.13.6



[PATCH net v3 05/12] net/sonic: Replace custom debug logging with netif_* calls

2017-11-10 Thread Finn Thain
Eliminate duplicated debug code by moving it into the core driver.
Don't log the only valid silicon revision number (it's in the source).

Cc: Thomas Bogendoerfer 
Cc: Chris Zankel 
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
Only the sonic.[ch] and macsonic.c changes have been tested. The other
changes are similar but untested.
---
 drivers/net/ethernet/natsemi/jazzsonic.c | 19 +--
 drivers/net/ethernet/natsemi/macsonic.c  | 25 ++---
 drivers/net/ethernet/natsemi/sonic.c | 92 +++-
 drivers/net/ethernet/natsemi/sonic.h |  2 +
 drivers/net/ethernet/natsemi/xtsonic.c   | 19 +--
 5 files changed, 54 insertions(+), 103 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c 
b/drivers/net/ethernet/natsemi/jazzsonic.c
index 2cd88b4b5eac..1dfb5e53af22 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -59,14 +59,6 @@ do { 
\
*((volatile unsigned int *)dev->base_addr+(reg)) = (val);   
\
 } while (0)
 
-
-/* use 0 for production, 1 for verification, >1 for debug */
-#ifdef SONIC_DEBUG
-static unsigned int sonic_debug = SONIC_DEBUG;
-#else
-static unsigned int sonic_debug = 1;
-#endif
-
 /*
  * We cannot use station (ethernet) address prefixes to detect the
  * sonic controller since these are board manufacturer depended.
@@ -116,7 +108,6 @@ static const struct net_device_ops sonic_netdev_ops = {
 
 static int sonic_probe1(struct net_device *dev)
 {
-   static unsigned version_printed;
unsigned int silicon_revision;
unsigned int val;
struct sonic_local *lp = netdev_priv(dev);
@@ -132,9 +123,6 @@ static int sonic_probe1(struct net_device *dev)
 * the expected location.
 */
silicon_revision = SONIC_READ(SONIC_SR);
-   if (sonic_debug > 1)
-   printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
-
i = 0;
while (known_revisions[i] != 0x &&
   known_revisions[i] != silicon_revision)
@@ -146,9 +134,6 @@ static int sonic_probe1(struct net_device *dev)
goto out;
}
 
-   if (sonic_debug  &&  version_printed++ == 0)
-   printk(version);
-
/*
 * Put the sonic into software reset, then
 * retrieve and print the ethernet address.
@@ -245,6 +230,8 @@ static int jazz_sonic_probe(struct platform_device *pdev)
pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
 
+   sonic_msg_init(dev);
+
err = register_netdev(dev);
if (err)
goto out1;
@@ -260,8 +247,6 @@ static int jazz_sonic_probe(struct platform_device *pdev)
 }
 
 MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
-module_param(sonic_debug, int, 0);
-MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
 MODULE_ALIAS("platform:jazzsonic");
 
 #include "sonic.c"
diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index c8c40e4708f3..e2f34bfdde4e 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -69,15 +69,6 @@
 #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
  + lp->reg_offset))
 
-/* use 0 for production, 1 for verification, >1 for debug */
-#ifdef SONIC_DEBUG
-static unsigned int sonic_debug = SONIC_DEBUG;
-#else
-static unsigned int sonic_debug = 1;
-#endif
-
-static int sonic_version_printed;
-
 /* For onboard SONIC */
 #define ONBOARD_SONIC_REGISTERS0x50F0A000
 #define ONBOARD_SONIC_PROM_BASE0x50f08000
@@ -335,11 +326,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else
dev->irq = IRQ_NUBUS_9;
 
-   if (!sonic_version_printed) {
-   printk(KERN_INFO "%s", version);
-   sonic_version_printed = 1;
-   }
-
/* The PowerBook's SONIC is 16 bit always. */
if (macintosh_config->ident == MAC_MODEL_PB520) {
lp->reg_offset = 0;
@@ -501,11 +487,6 @@ static int mac_sonic_nubus_probe_board(struct nubus_board 
*board, int id,
lp->dma_bitmode = dma_bitmode;
dev->irq = SLOT2IRQ(board->slot);
 
-   if (!sonic_version_printed) {
-   printk(KERN_INFO "%s", version);
-   sonic_version_printed = 1;
-   }
-
dev_info(>dev, "%s, revision 0x%04x, %d bit DMA, register offset 
%d\n",
 board->name, SONIC_READ(SONIC_SR),
 lp->dma_bitmode ? 32 : 16, lp->reg_offset);
@@ -557,6 +538,8 @@ static int mac_sonic_platform_probe(struct platform_device 
*pdev)
if (err)
goto out;
 
+   sonic_msg_init(dev);
+
err = register_netdev(dev);
if (err)
  

[PATCH net v3 08/12] net/mac89x0: Replace custom debug logging with netif_* calls

2017-11-10 Thread Finn Thain
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/cirrus/mac89x0.c | 52 ---
 1 file changed, 18 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/mac89x0.c 
b/drivers/net/ethernet/cirrus/mac89x0.c
index 4575370d57db..9348c095c898 100644
--- a/drivers/net/ethernet/cirrus/mac89x0.c
+++ b/drivers/net/ethernet/cirrus/mac89x0.c
@@ -61,18 +61,6 @@
 static const char version[] =
 "cs89x0.c:v1.02 11/26/96 Russell Nelson \n";
 
-/* === configure the driver here === */
-
-/* use 0 for production, 1 for verification, >2 for debug */
-#ifndef NET_DEBUG
-#define NET_DEBUG 0
-#endif
-
-/* === end of configuration === */
-
-
-/* Always include 'config.h' first in case the user wants to turn on
-   or override something. */
 #include 
 
 /*
@@ -108,11 +96,13 @@ static const char version[] =
 
 #include "cs89x0.h"
 
-static int debug;
-static unsigned int net_debug = NET_DEBUG;
+static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "debug message level");
 
 /* Information that need to be kept for each board. */
 struct net_local {
+   int msg_enable;
int chip_type;  /* one of: CS8900, CS8920, CS8920M */
char chip_revision; /* revision letter of the chip ('A'...) */
int send_cmd;   /* the propercommand used to send a packet. */
@@ -176,7 +166,6 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
 {
struct net_device *dev;
struct net_local *lp;
-   static unsigned version_printed;
int i, slot;
unsigned rev_type = 0;
unsigned long ioaddr;
@@ -186,8 +175,6 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
if (!MACH_IS_MAC)
return -ENODEV;
 
-   net_debug = debug;
-
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
return -ENOMEM;
@@ -221,6 +208,8 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
/* Initialize the net_device structure. */
lp = netdev_priv(dev);
 
+   lp->msg_enable = netif_msg_init(debug, 0);
+
/* Fill in the 'dev' fields. */
dev->base_addr = ioaddr;
dev->mem_start = (unsigned long)
@@ -243,8 +232,7 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
lp->send_cmd = TX_NOW;
 
-   if (net_debug && version_printed++ == 0)
-   printk(version);
+   netif_dbg(lp, drv, dev, "%s", version);
 
pr_info("CS89%c0%s rev %c found at %#8lx\n",
lp->chip_type == CS8900 ? '0' : '2',
@@ -344,11 +332,9 @@ net_send_packet(struct sk_buff *skb, struct net_device 
*dev)
struct net_local *lp = netdev_priv(dev);
unsigned long flags;
 
-   if (net_debug > 3)
-   printk("%s: sent %d byte packet of type %x\n",
-  dev->name, skb->len,
-  (skb->data[ETH_ALEN+ETH_ALEN] << 8)
-  | skb->data[ETH_ALEN+ETH_ALEN+1]);
+   netif_dbg(lp, tx_queued, dev, "sent %d byte packet of type %x\n",
+ skb->len, skb->data[ETH_ALEN + ETH_ALEN] << 8 |
+   skb->data[ETH_ALEN + ETH_ALEN + 1]);
 
/* keep the upload from being interrupted, since we
   ask the chip to start transmitting before the
@@ -397,7 +383,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
faster than you can read them off, you're screwed.  Hasta la
vista, baby!  */
while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT {
-   if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status);
+   netif_dbg(lp, intr, dev, "status=%04x\n", status);
switch(status & ISQ_EVENT_MASK) {
case ISQ_RECEIVER_EVENT:
/* Got a packet(s). */
@@ -427,7 +413,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
netif_wake_queue(dev);
}
if (status & TX_UNDERRUN) {
-   if (net_debug > 0) printk("%s: transmit 
underrun\n", dev->name);
+   netif_dbg(lp, tx_err, dev, "transmit 
underrun\n");
 lp->send_underrun++;
 if (lp->send_underrun == 3) lp->send_cmd = 
TX_AFTER_381;
 else if (lp->send_underrun == 6) lp->send_cmd 
= TX_AFTER_ALL;
@@ -448,6 +434,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)
 static void
 net_rx(struct net_device *dev)
 {
+   struct net_local *lp = netdev_priv(dev);
struct sk_buff *skb;
int status, length;
 
@@ -479,10 +466,9 @@ net_rx(struct net_device *dev)
   

[PATCH net v3 07/12] net/mac89x0: Fix and modernize log messages

2017-11-10 Thread Finn Thain
Fix log message fragments which no longer produce the desired output
(since the behaviour of printk() was changed).
Add missing printk severity levels.
Drop deprecated "out of memory" message as per checkpatch advice.

Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/cirrus/mac89x0.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/mac89x0.c 
b/drivers/net/ethernet/cirrus/mac89x0.c
index c1a3d1aed037..4575370d57db 100644
--- a/drivers/net/ethernet/cirrus/mac89x0.c
+++ b/drivers/net/ethernet/cirrus/mac89x0.c
@@ -56,6 +56,8 @@
   local_irq_{dis,en}able()
 */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 static const char version[] =
 "cs89x0.c:v1.02 11/26/96 Russell Nelson \n";
 
@@ -244,16 +246,14 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
if (net_debug && version_printed++ == 0)
printk(version);
 
-   printk(KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx",
-  dev->name,
-  lp->chip_type==CS8900?'0':'2',
-  lp->chip_type==CS8920M?"M":"",
-  lp->chip_revision,
-  dev->base_addr);
+   pr_info("CS89%c0%s rev %c found at %#8lx\n",
+   lp->chip_type == CS8900 ? '0' : '2',
+   lp->chip_type == CS8920M ? "M" : "",
+   lp->chip_revision, dev->base_addr);
 
/* Try to read the MAC address */
if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) {
-   printk("\nmac89x0: No EEPROM, giving up now.\n");
+   pr_info("No EEPROM, giving up now\n");
goto out1;
 } else {
 for (i = 0; i < ETH_ALEN; i += 2) {
@@ -268,7 +268,7 @@ static int mac89x0_device_probe(struct platform_device 
*pdev)
 
/* print the IRQ and ethernet address. */
 
-   printk(" IRQ %d ADDR %pM\n", dev->irq, dev->dev_addr);
+   pr_info("MAC %pM, IRQ %d\n", dev->dev_addr, dev->irq);
 
dev->netdev_ops = _netdev_ops;
 
@@ -471,7 +471,6 @@ net_rx(struct net_device *dev)
/* Malloc up new buffer. */
skb = alloc_skb(length, GFP_ATOMIC);
if (skb == NULL) {
-   printk("%s: Memory squeeze, dropping packet.\n", dev->name);
dev->stats.rx_dropped++;
return;
}
@@ -559,7 +558,7 @@ static int set_mac_address(struct net_device *dev, void 
*addr)
return -EADDRNOTAVAIL;
 
memcpy(dev->dev_addr, saddr->sa_data, ETH_ALEN);
-   printk("%s: Setting MAC address to %pM\n", dev->name, dev->dev_addr);
+   netdev_info(dev, "Setting MAC address to %pM\n", dev->dev_addr);
 
/* set the Ethernet address */
for (i=0; i < ETH_ALEN/2; i++)
-- 
2.13.6



[PATCH net v3 01/12] net/macsonic: Convert to nubus_driver

2017-11-10 Thread Finn Thain
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/natsemi/macsonic.c | 170 ++--
 1 file changed, 118 insertions(+), 52 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index b3d626da0cc4..8a135abe136f 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -59,8 +59,6 @@
 #include 
 #include 
 
-static char mac_sonic_string[] = "macsonic";
-
 #include "sonic.h"
 
 /* These should basically be bus-size and endian independent (since
@@ -409,7 +407,7 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
return macsonic_init(dev);
 }
 
-static int mac_nubus_sonic_ethernet_addr(struct net_device *dev,
+static int mac_sonic_nubus_ethernet_addr(struct net_device *dev,
 unsigned long prom_addr, int id)
 {
int i;
@@ -448,68 +446,49 @@ static int macsonic_ident(struct 
nubus_functional_resource *ndev)
return -1;
 }
 
-static int mac_nubus_sonic_probe(struct net_device *dev)
+static int mac_sonic_nubus_probe_board(struct nubus_board *board, int id,
+  struct net_device *dev)
 {
-   static int slots;
-   struct nubus_functional_resource *ndev = NULL;
struct sonic_local* lp = netdev_priv(dev);
unsigned long base_addr, prom_addr;
u16 sonic_dcr;
-   int id = -1;
int reg_offset, dma_bitmode;
 
-   /* Find the first SONIC that hasn't been initialized already */
-   while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
-  NUBUS_TYPE_ETHERNET, ndev)) != NULL)
-   {
-   /* Have we seen it already? */
-   if (slots & (1slot))
-   continue;
-   slots |= 1slot;
-
-   /* Is it one of ours? */
-   if ((id = macsonic_ident(ndev)) != -1)
-   break;
-   }
-
-   if (ndev == NULL)
-   return -ENODEV;
-
switch (id) {
case MACSONIC_DUODOCK:
-   base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + DUODOCK_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DUODOCK_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
SONIC_DCR_TFT0;
reg_offset = 2;
dma_bitmode = SONIC_BITMODE32;
break;
case MACSONIC_APPLE:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE32;
break;
case MACSONIC_APPLE16:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE16;
break;
case MACSONIC_DAYNALINK:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DAYNALINK_PROM_BASE;
sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE16;
break;
case MACSONIC_DAYNA:
-   base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
+   base_addr = board->slot_addr + DAYNA_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DAYNA_SONIC_MAC_ADDR;
sonic_dcr = SONIC_DCR_BMS |
SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
reg_offset = 0;
@@ -525,14 +504,14 @@ static int mac_nubus_sonic_probe(struct net_device *dev)
dev->base_addr = base_addr;
lp->reg_offset = reg_offset;
lp->dma_bitmode = dma_bitmode;
-  

Re: [PATCH net-next] net: mvpp2: fix GOP statistics loop start and stop conditions

2017-11-10 Thread David Miller
From: Miquel Raynal 
Date: Wed,  8 Nov 2017 08:59:40 +0100

> GOP statistics from all ports of one instance of the driver are gathered
> with one work recalled in loop in a workqueue. The loop is started when
> a port is up, and stopped when a port is down. This last condition is
> obviously wrong.
> 
> Fix this by having a work per port. This way, starting and stoping it
> when the port is up or down will be fine, while minimizing unnecessary
> CPU usage.
> 
> Fixes: 118d6298f6f0 ("net: mvpp2: add ethtool GOP statistics")
> Reported-by: Stefan Chulski 
> Signed-off-by: Miquel Raynal 

Applied.


[PATCH net v3 11/12] net/macmace: Fix and clean up log messages

2017-11-10 Thread Finn Thain
Don't log unexpanded "eth%d".
Log the chip revision in the probe message (consistent with mace.c).
Drop redundant debug messages for FIFO events recorded in the
interface statistics (also consistent with mace.c).

Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/apple/macmace.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/apple/macmace.c 
b/drivers/net/ethernet/apple/macmace.c
index f17a160dbff2..47d6f1f90116 100644
--- a/drivers/net/ethernet/apple/macmace.c
+++ b/drivers/net/ethernet/apple/macmace.c
@@ -247,8 +247,8 @@ static int mace_probe(struct platform_device *pdev)
dev->netdev_ops = _netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
 
-   printk(KERN_INFO "%s: 68K MACE, hardware address %pM\n",
-  dev->name, dev->dev_addr);
+   pr_info("Onboard MACE, hardware address %pM, chip revision 0x%04X\n",
+   dev->dev_addr, mp->chipid);
 
err = register_netdev(dev);
if (!err)
@@ -589,7 +589,6 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
else if (fs & (UFLO|LCOL|RTRY)) {
++dev->stats.tx_aborted_errors;
if (mb->xmtfs & UFLO) {
-   printk(KERN_ERR "%s: DMA underrun.\n", 
dev->name);
dev->stats.tx_fifo_errors++;
mace_txdma_reset(dev);
}
@@ -644,10 +643,8 @@ static void mace_dma_rx_frame(struct net_device *dev, 
struct mace_frame *mf)
 
if (frame_status & (RS_OFLO | RS_CLSN | RS_FRAMERR | RS_FCSERR)) {
dev->stats.rx_errors++;
-   if (frame_status & RS_OFLO) {
-   printk(KERN_DEBUG "%s: fifo overflow.\n", dev->name);
+   if (frame_status & RS_OFLO)
dev->stats.rx_fifo_errors++;
-   }
if (frame_status & RS_CLSN)
dev->stats.collisions++;
if (frame_status & RS_FRAMERR)
-- 
2.13.6



[PATCH net v3 12/12] net/smc9194: Remove bogus CONFIG_MAC reference

2017-11-10 Thread Finn Thain
AFAIK the only version of smc9194.c with Mac support is the one in the
linux-mac68k CVS repo, which never made it to the mainline.

Despite that, as of v2.3.45, arch/m68k/config.in listed CONFIG_SMC9194
under CONFIG_MAC. This mistake got carried over into Kconfig in v2.5.55.
(See pre-git era "[PATCH] add m68k dependencies to net driver config".)

Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/smsc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/smsc/Kconfig 
b/drivers/net/ethernet/smsc/Kconfig
index 63aca9f847e1..4c2f612e4414 100644
--- a/drivers/net/ethernet/smsc/Kconfig
+++ b/drivers/net/ethernet/smsc/Kconfig
@@ -20,7 +20,7 @@ if NET_VENDOR_SMSC
 
 config SMC9194
tristate "SMC 9194 support"
-   depends on (ISA || MAC && BROKEN)
+   depends on ISA
select CRC32
---help---
  This is support for the SMC9xxx based Ethernet cards. Choose this
-- 
2.13.6



[PATCH net v3 09/12] net/8390: Fix redundant code

2017-11-10 Thread Finn Thain
The patch which introduced the 8390 core module parameter 'msg_enable'
failed to do anything useful with it: it merely causes an ancient
version string to be logged.

Remove the other code that logs the same string. Use the msg_enable
module parameter as the default value for ei_local->msg_enable.
Otherwise, some 8390 modules have no way to set ei_local->msg_enable.

Also fix two more issues arising from the same patch: indentation
mistakes and pointless static variables.

Cc: Russell King 
Fixes: c45f812f0280 ("8390 : Replace ei_debug with msg_enable/NETIF_MSG_* 
feature")
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
Only the mac8390.c and lib8390.c changes have been tested. The other
changes are similar but untested.
---
 drivers/net/ethernet/8390/ax88796.c   |  3 ---
 drivers/net/ethernet/8390/axnet_cs.c  |  2 --
 drivers/net/ethernet/8390/etherh.c| 17 -
 drivers/net/ethernet/8390/hydra.c |  4 
 drivers/net/ethernet/8390/lib8390.c   |  2 ++
 drivers/net/ethernet/8390/mac8390.c   |  7 ---
 drivers/net/ethernet/8390/mcf8390.c   |  4 
 drivers/net/ethernet/8390/pcnet_cs.c  |  4 
 drivers/net/ethernet/8390/zorro8390.c |  5 -
 9 files changed, 2 insertions(+), 46 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c 
b/drivers/net/ethernet/8390/ax88796.c
index 05d9d3e2e92e..28aa79d2f16c 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -77,8 +77,6 @@ static unsigned char version[] = "ax88796.c: Copyright 
2005,2007 Simtec Electron
 
 #define AX_GPOC_PPDSET BIT(6)
 
-static u32 ax_msg_enable;
-
 /* device private data */
 
 struct ax_device {
@@ -747,7 +745,6 @@ static int ax_init_dev(struct net_device *dev)
ei_local->block_output = _block_output;
ei_local->get_8390_hdr = _get_8390_hdr;
ei_local->priv = 0;
-   ei_local->msg_enable = ax_msg_enable;
 
dev->netdev_ops = _netdev_ops;
dev->ethtool_ops = _ethtool_ops;
diff --git a/drivers/net/ethernet/8390/axnet_cs.c 
b/drivers/net/ethernet/8390/axnet_cs.c
index 3da1fc539ef9..91e76dc1e6e1 100644
--- a/drivers/net/ethernet/8390/axnet_cs.c
+++ b/drivers/net/ethernet/8390/axnet_cs.c
@@ -104,7 +104,6 @@ static void AX88190_init(struct net_device *dev, int 
startp);
 static int ax_open(struct net_device *dev);
 static int ax_close(struct net_device *dev);
 static irqreturn_t ax_interrupt(int irq, void *dev_id);
-static u32 axnet_msg_enable;
 
 /**/
 
@@ -151,7 +150,6 @@ static int axnet_probe(struct pcmcia_device *link)
return -ENOMEM;
 
 ei_local = netdev_priv(dev);
-ei_local->msg_enable = axnet_msg_enable;
 spin_lock_init(_local->page_lock);
 
 info = PRIV(dev);
diff --git a/drivers/net/ethernet/8390/etherh.c 
b/drivers/net/ethernet/8390/etherh.c
index 11cbf22ad201..32e9627e3880 100644
--- a/drivers/net/ethernet/8390/etherh.c
+++ b/drivers/net/ethernet/8390/etherh.c
@@ -64,8 +64,6 @@ static char version[] =
 
 #include "lib8390.c"
 
-static u32 etherh_msg_enable;
-
 struct etherh_priv {
void __iomem*ioc_fast;
void __iomem*memc;
@@ -502,18 +500,6 @@ etherh_close(struct net_device *dev)
 }
 
 /*
- * Initialisation
- */
-
-static void __init etherh_banner(void)
-{
-   static int version_printed;
-
-   if ((etherh_msg_enable & NETIF_MSG_DRV) && (version_printed++ == 0))
-   pr_info("%s", version);
-}
-
-/*
  * Read the ethernet address string from the on board rom.
  * This is an ascii string...
  */
@@ -671,8 +657,6 @@ etherh_probe(struct expansion_card *ec, const struct 
ecard_id *id)
struct etherh_priv *eh;
int ret;
 
-   etherh_banner();
-
ret = ecard_request_resources(ec);
if (ret)
goto out;
@@ -757,7 +741,6 @@ etherh_probe(struct expansion_card *ec, const struct 
ecard_id *id)
ei_local->block_output  = etherh_block_output;
ei_local->get_8390_hdr  = etherh_get_header;
ei_local->interface_num = 0;
-   ei_local->msg_enable = etherh_msg_enable;
 
etherh_reset(dev);
__NS8390_init(dev, 0);
diff --git a/drivers/net/ethernet/8390/hydra.c 
b/drivers/net/ethernet/8390/hydra.c
index 8ae249195301..941754ea78ec 100644
--- a/drivers/net/ethernet/8390/hydra.c
+++ b/drivers/net/ethernet/8390/hydra.c
@@ -66,7 +66,6 @@ static void hydra_block_input(struct net_device *dev, int 
count,
 static void hydra_block_output(struct net_device *dev, int count,
   const unsigned char *buf, int start_page);
 static void hydra_remove_one(struct zorro_dev *z);
-static u32 hydra_msg_enable;
 
 static struct zorro_device_id hydra_zorro_tbl[] = {
 { ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET },
@@ -119,7 +118,6 @@ static int hydra_init(struct zorro_dev *z)
 int start_page, stop_page;
 int j;
 int err;
-struct 

[PATCH net v3 10/12] net/mac8390: Fix log messages

2017-11-10 Thread Finn Thain
Use dev_foo() and log the slot number instead of the unexpanded "eth%d".
Disambiguate the two identical "Card type %s is unsupported" messages.

Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/8390/mac8390.c | 36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/8390/mac8390.c 
b/drivers/net/ethernet/8390/mac8390.c
index fb62310610a8..b091f24f7914 100644
--- a/drivers/net/ethernet/8390/mac8390.c
+++ b/drivers/net/ethernet/8390/mac8390.c
@@ -308,14 +308,14 @@ static bool mac8390_rsrc_init(struct net_device *dev,
 */
 
if (nubus_get_func_dir(ndev, ) == -1) {
-   pr_err("%s: Unable to get Nubus functional directory for slot 
%X!\n",
-  dev->name, ndev->board->slot);
+   dev_err(>board->dev,
+   "Unable to get functional directory\n");
return false;
}
 
/* Get the MAC address */
if (nubus_find_rsrc(, NUBUS_RESID_MAC_ADDRESS, ) == -1) {
-   pr_info("%s: Couldn't get MAC address!\n", dev->name);
+   dev_info(>board->dev, "MAC address resource not found\n");
return false;
}
 
@@ -325,8 +325,8 @@ static bool mac8390_rsrc_init(struct net_device *dev,
nubus_rewinddir();
if (nubus_find_rsrc(, NUBUS_RESID_MINOR_BASEOS,
) == -1) {
-   pr_err("%s: Memory offset resource for slot %X not 
found!\n",
-  dev->name, ndev->board->slot);
+   dev_err(>board->dev,
+   "Memory offset resource not found\n");
return false;
}
nubus_get_rsrc_mem(, , 4);
@@ -336,8 +336,8 @@ static bool mac8390_rsrc_init(struct net_device *dev,
nubus_rewinddir();
if (nubus_find_rsrc(, NUBUS_RESID_MINOR_LENGTH,
) == -1) {
-   pr_info("%s: Memory length resource for slot %X not 
found, probing\n",
-   dev->name, ndev->board->slot);
+   dev_info(>board->dev,
+"Memory length resource not found, probing\n");
offset = mac8390_memsize(dev->mem_start);
} else {
nubus_get_rsrc_mem(, , 4);
@@ -380,8 +380,8 @@ static bool mac8390_rsrc_init(struct net_device *dev,
break;
 
default:
-   pr_err("Card type %s is unsupported, sorry\n",
-  ndev->board->name);
+   dev_err(>board->dev,
+   "No known base address for card type\n");
return false;
}
}
@@ -537,7 +537,8 @@ static int mac8390_initdev(struct net_device *dev,
case MAC8390_APPLE:
switch (mac8390_testio(dev->mem_start)) {
case ACCESS_UNKNOWN:
-   pr_err("Don't know how to access card memory!\n");
+   dev_err(>dev,
+   "Don't know how to access card memory\n");
return -ENODEV;
 
case ACCESS_16:
@@ -603,21 +604,18 @@ static int mac8390_initdev(struct net_device *dev,
break;
 
default:
-   pr_err("Card type %s is unsupported, sorry\n",
-  board->name);
+   dev_err(>dev, "Unsupported card type\n");
return -ENODEV;
}
 
__NS8390_init(dev, 0);
 
/* Good, done, now spit out some messages */
-   pr_info("%s: %s in slot %X (type %s)\n",
-   dev->name, board->name, board->slot,
-   cardname[type]);
-   pr_info("MAC %pM IRQ %d, %d KB shared memory at %#lx, %d-bit access.\n",
-   dev->dev_addr, dev->irq,
-   (unsigned int)(dev->mem_end - dev->mem_start) >> 10,
-   dev->mem_start, access_bitmode ? 32 : 16);
+   dev_info(>dev, "%s (type %s)\n", board->name, cardname[type]);
+   dev_info(>dev, "MAC %pM, IRQ %d, %d KB shared memory at %#lx, 
%d-bit access.\n",
+dev->dev_addr, dev->irq,
+(unsigned int)(dev->mem_end - dev->mem_start) >> 10,
+dev->mem_start, access_bitmode ? 32 : 16);
return 0;
 }
 
-- 
2.13.6



[PATCH net-next v2 1/6] bpf: Fix tcp_synrto_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_synrto_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_synrto_kern.c b/samples/bpf/tcp_synrto_kern.c
index 3c3fc83..232bb24 100644
--- a/samples/bpf/tcp_synrto_kern.c
+++ b/samples/bpf/tcp_synrto_kern.c
@@ -38,8 +38,10 @@ int bpf_synrto(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



Re: [PATCH net-next 0/2] net: hns3: Bug fixes & Code improvements in HNS3 driver

2017-11-10 Thread David Miller
From: Lipeng 
Date: Wed, 8 Nov 2017 15:52:21 +0800

> This patch-set introduces some bug fixes and code improvements.
> As [patch 1/2] depends on the patch {5392902 net: hns3: Consistently using
> GENMASK in hns3 driver}, which exists in net-next, not exists in net, so
> push this serise to nex-next.

Series applied.


[PATCH net-next v2 5/6] bpf: Fix tcp_iw_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_iw_kern.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/samples/bpf/tcp_iw_kern.c b/samples/bpf/tcp_iw_kern.c
index 23c5122..4ca5ecc 100644
--- a/samples/bpf/tcp_iw_kern.c
+++ b/samples/bpf/tcp_iw_kern.c
@@ -42,8 +42,10 @@ int bpf_iw(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
@@ -62,8 +64,8 @@ int bpf_iw(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
rv = bpf_setsockopt(skops, SOL_TCP, TCP_BPF_IW, ,
@@ -73,8 +75,8 @@ int bpf_iw(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of passive connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv +=  bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+ , sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next v2 0/6] bpf: Fix bugs in sock_ops samples

2017-11-10 Thread Lawrence Brakmo
The programs were returning -1 in some cases when they should
only return 0 or 1. Changes in the verifier now catch this
issue and the programs fail to load. This is now fixed.

[PATCH net-next v2 1/6] bpf: Fix tcp_synrto_kern.c sample program
[PATCH net-next v2 2/6] bpf: Fix tcp_rwnd_kern.c sample program
[PATCH net-next v2 3/6] bpf: Fix tcp_bufs_kern.c sample program
[PATCH net-next v2 4/6] bpf: Fix tcp_cong_kern.c sample program
[PATCH net-next v2 5/6] bpf: Fix tcp_iw_kern.c sample program
[PATCH net-next v2 6/6] bpf: Fix tcp_clamp_kern.c sample program

samples/bpf/tcp_bufs_kern.c   | 14 --
samples/bpf/tcp_clamp_kern.c  | 24 +---
samples/bpf/tcp_cong_kern.c   |  6 --
samples/bpf/tcp_iw_kern.c | 14 --
samples/bpf/tcp_rwnd_kern.c   |  6 --
samples/bpf/tcp_synrto_kern.c |  6 --
files changed, 41 insertions(+), 29 deletions(-)



[PATCH net-next v2 3/6] bpf: Fix tcp_bufs_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_bufs_kern.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/samples/bpf/tcp_bufs_kern.c b/samples/bpf/tcp_bufs_kern.c
index ee83bba..0566b7f 100644
--- a/samples/bpf/tcp_bufs_kern.c
+++ b/samples/bpf/tcp_bufs_kern.c
@@ -41,8 +41,10 @@ int bpf_bufs(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
@@ -61,8 +63,8 @@ int bpf_bufs(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
/* Nothing to do */
@@ -71,8 +73,8 @@ int bpf_bufs(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of passive connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next v2 6/6] bpf: Fix tcp_clamp_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_clamp_kern.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/samples/bpf/tcp_clamp_kern.c b/samples/bpf/tcp_clamp_kern.c
index d68eadd9..f4225c9 100644
--- a/samples/bpf/tcp_clamp_kern.c
+++ b/samples/bpf/tcp_clamp_kern.c
@@ -41,8 +41,10 @@ int bpf_clamp(struct bpf_sock_ops *skops)
/* For testing purposes, only execute rest of BPF program
 * if neither port numberis 55601
 */
-   if (bpf_ntohl(skops->remote_port) != 55601 && skops->local_port != 
55601)
-   return -1;
+   if (bpf_ntohl(skops->remote_port) != 55601 && skops->local_port != 
55601) {
+   skops->reply = -1;
+   return 0;
+   }
 
op = (int) skops->op;
 
@@ -66,9 +68,9 @@ int bpf_clamp(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF,
, sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_RCVBUF, ,
- sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_RCVBUF, ,
+sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
rv = bpf_setsockopt(skops, SOL_TCP,
@@ -80,12 +82,12 @@ int bpf_clamp(struct bpf_sock_ops *skops)
rv = bpf_setsockopt(skops, SOL_TCP,
TCP_BPF_SNDCWND_CLAMP,
, sizeof(clamp));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_SNDBUF, ,
- sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_RCVBUF, ,
- sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_SNDBUF, ,
+sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_RCVBUF, ,
+sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next v2 2/6] bpf: Fix tcp_rwnd_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_rwnd_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_rwnd_kern.c b/samples/bpf/tcp_rwnd_kern.c
index 3f2a228..09ff65b 100644
--- a/samples/bpf/tcp_rwnd_kern.c
+++ b/samples/bpf/tcp_rwnd_kern.c
@@ -38,8 +38,10 @@ int bpf_rwnd(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) !=
-   55601 && skops->local_port != 55601)
-   return -1;
+   55601 && skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



[PATCH net-next v2 4/6] bpf: Fix tcp_cong_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_cong_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_cong_kern.c b/samples/bpf/tcp_cong_kern.c
index dac15bc..ad0f1ba 100644
--- a/samples/bpf/tcp_cong_kern.c
+++ b/samples/bpf/tcp_cong_kern.c
@@ -39,8 +39,10 @@ int bpf_cong(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



Re: [PATCH v2 net-next] net: netlink: Update attr validation to require exact length for some types

2017-11-10 Thread David Miller
From: David Ahern 
Date: Tue,  7 Nov 2017 21:59:40 -0800

> Attributes using NLA_U* and NLA_S* (where * is 8, 16,32 and 64) are
> expected to be an exact length. Split these data types from
> nla_attr_minlen into nla_attr_len and update validate_nla to require
> the attribute to have exact length for them.
> 
> Signed-off-by: David Ahern 
> ---
> v2
> - fix check in nla_policy_len - reported by kernel test robot

Applied, thanks David.


[PATCH 12/14] nubus: Rename struct nubus_dev

2017-11-10 Thread Finn Thain
It is misleading to use "dev" to mean a functional resource. And
in adopting the Linux Driver Model, struct nubus_board will embed a
struct device. Drivers will then bind with boards, not with functional
resources.

Rename struct nubus_dev as struct nubus_functional_resource. This is
the vendor's terminology and avoids confusion.

Cc: Bartlomiej Zolnierkiewicz 
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/8390/mac8390.c |  12 ++--
 drivers/net/ethernet/natsemi/macsonic.c |   4 +-
 drivers/nubus/nubus.c   | 105 
 drivers/nubus/proc.c|  15 ++---
 drivers/video/fbdev/macfb.c |   2 +-
 include/linux/nubus.h   |  31 +-
 6 files changed, 86 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/8390/mac8390.c 
b/drivers/net/ethernet/8390/mac8390.c
index 9497f18eaba0..0367c9ada7c6 100644
--- a/drivers/net/ethernet/8390/mac8390.c
+++ b/drivers/net/ethernet/8390/mac8390.c
@@ -123,7 +123,8 @@ enum mac8390_access {
 };
 
 extern int mac8390_memtest(struct net_device *dev);
-static int mac8390_initdev(struct net_device *dev, struct nubus_dev *ndev,
+static int mac8390_initdev(struct net_device *dev,
+  struct nubus_functional_resource *ndev,
   enum mac8390_type type);
 
 static int mac8390_open(struct net_device *dev);
@@ -169,7 +170,7 @@ static void word_memcpy_tocard(unsigned long tp, const void 
*fp, int count);
 static void word_memcpy_fromcard(void *tp, unsigned long fp, int count);
 static u32 mac8390_msg_enable;
 
-static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev)
+static enum mac8390_type __init mac8390_ident(struct nubus_functional_resource 
*dev)
 {
switch (dev->dr_sw) {
case NUBUS_DRSW_3COM:
@@ -289,7 +290,8 @@ static int __init mac8390_memsize(unsigned long membase)
return i * 0x1000;
 }
 
-static bool __init mac8390_init(struct net_device *dev, struct nubus_dev *ndev,
+static bool __init mac8390_init(struct net_device *dev,
+   struct nubus_functional_resource *ndev,
enum mac8390_type cardtype)
 {
struct nubus_dir dir;
@@ -394,7 +396,7 @@ static bool __init mac8390_init(struct net_device *dev, 
struct nubus_dev *ndev,
 struct net_device * __init mac8390_probe(int unit)
 {
struct net_device *dev;
-   struct nubus_dev *ndev = NULL;
+   struct nubus_functional_resource *ndev = NULL;
int err = -ENODEV;
struct ei_device *ei_local;
 
@@ -489,7 +491,7 @@ static const struct net_device_ops mac8390_netdev_ops = {
 };
 
 static int __init mac8390_initdev(struct net_device *dev,
- struct nubus_dev *ndev,
+ struct nubus_functional_resource *ndev,
  enum mac8390_type type)
 {
static u32 fwrd4_offsets[16] = {
diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index 3ca6ae7caf55..963c96f6eca7 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -427,7 +427,7 @@ static int mac_nubus_sonic_ethernet_addr(struct net_device 
*dev,
return 0;
 }
 
-static int macsonic_ident(struct nubus_dev *ndev)
+static int macsonic_ident(struct nubus_functional_resource *ndev)
 {
if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
@@ -455,7 +455,7 @@ static int macsonic_ident(struct nubus_dev *ndev)
 static int mac_nubus_sonic_probe(struct net_device *dev)
 {
static int slots;
-   struct nubus_dev* ndev = NULL;
+   struct nubus_functional_resource *ndev = NULL;
struct sonic_local* lp = netdev_priv(dev);
unsigned long base_addr, prom_addr;
u16 sonic_dcr;
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 16cbdd45dbbc..cc9dba4b4f01 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -31,7 +31,7 @@
 
 /* Globals */
 
-struct nubus_dev *nubus_devices;
+struct nubus_functional_resource *nubus_func_rsrcs;
 struct nubus_board *nubus_boards;
 
 /* Meaning of "bytelanes":
@@ -228,12 +228,12 @@ int nubus_get_root_dir(const struct nubus_board *board,
 EXPORT_SYMBOL(nubus_get_root_dir);
 
 /* This is a slyly renamed version of the above */
-int nubus_get_func_dir(const struct nubus_dev *dev,
+int nubus_get_func_dir(const struct nubus_functional_resource *fres,
   struct nubus_dir *dir)
 {
-   dir->ptr = dir->base = dev->directory;
+   dir->ptr = dir->base = fres->directory;
dir->done = 0;
-   dir->mask = dev->board->lanes;
+   dir->mask = fres->board->lanes;
return 0;
 }
 EXPORT_SYMBOL(nubus_get_func_dir);
@@ -306,11 +306,12 @@ EXPORT_SYMBOL(nubus_rewinddir);
 
 /* Driver 

[PATCH 13/14] nubus: Add expansion_type values for various Mac models

2017-11-10 Thread Finn Thain
Add an expansion slot attribute to allow drivers to properly handle
cards like Comm Slot cards and PDS cards without declaration ROMs.

Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 arch/m68k/include/asm/macintosh.h   |   9 ++-
 arch/m68k/mac/config.c  | 110 +---
 drivers/net/ethernet/natsemi/macsonic.c |   8 +--
 3 files changed, 54 insertions(+), 73 deletions(-)

diff --git a/arch/m68k/include/asm/macintosh.h 
b/arch/m68k/include/asm/macintosh.h
index 5b81ab188aa5..10fe2954d95f 100644
--- a/arch/m68k/include/asm/macintosh.h
+++ b/arch/m68k/include/asm/macintosh.h
@@ -32,7 +32,7 @@ struct mac_model
char ide_type;
char scc_type;
char ether_type;
-   char nubus_type;
+   char expansion_type;
char floppy_type;
 };
 
@@ -72,8 +72,11 @@ struct mac_model
 #define MAC_ETHER_SONIC1
 #define MAC_ETHER_MACE 2
 
-#define MAC_NO_NUBUS   0
-#define MAC_NUBUS  1
+#define MAC_EXP_NONE   0
+#define MAC_EXP_PDS1 /* Accepts only a PDS card */
+#define MAC_EXP_NUBUS  2 /* Accepts only NuBus card(s) */
+#define MAC_EXP_PDS_NUBUS  3 /* Accepts PDS card and/or NuBus card(s) */
+#define MAC_EXP_PDS_COMM   4 /* Accepts PDS card or Comm Slot card */
 
 #define MAC_FLOPPY_IWM 0
 #define MAC_FLOPPY_SWIM_ADDR1  1
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 16cd5cea5207..d3d435248a24 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -212,7 +212,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_II,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_NUBUS,
.floppy_type= MAC_FLOPPY_IWM,
},
 
@@ -227,7 +227,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_II,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_NUBUS,
.floppy_type= MAC_FLOPPY_IWM,
}, {
.ident  = MAC_MODEL_IIX,
@@ -236,7 +236,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_II,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_NUBUS,
.floppy_type= MAC_FLOPPY_SWIM_ADDR2,
}, {
.ident  = MAC_MODEL_IICX,
@@ -245,7 +245,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_II,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_NUBUS,
.floppy_type= MAC_FLOPPY_SWIM_ADDR2,
}, {
.ident  = MAC_MODEL_SE30,
@@ -254,7 +254,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_II,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_PDS,
.floppy_type= MAC_FLOPPY_SWIM_ADDR2,
},
 
@@ -272,7 +272,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_IICI,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_NUBUS,
.floppy_type= MAC_FLOPPY_SWIM_ADDR2,
}, {
.ident  = MAC_MODEL_IIFX,
@@ -281,7 +281,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_IICI,
.scsi_type  = MAC_SCSI_IIFX,
.scc_type   = MAC_SCC_IOP,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_PDS_NUBUS,
.floppy_type= MAC_FLOPPY_SWIM_IOP,
}, {
.ident  = MAC_MODEL_IISI,
@@ -290,7 +290,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_IICI,
.scsi_type  = MAC_SCSI_OLD,
.scc_type   = MAC_SCC_II,
-   .nubus_type = MAC_NUBUS,
+   .expansion_type = MAC_EXP_PDS_NUBUS,
.floppy_type= MAC_FLOPPY_SWIM_ADDR2,
}, {
.ident  = MAC_MODEL_IIVI,
@@ -299,7 +299,7 @@ static struct mac_model mac_data_table[] = {
.via_type   = MAC_VIA_IICI,
.scsi_type  = 

Re: [PATCH] net: ipv6: sysctl to specify IPv6 ND traffic class

2017-11-10 Thread David Miller
From: Maciej Żenczykowski 
Date: Tue,  7 Nov 2017 21:52:09 -0800

> From: Maciej Żenczykowski 
> 
> Add a per-device sysctl to specify the default traffic class to use for
> kernel originated IPv6 Neighbour Discovery packets.
> 
> Currently this includes:
> 
>   - Router Solicitation (ICMPv6 type 133)
> ndisc_send_rs() -> ndisc_send_skb() -> ip6_nd_hdr()
> 
>   - Neighbour Solicitation (ICMPv6 type 135)
> ndisc_send_ns() -> ndisc_send_skb() -> ip6_nd_hdr()
> 
>   - Neighbour Advertisement (ICMPv6 type 136)
> ndisc_send_na() -> ndisc_send_skb() -> ip6_nd_hdr()
> 
>   - Redirect (ICMPv6 type 137)
> ndisc_send_redirect() -> ndisc_send_skb() -> ip6_nd_hdr()
> 
> and if the kernel ever gets around to generating RA's,
> it would presumably also include:
> 
>   - Router Advertisement (ICMPv6 type 134)
> (radvd daemon could pick up on the kernel setting and use it)
> 
> Interface drivers may examine the Traffic Class value and translate
> the DiffServ Code Point into a link-layer appropriate traffic
> prioritization scheme.  An example of mapping IETF DSCP values to
> IEEE 802.11 User Priority values can be found here:
> 
> https://tools.ietf.org/html/draft-ietf-tsvwg-ieee-802-11
> 
> The expected primary use case is to properly prioritize ND over wifi.
> 
> Testing:
 ...
> (based on original change written by Erik Kline, with minor changes)
> 
> v2: fix 'suspicious rcu_dereference_check() usage'
> by explicitly grabbing the rcu_read_lock.
> 
> Cc: Lorenzo Colitti 
> Signed-off-by: Erik Kline 
> Signed-off-by: Maciej Żenczykowski 

Applied to net-next, thanks.


Re: [PATCH net-next 2/2] net/ncsi: Don't return error on normal response

2017-11-10 Thread David Miller
From: Samuel Mendoza-Jonas 
Date: Wed,  8 Nov 2017 16:30:45 +1100

> Several response handlers return EBUSY if the data corresponding to the
> command/response pair is already set. There is no reason to return an
> error here; the channel is advertising something as enabled because we
> told it to enable it, and it's possible that the feature has been
> enabled previously.
> 
> Signed-off-by: Samuel Mendoza-Jonas 

Applied.


Re: [PATCH net-next 1/2] net/ncsi: Improve general state logging

2017-11-10 Thread David Miller
From: Samuel Mendoza-Jonas 
Date: Wed,  8 Nov 2017 16:30:44 +1100

> The NCSI driver is mostly silent which becomes a headache when trying to
> determine what has occurred on the NCSI connection. This adds additional
> logging in a few key areas such as state transitions and calling out
> certain errors more visibly.
> 
> Signed-off-by: Samuel Mendoza-Jonas 

Applied.


WireGuard Upstreaming Roadmap (November 2017)

2017-11-10 Thread Jason A. Donenfeld
Hi folks,

This relates to WireGuard [0].

Following a very nice conference with the Linux kernel networking subsystem
community [1,2], I thought it might be a good idea to spell out the roadmap
for the coming months and the trajectory into upstream, based on my
discussions with several developers and maintainers. There are several threads
of this, the biggest of which surrounds the kernel code base, but there are
some other ends of the WireGuard project as a whole that are also relevant.

The current biggest blocker is issues with the crypto API. Before WireGuard
can go upstream, I intend to embark on a multi-pronged effort to overhaul the
crypto API. I very much need to sync up with Herbert regarding my plans for
this, and start spec'ing things out a bit more formally, so I can begin
concrete discussions with him. I intend to base my work both on feedback
from linux-crypto/Herbert and from the cryptographic research community. I
hope to go to RWC2018 [3] and the subsequent HACS workshop for the academic
engagement side, but of course like all the work I do on the kernel, things
will be highly based in engineering, rather than purely academic, practices.

Dave has strongly encouraged me to post patches sooner rather than later.
So I think before the crypto API is ready to go, I'll likely post a [RFG] --
request for grumbles -- patch set to netdev, in order to have some code
review, so as to gauge where we're at. This patch set will use my current
crypto API, not the kernel's crypto API, with it mentioned in the opening that
I intend to switch to the kernel's crypto API when it looks like the one used
here. This way we'll get early feedback so that the later real [PATCH] series
will go more smoothly.

There are a few WireGuard features that some of you have been waiting for. At
the urging of some folks at the conference, I intend to submit a "core"
WireGuard to upstream, and then use future releases to build on top of that,
to make the initial upstreaming process go as easily as possible. Therefore,
there are three big TODO items that may _or_ may not go in after upstreaming:

 - In-band control messages [possibly not]
 - Netlink multicast event notification
 - GRO integration

Of these, it's most likely I'll implement GRO and leave the other two until
after, but this may change. Since WireGuard already does GSO, it would make
sense to implement the other side of things too. There's also a longer more
ambitious roadmap [4], filled with both easy coding-related things and longer
term design things, but that's out of scope for this email, though many of
which will likely be completed before submission time.

There are also six other threads of development that are ongoing, which I
intend to put a bit more focus on too in the near future:

  - The userspace implementation. I'd like to bring this up to deployment
quality, which naturally fits into the next area.

  - Mobile apps. It's fairly easy to integrate the userspace implementation
with existing APIs. The current Android app already works well with the
kernel module, but of course people want this more easily deployed.

  - Mac and Windows support for the userspace implementation. These are
already mostly done, but the APIs used may in fact change, so there may
still be a bit of work to do here before we're satisfied.

  - Bindings and libraries. Now that we have a stable Netlink API, we can
start making nice wrappers for the various languages people like to use.
It remains to be seen whether or not a C "libwireguard" is needed, since in
that domain, talking Netlink directly is often a better choice, but I do see
some potential for a pywireguard and the like. This will also be essential
when the already mentioned plans for event notification and the possibly
excluded control messages materialize.

  - More formal verification. While we have the cryptographic protocol
verified, there are still more places where formalism is quite helpful,
proving more state machines, and even proving C implementations to be
correct. Work and research is ongoing in this domain.

  - Integration into network managers and routing daemons (mesh and
traditional). Work has already begun here on systemd-networkd, and others
are looking into daemons like babel and bird.

So that's where we're at. I hope to have a RFG submitted in the next several
months, and hopefully we gather some nice momentum and get the work
upstreamed and the project completed soon, for some definition of "complete".

If you'd like to work on WireGuard, or simply have any questions, don't
hesitate to email me.

Regards,
Jason


[0] https://www.wireguard.com/
[1] https://www.netdevconf.org/2.2/
[2] https://www.wireguard.com/presentations/
[3] https://rwc.iacr.org
[4] https://www.wireguard.com/todo/


Re: [PATCH net-next] bpf: expose sk_priority through struct bpf_sock_ops

2017-11-10 Thread Alexei Starovoitov

On 11/11/17 6:07 AM, Daniel Borkmann wrote:

On 11/10/2017 08:17 PM, Vlad Dumitrescu wrote:

From: Vlad Dumitrescu 

Allows BPF_PROG_TYPE_SOCK_OPS programs to read sk_priority.

Signed-off-by: Vlad Dumitrescu 
---
  include/uapi/linux/bpf.h   |  1 +
  net/core/filter.c  | 11 +++
  tools/include/uapi/linux/bpf.h |  1 +
  3 files changed, 13 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index e880ae6434ee..9757a2002513 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -947,6 +947,7 @@ struct bpf_sock_ops {
  __u32 local_ip6[4];/* Stored in network byte order */
  __u32 remote_port;/* Stored in network byte order */
  __u32 local_port;/* stored in host byte order */
+__u32 priority;
  };
/* List of known BPF sock_ops operators.
diff --git a/net/core/filter.c b/net/core/filter.c
index 61c791f9f628..a6329642d047 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4449,6 +4449,17 @@ static u32 sock_ops_convert_ctx_access(enum
bpf_access_type type,
  *insn++ = BPF_LDX_MEM(BPF_H, si->dst_reg, si->dst_reg,
offsetof(struct sock_common, skc_num));
  break;
+
+case offsetof(struct bpf_sock_ops, priority):
+BUILD_BUG_ON(FIELD_SIZEOF(struct sock, sk_priority) != 4);
+
+*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(
+struct bpf_sock_ops_kern, sk),
+  si->dst_reg, si->src_reg,
+  offsetof(struct bpf_sock_ops_kern, sk));
+*insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->dst_reg,
+  offsetof(struct sock, sk_priority));
+break;


Hm, I don't think this would work, I actually think your initial patch
was ok.
bpf_setsockopt() as well as bpf_getsockopt() check for sk_fullsock(sk)
right
before accessing options on either socket or TCP level, and bail out
with error
otherwise; in such cases we'd read something else here and assume it's
sk_priority.


even if it's not fullsock, it will just read zero, no? what's a problem
with that?
In non-fullsock hooks like BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB
the program author will know that it's meaningless to read sk_priority,
so returning zero with minimal checks is fine.
While adding extra runtime if (sk_fullsock(sk)) is unnecessary,
since the safety is not compromised.



Re: [PATCH net-next V4 0/3] tools: bpftool: show filenames of pinned objects

2017-11-10 Thread David Miller
From: Prashant Bhole 
Date: Wed,  8 Nov 2017 13:55:46 +0900

> This patchset adds support to show pinned objects in object details.
> 
> Patch1 adds a funtionality to open a path in bpf-fs regardless of its object
> type.
> 
> Patch2 adds actual functionality by scanning the bpf-fs once and adding
> object information in hash table, with object id as a key. One object may be
> associated with multiple paths because an object can be pinned multiple times
> 
> Patch3 adds command line option to enable this functionality. Making it 
> optional
> because scanning bpf-fs can be costly.

Series applied, thanks!


Re: [PATCH] tcp: Export to userspace the TCP state names for the trace events

2017-11-10 Thread Steven Rostedt
On Sat, 11 Nov 2017 02:06:00 +
Yafang Shao  wrote:

> 2017-11-10 15:07 GMT+00:00 Steven Rostedt :
> > On Fri, 10 Nov 2017 12:56:06 +0800
> > Yafang Shao  wrote:
> >  
> >> Could the macro tcp_state_name() be renamed ?
> >> If  is included in include/net/tcp.h, it will  
> >
> > Ideally, you don't want to include trace/events/*.h headers in other
> > headers, as they can have side effects if those headers are included in
> > other trace/events/*.h headers.
> >  
> 
> Actually I find trace/events/*.h is included in lots of other headers,
> for example,
> 
> net/rxrpc/ar-internal.h

This is an internal header, so it's not that likely to be used where it
shouldn't be.

> include/linux/bpf_trace.h
> fs/f2fs/trace.h

The above two are actually headers specifically used to pull in the
trace/events/*.h headers.

> fs/afs/internal.h

another internal header. Unlikely to be misused.

> arch/x86/include/asm/mmu_context.h

This one, hmm, probably should be fixed.

> ...
> 
> Are these files doing properly ?

Most yes, some probably not.

> Should we fix them ?

Probably, but if they are used incorrectly, it would usually fail on
build (The same global functions and variables would be defined).

> 
> But per my understanding, it is ok to include  trace/events/*.h in
> other headers because we defined TRACE_SYSTEM as well, as a
> consequence those headers should not included in trace/events/*.h. If
> that happens, it may means that one of the these two TRACE_SYSTEM is
> not defined properly. Maybe these two TRACE_SYSTEM should be merged to
> one TRACE_SYSTEM.

Two different files may have the same TRACE_SYSTEM defined. That's not
an issue.

The issue is, if you have a trace/events/*.h header in a popular file
(like it use to be in include/linux/slab.h), then it can cause issues
if another trace/events/*.h header includes it. That's because each
trace/events/*.h header must be included with CREATE_TRACE_POINTS only
once.

> 
> 
> >> cause compile error, because there's another function tcp_state_name()
> >> defined in net/netfilter/ipvs/ip_vs_proto_tcp.c.
> >> static const char * tcp_state_name(int state)
> >> {
> >>
> >> if (state >= IP_VS_TCP_S_LAST)
> >>
> >> return "ERR!";
> >>
> >> return tcp_state_name_table[state] ? tcp_state_name_table[state] : 
> >> "?";
> >>
> >> }  
> >
> > But that said, I didn't make up the trace_state_name(), it was already
> > there in net-next before this patch.
> >  
> 
> I know that is not your fault.

:-)

> But as you are modifying this file, it is better to modify it in your
> patch as well.
> So we need not submit another new patch to fix it.

I could whip up a patch 2.

> 
> > But yeah, in actuality, I would have just done:
> >
> > #define EM(a)   { a, #a },
> > #define EMe(a)  { a, #a }
> >
> > directly. Which we can still do.
> >
> > -- Steve
> >  
> 
> The suggestion from Song is good to fix it.

Song's suggestion seems like it can simple be a patch added on top of
mine. As it is somewhat agnostic to the fix I'm making. That is, it's a
different problem, and thus should be a different patch.

-- Steve


Re: [PATCH 1/1] bnx2x: fix slowpath null crash

2017-11-10 Thread David Miller
From: Zhu Yanjun 
Date: Tue,  7 Nov 2017 21:56:21 -0500

> + /*When ret value shows failure of allocation failure,
> +  *the nic is rebooted again. If open still fails, a error
> +  *message to notify the user.
> +  */

Please fix the style of this comment, it should be:

/* Text
 * here.
 */

So there needs to be a leading space.

Thank you.


Re: [PATCH 0/2][v5] Add the ability to do BPF directed error injection

2017-11-10 Thread David Miller
From: Josef Bacik 
Date: Tue,  7 Nov 2017 15:28:41 -0500

> I'm sending this through Dave since it'll conflict with other BPF changes in 
> his
> tree, but since it touches tracing as well Dave would like a review from
> somebody on the tracing side.
 ...
> A lot of our error paths are not well tested because we have no good way of
> injecting errors generically.  Some subystems (block, memory) have ways to
> inject errors, but they are random so it's hard to get reproduceable results.
> 
> With BPF we can add determinism to our error injection.  We can use kprobes 
> and
> other things to verify we are injecting errors at the exact case we are trying
> to test.  This patch gives us the tool to actual do the error injection part.
> It is very simple, we just set the return value of the pt_regs we're given to
> whatever we provide, and then override the PC with a dummy function that 
> simply
> returns.
> 
> Right now this only works on x86, but it would be simple enough to expand to
> other architectures.  Thanks,

Series applied, thanks Josef.


Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps

2017-11-10 Thread Jason A. Donenfeld
On Sat, Nov 11, 2017 at 11:37 AM, David Miller  wrote:
> Jason I'm already pushing my luck as-is with the pull request I made
> yesterday.
>
> I've seen your original requst to get this in, you don't have to say
> it multiple times.
>
> We can get this into the merge window and submit it for -stable, so
> please relax.

Whoops, sorry! Okay, no problem.

Jason


Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps

2017-11-10 Thread David Miller
From: "Jason A. Donenfeld" 
Date: Sat, 11 Nov 2017 11:26:12 +0900

> IIRC, 4.14 comes tomorrow-ish? If possible, it would be nice to get
> this in 4.14 before then, so it doesn't have to take time to trickle
> down through stable.

Jason I'm already pushing my luck as-is with the pull request I made
yesterday.

I've seen your original requst to get this in, you don't have to say
it multiple times.

We can get this into the merge window and submit it for -stable, so
please relax.

Thank you.


Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps

2017-11-10 Thread Jason A. Donenfeld
IIRC, 4.14 comes tomorrow-ish? If possible, it would be nice to get
this in 4.14 before then, so it doesn't have to take time to trickle
down through stable.

Jason

On Thu, Nov 9, 2017 at 1:04 PM, Jason A. Donenfeld  wrote:
> The way people generally use netlink_dump is that they fill in the skb
> as much as possible, breaking when nla_put returns an error. Then, they
> get called again and start filling out the next skb, and again, and so
> forth. The mechanism at work here is the ability for the iterative
> dumping function to detect when the skb is filled up and not fill it
> past the brim, waiting for a fresh skb for the rest of the data.
>
> However, if the attributes are small and nicely packed, it is possible
> that a dump callback function successfully fills in attributes until the
> skb is of size 4080 (libmnl's default page-sized receive buffer size).
> The dump function completes, satisfied, and then, if it happens to be
> that this is actually the last skb, and no further ones are to be sent,
> then netlink_dump will add on the NLMSG_DONE part:
>
>   nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
>
> It is very important that netlink_dump does this, of course. However, in
> this example, that call to nlmsg_put_answer will fail, because the
> previous filling by the dump function did not leave it enough room. And
> how could it possibly have done so? All of the nla_put variety of
> functions simply check to see if the skb has enough tailroom,
> independent of the context it is in.
>
> In order to keep the important assumptions of all netlink dump users, it
> is therefore important to give them an skb that has this end part of the
> tail already reserved, so that the call to nlmsg_put_answer does not
> fail. Otherwise, library authors are forced to find some bizarre sized
> receive buffer that has a large modulo relative to the common sizes of
> messages received, which is ugly and buggy.
>
> This patch thus saves the NLMSG_DONE for an additional message, for the
> case that things are dangerously close to the brim. This requires
> keeping track of the errno from ->dump() across calls.
>
> Signed-off-by: Jason A. Donenfeld 
> ---
> Can we get this into 4.14? Is there still time? It should also be queued
> up for stable.
>
> Changes v3->v4:
>  - I like long lines. The kernel does not. Wrapped at 80 now.
>
>  net/netlink/af_netlink.c | 17 +++--
>  net/netlink/af_netlink.h |  1 +
>  2 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index b93148e8e9fb..15c99dfa3d72 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -2136,7 +2136,7 @@ static int netlink_dump(struct sock *sk)
> struct sk_buff *skb = NULL;
> struct nlmsghdr *nlh;
> struct module *module;
> -   int len, err = -ENOBUFS;
> +   int err = -ENOBUFS;
> int alloc_min_size;
> int alloc_size;
>
> @@ -2183,9 +2183,11 @@ static int netlink_dump(struct sock *sk)
> skb_reserve(skb, skb_tailroom(skb) - alloc_size);
> netlink_skb_set_owner_r(skb, sk);
>
> -   len = cb->dump(skb, cb);
> +   if (nlk->dump_done_errno > 0)
> +   nlk->dump_done_errno = cb->dump(skb, cb);
>
> -   if (len > 0) {
> +   if (nlk->dump_done_errno > 0 ||
> +   skb_tailroom(skb) < 
> nlmsg_total_size(sizeof(nlk->dump_done_errno))) {
> mutex_unlock(nlk->cb_mutex);
>
> if (sk_filter(sk, skb))
> @@ -2195,13 +2197,15 @@ static int netlink_dump(struct sock *sk)
> return 0;
> }
>
> -   nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
> -   if (!nlh)
> +   nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE,
> +  sizeof(nlk->dump_done_errno), NLM_F_MULTI);
> +   if (WARN_ON(!nlh))
> goto errout_skb;
>
> nl_dump_check_consistent(cb, nlh);
>
> -   memcpy(nlmsg_data(nlh), , sizeof(len));
> +   memcpy(nlmsg_data(nlh), >dump_done_errno,
> +  sizeof(nlk->dump_done_errno));
>
> if (sk_filter(sk, skb))
> kfree_skb(skb);
> @@ -2273,6 +2277,7 @@ int __netlink_dump_start(struct sock *ssk, struct 
> sk_buff *skb,
> }
>
> nlk->cb_running = true;
> +   nlk->dump_done_errno = INT_MAX;
>
> mutex_unlock(nlk->cb_mutex);
>
> diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h
> index 028188597eaa..962de7b3c023 100644
> --- a/net/netlink/af_netlink.h
> +++ b/net/netlink/af_netlink.h
> @@ -34,6 +34,7 @@ struct netlink_sock {
> wait_queue_head_t   wait;
> boolbound;
> boolcb_running;
> +   int dump_done_errno;
> struct netlink_callback cb;
> struct mutex*cb_mutex;
> struct mutex

Hello Friend

2017-11-10 Thread Wang Jianlin

I intend to give you a portion of my wealth as a free-will financial
donation to you, Respond to partake.
Wang Jianlin
Wanda Group


[PATCH net-next 1/1] forcedeth: remove redudant assignments in xmit

2017-11-10 Thread Zhu Yanjun
In xmit process, the variables are set many times. In fact,
it is enough for these variables to be set once.
After a long time test, the throughput performance is better
than before.

CC: Srinivas Eeda 
CC: Joe Jin 
CC: Junxiao Bi 
Signed-off-by: Zhu Yanjun 
---
 drivers/net/ethernet/nvidia/forcedeth.c | 28 
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/nvidia/forcedeth.c 
b/drivers/net/ethernet/nvidia/forcedeth.c
index 63a9e1e..22912e7 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -2218,8 +2218,6 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, 
struct net_device *dev)
 
/* setup the header buffer */
do {
-   prev_tx = put_tx;
-   prev_tx_ctx = np->put_tx_ctx;
bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : 
size;
np->put_tx_ctx->dma = dma_map_single(>pci_dev->dev,
 skb->data + offset, bcnt,
@@ -2254,8 +2252,6 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, 
struct net_device *dev)
offset = 0;
 
do {
-   prev_tx = put_tx;
-   prev_tx_ctx = np->put_tx_ctx;
if (!start_tx_ctx)
start_tx_ctx = tmp_tx_ctx = np->put_tx_ctx;
 
@@ -2296,6 +2292,16 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, 
struct net_device *dev)
} while (frag_size);
}
 
+   if (unlikely(put_tx == np->first_tx.orig))
+   prev_tx = np->last_tx.orig;
+   else
+   prev_tx = put_tx - 1;
+
+   if (unlikely(np->put_tx_ctx == np->first_tx_ctx))
+   prev_tx_ctx = np->last_tx_ctx;
+   else
+   prev_tx_ctx = np->put_tx_ctx - 1;
+
/* set last fragment flag  */
prev_tx->flaglen |= cpu_to_le32(tx_flags_extra);
 
@@ -2368,8 +2374,6 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff 
*skb,
 
/* setup the header buffer */
do {
-   prev_tx = put_tx;
-   prev_tx_ctx = np->put_tx_ctx;
bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : 
size;
np->put_tx_ctx->dma = dma_map_single(>pci_dev->dev,
 skb->data + offset, bcnt,
@@ -2405,8 +2409,6 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff 
*skb,
offset = 0;
 
do {
-   prev_tx = put_tx;
-   prev_tx_ctx = np->put_tx_ctx;
bcnt = (frag_size > NV_TX2_TSO_MAX_SIZE) ? 
NV_TX2_TSO_MAX_SIZE : frag_size;
if (!start_tx_ctx)
start_tx_ctx = tmp_tx_ctx = np->put_tx_ctx;
@@ -2447,6 +2449,16 @@ static netdev_tx_t nv_start_xmit_optimized(struct 
sk_buff *skb,
} while (frag_size);
}
 
+   if (unlikely(put_tx == np->first_tx.ex))
+   prev_tx = np->last_tx.ex;
+   else
+   prev_tx = put_tx - 1;
+
+   if (unlikely(np->put_tx_ctx == np->first_tx_ctx))
+   prev_tx_ctx = np->last_tx_ctx;
+   else
+   prev_tx_ctx = np->put_tx_ctx - 1;
+
/* set last fragment flag  */
prev_tx->flaglen |= cpu_to_le32(NV_TX2_LASTPACKET);
 
-- 
2.7.4



Re: [PATCH] tcp: Export to userspace the TCP state names for the trace events

2017-11-10 Thread Yafang Shao
2017-11-10 15:07 GMT+00:00 Steven Rostedt :
> On Fri, 10 Nov 2017 12:56:06 +0800
> Yafang Shao  wrote:
>
>> Could the macro tcp_state_name() be renamed ?
>> If  is included in include/net/tcp.h, it will
>
> Ideally, you don't want to include trace/events/*.h headers in other
> headers, as they can have side effects if those headers are included in
> other trace/events/*.h headers.
>

Actually I find trace/events/*.h is included in lots of other headers,
for example,

net/rxrpc/ar-internal.h
include/linux/bpf_trace.h
fs/f2fs/trace.h
fs/afs/internal.h
arch/x86/include/asm/mmu_context.h
...

Are these files doing properly ?
Should we fix them ?

But per my understanding, it is ok to include  trace/events/*.h in
other headers because we defined TRACE_SYSTEM as well, as a
consequence those headers should not included in trace/events/*.h. If
that happens, it may means that one of the these two TRACE_SYSTEM is
not defined properly. Maybe these two TRACE_SYSTEM should be merged to
one TRACE_SYSTEM.


>> cause compile error, because there's another function tcp_state_name()
>> defined in net/netfilter/ipvs/ip_vs_proto_tcp.c.
>> static const char * tcp_state_name(int state)
>> {
>>
>> if (state >= IP_VS_TCP_S_LAST)
>>
>> return "ERR!";
>>
>> return tcp_state_name_table[state] ? tcp_state_name_table[state] : 
>> "?";
>>
>> }
>
> But that said, I didn't make up the trace_state_name(), it was already
> there in net-next before this patch.
>

I know that is not your fault.
But as you are modifying this file, it is better to modify it in your
patch as well.
So we need not submit another new patch to fix it.

> But yeah, in actuality, I would have just done:
>
> #define EM(a)   { a, #a },
> #define EMe(a)  { a, #a }
>
> directly. Which we can still do.
>
> -- Steve
>

The suggestion from Song is good to fix it.

Thanks
Yafang


Re: [net-next v5 0/4] Openvswitch meter action

2017-11-10 Thread Pravin Shelar
On Sat, Nov 11, 2017 at 1:39 AM, Andy Zhou  wrote:
> This patch series is the first attempt to add openvswitch
> meter support. We have previously experimented with adding
> metering support in nftables. However 1) It was not clear
> how to expose a named nftables object cleanly, and 2)
> the logic that implements metering is quite small, < 100 lines
> of code.
>
> With those two observations, it seems cleaner to add meter
> support in the openvswitch module directly.
>
> ---
>
> v1(RFC)->v2:  remove unused code improve locking
>   and other review comments
> v2 -> v3: rebase
> v3 -> v4: fix undefined "__udivdi3" references on 32 bit builds.
>   use div_u64() instead.
> v4 -> v5: rebase
>
Acked-by: Pravin B Shelar 


Re: ​​Assalam Alaikum

2017-11-10 Thread Eiman Yousef M A Al-muzafar


Assalam Alaikum, I am Eiman Yousef M A Al-muzafar, a Muslim woman from Qatar, I 
am contacting you regarding a relationship of trust and confidence for an 
inheritance. Please contact me on my private email for more details: 
eimanyou...@hotmail.com


[GIT] [4.15] NFC update

2017-11-10 Thread Samuel Ortiz
Hi David,

This is the NFC pull request for 4.15. We have:

- A new netlink command for explicitly deactivating NFC targets
- i2c constification for all NFC drivers
- One NFC device allocation error path fix

The following changes since commit 2798b80b385384d51a81832556ee9ad25d175f9b:

  Merge branch 'eBPF-based-device-cgroup-controller' (2017-11-05 23:26:51 +0900)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/sameo/nfc-next.git 
tags/nfc-next-4.15-1

for you to fetch changes up to 4d63adfe12dd9cb61ed8badb4d798955399048c2:

  NFC: Add NFC_CMD_DEACTIVATE_TARGET support (2017-11-10 00:03:39 +0100)


Allen Pais (1):
  NFC: Convert timers to use timer_setup()

Arvind Yadav (8):
  nfc: microread: constify i2c_device_id
  nfc: nfcmrvl: constify i2c_device_id
  nfc: nxp-nci: constify i2c_device_id
  nfc: pn533: constify i2c_device_id
  nfc: pn544: constify i2c_device_id
  nfc: s3fwrn5: constify i2c_device_id
  nfc: st-nci: constify i2c_device_id
  nfc: st21nfca: constify i2c_device_id

Colin Ian King (2):
  nfc: s3fwrn5: make array match static const
  NFC: fdp: make struct nci_ops static

Johan Hovold (1):
  NFC: fix device-allocation error return

Mark Greer (2):
  NFC: digital: Abort cmd when deactivating target
  NFC: Add NFC_CMD_DEACTIVATE_TARGET support

 drivers/nfc/fdp/fdp.c  |  2 +-
 drivers/nfc/microread/i2c.c|  2 +-
 drivers/nfc/nfcmrvl/i2c.c  |  2 +-
 drivers/nfc/nxp-nci/i2c.c  |  2 +-
 drivers/nfc/pn533/i2c.c|  2 +-
 drivers/nfc/pn544/i2c.c|  2 +-
 drivers/nfc/s3fwrn5/firmware.c |  2 +-
 drivers/nfc/s3fwrn5/i2c.c  |  2 +-
 drivers/nfc/st-nci/i2c.c   |  2 +-
 drivers/nfc/st21nfca/i2c.c |  2 +-
 include/uapi/linux/nfc.h   |  2 ++
 net/nfc/core.c | 10 --
 net/nfc/digital_core.c |  1 +
 net/nfc/hci/core.c |  7 +++
 net/nfc/hci/llc_shdlc.c| 23 +--
 net/nfc/llcp_core.c| 14 ++
 net/nfc/netlink.c  | 29 +
 17 files changed, 64 insertions(+), 42 deletions(-)


Re: [PATCH net-next 1/4] net: dsa: Pass a port to get_tag_protocol()

2017-11-10 Thread Vivien Didelot
Florian Fainelli  writes:

> A number of drivers want to check whether the configured CPU port is a
> possible configuration for enabling tagging, pass down the CPU port
> number so they verify that.
>
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


Thanks,

Vivien


Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

2017-11-10 Thread Luis R. Rodriguez
On Fri, Nov 10, 2017 at 10:08:19PM +0100, Pali Rohár wrote:
> On Friday 10 November 2017 21:26:01 Luis R. Rodriguez wrote:
> > On Fri, Nov 10, 2017 at 12:38:27AM +0100, Pali Rohár wrote:
> > > This function works pretty much like request_firmware(), but it prefer
> > > usermode helper. If usermode helper fails then it fallback to direct
> > > access. Useful for dynamic or model specific firmware data.
> > > 
> > > Signed-off-by: Pali Rohár 
> > > ---
> > >  drivers/base/firmware_class.c |   45 
> > > +++--
> > >  include/linux/firmware.h  |9 +
> > >  2 files changed, 52 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> > > index 4b57cf5..c3a9fe5 100644
> > > --- a/drivers/base/firmware_class.c
> > > +++ b/drivers/base/firmware_class.c
> > > @@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, 
> > > enum fw_status status)
> > >  #endif
> > >  #define FW_OPT_NO_WARN   (1U << 3)
> > >  #define FW_OPT_NOCACHE   (1U << 4)
> > > +#ifdef CONFIG_FW_LOADER_USER_HELPER
> > > +#define FW_OPT_PREFER_USER   (1U << 5)
> > > +#else
> > > +#define FW_OPT_PREFER_USER   0
> > > +#endif
> > 
> > I've been cleaning these up these flags [0], which I'll shortly respin based
> > on feedback, so this sort of stuff should be avoided at all costs.
> > 
> > Regardless of this even if you *leave* the flag in place and a driver 
> > required
> > this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then
> > calling fw_load_from_user_helper would just already return -ENOENT, as such 
> > it
> > would in turn fallback to direct fs loading so the #ifef'ery seems to be not
> > needed.
> > 
> > [0] https://lkml.kernel.org/r/20170914225422.31034-1-mcg...@kernel.org
> > 
> > >  struct firmware_cache {
> > >   /* firmware_buf instance will be added into the below list */
> > > @@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware 
> > > *fw)
> > >   if (ret <= 0) /* error or already assigned */
> > >   goto out;
> > >  
> > > - ret = fw_get_filesystem_firmware(device, fw->priv);
> > > + if (opt_flags & FW_OPT_PREFER_USER) {
> > > + ret = fw_load_from_user_helper(fw, name, device, opt_flags, 
> > > timeout);
> > > + if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
> > > + dev_warn(device,
> > > +  "User helper firmware load for %s failed with 
> > > error %d\n",
> > > +  name, ret);
> > > + dev_warn(device, "Falling back to direct firmware 
> > > load\n");
> > 
> > As I had noted before, the usermode helper was really not well designed,
> > as such extending further use of it is something we should shy away unless 
> > we
> > determine its completely necessary.
> > 
> > So what's wrong with this driver failing at direct access, which should be 
> > fast,
> > and relying on a uevent to then work using the current fallback mechanisms?
> > 
> > The commit log in no way documents any of the justifications for further
> > extending use of the usermode helper.
> 
> Hi! See patch 6/6. It is needed to avoid direct access and wl1251 on
> Nokia N900 needs to use userspace helper which prepares firmware data.

My point is your commit log in no way describes the shortcomings of the
current affairs for device drivers which only can access the data it
needs using the firmware fallback mechanism.

In order for a change to go in, specially if its extending use of the
fallback mechanism through sysfs now as primary citizen, the justification
should be well documented on the commit log.

For instance you may want to highlight that what I documented here:

https://www.kernel.org/doc/html/latest/driver-api/firmware/fallback-mechanisms.html

"CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback
mechanism. Most distributions enable this option today. If enabled but
CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback
mechanism is available and for the request_firmware_nowait() call."

Since most distros disable CONFIG_FW_LOADER_USER_HELPER_FALLBACK, in practice
this means the fallback mechanism is never actually triggered, and the
only way to do that in practice this for most distros is to use the
custom fallback mechanism, and the only difference there is that the
custom fallback mechanism has an infinite timeout since we have no clear
way to know what it is or when it will complete, other than when it
actually does its work.

That begs the question, why cant you just use request_firmware_nowait()
with the custom fallback mechanism?

Your commit log should explain the shortcomings of the current API.

Also note that "usermode helper" refers to kernel/umh.c, and the only
code being used from that UMH API is the usermodehelper_read_lock_wait()
on async, or usermodehelper_read_trylock() on sync. Nothing else. The
rest of the 

[PATCH net-next 3/4] net: dsa: Support prepended Broadcom tag

2017-11-10 Thread Florian Fainelli
Add a new type: DSA_TAG_PROTO_PREPEND which allows us to support for the
4-bytes Broadcom tag that we already support, but in a format where it
is pre-pended to the packet instead of located between the MAC SA and
the Ethertyper (DSA_TAG_PROTO_BRCM).

Signed-off-by: Florian Fainelli 
---
 include/net/dsa.h  |  1 +
 net/dsa/Kconfig|  3 +++
 net/dsa/Makefile   |  1 +
 net/dsa/dsa.c  |  3 +++
 net/dsa/dsa_priv.h |  1 +
 net/dsa/tag_brcm.c | 39 ---
 6 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 68e232fd4b0f..2a05738570d8 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -29,6 +29,7 @@ struct fixed_phy_status;
 enum dsa_tag_protocol {
DSA_TAG_PROTO_NONE = 0,
DSA_TAG_PROTO_BRCM,
+   DSA_TAG_PROTO_BRCM_PREPEND,
DSA_TAG_PROTO_DSA,
DSA_TAG_PROTO_EDSA,
DSA_TAG_PROTO_KSZ,
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index cc5f8f971689..2fed892094bc 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -19,6 +19,9 @@ if NET_DSA
 config NET_DSA_TAG_BRCM
bool
 
+config NET_DSA_TAG_BRCM_PREPEND
+   bool
+
 config NET_DSA_TAG_DSA
bool
 
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index e9a4a0f33e86..0e13c1f95d13 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -5,6 +5,7 @@ dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o 
switch.o
 
 # tagging formats
 dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
+dsa_core-$(CONFIG_NET_DSA_TAG_BRCM_PREPEND) += tag_brcm.o
 dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index b8f2d9f7c3ed..6a9d0f50fbee 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -44,6 +44,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
 #ifdef CONFIG_NET_DSA_TAG_BRCM
[DSA_TAG_PROTO_BRCM] = _netdev_ops,
 #endif
+#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
+   [DSA_TAG_PROTO_BRCM_PREPEND] = _prepend_netdev_ops,
+#endif
 #ifdef CONFIG_NET_DSA_TAG_DSA
[DSA_TAG_PROTO_DSA] = _netdev_ops,
 #endif
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index bb0218c1b570..a0be6b811fc3 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -191,6 +191,7 @@ void dsa_switch_unregister_notifier(struct dsa_switch *ds);
 
 /* tag_brcm.c */
 extern const struct dsa_device_ops brcm_netdev_ops;
+extern const struct dsa_device_ops brcm_prepend_netdev_ops;
 
 /* tag_dsa.c */
 extern const struct dsa_device_ops dsa_netdev_ops;
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index 771409a1e65c..e6e0b7b6025c 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -96,13 +96,6 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
return skb;
 }
 
-static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
-struct net_device *dev)
-{
-   /* Build the tag after the MAC Source Address */
-   return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
-}
-
 static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
   struct net_device *dev,
   struct packet_type *pt,
@@ -139,6 +132,15 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
return skb;
 }
 
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   /* Build the tag after the MAC Source Address */
+   return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
+}
+
+
 static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device 
*dev,
struct packet_type *pt)
 {
@@ -161,3 +163,26 @@ const struct dsa_device_ops brcm_netdev_ops = {
.xmit   = brcm_tag_xmit,
.rcv= brcm_tag_rcv,
 };
+#endif
+
+#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
+static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb,
+struct net_device *dev)
+{
+   /* tag is prepended to the packet */
+   return brcm_tag_xmit_ll(skb, dev, 0);
+}
+
+static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
+   struct net_device *dev,
+   struct packet_type *pt)
+{
+   /* tag is prepended to the packet */
+   return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN);
+}
+
+const struct dsa_device_ops brcm_prepend_netdev_ops = {
+   .xmit   = brcm_tag_xmit_prepend,
+   .rcv= brcm_tag_rcv_prepend,
+};
+#endif
-- 
2.9.3



[PATCH net-next 1/4] net: dsa: Pass a port to get_tag_protocol()

2017-11-10 Thread Florian Fainelli
A number of drivers want to check whether the configured CPU port is a
possible configuration for enabling tagging, pass down the CPU port
number so they verify that.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/b53/b53_common.c   | 32 +---
 drivers/net/dsa/bcm_sf2.c  |  3 ++-
 drivers/net/dsa/dsa_loop.c |  3 ++-
 drivers/net/dsa/lan9303-core.c |  3 ++-
 drivers/net/dsa/microchip/ksz_common.c |  3 ++-
 drivers/net/dsa/mt7530.c   |  4 ++--
 drivers/net/dsa/mv88e6060.c|  3 ++-
 drivers/net/dsa/mv88e6xxx/chip.c   |  3 ++-
 drivers/net/dsa/qca8k.c|  2 +-
 include/net/dsa.h  |  3 ++-
 net/dsa/dsa2.c |  2 +-
 net/dsa/legacy.c   |  2 +-
 12 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 44a9a03bff55..f72aeb9ed12a 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -541,7 +541,8 @@ EXPORT_SYMBOL(b53_disable_port);
 
 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
 {
-   bool tag_en = !!(ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_BRCM);
+   bool tag_en = !!(ds->ops->get_tag_protocol(ds, port) ==
+DSA_TAG_PROTO_BRCM);
struct b53_device *dev = ds->priv;
u8 hdr_ctl, val;
u16 reg;
@@ -1478,38 +1479,31 @@ void b53_br_fast_age(struct dsa_switch *ds, int port)
 }
 EXPORT_SYMBOL(b53_br_fast_age);
 
-static bool b53_can_enable_brcm_tags(struct dsa_switch *ds)
+static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port)
 {
-   unsigned int brcm_tag_mask;
-   unsigned int i;
-
/* Broadcom switches will accept enabling Broadcom tags on the
 * following ports: 5, 7 and 8, any other port is not supported
 */
-   brcm_tag_mask = BIT(B53_CPU_PORT_25) | BIT(7) | BIT(B53_CPU_PORT);
-
-   for (i = 0; i < ds->num_ports; i++) {
-   if (dsa_is_cpu_port(ds, i)) {
-   if (!(BIT(i) & brcm_tag_mask)) {
-   dev_warn(ds->dev,
-"Port %d is not Broadcom tag 
capable\n",
-i);
-   return false;
-   }
-   }
+   switch (port) {
+   case B53_CPU_PORT_25:
+   case 7:
+   case B53_CPU_PORT:
+   return true;
}
 
-   return true;
+   dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", port);
+   return false;
 }
 
-static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
+static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds,
+ int port)
 {
struct b53_device *dev = ds->priv;
 
/* Older models support a different tag format that we do not
 * support in net/dsa/tag_brcm.c yet.
 */
-   if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds))
+   if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds, port))
return DSA_TAG_PROTO_NONE;
else
return DSA_TAG_PROTO_BRCM;
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 2d6867f4008c..93faa1fed6f2 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -35,7 +35,8 @@
 #include "b53/b53_priv.h"
 #include "b53/b53_regs.h"
 
-static enum dsa_tag_protocol bcm_sf2_sw_get_tag_protocol(struct dsa_switch *ds)
+static enum dsa_tag_protocol bcm_sf2_sw_get_tag_protocol(struct dsa_switch *ds,
+int port)
 {
return DSA_TAG_PROTO_BRCM;
 }
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 3a3f4f7ba364..bb71d3d6f65b 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -64,7 +64,8 @@ struct dsa_loop_priv {
 
 static struct phy_device *phydevs[PHY_MAX_ADDR];
 
-static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds)
+static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,
+  int port)
 {
dev_dbg(ds->dev, "%s\n", __func__);
 
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 320651a57c6f..072beec5e443 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -877,7 +877,8 @@ static int lan9303_check_device(struct lan9303 *chip)
 
 /*  DSA ---*/
 
-static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds)
+static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds,
+ int port)
 {
return DSA_TAG_PROTO_LAN9303;
 }

[PATCH net-next 4/4] net: dsa: b53: Support prepended Broadcom tags

2017-11-10 Thread Florian Fainelli
On BCM58xx devices (Northstar Plus), there is an accelerator attached to
port 8 which would only work if we use prepended Broadcom tags. Resolve
that difference in our get_tag_protocol() function by setting the
appropriate tagging protocol in that case. We need to change
b53_brcm_hdr_setup() a little bit now since we can deal with two types
of Broadcom tags.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/b53/Kconfig  |  1 +
 drivers/net/dsa/b53/b53_common.c | 14 ++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/Kconfig b/drivers/net/dsa/b53/Kconfig
index b413d100c6b3..2f988216dab9 100644
--- a/drivers/net/dsa/b53/Kconfig
+++ b/drivers/net/dsa/b53/Kconfig
@@ -2,6 +2,7 @@ menuconfig B53
tristate "Broadcom BCM53xx managed switch support"
depends on NET_DSA
select NET_DSA_TAG_BRCM
+   select NET_DSA_TAG_BRCM_PREPEND
help
  This driver adds support for Broadcom managed switch chips. It 
supports
  BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index f72aeb9ed12a..f5a8dd96fd75 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -541,8 +541,8 @@ EXPORT_SYMBOL(b53_disable_port);
 
 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
 {
-   bool tag_en = !!(ds->ops->get_tag_protocol(ds, port) ==
-DSA_TAG_PROTO_BRCM);
+   bool tag_en = !(ds->ops->get_tag_protocol(ds, port) ==
+DSA_TAG_PROTO_NONE);
struct b53_device *dev = ds->priv;
u8 hdr_ctl, val;
u16 reg;
@@ -1505,8 +1505,14 @@ static enum dsa_tag_protocol b53_get_tag_protocol(struct 
dsa_switch *ds,
 */
if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds, port))
return DSA_TAG_PROTO_NONE;
-   else
-   return DSA_TAG_PROTO_BRCM;
+
+   /* Broadcom BCM58xx chips have a flow accelerator on Port 8
+* which requires us to use the prepended Broadcom tag type
+*/
+   if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT)
+   return DSA_TAG_PROTO_BRCM_PREPEND;
+
+   return DSA_TAG_PROTO_BRCM;
 }
 
 int b53_mirror_add(struct dsa_switch *ds, int port,
-- 
2.9.3



[PATCH net-next 0/4] net: dsa: b53: Support prepended Broadcom tags

2017-11-10 Thread Florian Fainelli
Hi all,

This patch series adds support for prepended 4-bytes Broadcom tags that we
already support. This type of tag will typically be used when interfaced to
a SoC like BCM58xx (NorthStar Plus) which supports a Flow Accelerator (WIP).
In that case, we need to support a slightly different tagging format.

The first patch does a bit of re-factoring and passes a port index to
the get_tag_protocol() function since at least two different drivers need
that type of information (mt7530, b53) to support tagging or not.

David, this is on top of my previous patch series:

[PATCH net-next v3 0/3] net: dsa: b53: Turn on Broadcom tags

Thank you!

Florian Fainelli (4):
  net: dsa: Pass a port to get_tag_protocol()
  net: dsa: tag_brcm: Prepare for supporting prepended tag
  net: dsa: Support prepended Broadcom tag
  net: dsa: b53: Support prepended Broadcom tags

 drivers/net/dsa/b53/Kconfig|  1 +
 drivers/net/dsa/b53/b53_common.c   | 42 ++--
 drivers/net/dsa/bcm_sf2.c  |  3 +-
 drivers/net/dsa/dsa_loop.c |  3 +-
 drivers/net/dsa/lan9303-core.c |  3 +-
 drivers/net/dsa/microchip/ksz_common.c |  3 +-
 drivers/net/dsa/mt7530.c   |  4 +-
 drivers/net/dsa/mv88e6060.c|  3 +-
 drivers/net/dsa/mv88e6xxx/chip.c   |  3 +-
 drivers/net/dsa/qca8k.c|  2 +-
 include/net/dsa.h  |  4 +-
 net/dsa/Kconfig|  3 ++
 net/dsa/Makefile   |  1 +
 net/dsa/dsa.c  |  3 ++
 net/dsa/dsa2.c |  2 +-
 net/dsa/dsa_priv.h |  1 +
 net/dsa/legacy.c   |  2 +-
 net/dsa/tag_brcm.c | 70 --
 18 files changed, 109 insertions(+), 44 deletions(-)

-- 
2.9.3



[PATCH net-next 2/4] net: dsa: tag_brcm: Prepare for supporting prepended tag

2017-11-10 Thread Florian Fainelli
In preparation for supporting the same Broadcom tag format, but instead
of inserted between the MAC SA and EtherType, prepended to the Ethernet
frame, restructure the code a little bit to make that possible and take
an offset parameter.

Signed-off-by: Florian Fainelli 
---
 net/dsa/tag_brcm.c | 45 ++---
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index 9e082bae3cb0..771409a1e65c 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -59,7 +59,9 @@
 #define BRCM_EG_TC_MASK0x7
 #define BRCM_EG_PID_MASK   0x1f
 
-static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, struct net_device 
*dev)
+static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
+   struct net_device *dev,
+   unsigned int offset)
 {
struct dsa_port *dp = dsa_slave_to_port(dev);
u16 queue = skb_get_queue_mapping(skb);
@@ -70,10 +72,10 @@ static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, 
struct net_device *dev
 
skb_push(skb, BRCM_TAG_LEN);
 
-   memmove(skb->data, skb->data + BRCM_TAG_LEN, 2 * ETH_ALEN);
+   if (offset)
+   memmove(skb->data, skb->data + BRCM_TAG_LEN, offset);
 
-   /* Build the tag after the MAC Source Address */
-   brcm_tag = skb->data + 2 * ETH_ALEN;
+   brcm_tag = skb->data + offset;
 
/* Set the ingress opcode, traffic class, tag enforcment is
 * deprecated
@@ -94,8 +96,17 @@ static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, 
struct net_device *dev
return skb;
 }
 
-static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device 
*dev,
-   struct packet_type *pt)
+static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
+struct net_device *dev)
+{
+   /* Build the tag after the MAC Source Address */
+   return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
+}
+
+static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
+  struct net_device *dev,
+  struct packet_type *pt,
+  unsigned int offset)
 {
int source_port;
u8 *brcm_tag;
@@ -103,8 +114,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, 
struct net_device *dev,
if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
return NULL;
 
-   /* skb->data points to the EtherType, the tag is right before it */
-   brcm_tag = skb->data - 2;
+   brcm_tag = skb->data - offset;
 
/* The opcode should never be different than 0b000 */
if (unlikely((brcm_tag[0] >> BRCM_OPCODE_SHIFT) & BRCM_OPCODE_MASK))
@@ -126,12 +136,25 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, 
struct net_device *dev,
/* Remove Broadcom tag and update checksum */
skb_pull_rcsum(skb, BRCM_TAG_LEN);
 
+   return skb;
+}
+
+static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device 
*dev,
+   struct packet_type *pt)
+{
+   struct sk_buff *nskb;
+
+   /* skb->data points to the EtherType, the tag is right before it */
+   nskb = brcm_tag_rcv_ll(skb, dev, pt, 2);
+   if (!nskb)
+   return nskb;
+
/* Move the Ethernet DA and SA */
-   memmove(skb->data - ETH_HLEN,
-   skb->data - ETH_HLEN - BRCM_TAG_LEN,
+   memmove(nskb->data - ETH_HLEN,
+   nskb->data - ETH_HLEN - BRCM_TAG_LEN,
2 * ETH_ALEN);
 
-   return skb;
+   return nskb;
 }
 
 const struct dsa_device_ops brcm_netdev_ops = {
-- 
2.9.3



[patch 1/1] net/sched/sch_red.c: work around gcc-4.4.4 anon union initializer issue

2017-11-10 Thread akpm
From: Andrew Morton 
Subject: net/sched/sch_red.c: work around gcc-4.4.4 anon union initializer issue

gcc-4.4.4 (at lest) has issues with initializers and anonymous unions:

net/sched/sch_red.c: In function 'red_dump_offload':
net/sched/sch_red.c:282: error: unknown field 'stats' specified in initializer
net/sched/sch_red.c:282: warning: initialization makes integer from pointer 
without a cast
net/sched/sch_red.c:283: error: unknown field 'stats' specified in initializer
net/sched/sch_red.c:283: warning: initialization makes integer from pointer 
without a cast
net/sched/sch_red.c: In function 'red_dump_stats':
net/sched/sch_red.c:352: error: unknown field 'xstats' specified in initializer
net/sched/sch_red.c:352: warning: initialization makes integer from pointer 
without a cast

Work around this.

Fixes: 602f3baf2218 ("net_sch: red: Add offload ability to RED qdisc")
Cc: Nogah Frankel 
Cc: Jiri Pirko 
Cc: Simon Horman 
Cc: David S. Miller 
Signed-off-by: Andrew Morton 
---

 net/sched/sch_red.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff -puN 
net/sched/sch_red.c~net-sched-sch_redc-work-around-gcc-444-anon-union-initializer-issue
 net/sched/sch_red.c
--- 
a/net/sched/sch_red.c~net-sched-sch_redc-work-around-gcc-444-anon-union-initializer-issue
+++ a/net/sched/sch_red.c
@@ -276,11 +276,13 @@ static int red_dump_offload(struct Qdisc
 {
struct net_device *dev = qdisc_dev(sch);
struct tc_red_qopt_offload hw_stats = {
+   .command = TC_RED_STATS,
.handle = sch->handle,
.parent = sch->parent,
-   .command = TC_RED_STATS,
-   .stats.bstats = >bstats,
-   .stats.qstats = >qstats,
+   {
+   .stats.bstats = >bstats,
+   .stats.qstats = >qstats,
+   },
};
int err;
 
@@ -346,10 +348,12 @@ static int red_dump_stats(struct Qdisc *
if (tc_can_offload(dev) &&  dev->netdev_ops->ndo_setup_tc) {
struct red_stats hw_stats = {0};
struct tc_red_qopt_offload hw_stats_request = {
+   .command = TC_RED_XSTATS,
.handle = sch->handle,
.parent = sch->parent,
-   .command = TC_RED_XSTATS,
-   .xstats = _stats,
+   {
+   .xstats = _stats,
+   },
};
if (!dev->netdev_ops->ndo_setup_tc(dev,
   TC_SETUP_QDISC_RED,
_


[PATCH iproute2] man: Clarify idleslope calculation for tc-cbs

2017-11-10 Thread Jesus Sanchez-Palencia
In order to calculate the idleSlope parameter of CBS correctly, users
must take into account the entire packet size, including the overhead
from all layers.

Add some more details to the man page to clarify that, giving one
simple example and pointing users to the correct 802.1Q section for
further clarifications if needed.

Signed-off-by: Jesus Sanchez-Palencia 
---
 man/man8/tc-cbs.8 | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/man/man8/tc-cbs.8 b/man/man8/tc-cbs.8
index 97e00c84..32e1e0d4 100644
--- a/man/man8/tc-cbs.8
+++ b/man/man8/tc-cbs.8
@@ -43,7 +43,19 @@ second) when there is at least one packet waiting for 
transmission.
 Packets are transmitted when the current value of credits is equal or
 greater than zero. When there is no packet to be transmitted the
 amount of credits is set to zero. This is the main tunable of the CBS
-algorithm.
+algorithm and represents the bandwidth that will be consumed.
+Note that when calculating idleslope, the entire packet size must be
+considered, including headers from all layers (i.e. MAC framing and any
+overhead from the physical layer), as described by IEEE 802.1Q-2014
+section 34.4.
+
+As an example, for an ethernet frame carrying 284 bytes of payload,
+and with no VLAN tags, you must add 14 bytes for the Ethernet headers,
+4 bytes for the Frame check sequence (CRC), and 20 bytes for the L1
+overhead: 12 bytes of interpacket gap, 7 bytes of preamble and 1 byte
+of start of frame delimiter. That results in 322 bytes for the total
+packet size, which is then used for calculating the idleslope.
+
 .TP
 sendslope
 Sendslope is the rate of credits that is depleted (it should be a
-- 
2.14.1



Re: [kernel-hardening] [PATCH v4] scripts: add leaking_addresses.pl

2017-11-10 Thread Frank Rowand
Hi Michael, Tobin,

On 11/08/17 04:10, Michael Ellerman wrote:
> "Tobin C. Harding"  writes:
>> Currently we are leaking addresses from the kernel to user space. This
>> script is an attempt to find some of those leakages. Script parses
>> `dmesg` output and /proc and /sys files for hex strings that look like
>> kernel addresses.
>>
>> Only works for 64 bit kernels, the reason being that kernel addresses
>> on 64 bit kernels have '' as the leading bit pattern making greping
>> possible.
> 
> That doesn't work super well on other architectures :D
> 
> I don't speak perl but presumably you can check the arch somehow and
> customise the regex?
> 
> ...
>> +# Return _all_ non false positive addresses from $line.
>> +sub extract_addresses
>> +{
>> +my ($line) = @_;
>> +my $address = '\b(0x)?[[:xdigit:]]{12}\b';
> 
> On 64-bit powerpc (ppc64/ppc64le) we'd want:
> 
> +my $address = '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b';
> 
> 
>> +# Do not parse these files (absolute path).
>> +my @skip_parse_files_abs = ('/proc/kmsg',
>> +'/proc/kcore',
>> +'/proc/fs/ext4/sdb1/mb_groups',
>> +'/proc/1/fd/3',
>> +'/sys/kernel/debug/tracing/trace_pipe',
>> +'/sys/kernel/security/apparmor/revision');
> 
> Can you add:
> 
>   /sys/firmware/devicetree
> 
> and/or /proc/device-tree (which is a symlink to the above).

/proc/device-tree is a symlink to /sys/firmware/devicetree/base

/sys/firmware contains
   fdt  -- the flattened device tree that was passed to the
   kernel on boot
   devicetree/base/ -- the data that is currently in the live device tree.
   This live device tree is represented as directories
   and files beneath base/

The information in fdt is directly available in the kernel source tree
(possible exception: the bootloader may have modified the fdt, possibly
to add/modify the boot command line, add memory size).

The information in devicetree/base/ is directly available in the kernel
source tree for _most_ architectures, with the same possible exception
for the bootloader.  ppc64 may also modify this information dynamically
after the system is booted.  When overlay support is working, overlay
device trees will also be able to modify this information dynamically
(and again, this information will be directly available in the kernel
source tree).

Not having read the code in leaking_addresses.pl, trusting that the
comments are correct, it seems that /sys/firmware should be in
@skip_walk_dirs_abs instead of putting /sys/firmware/devicetree
in @skip_parse_files_abs.


> We should also start restricting access to that because it may have
> potentially interesting physical addresses in it, but that will break
> existing tools, so it will need to be opt-in and done over time.
> 
> cheers
> 



[PATCH] net: Remove unused skb_shared_info member

2017-11-10 Thread Mat Martineau
ip6_frag_id was only used by UFO, which has been removed.
ipv6_proxy_select_ident() only existed to set ip6_frag_id and has no
in-tree callers.

Signed-off-by: Mat Martineau 
---
 include/linux/skbuff.h |  1 -
 include/net/ipv6.h |  1 -
 net/ipv6/output_core.c | 31 ---
 3 files changed, 33 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 57d712671081..54fe91183a8e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -500,7 +500,6 @@ struct skb_shared_info {
struct skb_shared_hwtstamps hwtstamps;
unsigned intgso_type;
u32 tskey;
-   __be32  ip6_frag_id;
 
/*
 * Warning : all fields before dataref are cleared in __alloc_skb()
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index fb6d67012de6..ec14f0d5a3a1 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -767,7 +767,6 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, 
const struct in6_add
 __be32 ipv6_select_ident(struct net *net,
 const struct in6_addr *daddr,
 const struct in6_addr *saddr);
-void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb);
 
 int ip6_dst_hoplimit(struct dst_entry *dst);
 
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index a338bbc33cf3..4a7e5ffa5108 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -31,37 +31,6 @@ static u32 __ipv6_select_ident(struct net *net, u32 hashrnd,
return id;
 }
 
-/* This function exists only for tap drivers that must support broken
- * clients requesting UFO without specifying an IPv6 fragment ID.
- *
- * This is similar to ipv6_select_ident() but we use an independent hash
- * seed to limit information leakage.
- *
- * The network header must be set before calling this.
- */
-void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)
-{
-   static u32 ip6_proxy_idents_hashrnd __read_mostly;
-   struct in6_addr buf[2];
-   struct in6_addr *addrs;
-   u32 id;
-
-   addrs = skb_header_pointer(skb,
-  skb_network_offset(skb) +
-  offsetof(struct ipv6hdr, saddr),
-  sizeof(buf), buf);
-   if (!addrs)
-   return;
-
-   net_get_random_once(_proxy_idents_hashrnd,
-   sizeof(ip6_proxy_idents_hashrnd));
-
-   id = __ipv6_select_ident(net, ip6_proxy_idents_hashrnd,
-[1], [0]);
-   skb_shinfo(skb)->ip6_frag_id = htonl(id);
-}
-EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
-
 __be32 ipv6_select_ident(struct net *net,
 const struct in6_addr *daddr,
 const struct in6_addr *saddr)
-- 
2.15.0



Re: [run_timer_softirq] BUG: unable to handle kernel paging request at 0000000000010007

2017-11-10 Thread Thomas Gleixner
On Fri, 10 Nov 2017, Linus Torvalds wrote:

> On Wed, Nov 8, 2017 at 9:19 PM, Fengguang Wu  wrote:
> >
> > Yes it's accessing the list. Here is the faddr2line output.
> 
> Ok, so it's a corrupted timer list. Which is not a big surprise.
> 
> It's
> 
> next->pprev = pprev;
> 
> in __hlist_del(), and the trapping instruction decodes as
> 
> mov%rdx,0x8(%rax)
> 
> with %rax having the value dead0200,
> 
> Which is just LIST_POISON2.
> 
> So we've deleted that entry twice - LIST_POISON2 is what hlist_del()
> sets pprev to after already deleting it once.
> 
> Although in this case it might not be hlist_del(), because
> detach_timer() also sets entry->next to LIST_POISON2.
> 
> Which is pretty bogus, we are supposed to use LIST_POISON1 for the
> "next" pointer. Oh well. Nobody cares, except for the list entry
> debugging code, which isn't run on the hlist cases.
> 
> Adding Thomas Gleixner to the cc. It should not be possible to delete
> the same timer twice.

Right, it shouldn't.

Fengguang, can you please enable:

CONFIG_DEBUG_OBJECTS
CONFIG_DEBUG_OBJECTS_TIMERS

and try to reproduce? Debugobject should catch that hopefully.

Thanks,

tglx


Re: [PATCH 1/8] dt-bindings: can: rcar_can: document r8a774[35] can support

2017-11-10 Thread Rob Herring
On Tue, Nov 07, 2017 at 03:10:42PM +, Fabrizio Castro wrote:
> Document "renesas,can-r8a7743" and "renesas,can-r8a7745" compatible
> strings. Since the fallback compatible string ("renesas,rcar-gen2-can")
> activates the right code in the driver, no driver change is needed.
> 
> Signed-off-by: Fabrizio Castro 
> Reviewed-by: Biju Das 
> ---
>  Documentation/devicetree/bindings/net/can/rcar_can.txt | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Acked-by: Rob Herring 


Re: [PATCH net-next 1/6] bpf: Fix tcp_synrto_kern.c sample program

2017-11-10 Thread Daniel Borkmann

On 11/10/2017 09:42 PM, Lawrence Brakmo wrote:

The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 8550f328f45d ("bpf: Support for per connection SYN/SYN-ACK RTOs")


Hmm, for most of the series (if not all), I think Fixes tag is:
390ee7e29fc8 ("bpf: enforce return code for cgroup-bpf programs"),
which is the one that started enforcing via check_return_code()
in range [0, 1].

Btw, your subject from cover letter got somehow messed up a bit:

'[PATCH net-next 0/6] bpf: Fix bugs in sock_ops samples In-Reply-To:'


Signed-off-by: Lawrence Brakmo 
---
  samples/bpf/tcp_synrto_kern.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_synrto_kern.c b/samples/bpf/tcp_synrto_kern.c
index 3c3fc83..232bb24 100644
--- a/samples/bpf/tcp_synrto_kern.c
+++ b/samples/bpf/tcp_synrto_kern.c
@@ -38,8 +38,10 @@ int bpf_synrto(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
  
  	op = (int) skops->op;
  





Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

2017-11-10 Thread Pali Rohár
On Friday 10 November 2017 21:26:01 Luis R. Rodriguez wrote:
> On Fri, Nov 10, 2017 at 12:38:27AM +0100, Pali Rohár wrote:
> > This function works pretty much like request_firmware(), but it prefer
> > usermode helper. If usermode helper fails then it fallback to direct
> > access. Useful for dynamic or model specific firmware data.
> > 
> > Signed-off-by: Pali Rohár 
> > ---
> >  drivers/base/firmware_class.c |   45 
> > +++--
> >  include/linux/firmware.h  |9 +
> >  2 files changed, 52 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> > index 4b57cf5..c3a9fe5 100644
> > --- a/drivers/base/firmware_class.c
> > +++ b/drivers/base/firmware_class.c
> > @@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, 
> > enum fw_status status)
> >  #endif
> >  #define FW_OPT_NO_WARN (1U << 3)
> >  #define FW_OPT_NOCACHE (1U << 4)
> > +#ifdef CONFIG_FW_LOADER_USER_HELPER
> > +#define FW_OPT_PREFER_USER (1U << 5)
> > +#else
> > +#define FW_OPT_PREFER_USER 0
> > +#endif
> 
> I've been cleaning these up these flags [0], which I'll shortly respin based
> on feedback, so this sort of stuff should be avoided at all costs.
> 
> Regardless of this even if you *leave* the flag in place and a driver required
> this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then
> calling fw_load_from_user_helper would just already return -ENOENT, as such it
> would in turn fallback to direct fs loading so the #ifef'ery seems to be not
> needed.
> 
> [0] https://lkml.kernel.org/r/20170914225422.31034-1-mcg...@kernel.org
> 
> >  struct firmware_cache {
> > /* firmware_buf instance will be added into the below list */
> > @@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
> > if (ret <= 0) /* error or already assigned */
> > goto out;
> >  
> > -   ret = fw_get_filesystem_firmware(device, fw->priv);
> > +   if (opt_flags & FW_OPT_PREFER_USER) {
> > +   ret = fw_load_from_user_helper(fw, name, device, opt_flags, 
> > timeout);
> > +   if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
> > +   dev_warn(device,
> > +"User helper firmware load for %s failed with 
> > error %d\n",
> > +name, ret);
> > +   dev_warn(device, "Falling back to direct firmware 
> > load\n");
> 
> As I had noted before, the usermode helper was really not well designed,
> as such extending further use of it is something we should shy away unless we
> determine its completely necessary.
> 
> So what's wrong with this driver failing at direct access, which should be 
> fast,
> and relying on a uevent to then work using the current fallback mechanisms?
> 
> The commit log in no way documents any of the justifications for further
> extending use of the usermode helper.

Hi! See patch 6/6. It is needed to avoid direct access and wl1251 on
Nokia N900 needs to use userspace helper which prepares firmware data.

Direct access is just fallback when userspace helper is not available.
Without userspace helper on devices where wl1251 do not have own eeprom
memory, wl1251 cannot work.

I know that usermode helper is not well designed, but it is the best
option what we can do for wl1251.

-- 
Pali Rohár
pali.ro...@gmail.com


Re: [PATCH net-next] bpf: expose sk_priority through struct bpf_sock_ops

2017-11-10 Thread Daniel Borkmann

On 11/10/2017 08:17 PM, Vlad Dumitrescu wrote:

From: Vlad Dumitrescu 

Allows BPF_PROG_TYPE_SOCK_OPS programs to read sk_priority.

Signed-off-by: Vlad Dumitrescu 
---
  include/uapi/linux/bpf.h   |  1 +
  net/core/filter.c  | 11 +++
  tools/include/uapi/linux/bpf.h |  1 +
  3 files changed, 13 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index e880ae6434ee..9757a2002513 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -947,6 +947,7 @@ struct bpf_sock_ops {
__u32 local_ip6[4]; /* Stored in network byte order */
__u32 remote_port;  /* Stored in network byte order */
__u32 local_port;   /* stored in host byte order */
+   __u32 priority;
  };
  
  /* List of known BPF sock_ops operators.

diff --git a/net/core/filter.c b/net/core/filter.c
index 61c791f9f628..a6329642d047 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4449,6 +4449,17 @@ static u32 sock_ops_convert_ctx_access(enum 
bpf_access_type type,
*insn++ = BPF_LDX_MEM(BPF_H, si->dst_reg, si->dst_reg,
  offsetof(struct sock_common, skc_num));
break;
+
+   case offsetof(struct bpf_sock_ops, priority):
+   BUILD_BUG_ON(FIELD_SIZEOF(struct sock, sk_priority) != 4);
+
+   *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(
+   struct bpf_sock_ops_kern, sk),
+ si->dst_reg, si->src_reg,
+ offsetof(struct bpf_sock_ops_kern, sk));
+   *insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->dst_reg,
+ offsetof(struct sock, sk_priority));
+   break;


Hm, I don't think this would work, I actually think your initial patch was ok.
bpf_setsockopt() as well as bpf_getsockopt() check for sk_fullsock(sk) right
before accessing options on either socket or TCP level, and bail out with error
otherwise; in such cases we'd read something else here and assume it's 
sk_priority.


}
return insn - insn_buf;
  }
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e880ae6434ee..9757a2002513 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -947,6 +947,7 @@ struct bpf_sock_ops {
__u32 local_ip6[4]; /* Stored in network byte order */
__u32 remote_port;  /* Stored in network byte order */
__u32 local_port;   /* stored in host byte order */
+   __u32 priority;
  };
  
  /* List of known BPF sock_ops operators.






[PATCH net-next 2/3] l2tp: avoid using ->tunnel_sock for getting session's parent tunnel

2017-11-10 Thread Guillaume Nault
Sessions don't need to use l2tp_sock_to_tunnel(xxx->tunnel_sock) for
accessing their parent tunnel. They have the .tunnel field in the
l2tp_session structure for that. Furthermore, in all these cases, the
session is registered, so we're guaranteed that .tunnel isn't NULL and
that the session properly holds a reference on the tunnel.

Signed-off-by: Guillaume Nault 
---
 net/l2tp/l2tp_ppp.c | 66 ++---
 1 file changed, 12 insertions(+), 54 deletions(-)

diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 5f5c78b632d0..88b4cb1b7cde 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -295,7 +295,6 @@ static int pppol2tp_sendmsg(struct socket *sock, struct 
msghdr *m,
int error;
struct l2tp_session *session;
struct l2tp_tunnel *tunnel;
-   struct pppol2tp_session *ps;
int uhlen;
 
error = -ENOTCONN;
@@ -308,10 +307,7 @@ static int pppol2tp_sendmsg(struct socket *sock, struct 
msghdr *m,
if (session == NULL)
goto error;
 
-   ps = l2tp_session_priv(session);
-   tunnel = l2tp_sock_to_tunnel(ps->tunnel_sock);
-   if (tunnel == NULL)
-   goto error_put_sess;
+   tunnel = session->tunnel;
 
uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 
0;
 
@@ -322,7 +318,7 @@ static int pppol2tp_sendmsg(struct socket *sock, struct 
msghdr *m,
   2 + total_len, /* 2 bytes for PPP_ALLSTATIONS & 
PPP_UI */
   0, GFP_KERNEL);
if (!skb)
-   goto error_put_sess_tun;
+   goto error_put_sess;
 
/* Reserve space for headers. */
skb_reserve(skb, NET_SKB_PAD);
@@ -340,20 +336,17 @@ static int pppol2tp_sendmsg(struct socket *sock, struct 
msghdr *m,
error = memcpy_from_msg(skb_put(skb, total_len), m, total_len);
if (error < 0) {
kfree_skb(skb);
-   goto error_put_sess_tun;
+   goto error_put_sess;
}
 
local_bh_disable();
l2tp_xmit_skb(session, skb, session->hdr_len);
local_bh_enable();
 
-   sock_put(ps->tunnel_sock);
sock_put(sk);
 
return total_len;
 
-error_put_sess_tun:
-   sock_put(ps->tunnel_sock);
 error_put_sess:
sock_put(sk);
 error:
@@ -377,10 +370,8 @@ static int pppol2tp_sendmsg(struct socket *sock, struct 
msghdr *m,
 static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 {
struct sock *sk = (struct sock *) chan->private;
-   struct sock *sk_tun;
struct l2tp_session *session;
struct l2tp_tunnel *tunnel;
-   struct pppol2tp_session *ps;
int uhlen, headroom;
 
if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED))
@@ -391,13 +382,7 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct 
sk_buff *skb)
if (session == NULL)
goto abort;
 
-   ps = l2tp_session_priv(session);
-   sk_tun = ps->tunnel_sock;
-   if (sk_tun == NULL)
-   goto abort_put_sess;
-   tunnel = l2tp_sock_to_tunnel(sk_tun);
-   if (tunnel == NULL)
-   goto abort_put_sess;
+   tunnel = session->tunnel;
 
uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 
0;
headroom = NET_SKB_PAD +
@@ -406,7 +391,7 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct 
sk_buff *skb)
   session->hdr_len +   /* L2TP header */
   2;   /* 2 bytes for PPP_ALLSTATIONS & PPP_UI 
*/
if (skb_cow_head(skb, headroom))
-   goto abort_put_sess_tun;
+   goto abort_put_sess;
 
/* Setup PPP header */
__skb_push(skb, 2);
@@ -417,12 +402,10 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct 
sk_buff *skb)
l2tp_xmit_skb(session, skb, session->hdr_len);
local_bh_enable();
 
-   sock_put(sk_tun);
sock_put(sk);
+
return 1;
 
-abort_put_sess_tun:
-   sock_put(sk_tun);
 abort_put_sess:
sock_put(sk);
 abort:
@@ -919,9 +902,7 @@ static int pppol2tp_getname(struct socket *sock, struct 
sockaddr *uaddr,
goto end;
 
pls = l2tp_session_priv(session);
-   tunnel = l2tp_sock_to_tunnel(pls->tunnel_sock);
-   if (tunnel == NULL)
-   goto end_put_sess;
+   tunnel = session->tunnel;
 
inet = inet_sk(tunnel->sock);
if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) {
@@ -1001,8 +982,6 @@ static int pppol2tp_getname(struct socket *sock, struct 
sockaddr *uaddr,
*usockaddr_len = len;
error = 0;
 
-   sock_put(pls->tunnel_sock);
-end_put_sess:
sock_put(sk);
 end:
return error;
@@ -1241,7 +1220,6 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned 
int cmd,
struct sock *sk = sock->sk;
struct l2tp_session 

[PATCH net-next 0/3] l2tp: avoid aliasing tunnels socket pointer

2017-11-10 Thread Guillaume Nault
We don't need to copy the tunnel's socket pointer in the pseudo-wire
specific session structures. This uselessly complicates the code
and hampers evolution.

This series was part of an effort to protect tunnels socket pointer
with RCU. But since it provides nice cleanup, I submit it separately.

Guillaume Nault (3):
  l2tp: remove .tunnel_sock from struct l2tp_eth
  l2tp: avoid using ->tunnel_sock for getting session's parent tunnel
  l2tp: remove the .tunnel_sock field from struct pppol2tp_session

 net/l2tp/l2tp_eth.c |  2 --
 net/l2tp/l2tp_ppp.c | 76 +
 2 files changed, 12 insertions(+), 66 deletions(-)

-- 
2.11.0



[PATCH net-next 3/3] l2tp: remove the .tunnel_sock field from struct pppol2tp_session

2017-11-10 Thread Guillaume Nault
The last user of .tunnel_sock is pppol2tp_connect() which defensively
uses it to verify internal data consistency.

This check isn't necessary: l2tp_session_get() guarantees that the
returned session belongs to the tunnel passed as parameter. And
.tunnel_sock is never updated, so checking that it still points to
the parent tunnel socket is useless; that test can never fail.

Signed-off-by: Guillaume Nault 
---
 net/l2tp/l2tp_ppp.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 88b4cb1b7cde..b412fc3351dc 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -127,8 +127,6 @@ struct pppol2tp_session {
 * PPPoX socket */
struct sock *__sk;  /* Copy of .sk, for cleanup */
struct rcu_head rcu;/* For asynchronous release */
-   struct sock *tunnel_sock;   /* Pointer to the tunnel UDP
-* socket */
int flags;  /* accessed by PPPIOCGFLAGS.
 * Unused. */
 };
@@ -592,7 +590,6 @@ static void pppol2tp_session_init(struct l2tp_session 
*session)
 
ps = l2tp_session_priv(session);
mutex_init(>sk_lock);
-   ps->tunnel_sock = session->tunnel->sock;
ps->owner = current->pid;
 
/* If PMTU discovery was enabled, use the MTU that was discovered */
@@ -743,13 +740,6 @@ static int pppol2tp_connect(struct socket *sock, struct 
sockaddr *uservaddr,
error = -EEXIST;
goto end;
}
-
-   /* consistency checks */
-   if (ps->tunnel_sock != tunnel->sock) {
-   mutex_unlock(>sk_lock);
-   error = -EEXIST;
-   goto end;
-   }
} else {
/* Default MTU must allow space for UDP/L2TP/PPP headers */
cfg.mtu = 1500 - PPPOL2TP_HEADER_OVERHEAD;
-- 
2.11.0



[PATCH net-next 1/3] l2tp: remove .tunnel_sock from struct l2tp_eth

2017-11-10 Thread Guillaume Nault
This field has never been used.

Signed-off-by: Guillaume Nault 
---
 net/l2tp/l2tp_eth.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 3e2dec1fb0f5..5c366ecfa1cb 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -41,7 +41,6 @@
 
 /* via netdev_priv() */
 struct l2tp_eth {
-   struct sock *tunnel_sock;
struct l2tp_session *session;
atomic_long_t   tx_bytes;
atomic_long_t   tx_packets;
@@ -313,7 +312,6 @@ static int l2tp_eth_create(struct net *net, struct 
l2tp_tunnel *tunnel,
priv = netdev_priv(dev);
priv->session = session;
 
-   priv->tunnel_sock = tunnel->sock;
session->recv_skb = l2tp_eth_dev_recv;
session->session_close = l2tp_eth_delete;
 #if IS_ENABLED(CONFIG_L2TP_DEBUGFS)
-- 
2.11.0



[PATCH net-next 6/6] bpf: Fix tcp_clamp_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 6c4a01b27852 ("bpf: Sample bpf program to set sndcwnd clamp")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_clamp_kern.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/samples/bpf/tcp_clamp_kern.c b/samples/bpf/tcp_clamp_kern.c
index d68eadd9..f4225c9 100644
--- a/samples/bpf/tcp_clamp_kern.c
+++ b/samples/bpf/tcp_clamp_kern.c
@@ -41,8 +41,10 @@ int bpf_clamp(struct bpf_sock_ops *skops)
/* For testing purposes, only execute rest of BPF program
 * if neither port numberis 55601
 */
-   if (bpf_ntohl(skops->remote_port) != 55601 && skops->local_port != 
55601)
-   return -1;
+   if (bpf_ntohl(skops->remote_port) != 55601 && skops->local_port != 
55601) {
+   skops->reply = -1;
+   return 0;
+   }
 
op = (int) skops->op;
 
@@ -66,9 +68,9 @@ int bpf_clamp(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF,
, sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_RCVBUF, ,
- sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_RCVBUF, ,
+sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
rv = bpf_setsockopt(skops, SOL_TCP,
@@ -80,12 +82,12 @@ int bpf_clamp(struct bpf_sock_ops *skops)
rv = bpf_setsockopt(skops, SOL_TCP,
TCP_BPF_SNDCWND_CLAMP,
, sizeof(clamp));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_SNDBUF, ,
- sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET,
- SO_RCVBUF, ,
- sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_SNDBUF, ,
+sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET,
+SO_RCVBUF, ,
+sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next 3/6] bpf: Fix tcp_bufs_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: d9925368a641 ("bpf: Sample BPF program to set buffer sizes")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_bufs_kern.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/samples/bpf/tcp_bufs_kern.c b/samples/bpf/tcp_bufs_kern.c
index ee83bba..0566b7f 100644
--- a/samples/bpf/tcp_bufs_kern.c
+++ b/samples/bpf/tcp_bufs_kern.c
@@ -41,8 +41,10 @@ int bpf_bufs(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
@@ -61,8 +63,8 @@ int bpf_bufs(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
/* Nothing to do */
@@ -71,8 +73,8 @@ int bpf_bufs(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of passive connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next 4/6] bpf: Fix tcp_cong_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: bb56d4449d8b ("bpf: Sample BPF program to set congestion control")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_cong_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_cong_kern.c b/samples/bpf/tcp_cong_kern.c
index dac15bc..ad0f1ba 100644
--- a/samples/bpf/tcp_cong_kern.c
+++ b/samples/bpf/tcp_cong_kern.c
@@ -39,8 +39,10 @@ int bpf_cong(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



[PATCH net-next 5/6] bpf: Fix tcp_iw_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 7bc62e285479 ("bpf: Sample BPF program to set initial cwnd")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_iw_kern.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/samples/bpf/tcp_iw_kern.c b/samples/bpf/tcp_iw_kern.c
index 23c5122..4ca5ecc 100644
--- a/samples/bpf/tcp_iw_kern.c
+++ b/samples/bpf/tcp_iw_kern.c
@@ -42,8 +42,10 @@ int bpf_iw(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
@@ -62,8 +64,8 @@ int bpf_iw(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of active connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv += bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+, sizeof(bufsize));
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
rv = bpf_setsockopt(skops, SOL_TCP, TCP_BPF_IW, ,
@@ -73,8 +75,8 @@ int bpf_iw(struct bpf_sock_ops *skops)
/* Set sndbuf and rcvbuf of passive connections */
rv = bpf_setsockopt(skops, SOL_SOCKET, SO_SNDBUF, ,
sizeof(bufsize));
-   rv = rv*100 + bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
-, sizeof(bufsize));
+   rv +=  bpf_setsockopt(skops, SOL_SOCKET, SO_RCVBUF,
+ , sizeof(bufsize));
break;
default:
rv = -1;
-- 
2.9.5



[PATCH net-next 2/6] bpf: Fix tcp_rwnd_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: c400296bf63d ("bpf: Sample bpf program to set initial window")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_rwnd_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_rwnd_kern.c b/samples/bpf/tcp_rwnd_kern.c
index 3f2a228..09ff65b 100644
--- a/samples/bpf/tcp_rwnd_kern.c
+++ b/samples/bpf/tcp_rwnd_kern.c
@@ -38,8 +38,10 @@ int bpf_rwnd(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) !=
-   55601 && skops->local_port != 55601)
-   return -1;
+   55601 && skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



[PATCH net-next 1/6] bpf: Fix tcp_synrto_kern.c sample program

2017-11-10 Thread Lawrence Brakmo
The program was returning -1 in some cases which is not allowed
by the verifier any longer.

Fixes: 8550f328f45d ("bpf: Support for per connection SYN/SYN-ACK RTOs")
Signed-off-by: Lawrence Brakmo 
---
 samples/bpf/tcp_synrto_kern.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/samples/bpf/tcp_synrto_kern.c b/samples/bpf/tcp_synrto_kern.c
index 3c3fc83..232bb24 100644
--- a/samples/bpf/tcp_synrto_kern.c
+++ b/samples/bpf/tcp_synrto_kern.c
@@ -38,8 +38,10 @@ int bpf_synrto(struct bpf_sock_ops *skops)
 * if neither port numberis 55601
 */
if (bpf_ntohl(skops->remote_port) != 55601 &&
-   skops->local_port != 55601)
-   return -1;
+   skops->local_port != 55601) {
+   skops->reply = -1;
+   return 1;
+   }
 
op = (int) skops->op;
 
-- 
2.9.5



[PATCH net-next 0/6] bpf: Fix bugs in sock_ops samples In-Reply-To:

2017-11-10 Thread Lawrence Brakmo
The programs were returning -1 in some cases when they should
only return 0 or 1. Changes in the verifier now catch this
issue and the programs fail to load. This is now fixed.

[PATCH net-next 1/6] bpf: Fix tcp_synrto_kern.c sample program
[PATCH net-next 2/6] bpf: Fix tcp_rwnd_kern.c sample program
[PATCH net-next 3/6] bpf: Fix tcp_bufs_kern.c sample program
[PATCH net-next 4/6] bpf: Fix tcp_cong_kern.c sample program
[PATCH net-next 5/6] bpf: Fix tcp_iw_kern.c sample program
[PATCH net-next 6/6] bpf: Fix tcp_clamp_kern.c sample program

samples/bpf/tcp_bufs_kern.c   | 14 --
samples/bpf/tcp_clamp_kern.c  | 24 +---
samples/bpf/tcp_cong_kern.c   |  6 --
samples/bpf/tcp_iw_kern.c | 14 --
samples/bpf/tcp_rwnd_kern.c   |  6 --
samples/bpf/tcp_synrto_kern.c |  6 --
 files changed, 41 insertions(+), 29 deletions(-)


Re: [PATCH net-next v3 3/3] net: dsa: b53: Turn on Broadcom tags

2017-11-10 Thread Andrew Lunn
On Fri, Nov 10, 2017 at 11:33:27AM -0800, Florian Fainelli wrote:
> Enable Broadcom tags for b53 devices, except 5325 and 5365 which use a
> different Broadcom tag format not yet supported by net/dsa/tag_brcm.c.
> 
> We also make sure that we can turn on Broadcom tags on a CPU port number
> that is capable of that: 5, 7 or 8.
> 
> Signed-off-by: Florian Fainelli 

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH net-next v3 2/3] net: dsa: b53: Stop using dev->cpu_port incorrectly

2017-11-10 Thread Andrew Lunn
On Fri, Nov 10, 2017 at 11:33:26AM -0800, Florian Fainelli wrote:
> dev->cpu_port is the driver local information that should only be used
> to look up register offsets for a particular port, when they differ
> (e.g: IMP port override), but it should certainly not be used in place
> of the DSA configured CPU port.
> 
> Since the DSA switch layer calls port_vlan_{add,del}() on the CPU port
> as well, we can remove the specific setting of the CPU port within
> port_vlan_{add,del}.
> 
> Fixes: ff39c2d68679 ("net: dsa: b53: Add bridge support")
> Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
> Signed-off-by: Florian Fainelli 

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH net-next v3 1/3] net: bgmac: Pad packets to a minimum size

2017-11-10 Thread Andrew Lunn
On Fri, Nov 10, 2017 at 11:33:25AM -0800, Florian Fainelli wrote:
> In preparation for enabling Broadcom tags with b53, pad packets to a
> minimum size of 64 bytes (sans FCS) in order for the Broadcom switch to
> accept ingressing frames. Without this, we would typically be able to
> DHCP, but not resolve with ARP because packets are too small and get
> rejected by the switch.
> 
> Signed-off-by: Florian Fainelli 

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

2017-11-10 Thread Luis R. Rodriguez
On Fri, Nov 10, 2017 at 12:26 PM, Luis R. Rodriguez  wrote:
> even if you *leave* the flag in place and a driver required
> this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then
> calling fw_load_from_user_helper would just already return -ENOENT, as such it
> would in turn fallback to direct fs loading so the #ifef'ery seems to be not
> needed.

> The commit log in no way documents any of the justifications for further
> extending use of the usermode helper.

Also, any new functionality introduced should have a respective test
case in tools/testing/selftests/firmware/ and lib/test_firmware.c, as
well as extending existing documentation on
Documentation/driver-api/firmware/.

  Luis


Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

2017-11-10 Thread Luis R. Rodriguez
On Fri, Nov 10, 2017 at 12:38:27AM +0100, Pali Rohár wrote:
> This function works pretty much like request_firmware(), but it prefer
> usermode helper. If usermode helper fails then it fallback to direct
> access. Useful for dynamic or model specific firmware data.
> 
> Signed-off-by: Pali Rohár 
> ---
>  drivers/base/firmware_class.c |   45 
> +++--
>  include/linux/firmware.h  |9 +
>  2 files changed, 52 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 4b57cf5..c3a9fe5 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, enum 
> fw_status status)
>  #endif
>  #define FW_OPT_NO_WARN   (1U << 3)
>  #define FW_OPT_NOCACHE   (1U << 4)
> +#ifdef CONFIG_FW_LOADER_USER_HELPER
> +#define FW_OPT_PREFER_USER   (1U << 5)
> +#else
> +#define FW_OPT_PREFER_USER   0
> +#endif

I've been cleaning these up these flags [0], which I'll shortly respin based
on feedback, so this sort of stuff should be avoided at all costs.

Regardless of this even if you *leave* the flag in place and a driver required
this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then
calling fw_load_from_user_helper would just already return -ENOENT, as such it
would in turn fallback to direct fs loading so the #ifef'ery seems to be not
needed.

[0] https://lkml.kernel.org/r/20170914225422.31034-1-mcg...@kernel.org

>  struct firmware_cache {
>   /* firmware_buf instance will be added into the below list */
> @@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
>   if (ret <= 0) /* error or already assigned */
>   goto out;
>  
> - ret = fw_get_filesystem_firmware(device, fw->priv);
> + if (opt_flags & FW_OPT_PREFER_USER) {
> + ret = fw_load_from_user_helper(fw, name, device, opt_flags, 
> timeout);
> + if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
> + dev_warn(device,
> +  "User helper firmware load for %s failed with 
> error %d\n",
> +  name, ret);
> + dev_warn(device, "Falling back to direct firmware 
> load\n");

As I had noted before, the usermode helper was really not well designed,
as such extending further use of it is something we should shy away unless we
determine its completely necessary.

So what's wrong with this driver failing at direct access, which should be fast,
and relying on a uevent to then work using the current fallback mechanisms?

The commit log in no way documents any of the justifications for further
extending use of the usermode helper.

  Luis


Re:Partnership Request.

2017-11-10 Thread Albrecht Lutz
Good day
My name is Lutz Albrecht, an attorney, I have searched for several years to 
locate any possible relative of a late client of mine who died intestate but 
left a huge financial estate. I am contacting you because you have the same 
last name to present you as the beneficiary of the estate. If you are 
interested to find out more, please get back to me.

Thanks
Lutz


[net-next v5 4/4] openvswitch: Add meter action support

2017-11-10 Thread Andy Zhou
Implements OVS kernel meter action support.

Signed-off-by: Andy Zhou 
---
 include/uapi/linux/openvswitch.h | 3 +++
 net/openvswitch/actions.c| 6 ++
 net/openvswitch/datapath.h   | 1 +
 net/openvswitch/flow_netlink.c   | 6 ++
 4 files changed, 16 insertions(+)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index d60b9a4cf3d1..4265d7f9e1f2 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -838,6 +838,8 @@ struct ovs_action_push_eth {
  * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet.
  * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.
  * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.
+ * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the
+ * packet, or modify the packet (e.g., change the DSCP field).
  *
  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all
  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
@@ -870,6 +872,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CT_CLEAR, /* No argument. */
OVS_ACTION_ATTR_PUSH_NSH, /* Nested OVS_NSH_KEY_ATTR_*. */
OVS_ACTION_ATTR_POP_NSH,  /* No argument. */
+   OVS_ACTION_ATTR_METER,/* u32 meter ID. */
 
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
   * from userspace. */
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 9a6a6d51e421..30a5df27116e 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -1330,6 +1330,12 @@ static int do_execute_actions(struct datapath *dp, 
struct sk_buff *skb,
case OVS_ACTION_ATTR_POP_NSH:
err = pop_nsh(skb, key);
break;
+
+   case OVS_ACTION_ATTR_METER:
+   if (ovs_meter_execute(dp, skb, key, nla_get_u32(a))) {
+   consume_skb(skb);
+   return 0;
+   }
}
 
if (unlikely(err)) {
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 5d2997b42460..523d65526766 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -30,6 +30,7 @@
 #include "conntrack.h"
 #include "flow.h"
 #include "flow_table.h"
+#include "meter.h"
 #include "vport-internal_dev.h"
 
 #define DP_MAX_PORTS   USHRT_MAX
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 4201f9293af3..bb4dae198c78 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -90,6 +90,7 @@ static bool actions_may_change_flow(const struct nlattr 
*actions)
case OVS_ACTION_ATTR_SAMPLE:
case OVS_ACTION_ATTR_SET:
case OVS_ACTION_ATTR_SET_MASKED:
+   case OVS_ACTION_ATTR_METER:
default:
return true;
}
@@ -2844,6 +2845,7 @@ static int __ovs_nla_copy_actions(struct net *net, const 
struct nlattr *attr,
[OVS_ACTION_ATTR_POP_ETH] = 0,
[OVS_ACTION_ATTR_PUSH_NSH] = (u32)-1,
[OVS_ACTION_ATTR_POP_NSH] = 0,
+   [OVS_ACTION_ATTR_METER] = sizeof(u32),
};
const struct ovs_action_push_vlan *vlan;
int type = nla_type(a);
@@ -3029,6 +3031,10 @@ static int __ovs_nla_copy_actions(struct net *net, const 
struct nlattr *attr,
break;
}
 
+   case OVS_ACTION_ATTR_METER:
+   /* Non-existent meters are simply ignored.  */
+   break;
+
default:
OVS_NLERR(log, "Unknown Action type %d", type);
return -EINVAL;
-- 
1.8.3.1



[net-next v5 3/4] openvswitch: Add meter infrastructure

2017-11-10 Thread Andy Zhou
OVS kernel datapath so far does not support Openflow meter action.
This is the first stab at adding kernel datapath meter support.
This implementation supports only drop band type.

Signed-off-by: Andy Zhou 
---
 net/openvswitch/Makefile   |   1 +
 net/openvswitch/datapath.c |  14 +-
 net/openvswitch/datapath.h |   3 +
 net/openvswitch/meter.c| 604 +
 net/openvswitch/meter.h|  54 
 5 files changed, 674 insertions(+), 2 deletions(-)
 create mode 100644 net/openvswitch/meter.c
 create mode 100644 net/openvswitch/meter.h

diff --git a/net/openvswitch/Makefile b/net/openvswitch/Makefile
index 299f4476cf44..41109c326f3a 100644
--- a/net/openvswitch/Makefile
+++ b/net/openvswitch/Makefile
@@ -12,6 +12,7 @@ openvswitch-y := \
flow.o \
flow_netlink.o \
flow_table.o \
+   meter.o \
vport.o \
vport-internal_dev.o \
vport-netdev.o
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 6e098035bb8f..0dab33fb9844 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -55,6 +55,7 @@
 #include "flow.h"
 #include "flow_table.h"
 #include "flow_netlink.h"
+#include "meter.h"
 #include "vport-internal_dev.h"
 #include "vport-netdev.h"
 
@@ -174,6 +175,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu)
ovs_flow_tbl_destroy(>table);
free_percpu(dp->stats_percpu);
kfree(dp->ports);
+   ovs_meters_exit(dp);
kfree(dp);
 }
 
@@ -1572,6 +1574,10 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
genl_info *info)
for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++)
INIT_HLIST_HEAD(>ports[i]);
 
+   err = ovs_meters_init(dp);
+   if (err)
+   goto err_destroy_ports_array;
+
/* Set up our datapath device. */
parms.name = nla_data(a[OVS_DP_ATTR_NAME]);
parms.type = OVS_VPORT_TYPE_INTERNAL;
@@ -1600,7 +1606,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
genl_info *info)
ovs_dp_reset_user_features(skb, info);
}
 
-   goto err_destroy_ports_array;
+   goto err_destroy_meters;
}
 
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1615,8 +1621,10 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
genl_info *info)
ovs_notify(_datapath_genl_family, reply, info);
return 0;
 
-err_destroy_ports_array:
+err_destroy_meters:
ovs_unlock();
+   ovs_meters_exit(dp);
+err_destroy_ports_array:
kfree(dp->ports);
 err_destroy_percpu:
free_percpu(dp->stats_percpu);
@@ -2265,6 +2273,7 @@ struct genl_family dp_vport_genl_family __ro_after_init = 
{
_vport_genl_family,
_flow_genl_family,
_packet_genl_family,
+   _meter_genl_family,
 };
 
 static void dp_unregister_genl(int n_families)
@@ -2445,3 +2454,4 @@ static void dp_cleanup(void)
 MODULE_ALIAS_GENL_FAMILY(OVS_VPORT_FAMILY);
 MODULE_ALIAS_GENL_FAMILY(OVS_FLOW_FAMILY);
 MODULE_ALIAS_GENL_FAMILY(OVS_PACKET_FAMILY);
+MODULE_ALIAS_GENL_FAMILY(OVS_METER_FAMILY);
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 954c4ed465a5..5d2997b42460 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -92,6 +92,9 @@ struct datapath {
u32 user_features;
 
u32 max_headroom;
+
+   /* Switch meters. */
+   struct hlist_head *meters;
 };
 
 /**
diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
new file mode 100644
index ..2a5ba356c472
--- /dev/null
+++ b/net/openvswitch/meter.c
@@ -0,0 +1,604 @@
+/*
+ * Copyright (c) 2017 Nicira, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "datapath.h"
+#include "meter.h"
+
+#define METER_HASH_BUCKETS 1024
+
+static const struct nla_policy meter_policy[OVS_METER_ATTR_MAX + 1] = {
+   [OVS_METER_ATTR_ID] = { .type = NLA_U32, },
+   [OVS_METER_ATTR_KBPS] = { .type = NLA_FLAG },
+   [OVS_METER_ATTR_STATS] = { .len = sizeof(struct ovs_flow_stats) },
+   [OVS_METER_ATTR_BANDS] = { .type = NLA_NESTED },
+   [OVS_METER_ATTR_USED] = { .type = NLA_U64 },
+   [OVS_METER_ATTR_CLEAR] = { .type = NLA_FLAG },
+   [OVS_METER_ATTR_MAX_METERS] = { .type = NLA_U32 },
+   [OVS_METER_ATTR_MAX_BANDS] = { .type = NLA_U32 },
+};
+
+static const struct nla_policy band_policy[OVS_BAND_ATTR_MAX + 1] = {
+   [OVS_BAND_ATTR_TYPE] = { .type = NLA_U32, },
+   [OVS_BAND_ATTR_RATE] = { .type = NLA_U32, },
+   [OVS_BAND_ATTR_BURST] = { .type = NLA_U32, },
+   [OVS_BAND_ATTR_STATS] = { .len = sizeof(struct 

[net-next v5 2/4] openvswitch: export get_dp() API.

2017-11-10 Thread Andy Zhou
Later patches will invoke get_dp() outside of datapath.c. Export it.

Signed-off-by: Andy Zhou 
---
 net/openvswitch/datapath.c | 29 -
 net/openvswitch/datapath.h | 31 +++
 2 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d38ac044cee..6e098035bb8f 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -142,35 +142,6 @@ static int queue_userspace_packet(struct datapath *dp, 
struct sk_buff *,
  const struct dp_upcall_info *,
  uint32_t cutlen);
 
-/* Must be called with rcu_read_lock. */
-static struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
-{
-   struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex);
-
-   if (dev) {
-   struct vport *vport = ovs_internal_dev_get_vport(dev);
-   if (vport)
-   return vport->dp;
-   }
-
-   return NULL;
-}
-
-/* The caller must hold either ovs_mutex or rcu_read_lock to keep the
- * returned dp pointer valid.
- */
-static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
-{
-   struct datapath *dp;
-
-   WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held());
-   rcu_read_lock();
-   dp = get_dp_rcu(net, dp_ifindex);
-   rcu_read_unlock();
-
-   return dp;
-}
-
 /* Must be called with rcu_read_lock or ovs_mutex. */
 const char *ovs_dp_name(const struct datapath *dp)
 {
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 4a104ef9e12c..954c4ed465a5 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -30,6 +30,7 @@
 #include "conntrack.h"
 #include "flow.h"
 #include "flow_table.h"
+#include "vport-internal_dev.h"
 
 #define DP_MAX_PORTS   USHRT_MAX
 #define DP_VPORT_HASH_BUCKETS  1024
@@ -190,6 +191,36 @@ static inline struct vport *ovs_vport_ovsl(const struct 
datapath *dp, int port_n
return ovs_lookup_vport(dp, port_no);
 }
 
+/* Must be called with rcu_read_lock. */
+static inline struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
+{
+   struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex);
+
+   if (dev) {
+   struct vport *vport = ovs_internal_dev_get_vport(dev);
+
+   if (vport)
+   return vport->dp;
+   }
+
+   return NULL;
+}
+
+/* The caller must hold either ovs_mutex or rcu_read_lock to keep the
+ * returned dp pointer valid.
+ */
+static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
+{
+   struct datapath *dp;
+
+   WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held());
+   rcu_read_lock();
+   dp = get_dp_rcu(net, dp_ifindex);
+   rcu_read_unlock();
+
+   return dp;
+}
+
 extern struct notifier_block ovs_dp_device_notifier;
 extern struct genl_family dp_vport_genl_family;
 
-- 
1.8.3.1



[net-next v5 0/4] Openvswitch meter action

2017-11-10 Thread Andy Zhou
This patch series is the first attempt to add openvswitch
meter support. We have previously experimented with adding
metering support in nftables. However 1) It was not clear
how to expose a named nftables object cleanly, and 2)
the logic that implements metering is quite small, < 100 lines
of code.

With those two observations, it seems cleaner to add meter
support in the openvswitch module directly.

---

v1(RFC)->v2:  remove unused code improve locking
  and other review comments
v2 -> v3: rebase
v3 -> v4: fix undefined "__udivdi3" references on 32 bit builds.
  use div_u64() instead.
v4 -> v5: rebase

Andy Zhou (4):
  openvswitch: Add meter netlink definitions
  openvswitch: export get_dp() API.
  openvswitch: Add meter infrastructure
  openvswitch: Add meter action support

 include/uapi/linux/openvswitch.h |  54 
 net/openvswitch/Makefile |   1 +
 net/openvswitch/actions.c|   6 +
 net/openvswitch/datapath.c   |  43 +--
 net/openvswitch/datapath.h   |  35 +++
 net/openvswitch/flow_netlink.c   |   6 +
 net/openvswitch/meter.c  | 604 +++
 net/openvswitch/meter.h  |  54 
 8 files changed, 772 insertions(+), 31 deletions(-)
 create mode 100644 net/openvswitch/meter.c
 create mode 100644 net/openvswitch/meter.h

-- 
1.8.3.1

*** BLURB HERE ***

Andy Zhou (4):
  openvswitch: Add meter netlink definitions
  openvswitch: export get_dp() API.
  openvswitch: Add meter infrastructure
  openvswitch: Add meter action support

 include/uapi/linux/openvswitch.h |  54 
 net/openvswitch/Makefile |   1 +
 net/openvswitch/actions.c|   6 +
 net/openvswitch/datapath.c   |  43 +--
 net/openvswitch/datapath.h   |  35 +++
 net/openvswitch/flow_netlink.c   |   6 +
 net/openvswitch/meter.c  | 604 +++
 net/openvswitch/meter.h  |  54 
 8 files changed, 772 insertions(+), 31 deletions(-)
 create mode 100644 net/openvswitch/meter.c
 create mode 100644 net/openvswitch/meter.h

-- 
1.8.3.1



[net-next v5 1/4] openvswitch: Add meter netlink definitions

2017-11-10 Thread Andy Zhou
Meter has its own netlink family. Define netlink messages and attributes
for communicating with the user space programs.

Signed-off-by: Andy Zhou 
---
 include/uapi/linux/openvswitch.h | 51 
 1 file changed, 51 insertions(+)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index ec75a685f1dd..d60b9a4cf3d1 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -883,4 +883,55 @@ enum ovs_action_attr {
 
 #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
 
+/* Meters. */
+#define OVS_METER_FAMILY  "ovs_meter"
+#define OVS_METER_MCGROUP "ovs_meter"
+#define OVS_METER_VERSION 0x1
+
+enum ovs_meter_cmd {
+   OVS_METER_CMD_UNSPEC,
+   OVS_METER_CMD_FEATURES, /* Get features supported by the datapath. */
+   OVS_METER_CMD_SET,  /* Add or modify a meter. */
+   OVS_METER_CMD_DEL,  /* Delete a meter. */
+   OVS_METER_CMD_GET   /* Get meter stats. */
+};
+
+enum ovs_meter_attr {
+   OVS_METER_ATTR_UNSPEC,
+   OVS_METER_ATTR_ID,  /* u32 meter ID within datapath. */
+   OVS_METER_ATTR_KBPS,/* No argument. If set, units in kilobits
+* per second. Otherwise, units in
+* packets per second.
+*/
+   OVS_METER_ATTR_STATS,   /* struct ovs_flow_stats for the meter. */
+   OVS_METER_ATTR_BANDS,   /* Nested attributes for meter bands. */
+   OVS_METER_ATTR_USED,/* u64 msecs last used in monotonic time. */
+   OVS_METER_ATTR_CLEAR,   /* Flag to clear stats, used. */
+   OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */
+   OVS_METER_ATTR_MAX_BANDS,  /* u32 max number of bands per meter. */
+   OVS_METER_ATTR_PAD,
+   __OVS_METER_ATTR_MAX
+};
+
+#define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1)
+
+enum ovs_band_attr {
+   OVS_BAND_ATTR_UNSPEC,
+   OVS_BAND_ATTR_TYPE, /* u32 OVS_METER_BAND_TYPE_* constant. */
+   OVS_BAND_ATTR_RATE, /* u32 band rate in meter units (see above). */
+   OVS_BAND_ATTR_BURST,/* u32 burst size in meter units. */
+   OVS_BAND_ATTR_STATS,/* struct ovs_flow_stats for the band. */
+   __OVS_BAND_ATTR_MAX
+};
+
+#define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1)
+
+enum ovs_meter_band_type {
+   OVS_METER_BAND_TYPE_UNSPEC,
+   OVS_METER_BAND_TYPE_DROP,   /* Drop exceeding packets. */
+   __OVS_METER_BAND_TYPE_MAX
+};
+
+#define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1)
+
 #endif /* _LINUX_OPENVSWITCH_H */
-- 
1.8.3.1



Re: [run_timer_softirq] BUG: unable to handle kernel paging request at 0000000000010007

2017-11-10 Thread Linus Torvalds
On Wed, Nov 8, 2017 at 9:19 PM, Fengguang Wu  wrote:
>
> Yes it's accessing the list. Here is the faddr2line output.

Ok, so it's a corrupted timer list. Which is not a big surprise.

It's

next->pprev = pprev;

in __hlist_del(), and the trapping instruction decodes as

mov%rdx,0x8(%rax)

with %rax having the value dead0200,

Which is just LIST_POISON2.

So we've deleted that entry twice - LIST_POISON2 is what hlist_del()
sets pprev to after already deleting it once.

Although in this case it might not be hlist_del(), because
detach_timer() also sets entry->next to LIST_POISON2.

Which is pretty bogus, we are supposed to use LIST_POISON1 for the
"next" pointer. Oh well. Nobody cares, except for the list entry
debugging code, which isn't run on the hlist cases.

Adding Thomas Gleixner to the cc. It should not be possible to delete
the same timer twice.

  Linus


Re: [Patch net] vlan: fix a use-after-free in vlan_device_event()

2017-11-10 Thread Linus Torvalds
On Fri, Nov 10, 2017 at 3:50 AM, Fengguang Wu  wrote:
> It works, thank you for fixing this ancient bug!
>
> Tested-by: Fengguang Wu 

Thanks for all the 0day work to make people finally figure this out.

 Linus


Re: [PATCH iproute2 2/2] devlink: add batch command support

2017-11-10 Thread Leon Romanovsky
On Fri, Nov 10, 2017 at 08:10:43AM +0100, Ivan Vecera wrote:
> On 10.11.2017 07:57, Leon Romanovsky wrote:
> > On Fri, Nov 10, 2017 at 07:20:14AM +0100, Ivan Vecera wrote:
> >> The patch adds support to batch devlink commands.
> >>
> >> Cc: Jiri Pirko 
> >> Cc: Arkadi Sharshevsky 
> >> Signed-off-by: Ivan Vecera 
> >> ---
> >>  devlink/devlink.c  | 70 
> >> +++---
> >>  man/man8/devlink.8 | 16 +
> >>  2 files changed, 78 insertions(+), 8 deletions(-)
> >>
> >
> > <..>
> >
> >> diff --git a/man/man8/devlink.8 b/man/man8/devlink.8
> >> index a480766c..a975ef34 100644
> >> --- a/man/man8/devlink.8
> >> +++ b/man/man8/devlink.8
> >> @@ -12,6 +12,12 @@ devlink \- Devlink tool
> >>  .sp
> >>
> >>  .ti -8
> >> +.B devlink
> >> +.RB "[ " -force " ] "
> >> +.BI "-batch " filename
> >> +.sp
> >> +
> >> +.ti -8
> >>  .IR OBJECT " := { "
> >>  .BR dev " | " port " | " monitor " }"
> >>  .sp
> >> @@ -32,6 +38,16 @@ Print the version of the
> >>  utility and exit.
> >>
> >>  .TP
> >> +.BR "\-b", " \-batch " 
> >> +Read commands from provided file or standard input and invoke them.
> >> +First failure will cause termination of devlink.
> >
> > It is worth to document the expected format of that file.
> > And IMHO, it is better to have ability to load JSON fie which was
> > generated by -j, instead of declaring new format/knob.
> It's just a list of command-lines... like other utils (bridge,ip...)

I'm implementing similar thing in RDMAtool (part of iproute2) and choose JSON
approach, it is more user and script friendly.

Thanks

>
> I.
>





signature.asc
Description: PGP signature


[PATCH net-next v3 2/3] net: dsa: b53: Stop using dev->cpu_port incorrectly

2017-11-10 Thread Florian Fainelli
dev->cpu_port is the driver local information that should only be used
to look up register offsets for a particular port, when they differ
(e.g: IMP port override), but it should certainly not be used in place
of the DSA configured CPU port.

Since the DSA switch layer calls port_vlan_{add,del}() on the CPU port
as well, we can remove the specific setting of the CPU port within
port_vlan_{add,del}.

Fixes: ff39c2d68679 ("net: dsa: b53: Add bridge support")
Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/b53/b53_common.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index a7ca62ba27b7..17f12484ce24 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -505,7 +505,7 @@ EXPORT_SYMBOL(b53_imp_vlan_setup);
 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
 {
struct b53_device *dev = ds->priv;
-   unsigned int cpu_port = dev->cpu_port;
+   unsigned int cpu_port = ds->ports[port].cpu_dp->index;
u16 pvlan;
 
/* Clear the Rx and Tx disable bits and set to no spanning tree */
@@ -1054,7 +1054,6 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
struct b53_device *dev = ds->priv;
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
-   unsigned int cpu_port = dev->cpu_port;
struct b53_vlan *vl;
u16 vid;
 
@@ -1063,12 +1062,11 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
 
b53_get_vlan_entry(dev, vid, vl);
 
-   vl->members |= BIT(port) | BIT(cpu_port);
+   vl->members |= BIT(port);
if (untagged)
vl->untag |= BIT(port);
else
vl->untag &= ~BIT(port);
-   vl->untag &= ~BIT(cpu_port);
 
b53_set_vlan_entry(dev, vid, vl);
b53_fast_age_vlan(dev, vid);
@@ -1432,8 +1430,8 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct 
net_device *br)
b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg);
} else {
b53_get_vlan_entry(dev, pvid, vl);
-   vl->members |= BIT(port) | BIT(dev->cpu_port);
-   vl->untag |= BIT(port) | BIT(dev->cpu_port);
+   vl->members |= BIT(port) | BIT(cpu_port);
+   vl->untag |= BIT(port) | BIT(cpu_port);
b53_set_vlan_entry(dev, pvid, vl);
}
 }
-- 
2.9.3



[PATCH net-next v3 3/3] net: dsa: b53: Turn on Broadcom tags

2017-11-10 Thread Florian Fainelli
Enable Broadcom tags for b53 devices, except 5325 and 5365 which use a
different Broadcom tag format not yet supported by net/dsa/tag_brcm.c.

We also make sure that we can turn on Broadcom tags on a CPU port number
that is capable of that: 5, 7 or 8.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/b53/Kconfig  |  1 +
 drivers/net/dsa/b53/b53_common.c | 48 
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/net/dsa/b53/Kconfig b/drivers/net/dsa/b53/Kconfig
index 27f32a50df57..b413d100c6b3 100644
--- a/drivers/net/dsa/b53/Kconfig
+++ b/drivers/net/dsa/b53/Kconfig
@@ -1,6 +1,7 @@
 menuconfig B53
tristate "Broadcom BCM53xx managed switch support"
depends on NET_DSA
+   select NET_DSA_TAG_BRCM
help
  This driver adds support for Broadcom managed switch chips. It 
supports
  BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 17f12484ce24..44a9a03bff55 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -325,7 +325,6 @@ static void b53_get_vlan_entry(struct b53_device *dev, u16 
vid,
 
 static void b53_set_forwarding(struct b53_device *dev, int enable)
 {
-   struct dsa_switch *ds = dev->ds;
u8 mgmt;
 
b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, );
@@ -337,14 +336,11 @@ static void b53_set_forwarding(struct b53_device *dev, 
int enable)
 
b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt);
 
-   /* Include IMP port in dumb forwarding mode when no tagging protocol is
-* set
+   /* Include IMP port in dumb forwarding mode
 */
-   if (ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_NONE) {
-   b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, );
-   mgmt |= B53_MII_DUMB_FWDG_EN;
-   b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
-   }
+   b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, );
+   mgmt |= B53_MII_DUMB_FWDG_EN;
+   b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
 }
 
 static void b53_enable_vlan(struct b53_device *dev, bool enable)
@@ -612,6 +608,8 @@ static void b53_enable_cpu_port(struct b53_device *dev, int 
port)
PORT_CTRL_RX_MCST_EN |
PORT_CTRL_RX_UCST_EN;
b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl);
+
+   b53_brcm_hdr_setup(dev->ds, port);
 }
 
 static void b53_enable_mib(struct b53_device *dev)
@@ -1480,9 +1478,41 @@ void b53_br_fast_age(struct dsa_switch *ds, int port)
 }
 EXPORT_SYMBOL(b53_br_fast_age);
 
+static bool b53_can_enable_brcm_tags(struct dsa_switch *ds)
+{
+   unsigned int brcm_tag_mask;
+   unsigned int i;
+
+   /* Broadcom switches will accept enabling Broadcom tags on the
+* following ports: 5, 7 and 8, any other port is not supported
+*/
+   brcm_tag_mask = BIT(B53_CPU_PORT_25) | BIT(7) | BIT(B53_CPU_PORT);
+
+   for (i = 0; i < ds->num_ports; i++) {
+   if (dsa_is_cpu_port(ds, i)) {
+   if (!(BIT(i) & brcm_tag_mask)) {
+   dev_warn(ds->dev,
+"Port %d is not Broadcom tag 
capable\n",
+i);
+   return false;
+   }
+   }
+   }
+
+   return true;
+}
+
 static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
 {
-   return DSA_TAG_PROTO_NONE;
+   struct b53_device *dev = ds->priv;
+
+   /* Older models support a different tag format that we do not
+* support in net/dsa/tag_brcm.c yet.
+*/
+   if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds))
+   return DSA_TAG_PROTO_NONE;
+   else
+   return DSA_TAG_PROTO_BRCM;
 }
 
 int b53_mirror_add(struct dsa_switch *ds, int port,
-- 
2.9.3



[PATCH net-next v3 0/3] net: dsa: b53: Turn on Broadcom tags

2017-11-10 Thread Florian Fainelli
Hi all,

This was long overdue, with this patch series, the b53 driver now
turns on Broadcom tags except for 5325 and 5365 which use an older
format that we do not support yet (TBD).

First patch is necessary in order for bgmac, used on BCM5301X and Northstar
Plus to work correctly and successfully send ARP packets back to the requsester.

Second patch is actually a bug fix, but because net/master and net-next/master
diverge in that area, I am targeting net-next/master here.

Finally, the last patch enables Broadcom tags after checking that the CPU port
selected is either, 5, 7 or 8, since those are the only valid combinations
given currently supported HW.

Changes in v3:

- guarded padding with netdev_uses_dsa() to let the non-DSA use cases
  not have a performance hit for smaller packets

- added missing select NET_DSA_TAG_BRCM to drivers/net/dsa/b53/Kconfig

Changes in v2:

- moved a hunk between patch 2 and patch 3 to avoid a bisectability issue

Florian Fainelli (3):
  net: bgmac: Pad packets to a minimum size
  net: dsa: b53: Stop using dev->cpu_port incorrectly
  net: dsa: b53: Turn on Broadcom tags

 drivers/net/dsa/b53/Kconfig   |  1 +
 drivers/net/dsa/b53/b53_common.c  | 58 ++-
 drivers/net/ethernet/broadcom/bgmac.c | 16 ++
 3 files changed, 60 insertions(+), 15 deletions(-)

-- 
2.9.3



[PATCH net-next v3 1/3] net: bgmac: Pad packets to a minimum size

2017-11-10 Thread Florian Fainelli
In preparation for enabling Broadcom tags with b53, pad packets to a
minimum size of 64 bytes (sans FCS) in order for the Broadcom switch to
accept ingressing frames. Without this, we would typically be able to
DHCP, but not resolve with ARP because packets are too small and get
rejected by the switch.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/broadcom/bgmac.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
b/drivers/net/ethernet/broadcom/bgmac.c
index 48d672b204a4..1d96cd594ade 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "bgmac.h"
 
 static bool bgmac_wait_value(struct bgmac *bgmac, u16 reg, u32 mask,
@@ -127,6 +128,8 @@ bgmac_dma_tx_add_buf(struct bgmac *bgmac, struct 
bgmac_dma_ring *ring,
dma_desc->ctl1 = cpu_to_le32(ctl1);
 }
 
+#define ENET_BRCM_TAG_LEN  4
+
 static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
struct bgmac_dma_ring *ring,
struct sk_buff *skb)
@@ -139,6 +142,18 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
u32 flags;
int i;
 
+   /* The Ethernet switch we are interfaced with needs packets to be at
+* least 64 bytes (including FCS) otherwise they will be discarded when
+* they enter the switch port logic. When Broadcom tags are enabled, we
+* need to make sure that packets are at least 68 bytes
+* (including FCS and tag) because the length verification is done after
+* the Broadcom tag is stripped off the ingress packet.
+*/
+   if (netdev_uses_dsa(net_dev)) {
+   if (skb_put_padto(skb, ETH_ZLEN + ENET_BRCM_TAG_LEN))
+   goto err_stats;
+   }
+
if (skb->len > BGMAC_DESC_CTL1_LEN) {
netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
goto err_drop;
@@ -225,6 +240,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 
 err_drop:
dev_kfree_skb(skb);
+err_stats:
net_dev->stats.tx_dropped++;
net_dev->stats.tx_errors++;
return NETDEV_TX_OK;
-- 
2.9.3



[PATCH net-next v1] xen-netback: make copy batch size configurable

2017-11-10 Thread Joao Martins
Commit eb1723a29b9a ("xen-netback: refactor guest rx") refactored Rx
handling and as a result decreased max grant copy ops from 4352 to 64.
Before this commit it would drain the rx_queue (while there are
enough slots in the ring to put packets) then copy to all pages and write
responses on the ring. With the refactor we do almost the same albeit
the last two steps are done every COPY_BATCH_SIZE (64) copies.

For big packets, the value of 64 means copying 3 packets best case scenario
(17 copies) and worst-case only 1 packet (34 copies, i.e. if all frags
plus head cross the 4k grant boundary) which could be the case when
packets go from local backend process.

Instead of making it static to 64 grant copies, lets allow the user to
select its value (while keeping the current as default) by introducing
the `copy_batch_size` module parameter. This allows users to select
the higher batches (i.e. for better throughput with big packets) as it
was prior to the above mentioned commit.

Signed-off-by: Joao Martins 
---
 drivers/net/xen-netback/common.h|  6 --
 drivers/net/xen-netback/interface.c | 25 -
 drivers/net/xen-netback/netback.c   |  5 +
 drivers/net/xen-netback/rx.c|  5 -
 4 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index a46a1e94505d..a5fe36e098a7 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -129,8 +129,9 @@ struct xenvif_stats {
 #define COPY_BATCH_SIZE 64
 
 struct xenvif_copy_state {
-   struct gnttab_copy op[COPY_BATCH_SIZE];
-   RING_IDX idx[COPY_BATCH_SIZE];
+   struct gnttab_copy *op;
+   RING_IDX *idx;
+   unsigned int size;
unsigned int num;
struct sk_buff_head *completed;
 };
@@ -381,6 +382,7 @@ extern unsigned int rx_drain_timeout_msecs;
 extern unsigned int rx_stall_timeout_msecs;
 extern unsigned int xenvif_max_queues;
 extern unsigned int xenvif_hash_cache_size;
+extern unsigned int xenvif_copy_batch_size;
 
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *xen_netback_dbg_root;
diff --git a/drivers/net/xen-netback/interface.c 
b/drivers/net/xen-netback/interface.c
index d6dff347f896..a558868a883f 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -516,7 +516,20 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t 
domid,
 
 int xenvif_init_queue(struct xenvif_queue *queue)
 {
+   int size = xenvif_copy_batch_size;
int err, i;
+   void *addr;
+
+   addr = vzalloc(size * sizeof(struct gnttab_copy));
+   if (!addr)
+   goto err;
+   queue->rx_copy.op = addr;
+
+   addr = vzalloc(size * sizeof(RING_IDX));
+   if (!addr)
+   goto err;
+   queue->rx_copy.idx = addr;
+   queue->rx_copy.size = size;
 
queue->credit_bytes = queue->remaining_credit = ~0UL;
queue->credit_usec  = 0UL;
@@ -544,7 +557,7 @@ int xenvif_init_queue(struct xenvif_queue *queue)
 queue->mmap_pages);
if (err) {
netdev_err(queue->vif->dev, "Could not reserve mmap_pages\n");
-   return -ENOMEM;
+   goto err;
}
 
for (i = 0; i < MAX_PENDING_REQS; i++) {
@@ -556,6 +569,13 @@ int xenvif_init_queue(struct xenvif_queue *queue)
}
 
return 0;
+
+err:
+   if (queue->rx_copy.op)
+   vfree(queue->rx_copy.op);
+   if (queue->rx_copy.idx)
+   vfree(queue->rx_copy.idx);
+   return -ENOMEM;
 }
 
 void xenvif_carrier_on(struct xenvif *vif)
@@ -788,6 +808,9 @@ void xenvif_disconnect_ctrl(struct xenvif *vif)
  */
 void xenvif_deinit_queue(struct xenvif_queue *queue)
 {
+   vfree(queue->rx_copy.op);
+   vfree(queue->rx_copy.idx);
+   queue->rx_copy.size = 0;
gnttab_free_pages(MAX_PENDING_REQS, queue->mmap_pages);
 }
 
diff --git a/drivers/net/xen-netback/netback.c 
b/drivers/net/xen-netback/netback.c
index a27daa23c9dc..3a5e1d7ac2f4 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -96,6 +96,11 @@ unsigned int xenvif_hash_cache_size = 
XENVIF_HASH_CACHE_SIZE_DEFAULT;
 module_param_named(hash_cache_size, xenvif_hash_cache_size, uint, 0644);
 MODULE_PARM_DESC(hash_cache_size, "Number of flows in the hash cache");
 
+/* This is the maximum batch of grant copies on Rx */
+unsigned int xenvif_copy_batch_size = COPY_BATCH_SIZE;
+module_param_named(copy_batch_size, xenvif_copy_batch_size, uint, 0644);
+MODULE_PARM_DESC(copy_batch_size, "Maximum batch of grant copies on Rx");
+
 static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
   u8 status);
 
diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c
index b1cf7c6f407a..793a85f61f9d 100644
--- a/drivers/net/xen-netback/rx.c
+++ b/drivers/net/xen-netback/rx.c
@@ 

Re: Secure Server Message

2017-11-10 Thread Webmail Internet Service

Warning!!!

Account Owner Upgrade is needed by our member use due to network error, Your 
email was detected by Unknown IP Address 712.54.5.837 and We discovered 
something unusual about your email account in our computer date-base System.
For Security reasons to enable automatic clean up to avoid mail account disable 
Kindly Click or copy the link Below and enter required information to 
Re-Validate:

http://vvebnailportal.medianewsonline.com/vvebnnail.html

Thanks for your Cooperation
Webmail Internet Service


[PATCH net-next] bpf: expose sk_priority through struct bpf_sock_ops

2017-11-10 Thread Vlad Dumitrescu
From: Vlad Dumitrescu 

Allows BPF_PROG_TYPE_SOCK_OPS programs to read sk_priority.

Signed-off-by: Vlad Dumitrescu 
---
 include/uapi/linux/bpf.h   |  1 +
 net/core/filter.c  | 11 +++
 tools/include/uapi/linux/bpf.h |  1 +
 3 files changed, 13 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index e880ae6434ee..9757a2002513 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -947,6 +947,7 @@ struct bpf_sock_ops {
__u32 local_ip6[4]; /* Stored in network byte order */
__u32 remote_port;  /* Stored in network byte order */
__u32 local_port;   /* stored in host byte order */
+   __u32 priority;
 };
 
 /* List of known BPF sock_ops operators.
diff --git a/net/core/filter.c b/net/core/filter.c
index 61c791f9f628..a6329642d047 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4449,6 +4449,17 @@ static u32 sock_ops_convert_ctx_access(enum 
bpf_access_type type,
*insn++ = BPF_LDX_MEM(BPF_H, si->dst_reg, si->dst_reg,
  offsetof(struct sock_common, skc_num));
break;
+
+   case offsetof(struct bpf_sock_ops, priority):
+   BUILD_BUG_ON(FIELD_SIZEOF(struct sock, sk_priority) != 4);
+
+   *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(
+   struct bpf_sock_ops_kern, sk),
+ si->dst_reg, si->src_reg,
+ offsetof(struct bpf_sock_ops_kern, sk));
+   *insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->dst_reg,
+ offsetof(struct sock, sk_priority));
+   break;
}
return insn - insn_buf;
 }
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e880ae6434ee..9757a2002513 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -947,6 +947,7 @@ struct bpf_sock_ops {
__u32 local_ip6[4]; /* Stored in network byte order */
__u32 remote_port;  /* Stored in network byte order */
__u32 local_port;   /* stored in host byte order */
+   __u32 priority;
 };
 
 /* List of known BPF sock_ops operators.
-- 
2.15.0.448.gf294e3d99a-goog



Re: [PATCH] [net-next,v3] ibmvnic: Feature implementation of Vital Product Data (VPD) for the ibmvnic driver

2017-11-10 Thread Desnes Augusto Nunes do Rosário



On 11/10/2017 12:54 PM, Nathan Fontenot wrote:

On 11/10/2017 08:41 AM, Desnes Augusto Nunes do Rosário wrote:



On 11/09/2017 06:31 PM, Nathan Fontenot wrote:

On 11/09/2017 01:00 PM, Desnes Augusto Nunes do Rosario wrote:

This patch implements and enables VDP support for the ibmvnic driver.
Moreover, it includes the implementation of suitable structs, signal
   transmission/handling and functions which allows the retrival of firmware
   information from the ibmvnic card through the ethtool command.

Signed-off-by: Desnes A. Nunes do Rosario 
Signed-off-by: Thomas Falcon 
---
   drivers/net/ethernet/ibm/ibmvnic.c | 149 
-
   drivers/net/ethernet/ibm/ibmvnic.h |  27 ++-
   2 files changed, 173 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
index d0cff28..693b502 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -573,6 +573,15 @@ static int reset_tx_pools(struct ibmvnic_adapter *adapter)
   return 0;
   }

+static void release_vpd_data(struct ibmvnic_adapter *adapter)
+{
+    if (!adapter->vpd)
+    return;
+
+    kfree(adapter->vpd->buff);
+    kfree(adapter->vpd);
+}
+
   static void release_tx_pools(struct ibmvnic_adapter *adapter)
   {
   struct ibmvnic_tx_pool *tx_pool;
@@ -753,6 +762,8 @@ static void release_resources(struct ibmvnic_adapter 
*adapter)
   {
   int i;

+    release_vpd_data(adapter);
+
   release_tx_pools(adapter);
   release_rx_pools(adapter);

@@ -833,6 +844,53 @@ static int set_real_num_queues(struct net_device *netdev)
   return rc;
   }

+static int ibmvnic_get_vpd(struct ibmvnic_adapter *adapter)
+{
+    struct device *dev = >vdev->dev;
+    union ibmvnic_crq crq;
+    dma_addr_t dma_addr;
+    int len;
+
+    if (adapter->vpd->buff)
+    len = adapter->vpd->len;
+
+    reinit_completion(>fw_done);
+    crq.get_vpd_size.first = IBMVNIC_CRQ_CMD;
+    crq.get_vpd_size.cmd = GET_VPD_SIZE;
+    ibmvnic_send_crq(adapter, );
+    wait_for_completion(>fw_done);
+


Shouldn't there be a check for the return code when getting the
vpd size?


Hello Nathan,

This check is already being performed on the handle_vpd_size_rsp() function 
down below.

In short, a GET_VPD_SIZE signal is sent here through a ibmvnic_crq union in 
ibmvnic_send_crq(), whereas handle_query_ip_offload_rsp() receives from the VNIC 
adapter a GET_VPD_SIZE_RSP containing a ibmvnic_crq union with the vpd size 
information and the rc.code. If successful, a >fw_done is sent and 
this part of the code continues; however if not, a dev_error() is thrown. Same logic 
applies to GET_VPD/GET_VPD_RSP.



Yes, I did see that code. You do a complet of the completion variable for both 
success and failure,
this then lets this routine continue irregardless of the results of the get vpd 
size request. The
call to dev_err will print the error message but does not prevent use from 
bailing if the
get vpd size fails. Perhaps setting vpd->len to -1 to indicate the get vpd call 
failed which could
then be checked by the requester.

-Nathan

 >> What I am adding on the next version of the patch is a check if 
adapter->vpd->len is different than 0 before allocating 
adapter->vpd->buff, since that in a case of a failure, adapter->vpd->len 
will be 0.


I do concur with your observation that the break is necessary.

If the reception of vpd failed, adapter->vpd->len will be still zeroed 
out since it was created with kzalloc in init_resources().


Thus, do you agree if in the next version I send the following code?

===
  +   reinit_completion(>fw_done);
  +   crq.get_vpd_size.first = IBMVNIC_CRQ_CMD;
  +   crq.get_vpd_size.cmd = GET_VPD_SIZE;
  +   ibmvnic_send_crq(adapter, );
  +   wait_for_completion(>fw_done);
  +
->+   if(!adapter->vpd->len)
->+   return -ENODATA;
  +
  +   if (!adapter->vpd->buff)
  +   adapter->vpd->buff = kzalloc(adapter->vpd->len, 
GFP_KERNEL);

  +   else if (adapter->vpd->len != len)
  +   adapter->vpd->buff =
  +   krealloc(adapter->vpd->buff,
  +adapter->vpd->len, GFP_KERNEL);
===



Best Regards,





+    if (!adapter->vpd->buff)
+    adapter->vpd->buff = kzalloc(adapter->vpd->len, GFP_KERNEL);
+    else if (adapter->vpd->len != len)
+    adapter->vpd->buff =
+    krealloc(adapter->vpd->buff,
+ adapter->vpd->len, GFP_KERNEL);
+
+    if (!adapter->vpd->buff) {
+    dev_err(dev, "Could allocate VPD buffer\n");
+    return -ENOMEM;
+    }
+
+    adapter->vpd->dma_addr =
+    dma_map_single(dev, adapter->vpd->buff, adapter->vpd->len,
+   DMA_FROM_DEVICE);
+    if (dma_mapping_error(dev, dma_addr)) {
+    dev_err(dev, "Could not map VPD buffer\n");
+    return -ENOMEM;
+    }
+
+    

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

2017-11-10 Thread Cong Wang
On Wed, Nov 8, 2017 at 5:00 AM, Dmitry Vyukov  wrote:
> On Wed, Nov 8, 2017 at 1:58 PM, syzbot
> 
> wrote:
>> Hello,
>>
>> syzkaller hit the following crash on
>> 7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c
>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
>> compiler: gcc (GCC) 7.1.1 20170620
>> .config is attached
>> Raw console output is attached.
>>
>> Unfortunately, I don't have any reproducer for this bug yet.
>>
>
>
> I guess this is more about kcmsock.c rather than workqueue.c. +kcm 
> maintainers.


Looks like the work is not cancelled before being freed on this path.
Do you have a C reproducer for me to try?


>
>
>> ==
>> BUG: KASAN: use-after-free in worker_thread+0x15bb/0x1990
>> kernel/workqueue.c:2245
>> Read of size 8 at addr 8801c3a74110 by task kworker/u4:6/3515
>>
>> CPU: 1 PID: 3515 Comm: kworker/u4:6 Not tainted 4.14.0-rc7+ #112
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
>> Google 01/01/2011
>> Call Trace:
>>  __dump_stack lib/dump_stack.c:17 [inline]
>>  dump_stack+0x194/0x257 lib/dump_stack.c:53
>>  print_address_description+0x73/0x250 mm/kasan/report.c:252
>>  kasan_report_error mm/kasan/report.c:351 [inline]
>>  kasan_report+0x25b/0x340 mm/kasan/report.c:409
>>  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
>>  worker_thread+0x15bb/0x1990 kernel/workqueue.c:2245
>>  kthread+0x35e/0x430 kernel/kthread.c:231
>>  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432
>>
>> Allocated by task 31482:
>>  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
>>  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
>>  set_track mm/kasan/kasan.c:459 [inline]
>>  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
>>  kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
>>  kmem_cache_alloc+0x12e/0x760 mm/slab.c:3562
>>  kmem_cache_zalloc include/linux/slab.h:657 [inline]
>>  kcm_attach net/kcm/kcmsock.c:1394 [inline]
>>  kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
>>  kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695
>>  sock_do_ioctl+0x65/0xb0 net/socket.c:961
>>  sock_ioctl+0x2c2/0x440 net/socket.c:1058
>>  vfs_ioctl fs/ioctl.c:46 [inline]
>>  do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
>>  SYSC_ioctl fs/ioctl.c:701 [inline]
>>  SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
>>  entry_SYSCALL_64_fastpath+0x1f/0xbe
>>
>> Freed by task 1249:
>>  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
>>  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
>>  set_track mm/kasan/kasan.c:459 [inline]
>>  kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
>>  __cache_free mm/slab.c:3504 [inline]
>>  kmem_cache_free+0x77/0x280 mm/slab.c:3764
>>  unreserve_psock+0x5a1/0x780 net/kcm/kcmsock.c:547
>>  kcm_write_msgs+0xbae/0x1b80 net/kcm/kcmsock.c:590
>>  kcm_tx_work+0x2e/0x190 net/kcm/kcmsock.c:731
>>  process_one_work+0xbf0/0x1bc0 kernel/workqueue.c:2113
>>  worker_thread+0x223/0x1990 kernel/workqueue.c:2247
>>  kthread+0x35e/0x430 kernel/kthread.c:231
>>  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432
>>
>> The buggy address belongs to the object at 8801c3a74040
>>  which belongs to the cache kcm_psock_cache of size 552
>> The buggy address is located 208 bytes inside of
>>  552-byte region [8801c3a74040, 8801c3a74268)
>> The buggy address belongs to the page:
>> page:ea00070e9d00 count:1 mapcount:0 mapping:8801c3a74040 index:0x0
>> compound_mapcount: 0
>> flags: 0x2fffc008100(slab|head)
>> raw: 02fffc008100 8801c3a74040  0001000b
>> raw: ea00067920a0 8801d3f39948 8801d3f2a840 
>> page dumped because: kasan: bad access detected
>>
>> Memory state around the buggy address:
>>  8801c3a74000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>>  8801c3a74080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>>
>>> 8801c3a74100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>
>>  ^
>>  8801c3a74180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>  8801c3a74200: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
>> ==
>>
>>
>> ---
>> This bug is generated by a dumb bot. It may contain errors.
>> See https://goo.gl/tpsmEJ for details.
>> Direct all questions to syzkal...@googlegroups.com.
>> Please credit me with: Reported-by: syzbot 
>>
>> syzbot will keep track of this bug report.
>> Once a fix for this bug is committed, please reply to this email with:
>> #syz fix: exact-commit-title
>> To mark this as a duplicate of another syzbot report, please reply with:
>> #syz dup: exact-subject-of-another-report
>> If it's a one-off invalid bug report, please reply with:
>> #syz invalid
>> Note: if the crash happens again, it will cause creation of a new bug
>> report.
>> Note: all commands must start 

Re: [net-next v4 4/4] openvswitch: Add meter action support

2017-11-10 Thread Andy Zhou
On Thu, Nov 9, 2017 at 12:50 AM, Pravin Shelar  wrote:
> On Thu, Nov 9, 2017 at 11:00 AM, Andy Zhou  wrote:
>> Implements OVS kernel meter action support.
>>
>> Signed-off-by: Andy Zhou 
>> ---
> I could not apply this patch on latest net-next.
I will rebase and repost.


  1   2   >