* Re: [PATCH iproute2 v2] man: fix documentation for range of route table ID
From: Stephen Hemminger @ 2017-09-22 17:09 UTC (permalink / raw)
To: Thomas Haller; +Cc: netdev, Phil Sutter
In-Reply-To: <20170922112854.21289-1-thaller@redhat.com>
On Fri, 22 Sep 2017 13:28:54 +0200
Thomas Haller <thaller@redhat.com> wrote:
> Signed-off-by: Thomas Haller <thaller@redhat.com>
> ---
> Changes in v2:
> - "0" is not a valid table ID.
>
> man/man8/ip-route.8.in | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
> index 803de3b9..705ceb20 100644
> --- a/man/man8/ip-route.8.in
> +++ b/man/man8/ip-route.8.in
> @@ -322,7 +322,7 @@ normal routing tables.
> .P
> .B Route tables:
> Linux-2.x can pack routes into several routing tables identified
> -by a number in the range from 1 to 2^31 or by name from the file
> +by a number in the range from 1 to 2^32-1 or by name from the file
> .B @SYSCONFDIR@/rt_tables
> By default all normal routes are inserted into the
> .B main
Applied
^ permalink raw reply
* [PATCH] Add a driver for Renesas uPD60620 and uPD60620A PHYs
From: Bernd Edlinger @ 2017-09-22 17:08 UTC (permalink / raw)
To: netdev@vger.kernel.org; +Cc: Andrew Lunn, Florian Fainelli
Signed-off-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
---
drivers/net/phy/Kconfig | 5 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/uPD60620.c | 226
+++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 232 insertions(+)
create mode 100644 drivers/net/phy/uPD60620.c
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index a9d16a3..25089f0 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -287,6 +287,11 @@ config DP83867_PHY
---help---
Currently supports the DP83867 PHY.
+config RENESAS_PHY
+ tristate "Driver for Renesas PHYs"
+ ---help---
+ Supports the uPD60620 and uPD60620A PHYs.
+
config FIXED_PHY
tristate "MDIO Bus/PHY emulation with fixed speed/link PHYs"
depends on PHYLIB
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 416df92..1404ad3 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_MICROSEMI_PHY) += mscc.o
obj-$(CONFIG_NATIONAL_PHY) += national.o
obj-$(CONFIG_QSEMI_PHY) += qsemi.o
obj-$(CONFIG_REALTEK_PHY) += realtek.o
+obj-$(CONFIG_RENESAS_PHY) += uPD60620.o
obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o
obj-$(CONFIG_SMSC_PHY) += smsc.o
obj-$(CONFIG_STE10XP) += ste10Xp.o
diff --git a/drivers/net/phy/uPD60620.c b/drivers/net/phy/uPD60620.c
new file mode 100644
index 0000000..b3d900c
--- /dev/null
+++ b/drivers/net/phy/uPD60620.c
@@ -0,0 +1,226 @@
+/*
+ * Driver for the Renesas PHY uPD60620.
+ *
+ * Copyright (C) 2015 Softing Industrial Automation GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/phy.h>
+
+#define UPD60620_PHY_ID 0xb8242824
+
+/* Extended Registers and values */
+/* PHY Special Control/Status */
+#define PHY_PHYSCR 0x1F /* PHY.31 */
+#define PHY_PHYSCR_10MB 0x0004 /* PHY speed = 10mb */
+#define PHY_PHYSCR_100MB 0x0008 /* PHY speed = 100mb */
+#define PHY_PHYSCR_DUPLEX 0x0010 /* PHY Duplex */
+#define PHY_PHYSCR_RSVD5 0x0020 /* Reserved Bit 5 */
+#define PHY_PHYSCR_MIIMOD 0x0040 /* Enable 4B5B MII mode */
+#define PHY_PHYSCR_RSVD7 0x0080 /* Reserved Bit 7 */
+#define PHY_PHYSCR_RSVD8 0x0100 /* Reserved Bit 8 */
+#define PHY_PHYSCR_RSVD9 0x0200 /* Reserved Bit 9 */
+#define PHY_PHYSCR_RSVD10 0x0400 /* Reserved Bit 10 */
+#define PHY_PHYSCR_RSVD11 0x0800 /* Reserved Bit 11 */
+#define PHY_PHYSCR_ANDONE 0x1000 /* Auto negotiation done */
+#define PHY_PHYSCR_RSVD13 0x2000 /* Reserved Bit 13 */
+#define PHY_PHYSCR_RSVD14 0x4000 /* Reserved Bit 14 */
+#define PHY_PHYSCR_RSVD15 0x8000 /* Reserved Bit 15 */
+
+/* PHY Global Config Mapping */
+#define PHY_GLOBAL_CONFIG 0x07
+/* PHY GPIO Config Register 1 */
+#define PHY_GPIO_CONFIG1 0x01 /* PHY 7.1 */
+#define PHY_GPIO4_INT0 0x000d /* GPIO4 configuration */
+#define PHY_GPIO5_INT1 0x00d0 /* GPIO5 configuration */
+
+/* PHY Interrupt Control Register */
+#define PHY_ICR 0x1e /* PHY.30 */
+#define PHY_ICR_RSVD0 0x0001 /* Reserved bit 0 */
+#define PHY_ICR_ANCPRRN 0x0002 /* Auto negotiation paged received */
+#define PHY_ICR_PDFEN 0x0004 /* Parallel detection fault */
+#define PHY_ICR_ANCLPAEN 0x0008 /* Auto negotiation last page ack */
+#define PHY_ICR_LNKINTEN 0x0010 /* Link down */
+#define PHY_ICR_REMFD 0x0020 /* Remote fault detected */
+#define PHY_ICR_ANCINTEN 0x0040 /* Auto negotiation complete */
+#define PHY_ICR_EOEN 0x0080 /* Energy on generated */
+#define PHY_ICR_RSVD8 0x0100 /* Reserved bit 8 */
+#define PHY_ICR_FEQTRGEN 0x0200 /* FEQ Trigger */
+#define PHY_ICR_BERTRGEN 0x0400 /* BER Counter Trigger */
+#define PHY_ICR_MLINTEN 0x0800 /* Maxlvl */
+#define PHY_ICR_CLPINTEN 0x1000 /* Clipping */
+#define PHY_ICR_RSVD13 0x2000 /* Reserved bit 13 */
+#define PHY_ICR_RSVD14 0x4000 /* Reserved bit 14 */
+#define PHY_ICR_RSVD15 0x8000 /* Reserved bit 15 */
+
+/* PHY Interrupt Status Register */
+#define PHY_ISR 0x1d /* PHY.29 */
+#define PHY_ISR_DUPINT 0x0000 /* Placeholder for Duplex/Speed
intr */
+#define PHY_ISR_RSVD0 0x0001 /* Reserved bit 0 */
+#define PHY_ISR_ANCPR 0x0002 /* Auto negotiation paged received */
+#define PHY_ISR_PDF 0x0004 /* Parallel detection fault */
+#define PHY_ISR_ANCLPA 0x0008 /* Auto negotiation last page ack */
+#define PHY_ISR_LNKINT 0x0010 /* Link down */
+#define PHY_ISR_REMFD 0x0020 /* Remote fault detected */
+#define PHY_ISR_ANCINT 0x0040 /* Auto negotiation complete */
+#define PHY_ISR_EO 0x0080 /* Energy on generated */
+#define PHY_ISR_RSVD8 0x0100 /* Reserved bit 8 */
+#define PHY_ISR_FEQTRG 0x0200 /* FEQ Trigger */
+#define PHY_ISR_BERTRG 0x0400 /* BER Counter Trigger */
+#define PHY_ISR_MLINT 0x0800 /* Maxlvl */
+#define PHY_ISR_CLPINT 0x1000 /* Clipping */
+#define PHY_ISR_RSVD13 0x2000 /* Reserved bit 13 */
+#define PHY_ISR_RSVD14 0x4000 /* Reserved bit 14 */
+#define PHY_ISR_RSVD15 0x8000 /* Reserved bit 15 */
+
+/* PHY Diagnosis Control/Status Register*/
+#define PHY_DCS 0x19 /* PHY.25 */
+#define PHY_DCS_PWDIAG1 0x0001 /* Pulse Width Diagnosis -- 8ns */
+#define PHY_DCS_DIAGSEL 0x0020 /* Diagnosis select Tx or Rx */
+#define PHY_DCS_DIAGPOL 0x0040 /* Diagnosis stop polarity */
+#define PHY_DCS_DIAGDONE 0x0080 /* Diagnosis done */
+#define PHY_DCS_ADCTRIG05 0x0700 /* ADC Trigger level 0.5V for
cable len */
+#define PHY_DCS_ADCMAX 0x3F00 /* ADC Max value */
+#define PHY_DCS_DIAGINIT 0x4000 /* Init TDR test */
+
+/* PHY Diagnosis Counter Register */
+#define PHY_DCR 0x1a /* PHY.26 */
+#define PHY_DCR_DIGNCNT 0x00ff /* Diagnosis Count */
+#define PHY_DCR_CNTWIN 0xff00 /* Diagnosis Count Window */
+
+/* PHY Mode Control/Status Register */
+#define PHY_MCS 0x11 /* PHY.17 */
+#define PHY_MCS_RSVD0 0x0001 /* Reserved bit 0 */
+#define PHY_MCS_ENERGYON 0x0002 /* Energy on the Line status */
+#define PHY_MCS_FGLS 0x0004 /* Force Good Link Status */
+#define PHY_MCS_RSVD3 0x0008 /* Reserved bit 3 */
+#define PHY_MCS_DCDPATGEN 0x0010 /* DCD measuring pattern generation */
+#define PHY_MCS_RSVD5 0x0020 /* Reserved bit 5 */
+#define PHY_MCS_MDIMODE 0x0040 /* Force MDIX or MDI */
+#define PHY_MCS_AUTOMDIX 0x0080 /* Auto MDIX enable */
+#define PHY_MCS_FASTEST 0x0100 /* Auto negotiation test mode */
+#define PHY_MCS_FARLOOP 0x0200 /* Remote loopback enable */
+#define PHY_MCS_RSVD10 0x0400 /* Reserved bit 10 */
+#define PHY_MCS_LOWSQEN 0x0800 /* Squelch Threshold */
+#define PHY_MCS_RSVD12 0x1000 /* Reserved bit 12 */
+#define PHY_MCS_EPWRDOWN 0x2000 /* Power down mode enable */
+#define PHY_MCS_FASTRIP 0x4000 /* 10Base-T Fast mode */
+#define PHY_MCS_RSVD15 0x8000 /* Reserved bit 15 */
+
+/* PHY Special Modes */
+#define PHY_SPM 0x12 /* PHY.18 */
+#define PHY_SPM_FX_MODE 0x400 /* Enable 100BASE-FX mode */
+#define PHY_SPM_PHYMODE 0x1E0 /* PHY mode of operation */
+#define PHY_SPM_PHYADD 0x01F /* PHY address of device */
+
+/* PHY BER Counter Register */
+#define PHY_BER 0x17 /* PHY.23 */
+#define PHY_BER_COUNT 0x007f /* BER Count Bits 6-0 */
+#define PHY_BER_WINDOW 0x0780 /* BER Window Bits 10-7 */
+#define PHY_BER_CNT_TRIG 0x3800 /* BER count trigger bits 13-11 */
+#define PHY_BER_CNT_LNK_EN 0x4000 /* BER count link enable */
+#define PHY_BER_LNK_OK 0x8000 /* BER link OK */
+
+/* Init PHY */
+
+static int upd60620_config_init(struct phy_device *phydev)
+{
+ /* Enable support for passive HUBs (could be a strap option) */
+ /* PHYMODE: All speeds, HD in parallel detect */
+ return phy_write(phydev, PHY_SPM, 0x0180 | phydev->mdio.addr);
+}
+
+/* Get PHY status from common registers */
+
+static int upd60620_read_status(struct phy_device *phydev)
+{
+ int phy_state;
+
+ /* Read negotiated state */
+ phy_state = phy_read(phydev, MII_BMSR);
+ if (phy_state < 0)
+ return phy_state;
+
+ phydev->link = 0;
+ phydev->lp_advertising = 0;
+ phydev->pause = 0;
+ phydev->asym_pause = 0;
+
+ if (phy_state & BMSR_ANEGCOMPLETE) {
+ phy_state = phy_read(phydev, PHY_PHYSCR);
+ if (phy_state < 0)
+ return phy_state;
+
+ if (phy_state & (PHY_PHYSCR_10MB | PHY_PHYSCR_100MB)) {
+ phydev->link = 1;
+ phydev->speed = SPEED_10;
+ phydev->duplex = DUPLEX_HALF;
+
+ if (phy_state & PHY_PHYSCR_100MB)
+ phydev->speed = SPEED_100;
+ if (phy_state & PHY_PHYSCR_DUPLEX)
+ phydev->duplex = DUPLEX_FULL;
+
+ phy_state = phy_read(phydev, MII_LPA);
+ if (phy_state < 0)
+ return phy_state;
+
+ phydev->lp_advertising
+ = mii_lpa_to_ethtool_lpa_t(phy_state);
+
+ if (phydev->duplex == DUPLEX_FULL) {
+ if (phy_state & LPA_PAUSE_CAP)
+ phydev->pause = 1;
+ if (phy_state & LPA_PAUSE_ASYM)
+ phydev->asym_pause = 1;
+ }
+ }
+ } else if (phy_state & BMSR_LSTATUS) {
+ phy_state = phy_read(phydev, MII_BMCR);
+ if (phy_state < 0)
+ return phy_state;
+
+ if (!(phy_state & BMCR_ANENABLE)) {
+ phydev->link = 1;
+ phydev->speed = SPEED_10;
+ phydev->duplex = DUPLEX_HALF;
+
+ if (phy_state & BMCR_SPEED100)
+ phydev->speed = SPEED_100;
+ if (phy_state & BMCR_FULLDPLX)
+ phydev->duplex = DUPLEX_FULL;
+ }
+ }
+ return 0;
+}
+
+MODULE_DESCRIPTION("Renesas uPD60620 PHY driver");
+MODULE_AUTHOR("Bernd Edlinger <bernd.edlinger@hotmail.de>");
+MODULE_LICENSE("GPL");
+
+static struct phy_driver upd60620_driver[1] = { {
+ .phy_id = UPD60620_PHY_ID,
+ .phy_id_mask = 0xfffffffe,
+ .name = "Renesas uPD60620",
+ .features = PHY_BASIC_FEATURES,
+ .flags = 0,
+ .config_init = upd60620_config_init,
+ .config_aneg = genphy_config_aneg,
+ .read_status = upd60620_read_status,
+} };
+
+module_phy_driver(upd60620_driver);
+
+static struct mdio_device_id __maybe_unused upd60620_tbl[] = {
+ { UPD60620_PHY_ID, 0xfffffffe },
+ { }
+};
+
+MODULE_DEVICE_TABLE(mdio, upd60620_tbl);
--
2.7.4
^ permalink raw reply related
* Re: [PATCH iproute2 master 0/2] BPF/XDP json follow-up
From: Stephen Hemminger @ 2017-09-22 17:07 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: ast, netdev
In-Reply-To: <cover.1505956723.git.daniel@iogearbox.net>
On Thu, 21 Sep 2017 10:42:27 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:
> After merging net-next branch into master, Stephen asked to
> fix up json dump for XDP as there were some merge conflicts,
> so here it is.
>
> Thanks!
>
> Daniel Borkmann (2):
> json: move json printer to common library
> bpf: properly output json for xdp
>
> include/json_print.h | 71 ++++++++++++++++
> ip/Makefile | 2 +-
> ip/ip_common.h | 65 ++------------
> ip/ip_print.c | 233 ---------------------------------------------------
> ip/iplink_xdp.c | 74 +++++++++-------
> lib/Makefile | 2 +-
> lib/bpf.c | 19 +++--
> lib/json_print.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 8 files changed, 369 insertions(+), 328 deletions(-)
> create mode 100644 include/json_print.h
> delete mode 100644 ip/ip_print.c
> create mode 100644 lib/json_print.c
>
Applied.
^ permalink raw reply
* usb/wireless/rsi_91x: use-after-free write in __run_timers
From: Andrey Konovalov @ 2017-09-22 17:04 UTC (permalink / raw)
To: Kalle Valo, Amitkumar Karwar, Prameela Rani Garnepudi,
Karun Eagalapati, linux-wireless, netdev, LKML
Cc: Dmitry Vyukov, Kostya Serebryany, syzkaller
Hi!
I've got the following report while fuzzing the kernel with syzkaller.
On commit 6e80ecdddf4ea6f3cd84e83720f3d852e6624a68 (Sep 21).
==================================================================
BUG: KASAN: use-after-free in __run_timers+0xc0e/0xd40
Write of size 8 at addr ffff880069f701b8 by task swapper/0/0
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.0-rc1-42311-g6e80ecdddf4e #234
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:16
dump_stack+0x292/0x395 lib/dump_stack.c:52
print_address_description+0x78/0x280 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351
kasan_report+0x22f/0x340 mm/kasan/report.c:409
__asan_report_store8_noabort+0x1c/0x20 mm/kasan/report.c:435
collect_expired_timers ./include/linux/list.h:729
__run_timers+0xc0e/0xd40 kernel/time/timer.c:1616
run_timer_softirq+0x83/0x140 kernel/time/timer.c:1646
__do_softirq+0x305/0xc2d kernel/softirq.c:284
invoke_softirq kernel/softirq.c:364
irq_exit+0x171/0x1a0 kernel/softirq.c:405
exiting_irq ./arch/x86/include/asm/apic.h:638
smp_apic_timer_interrupt+0x2b9/0x8d0 arch/x86/kernel/apic/apic.c:1048
apic_timer_interrupt+0x9d/0xb0
</IRQ>
RIP: 0010:native_safe_halt+0x6/0x10 ./arch/x86/include/asm/irqflags.h:53
RSP: 0018:ffffffff86607958 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff10
RAX: dffffc0000000020 RBX: 1ffffffff0cc0f2f RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffff8662ea64
RBP: ffffffff86607958 R08: ffffffff813d3501 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffffffff0cc0f3b
R13: ffffffff86607a98 R14: ffffffff86fc1628 R15: 0000000000000000
arch_safe_halt ./arch/x86/include/asm/paravirt.h:93
default_idle+0x127/0x690 arch/x86/kernel/process.c:341
arch_cpu_idle+0xf/0x20 arch/x86/kernel/process.c:332
default_idle_call+0x3b/0x60 kernel/sched/idle.c:98
cpuidle_idle_call kernel/sched/idle.c:156
do_idle+0x35c/0x440 kernel/sched/idle.c:246
cpu_startup_entry+0x1d/0x20 kernel/sched/idle.c:351
rest_init+0xf3/0x100 init/main.c:435
start_kernel+0x782/0x7b0 init/main.c:710
x86_64_start_reservations+0x2a/0x2c arch/x86/kernel/head64.c:377
x86_64_start_kernel+0x77/0x7a arch/x86/kernel/head64.c:358
secondary_startup_64+0xa5/0xa5 arch/x86/kernel/head_64.S:235
Allocated by task 1845:
save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772
kmalloc ./include/linux/slab.h:493
kzalloc ./include/linux/slab.h:666
rsi_91x_init+0x98/0x510 drivers/net/wireless/rsi/rsi_91x_main.c:203
rsi_probe+0xb6/0x13b0 drivers/net/wireless/rsi/rsi_91x_usb.c:665
usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
really_probe drivers/base/dd.c:413
driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
device_add+0xd0b/0x1660 drivers/base/core.c:1835
usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
really_probe drivers/base/dd.c:413
driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
device_add+0xd0b/0x1660 drivers/base/core.c:1835
usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457
hub_port_connect drivers/usb/core/hub.c:4903
hub_port_connect_change drivers/usb/core/hub.c:5009
port_event drivers/usb/core/hub.c:5115
hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195
process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
worker_thread+0x221/0x1850 kernel/workqueue.c:2253
kthread+0x3a1/0x470 kernel/kthread.c:231
ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
Freed by task 1845:
save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459
kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:524
slab_free_hook mm/slub.c:1390
slab_free_freelist_hook mm/slub.c:1412
slab_free mm/slub.c:2988
kfree+0xf6/0x2f0 mm/slub.c:3919
rsi_91x_deinit+0x1e8/0x250 drivers/net/wireless/rsi/rsi_91x_main.c:268
rsi_probe+0xed1/0x13b0 drivers/net/wireless/rsi/rsi_91x_usb.c:709
usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
really_probe drivers/base/dd.c:413
driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
device_add+0xd0b/0x1660 drivers/base/core.c:1835
usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
really_probe drivers/base/dd.c:413
driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
device_add+0xd0b/0x1660 drivers/base/core.c:1835
usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457
hub_port_connect drivers/usb/core/hub.c:4903
hub_port_connect_change drivers/usb/core/hub.c:5009
port_event drivers/usb/core/hub.c:5115
hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195
process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
worker_thread+0x221/0x1850 kernel/workqueue.c:2253
kthread+0x3a1/0x470 kernel/kthread.c:231
ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
The buggy address belongs to the object at ffff880069f70000
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 440 bytes inside of
2048-byte region [ffff880069f70000, ffff880069f70800)
The buggy address belongs to the page:
page:ffffea0001a7dc00 count:1 mapcount:0 mapping: (null)
index:0xffff880069f77700 compound_mapcount: 0
flags: 0x100000000008100(slab|head)
raw: 0100000000008100 0000000000000000 ffff880069f77700 00000001800f000c
raw: ffffea000190e000 0000000200000002 ffff88006c402d80 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff880069f70080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880069f70100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff880069f70180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff880069f70200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880069f70280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
^ permalink raw reply
* Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core
From: Florian Fainelli @ 2017-09-22 16:58 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot; +Cc: netdev, linux-kernel, kernel, David S. Miller
In-Reply-To: <20170922163258.GA3470@lunn.ch>
On 09/22/2017 09:32 AM, Andrew Lunn wrote:
> On Fri, Sep 22, 2017 at 12:17:50PM -0400, Vivien Didelot wrote:
>> bcm_sf2 is currently the only driver using the phy argument passed to
>> .port_enable. It resets the state machine if the phy has been hard
>> reset. This check is generic and can be moved to DSA core.
>>
>> dsa_port_set_state_now(p->dp, stp_state);
>>
>> - if (p->phy)
>> - phy_start(p->phy);
>> + if (phy) {
>> + /* If phy_stop() has been called before, phy will be in
>> + * halted state, and phy_start() will call resume.
>> + *
>> + * The resume path does not configure back autoneg
>> + * settings, and since the internal phy may have been
>> + * hard reset, we need to reset the state machine also.
>> + */
>> + phy->state = PHY_READY;
>> + phy_init_hw(phy);
>> + phy_start(phy);
>> + }
>
> Hi Vivien
>
> If this is generic, why is it needed at all here? Shouldn't this
> actually by in phylib?
This does not belong in the core logic within net/dsa/slave.c. The
reason why this is necessary here is because we are doing a HW-based
reset of the PHY, as the comment explains this is specific to how the HW
works. There may be a cleaner solution to this problem, but in any case,
I don't think other drivers should inherit that logic.
--
Florian
^ permalink raw reply
* Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core
From: Florian Fainelli @ 2017-09-22 16:52 UTC (permalink / raw)
To: Vivien Didelot, netdev; +Cc: linux-kernel, kernel, David S. Miller, Andrew Lunn
In-Reply-To: <20170922161753.19563-2-vivien.didelot@savoirfairelinux.com>
On 09/22/2017 09:17 AM, Vivien Didelot wrote:
> bcm_sf2 is currently the only driver using the phy argument passed to
> .port_enable. It resets the state machine if the phy has been hard
> reset. This check is generic and can be moved to DSA core.
This is completely specific to bcm_sf2 because it does call
bcm_sf2_gphy_enable_set() which performs a HW reset of the PHY, you
can't move this to the generic portion of net/dsa/slave.c. NACK.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
> drivers/net/dsa/bcm_sf2.c | 16 +---------------
> net/dsa/slave.c | 15 +++++++++++++--
> 2 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 898d5642b516..ad96b9725a2c 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -184,22 +184,8 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
> core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port));
>
> /* Re-enable the GPHY and re-apply workarounds */
> - if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
> + if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1)
> bcm_sf2_gphy_enable_set(ds, true);
> - if (phy) {
> - /* if phy_stop() has been called before, phy
> - * will be in halted state, and phy_start()
> - * will call resume.
> - *
> - * the resume path does not configure back
> - * autoneg settings, and since we hard reset
> - * the phy manually here, we need to reset the
> - * state machine also.
> - */
> - phy->state = PHY_READY;
> - phy_init_hw(phy);
> - }
> - }
>
> /* Enable MoCA port interrupts to get notified */
> if (port == priv->moca_port)
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 02ace7d462c4..606812160fd5 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -72,6 +72,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
> static int dsa_slave_open(struct net_device *dev)
> {
> struct dsa_slave_priv *p = netdev_priv(dev);
> + struct phy_device *phy = p->phy;
> struct dsa_port *dp = p->dp;
> struct dsa_switch *ds = dp->ds;
> struct net_device *master = dsa_master_netdev(p);
> @@ -106,8 +107,18 @@ static int dsa_slave_open(struct net_device *dev)
>
> dsa_port_set_state_now(p->dp, stp_state);
>
> - if (p->phy)
> - phy_start(p->phy);
> + if (phy) {
> + /* If phy_stop() has been called before, phy will be in
> + * halted state, and phy_start() will call resume.
> + *
> + * The resume path does not configure back autoneg
> + * settings, and since the internal phy may have been
> + * hard reset, we need to reset the state machine also.
> + */
> + phy->state = PHY_READY;
> + phy_init_hw(phy);
> + phy_start(phy);
> + }
>
> return 0;
>
>
--
Florian
^ permalink raw reply
* Re: [PATCH,v2,net-next 2/2] tun: enable napi_gro_frags() for TUN/TAP driver
From: Mahesh Bandewar (महेश बंडेवार) @ 2017-09-22 16:51 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Petar Penkov, Network Development, Eric Dumazet, Willem de Bruijn,
David Miller, Petar Bozhidarov Penkov
In-Reply-To: <CAF=yD-KSdujdkgOAvUnuj+xeok9KgT0mem0oQYHP4uq+U8uahA@mail.gmail.com>
On Fri, Sep 22, 2017 at 7:06 AM, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>> @@ -2061,6 +2174,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
>> if (tfile->detached)
>> return -EINVAL;
>>
>> + if ((ifr->ifr_flags & IFF_NAPI_FRAGS) && !capable(CAP_NET_ADMIN))
>> + return -EPERM;
>> +
>
> This should perhaps be moved into the !dev branch, directly below the
> ns_capable check.
>
Hmm, does that mean fail only on creation but allow to attach if
exists? That would be wrong, isn't it? Correct me if I'm wrong but we
want to prevent both these scenarios if user does not have sufficient
privileges (i.e. NET_ADMIN in init-ns).
>> dev = __dev_get_by_name(net, ifr->ifr_name);
>> if (dev) {
>> if (ifr->ifr_flags & IFF_TUN_EXCL)
>> @@ -2185,6 +2301,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
>> tun->flags = (tun->flags & ~TUN_FEATURES) |
>> (ifr->ifr_flags & TUN_FEATURES);
>>
>> + if (!(tun->flags & IFF_NAPI) || (tun->flags & TUN_TYPE_MASK) != IFF_TAP)
>> + tun->flags = tun->flags & ~IFF_NAPI_FRAGS;
>> +
>
> Similarly, this check only need to be performed in that branch.
> Instead of reverting to non-frags mode, a tun_set_iff with the wrong
> set of flags should probably fail hard.
Yes, agree, wrong set of flags should fail hard and probably be done
before attach or open, no?
^ permalink raw reply
* Re: [PATCH] brcm80211: make const array ucode_ofdm_rates static, reduces object code size
From: Arend van Spriel @ 2017-09-22 16:51 UTC (permalink / raw)
To: Colin King, Franky Lin, Hante Meuleman, Chi-Hsien Lin,
Wright Feng, Kalle Valo, linux-wireless, brcm80211-dev-list.pdl,
brcm80211-dev-list, netdev
Cc: kernel-janitors, linux-kernel
In-Reply-To: <20170922140316.12768-1-colin.king@canonical.com>
Please use 'brcmsmac:' as prefix instead of 'brcm80211:'.
On 22-09-17 16:03, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate const array ucode_ofdm_rates on the stack, instead make it
> static. Makes the object code smaller by 100 bytes:
>
> Before:
> text data bss dec hex filename
> 39482 564 0 40046 9c6e phy_cmn.o
>
> After
> text data bss dec hex filename
> 39326 620 0 39946 9c0a phy_cmn.o
>
> (gcc 6.3.0, x86-64)
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c
> index 1c4e9dd57960..3a13d176b221 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c
> @@ -1916,7 +1916,7 @@ void wlc_phy_txpower_update_shm(struct brcms_phy *pi)
> pi->hwpwr_txcur);
>
> for (j = TXP_FIRST_OFDM; j <= TXP_LAST_OFDM; j++) {
> - const u8 ucode_ofdm_rates[] = {
> + static const u8 ucode_ofdm_rates[] = {
> 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c
> };
> offset = wlapi_bmac_rate_shm_offset(
>
^ permalink raw reply
* Re: [Intel-wired-lan] [PATCH] i40e: make const array patterns static, reduces object code size
From: Jesse Brandeburg @ 2017-09-22 16:44 UTC (permalink / raw)
To: Colin King
Cc: Jeff Kirsher, intel-wired-lan, netdev, kernel-janitors,
linux-kernel, jesse.brandeburg
In-Reply-To: <20170922141138.13038-1-colin.king@canonical.com>
On Fri, 22 Sep 2017 15:11:38 +0100
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate const array patterns on the stack, instead make it
> static. Makes the object code smaller by over 60 bytes:
>
> Before:
> text data bss dec hex filename
> 1953 496 0 2449 991 i40e_diag.o
>
> After:
> text data bss dec hex filename
> 1798 584 0 2382 94e i40e_diag.o
>
> (gcc 6.3.0, x86-64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Looks good, thanks Colin!
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
^ permalink raw reply
* Re: [PATCH net-next 4/4] net: dsa: add port enable and disable helpers
From: Andrew Lunn @ 2017-09-22 16:35 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <20170922161753.19563-5-vivien.didelot@savoirfairelinux.com>
On Fri, Sep 22, 2017 at 12:17:53PM -0400, Vivien Didelot wrote:
> Provide dsa_port_enable and dsa_port_disable helpers to respectively
> enable and disable a switch port. This makes the dsa_port_set_state_now
> helper static.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 3/4] net: dsa: make slave close symmetrical to open
From: Andrew Lunn @ 2017-09-22 16:34 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <20170922161753.19563-4-vivien.didelot@savoirfairelinux.com>
On Fri, Sep 22, 2017 at 12:17:52PM -0400, Vivien Didelot wrote:
> The DSA slave open function configures the unicast MAC addresses on the
> master device, enable the switch port, change its STP state, then start
> the PHY device.
>
> Make the close function symmetric, by first stopping the PHY device,
> then changing the STP state, disabling the switch port and restore the
> master device.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 1/4] net: dsa: move up phy enabling in core
From: Andrew Lunn @ 2017-09-22 16:32 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <20170922161753.19563-2-vivien.didelot@savoirfairelinux.com>
On Fri, Sep 22, 2017 at 12:17:50PM -0400, Vivien Didelot wrote:
> bcm_sf2 is currently the only driver using the phy argument passed to
> .port_enable. It resets the state machine if the phy has been hard
> reset. This check is generic and can be moved to DSA core.
>
> dsa_port_set_state_now(p->dp, stp_state);
>
> - if (p->phy)
> - phy_start(p->phy);
> + if (phy) {
> + /* If phy_stop() has been called before, phy will be in
> + * halted state, and phy_start() will call resume.
> + *
> + * The resume path does not configure back autoneg
> + * settings, and since the internal phy may have been
> + * hard reset, we need to reset the state machine also.
> + */
> + phy->state = PHY_READY;
> + phy_init_hw(phy);
> + phy_start(phy);
> + }
Hi Vivien
If this is generic, why is it needed at all here? Shouldn't this
actually by in phylib?
Florian ?
Andrew
^ permalink raw reply
* [PATCH] Switch to use the new hashtable implementation. This reduces the code and need for yet another hashtable implementation.
From: Aaron Wood @ 2017-09-22 16:25 UTC (permalink / raw)
To: ericvh, rminnich, lucho, davem, v9fs-developer, netdev,
linux-kernel
Cc: Aaron Wood
Signed-off-by: Aaron Wood <aaronjwood@gmail.com>
---
net/9p/error.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/net/9p/error.c b/net/9p/error.c
index 126fd0dceea2..2e966fcc5cbb 100644
--- a/net/9p/error.c
+++ b/net/9p/error.c
@@ -32,6 +32,7 @@
#include <linux/module.h>
#include <linux/list.h>
#include <linux/jhash.h>
+#include <linux/hashtable.h>
#include <linux/errno.h>
#include <net/9p/9p.h>
@@ -50,8 +51,8 @@ struct errormap {
struct hlist_node list;
};
-#define ERRHASHSZ 32
-static struct hlist_head hash_errmap[ERRHASHSZ];
+#define ERR_HASH_BITS 5
+static DEFINE_HASHTABLE(hash_errmap, ERR_HASH_BITS);
/* FixMe - reduce to a reasonable size */
static struct errormap errmap[] = {
@@ -193,18 +194,14 @@ static struct errormap errmap[] = {
int p9_error_init(void)
{
struct errormap *c;
- int bucket;
-
- /* initialize hash table */
- for (bucket = 0; bucket < ERRHASHSZ; bucket++)
- INIT_HLIST_HEAD(&hash_errmap[bucket]);
+ int key;
/* load initial error map into hash table */
for (c = errmap; c->name != NULL; c++) {
c->namelen = strlen(c->name);
- bucket = jhash(c->name, c->namelen, 0) % ERRHASHSZ;
+ key = jhash(c->name, c->namelen, 0);
INIT_HLIST_NODE(&c->list);
- hlist_add_head(&c->list, &hash_errmap[bucket]);
+ hash_add(hash_errmap, &c->list, key);
}
return 1;
@@ -222,12 +219,12 @@ int p9_errstr2errno(char *errstr, int len)
{
int errno;
struct errormap *c;
- int bucket;
+ int key;
errno = 0;
c = NULL;
- bucket = jhash(errstr, len, 0) % ERRHASHSZ;
- hlist_for_each_entry(c, &hash_errmap[bucket], list) {
+ key = jhash(errstr, len, 0);
+ hash_for_each_possible(hash_errmap, c, list, key) {
if (c->namelen == len && !memcmp(c->name, errstr, len)) {
errno = c->val;
break;
--
2.11.0
^ permalink raw reply related
* Re: [PATCH net-next] bpf/verifier: improve disassembly of BPF_END instructions
From: Edward Cree @ 2017-09-22 16:23 UTC (permalink / raw)
To: Alexei Starovoitov, Y Song; +Cc: Daniel Borkmann, David Miller, netdev
In-Reply-To: <20170922151614.bg4ovrp6m27cppr7@ast-mbp>
On 22/09/17 16:16, Alexei Starovoitov wrote:
> looks like we're converging on
> "be16/be32/be64/le16/le32/le64 #register" for BPF_END.
> I guess it can live with that. I would prefer more C like syntax
> to match the rest, but llvm parsing point is a strong one.
Yep, agreed. I'll post a v2 once we've settled BPF_NEG.
> For BPG_NEG I prefer to do it in C syntax like interpreter does:
> ALU_NEG:
> DST = (u32) -DST;
> ALU64_NEG:
> DST = -DST;
> Yonghong, does it mean that asmparser will equally suffer?
Correction to my earlier statements: verifier will currently disassemble
neg as:
(87) r0 neg 0
(84) (u32) r0 neg (u32) 0
because it pretends 'neg' is a compound-assignment operator like +=.
The analogy with be16 and friends would be to use
neg64 r0
neg32 r0
whereas the analogy with everything else would be
r0 = -r0
r0 = (u32) -r0
as Alexei says.
I'm happy to go with Alexei's version if it doesn't cause problems for llvm.
^ permalink raw reply
* [PATCH net-next 4/4] net: dsa: add port enable and disable helpers
From: Vivien Didelot @ 2017-09-22 16:17 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
In-Reply-To: <20170922161753.19563-1-vivien.didelot@savoirfairelinux.com>
Provide dsa_port_enable and dsa_port_disable helpers to respectively
enable and disable a switch port. This makes the dsa_port_set_state_now
helper static.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/dsa_priv.h | 3 ++-
net/dsa/port.c | 31 ++++++++++++++++++++++++++++++-
net/dsa/slave.c | 19 +++++--------------
3 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 9803952a5b40..6bfff19d1615 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -117,7 +117,8 @@ void dsa_master_ethtool_restore(struct net_device *dev);
/* port.c */
int dsa_port_set_state(struct dsa_port *dp, u8 state,
struct switchdev_trans *trans);
-void dsa_port_set_state_now(struct dsa_port *dp, u8 state);
+int dsa_port_enable(struct dsa_port *dp);
+void dsa_port_disable(struct dsa_port *dp);
int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 76d43a82d397..50749339e252 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -56,7 +56,7 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state,
return 0;
}
-void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
+static void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
{
int err;
@@ -65,6 +65,35 @@ void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
pr_err("DSA: failed to set STP state %u (%d)\n", state, err);
}
+int dsa_port_enable(struct dsa_port *dp)
+{
+ u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
+ struct dsa_switch *ds = dp->ds;
+ int port = dp->index;
+ int err;
+
+ if (ds->ops->port_enable) {
+ err = ds->ops->port_enable(ds, port);
+ if (err)
+ return err;
+ }
+
+ dsa_port_set_state_now(dp, stp_state);
+
+ return 0;
+}
+
+void dsa_port_disable(struct dsa_port *dp)
+{
+ struct dsa_switch *ds = dp->ds;
+ int port = dp->index;
+
+ dsa_port_set_state_now(dp, BR_STATE_DISABLED);
+
+ if (ds->ops->port_disable)
+ ds->ops->port_disable(ds, port);
+}
+
int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)
{
struct dsa_notifier_bridge_info info = {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 235a5c95dfcc..e40623939323 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -74,9 +74,7 @@ static int dsa_slave_open(struct net_device *dev)
struct dsa_slave_priv *p = netdev_priv(dev);
struct phy_device *phy = p->phy;
struct dsa_port *dp = p->dp;
- struct dsa_switch *ds = dp->ds;
struct net_device *master = dsa_master_netdev(p);
- u8 stp_state = dp->bridge_dev ? BR_STATE_BLOCKING : BR_STATE_FORWARDING;
int err;
if (!(master->flags & IFF_UP))
@@ -99,13 +97,9 @@ static int dsa_slave_open(struct net_device *dev)
goto clear_allmulti;
}
- if (ds->ops->port_enable) {
- err = ds->ops->port_enable(ds, p->dp->index);
- if (err)
- goto clear_promisc;
- }
-
- dsa_port_set_state_now(p->dp, stp_state);
+ err = dsa_port_enable(dp);
+ if (err)
+ goto clear_promisc;
if (phy) {
/* If phy_stop() has been called before, phy will be in
@@ -139,15 +133,12 @@ static int dsa_slave_close(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct net_device *master = dsa_master_netdev(p);
- struct dsa_switch *ds = p->dp->ds;
+ struct dsa_port *dp = p->dp;
if (p->phy)
phy_stop(p->phy);
- dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
-
- if (ds->ops->port_disable)
- ds->ops->port_disable(ds, p->dp->index);
+ dsa_port_disable(dp);
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
--
2.14.1
^ permalink raw reply related
* [PATCH net-next 3/4] net: dsa: make slave close symmetrical to open
From: Vivien Didelot @ 2017-09-22 16:17 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
In-Reply-To: <20170922161753.19563-1-vivien.didelot@savoirfairelinux.com>
The DSA slave open function configures the unicast MAC addresses on the
master device, enable the switch port, change its STP state, then start
the PHY device.
Make the close function symmetric, by first stopping the PHY device,
then changing the STP state, disabling the switch port and restore the
master device.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/slave.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6290741e496a..235a5c95dfcc 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -144,6 +144,11 @@ static int dsa_slave_close(struct net_device *dev)
if (p->phy)
phy_stop(p->phy);
+ dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
+
+ if (ds->ops->port_disable)
+ ds->ops->port_disable(ds, p->dp->index);
+
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
if (dev->flags & IFF_ALLMULTI)
@@ -154,11 +159,6 @@ static int dsa_slave_close(struct net_device *dev)
if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_del(master, dev->dev_addr);
- if (ds->ops->port_disable)
- ds->ops->port_disable(ds, p->dp->index);
-
- dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
-
return 0;
}
--
2.14.1
^ permalink raw reply related
* [PATCH net-next 2/4] net: dsa: remove phy arg from port enable/disable
From: Vivien Didelot @ 2017-09-22 16:17 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
In-Reply-To: <20170922161753.19563-1-vivien.didelot@savoirfairelinux.com>
The .port_enable and .port_disable functions are meant to deal with the
switch ports only, and no driver is using the phy argument anyway.
Remove it.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/b53/b53_common.c | 6 +++---
drivers/net/dsa/b53/b53_priv.h | 4 ++--
drivers/net/dsa/bcm_sf2.c | 16 +++++++---------
drivers/net/dsa/lan9303-core.c | 6 ++----
drivers/net/dsa/microchip/ksz_common.c | 6 ++----
drivers/net/dsa/mt7530.c | 8 +++-----
drivers/net/dsa/mv88e6xxx/chip.c | 6 ++----
drivers/net/dsa/qca8k.c | 6 ++----
include/net/dsa.h | 6 ++----
net/dsa/slave.c | 4 ++--
10 files changed, 27 insertions(+), 41 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index d4ce092def83..e46eb29d29f0 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -502,7 +502,7 @@ void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port)
}
EXPORT_SYMBOL(b53_imp_vlan_setup);
-int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
+int b53_enable_port(struct dsa_switch *ds, int port)
{
struct b53_device *dev = ds->priv;
unsigned int cpu_port = dev->cpu_port;
@@ -531,7 +531,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
}
EXPORT_SYMBOL(b53_enable_port);
-void b53_disable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
+void b53_disable_port(struct dsa_switch *ds, int port)
{
struct b53_device *dev = ds->priv;
u8 reg;
@@ -874,7 +874,7 @@ static int b53_setup(struct dsa_switch *ds)
if (dsa_is_cpu_port(ds, port))
b53_enable_cpu_port(dev, port);
else if (!(BIT(port) & ds->enabled_port_mask))
- b53_disable_port(ds, port, NULL);
+ b53_disable_port(ds, port);
}
return ret;
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 603c66d240d8..688d02ee6155 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -311,8 +311,8 @@ int b53_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror, bool ingress);
void b53_mirror_del(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror);
-int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
-void b53_disable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
+int b53_enable_port(struct dsa_switch *ds, int port);
+void b53_disable_port(struct dsa_switch *ds, int port);
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable);
int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index ad96b9725a2c..77e0c43f973b 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -159,8 +159,7 @@ static inline void bcm_sf2_port_intr_disable(struct bcm_sf2_priv *priv,
intrl2_1_writel(priv, P_IRQ_MASK(off), INTRL2_CPU_CLEAR);
}
-static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static int bcm_sf2_port_setup(struct dsa_switch *ds, int port)
{
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
unsigned int i;
@@ -191,11 +190,10 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
if (port == priv->moca_port)
bcm_sf2_port_intr_enable(priv, port);
- return b53_enable_port(ds, port, phy);
+ return b53_enable_port(ds, port);
}
-static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static void bcm_sf2_port_disable(struct dsa_switch *ds, int port)
{
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
u32 off, reg;
@@ -214,7 +212,7 @@ static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
else
off = CORE_G_PCTL_PORT(port);
- b53_disable_port(ds, port, phy);
+ b53_disable_port(ds, port);
/* Power down the port memory */
reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
@@ -613,7 +611,7 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
for (port = 0; port < DSA_MAX_PORTS; port++) {
if ((1 << port) & ds->enabled_port_mask ||
dsa_is_cpu_port(ds, port))
- bcm_sf2_port_disable(ds, port, NULL);
+ bcm_sf2_port_disable(ds, port);
}
return 0;
@@ -636,7 +634,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
for (port = 0; port < DSA_MAX_PORTS; port++) {
if ((1 << port) & ds->enabled_port_mask)
- bcm_sf2_port_setup(ds, port, NULL);
+ bcm_sf2_port_setup(ds, port);
else if (dsa_is_cpu_port(ds, port))
bcm_sf2_imp_setup(ds, port);
}
@@ -745,7 +743,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
if (dsa_is_cpu_port(ds, port))
bcm_sf2_imp_setup(ds, port);
else if (!((1 << port) & ds->enabled_port_mask))
- bcm_sf2_port_disable(ds, port, NULL);
+ bcm_sf2_port_disable(ds, port);
}
bcm_sf2_sw_configure_vlan(ds);
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 07355db2ad81..0c33b02562dc 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -799,8 +799,7 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
}
}
-static int lan9303_port_enable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static int lan9303_port_enable(struct dsa_switch *ds, int port)
{
struct lan9303 *chip = ds->priv;
@@ -817,8 +816,7 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
return -ENODEV;
}
-static void lan9303_port_disable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static void lan9303_port_disable(struct dsa_switch *ds, int port)
{
struct lan9303 *chip = ds->priv;
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 56cd6d365352..4095c50ae111 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -418,8 +418,7 @@ static int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
return 0;
}
-static int ksz_enable_port(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static int ksz_enable_port(struct dsa_switch *ds, int port)
{
struct ksz_device *dev = ds->priv;
@@ -429,8 +428,7 @@ static int ksz_enable_port(struct dsa_switch *ds, int port,
return 0;
}
-static void ksz_disable_port(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+static void ksz_disable_port(struct dsa_switch *ds, int port)
{
struct ksz_device *dev = ds->priv;
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index faa3b88d2206..0a7f6209767f 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -693,8 +693,7 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,
}
static int
-mt7530_port_enable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+mt7530_port_enable(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;
@@ -719,8 +718,7 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
}
static void
-mt7530_port_disable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+mt7530_port_disable(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;
@@ -1006,7 +1004,7 @@ mt7530_setup(struct dsa_switch *ds)
if (dsa_is_cpu_port(ds, i))
mt7530_cpu_port_enable(priv, i);
else
- mt7530_port_disable(ds, i, NULL);
+ mt7530_port_disable(ds, i);
}
/* Flush the FDB table */
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index c6678aa9b4ef..e47898fb7dbc 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1862,8 +1862,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
}
-static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
- struct phy_device *phydev)
+static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;
@@ -1875,8 +1874,7 @@ static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
return err;
}
-static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
- struct phy_device *phydev)
+static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
{
struct mv88e6xxx_chip *chip = ds->priv;
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 82f09711ac1a..622ee9b8e72b 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -743,8 +743,7 @@ qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br)
}
static int
-qca8k_port_enable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+qca8k_port_enable(struct dsa_switch *ds, int port)
{
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
@@ -755,8 +754,7 @@ qca8k_port_enable(struct dsa_switch *ds, int port,
}
static void
-qca8k_port_disable(struct dsa_switch *ds, int port,
- struct phy_device *phy)
+qca8k_port_disable(struct dsa_switch *ds, int port)
{
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 8dee216a5a9b..65b031a69c19 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -337,10 +337,8 @@ struct dsa_switch_ops {
/*
* Port enable/disable
*/
- int (*port_enable)(struct dsa_switch *ds, int port,
- struct phy_device *phy);
- void (*port_disable)(struct dsa_switch *ds, int port,
- struct phy_device *phy);
+ int (*port_enable)(struct dsa_switch *ds, int port);
+ void (*port_disable)(struct dsa_switch *ds, int port);
/*
* Port's MAC EEE settings
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 606812160fd5..6290741e496a 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -100,7 +100,7 @@ static int dsa_slave_open(struct net_device *dev)
}
if (ds->ops->port_enable) {
- err = ds->ops->port_enable(ds, p->dp->index, p->phy);
+ err = ds->ops->port_enable(ds, p->dp->index);
if (err)
goto clear_promisc;
}
@@ -155,7 +155,7 @@ static int dsa_slave_close(struct net_device *dev)
dev_uc_del(master, dev->dev_addr);
if (ds->ops->port_disable)
- ds->ops->port_disable(ds, p->dp->index, p->phy);
+ ds->ops->port_disable(ds, p->dp->index);
dsa_port_set_state_now(p->dp, BR_STATE_DISABLED);
--
2.14.1
^ permalink raw reply related
* [PATCH net-next 1/4] net: dsa: move up phy enabling in core
From: Vivien Didelot @ 2017-09-22 16:17 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
In-Reply-To: <20170922161753.19563-1-vivien.didelot@savoirfairelinux.com>
bcm_sf2 is currently the only driver using the phy argument passed to
.port_enable. It resets the state machine if the phy has been hard
reset. This check is generic and can be moved to DSA core.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/bcm_sf2.c | 16 +---------------
net/dsa/slave.c | 15 +++++++++++++--
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 898d5642b516..ad96b9725a2c 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -184,22 +184,8 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port));
/* Re-enable the GPHY and re-apply workarounds */
- if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
+ if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1)
bcm_sf2_gphy_enable_set(ds, true);
- if (phy) {
- /* if phy_stop() has been called before, phy
- * will be in halted state, and phy_start()
- * will call resume.
- *
- * the resume path does not configure back
- * autoneg settings, and since we hard reset
- * the phy manually here, we need to reset the
- * state machine also.
- */
- phy->state = PHY_READY;
- phy_init_hw(phy);
- }
- }
/* Enable MoCA port interrupts to get notified */
if (port == priv->moca_port)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 02ace7d462c4..606812160fd5 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -72,6 +72,7 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
static int dsa_slave_open(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
+ struct phy_device *phy = p->phy;
struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds;
struct net_device *master = dsa_master_netdev(p);
@@ -106,8 +107,18 @@ static int dsa_slave_open(struct net_device *dev)
dsa_port_set_state_now(p->dp, stp_state);
- if (p->phy)
- phy_start(p->phy);
+ if (phy) {
+ /* If phy_stop() has been called before, phy will be in
+ * halted state, and phy_start() will call resume.
+ *
+ * The resume path does not configure back autoneg
+ * settings, and since the internal phy may have been
+ * hard reset, we need to reset the state machine also.
+ */
+ phy->state = PHY_READY;
+ phy_init_hw(phy);
+ phy_start(phy);
+ }
return 0;
--
2.14.1
^ permalink raw reply related
* [PATCH net-next 0/4] net: dsa: simplify port enabling
From: Vivien Didelot @ 2017-09-22 16:17 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
This patchset removes the unnecessary PHY device argument in port
enable/disable switch operations, makes slave open and close symmetrical
and finally provides helpers for enabling or disabling a DSA port.
Vivien Didelot (4):
net: dsa: move up phy enabling in core
net: dsa: remove phy arg from port enable/disable
net: dsa: make slave close symmetrical to open
net: dsa: add port enable and disable helpers
drivers/net/dsa/b53/b53_common.c | 6 +++---
drivers/net/dsa/b53/b53_priv.h | 4 ++--
drivers/net/dsa/bcm_sf2.c | 32 ++++++++----------------------
drivers/net/dsa/lan9303-core.c | 6 ++----
drivers/net/dsa/microchip/ksz_common.c | 6 ++----
drivers/net/dsa/mt7530.c | 8 +++-----
drivers/net/dsa/mv88e6xxx/chip.c | 6 ++----
drivers/net/dsa/qca8k.c | 6 ++----
include/net/dsa.h | 6 ++----
net/dsa/dsa_priv.h | 3 ++-
net/dsa/port.c | 31 ++++++++++++++++++++++++++++-
net/dsa/slave.c | 36 ++++++++++++++++++----------------
12 files changed, 77 insertions(+), 73 deletions(-)
--
2.14.1
^ permalink raw reply
* Re: [PATCH net v2] l2tp: fix race condition in l2tp_tunnel_delete
From: Sabrina Dubroca @ 2017-09-22 16:16 UTC (permalink / raw)
To: Guillaume Nault; +Cc: netdev, Xin Long, Tom Parkin
In-Reply-To: <20170919164337.zn3p6ikwsgnw7ba6@alphalink.fr>
2017-09-19, 18:43:37 +0200, Guillaume Nault wrote:
> On Tue, Sep 19, 2017 at 03:40:40PM +0200, Sabrina Dubroca wrote:
> > If we try to delete the same tunnel twice, the first delete operation
> > does a lookup (l2tp_tunnel_get), finds the tunnel, calls
> > l2tp_tunnel_delete, which queues it for deletion by
> > l2tp_tunnel_del_work.
> >
> > The second delete operation also finds the tunnel and calls
> > l2tp_tunnel_delete. If the workqueue has already fired and started
> > running l2tp_tunnel_del_work, then l2tp_tunnel_delete will queue the
> > same tunnel a second time, and try to free the socket again.
> >
> > Add a dead flag to prevent firing the workqueue twice. Then we can
> > remove the check of queue_work's result that was meant to prevent that
> > race but doesn't.
> >
> > Also check the flag in the tunnel lookup functions, to avoid returning a
> > tunnel that is already scheduled for destruction.
> >
> > Reproducer:
> >
> > ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 local 192.168.0.2 remote 192.168.0.1 encap udp udp_sport 5000 udp_dport 6000
> > ip l2tp add session name l2tp1 tunnel_id 3000 session_id 1000 peer_session_id 2000
> > ip link set l2tp1 up
> > ip l2tp del tunnel tunnel_id 3000
> > ip l2tp del tunnel tunnel_id 3000
> >
> > Fixes: f8ccac0e4493 ("l2tp: put tunnel socket release on a workqueue")
> > Reported-by: Jianlin Shi <jishi@redhat.com>
> > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > ---
> > v2: as Tom Parkin explained, we can't remove the tunnel from the
> > per-net list from netlink. v2 uses only a dead flag, and adds
> > corresponding checks during lookups
> >
> > net/l2tp/l2tp_core.c | 18 +++++++++---------
> > net/l2tp/l2tp_core.h | 5 ++++-
> > 2 files changed, 13 insertions(+), 10 deletions(-)
> >
> > diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> > index ee485df73ccd..3891f0260f2b 100644
> > --- a/net/l2tp/l2tp_core.c
> > +++ b/net/l2tp/l2tp_core.c
> > @@ -203,7 +203,8 @@ struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id)
> >
> > rcu_read_lock_bh();
> > list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
> > - if (tunnel->tunnel_id == tunnel_id) {
> > + if (tunnel->tunnel_id == tunnel_id &&
> > + !test_bit(0, &tunnel->dead)) {
> > l2tp_tunnel_inc_refcount(tunnel);
> > rcu_read_unlock_bh();
> >
> > @@ -390,7 +391,8 @@ struct l2tp_tunnel *l2tp_tunnel_find(const struct net *net, u32 tunnel_id)
> >
> > rcu_read_lock_bh();
> > list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
> > - if (tunnel->tunnel_id == tunnel_id) {
> > + if (tunnel->tunnel_id == tunnel_id &&
> > + !test_bit(0, &tunnel->dead)) {
> > rcu_read_unlock_bh();
> > return tunnel;
> > }
> > @@ -409,7 +411,7 @@ struct l2tp_tunnel *l2tp_tunnel_find_nth(const struct net *net, int nth)
> >
> > rcu_read_lock_bh();
> > list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
> > - if (++count > nth) {
> > + if (++count > nth && !test_bit(0, &tunnel->dead)) {
> > rcu_read_unlock_bh();
> > return tunnel;
> > }
> >
> I don't get why you're checking the dead flag in l2tp_tunnel_{get,find}*().
> Since it can be set concurrently right after test_bit(), it doesn't
> protect the caller from getting a tunnel that is being removed by
> l2tp_tunnel_delete().
> Or have I missed something?
You're right.
Then I would try going back to essentially v1, but keeping code to
remove the tunnel from the list in l2tp_tunnel_destruct if it's not
dead yet.
What do you think?
-------- 8< --------
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index ee485df73ccd..63cd1f30ac7d 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1234,6 +1234,23 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
}
EXPORT_SYMBOL_GPL(l2tp_xmit_skb);
+static bool __l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
+{
+ struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
+ bool ret = false;
+
+ spin_lock_bh(&pn->l2tp_tunnel_list_lock);
+ if (!tunnel->dead) {
+ tunnel->dead = 1;
+ list_del_rcu(&tunnel->list);
+ atomic_dec(&l2tp_tunnel_count);
+ ret = true;
+ }
+ spin_unlock_bh(&pn->l2tp_tunnel_list_lock);
+
+ return ret;
+}
+
/*****************************************************************************
* Tinnel and session create/destroy.
*****************************************************************************/
@@ -1245,7 +1262,6 @@ EXPORT_SYMBOL_GPL(l2tp_xmit_skb);
static void l2tp_tunnel_destruct(struct sock *sk)
{
struct l2tp_tunnel *tunnel = l2tp_tunnel(sk);
- struct l2tp_net *pn;
if (tunnel == NULL)
goto end;
@@ -1270,11 +1286,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
sk->sk_user_data = NULL;
/* Remove the tunnel struct from the tunnel list */
- pn = l2tp_pernet(tunnel->l2tp_net);
- spin_lock_bh(&pn->l2tp_tunnel_list_lock);
- list_del_rcu(&tunnel->list);
- spin_unlock_bh(&pn->l2tp_tunnel_list_lock);
- atomic_dec(&l2tp_tunnel_count);
+ __l2tp_tunnel_delete(tunnel);
l2tp_tunnel_closeall(tunnel);
@@ -1685,14 +1697,12 @@ EXPORT_SYMBOL_GPL(l2tp_tunnel_create);
/* This function is used by the netlink TUNNEL_DELETE command.
*/
-int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
+void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel)
{
- l2tp_tunnel_inc_refcount(tunnel);
- if (false == queue_work(l2tp_wq, &tunnel->del_work)) {
- l2tp_tunnel_dec_refcount(tunnel);
- return 1;
+ if (__l2tp_tunnel_delete(tunnel)) {
+ l2tp_tunnel_inc_refcount(tunnel);
+ queue_work(l2tp_wq, &tunnel->del_work);
}
- return 0;
}
EXPORT_SYMBOL_GPL(l2tp_tunnel_delete);
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
index a305e0c5925a..173e68bb8119 100644
--- a/net/l2tp/l2tp_core.h
+++ b/net/l2tp/l2tp_core.h
@@ -160,6 +160,8 @@ struct l2tp_tunnel_cfg {
struct l2tp_tunnel {
int magic; /* Should be L2TP_TUNNEL_MAGIC */
+ int dead;
+
struct rcu_head rcu;
rwlock_t hlist_lock; /* protect session_hlist */
bool acpt_newsess; /* Indicates whether this
@@ -254,7 +256,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id,
u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg,
struct l2tp_tunnel **tunnelp);
void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel);
-int l2tp_tunnel_delete(struct l2tp_tunnel *tunnel);
+void l2tp_tunnel_delete(struct l2tp_tunnel *tunnel);
struct l2tp_session *l2tp_session_create(int priv_size,
struct l2tp_tunnel *tunnel,
u32 session_id, u32 peer_session_id,
--
Sabrina
^ permalink raw reply related
* URGENT RESPOND NEEDED FROM YOU BY DANIEL MMINELE THE DEPUTY GOVERNOR OF SOUTH AFRICAN RESERVE BANK
From: Mrs, Suran Yoda @ 2017-09-22 16:06 UTC (permalink / raw)
Hello Dear,
My Name is Dr. Daniel Mminele the deputy governor of south African
reserve bank, you can also check on our Bank website here for your
assurance , http://www.whoswhosa.co.za/south-african-reserve-bank-20991
I am a citizen of South African. I am a computer analyst long time
working with reserve Bank of South African. (R.B.) My Dear, I came
across your payment file which was Marked X and your Fund Release Hard
Disk Painted Red, I took my time to study your payment file and found
out that you have really attempted to receive the funds without
success till now. But I am using another person email address to send
you this because I don’t want my bank to notify me alright
The most annoying thing is that the directors and top officials of
this nation could not tell you the truth that on no account will they
ever release the fund to you; instead they will let you spend money
unnecessarily. I swear with my life, I can release this funds to you
if you can certify me of my security and how I can run away from this
country to meet with you. This is like a Mafia Setting here, if I do
this for you, I do not intend to work here all the days of my life and
I cannot run back to my country as this Bank has my home address ,
and if I don't run away after I making the transfer to your bank
account, I may be in trouble or my life will be in danger.
The only thing I will need to release this fund is a Special Hard
Disk, we call it HD120 GIG. I will buy two of it, recopy your
information, destroy the previous one, and punch the computer to make
the fund reflect in your bank account within 24 banking hours. I will
clean up the tracer and destroy your file, after which I will run away
from here to meet with you in your country if you are interested. But
you must assure me the absolute confidentiality of this deal before I
can do anything further. Do get in touch with me immediately, You
should send to me your convenient
Tell phone number /fax numbers for easy communications and also re
confirm your banking
details, so that there won't be any mistake.
For phone conversation, please call me on +27011745039 or
+27843464227, And you must contact me though this my Email address
which is, danielmminele1@yahoo.com
SPECIAL INFORMATION:
YOU WILL SEND THE FEE FOR THE HARD DISK FIRST BEFORE I MAKE YOUR
TRANSFER OR YOU BUY
THE HARD DISK IN YOUR COUNTRY AND SEND IT TO ME,DON'T CONTACT ME IF
YOU CAN NOT SEND
THE HARD DISK FEE FIRST OR THE HARD DISK. AS SOON AS I RECEIVED YOUR
EMAIL I WILL LET
YOU KNOW HOW MUCH THE DISK WILL COST YOU.
Regards, Dr. Daniel Mminele the deputy governor of south African reserve bank
^ permalink raw reply
* Re: [PATCH net-next 10/10] net: hns3: Add mqprio support when interacting with network stack
From: Jiri Pirko @ 2017-09-22 16:03 UTC (permalink / raw)
To: linyunsheng
Cc: davem@davemloft.net, huangdaode, xuwei (O), Liguozhu (Kenneth),
Zhuangyuzeng (Yisen), Gabriele Paoloni, John Garry, Linuxarm,
Salil Mehta, lipeng (Y), netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <59c51a37.a1c4df0a.ac4e2.8df0SMTPIN_ADDED_BROKEN@mx.google.com>
Fri, Sep 22, 2017 at 04:11:51PM CEST, linyunsheng@huawei.com wrote:
>Hi, Jiri
>
>>>- if (!tc) {
>>>+ if (if_running) {
>>>+ (void)hns3_nic_net_stop(netdev);
>>>+ msleep(100);
>>>+ }
>>>+
>>>+ ret = (kinfo->dcb_ops && kinfo->dcb_ops->>setup_tc) ?
>>>+ kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : ->EOPNOTSUPP;
>
>>This is most odd. Why do you call dcb_ops from >ndo_setup_tc callback?
>>Why are you mixing this together? prio->tc mapping >can be done
>>directly in dcbnl
>
>Here is what we do in dcb_ops->setup_tc:
>Firstly, if current tc num is different from the tc num
>that user provide, then we setup the queues for each
>tc.
>
>Secondly, we tell hardware the pri to tc mapping that
>the stack is using. In rx direction, our hardware need
>that mapping to put different packet into different tc'
>queues according to the priority of the packet, then
>rss decides which specific queue in the tc should the
>packet goto.
>
>By mixing, I suppose you meant why we need the
>pri to tc infomation?
by mixing, I mean what I wrote. You are calling dcb_ops callback from
ndo_setup_tc callback. So you are mixing DCBNL subsystem and TC
subsystem. Why? Why do you need sch_mqprio? Why DCBNL is not enough for
all?
>I hope I did not misunderstand your question, thanks
>for your time reviewing.
^ permalink raw reply
* RE: [PATCH] hv_netvsc: make const array ver_list static, reduces object code size
From: Haiyang Zhang @ 2017-09-22 16:00 UTC (permalink / raw)
To: Colin King, KY Srinivasan, Stephen Hemminger,
devel@linuxdriverproject.org, netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20170922155023.15821-1-colin.king@canonical.com>
> -----Original Message-----
> From: Colin King [mailto:colin.king@canonical.com]
> Sent: Friday, September 22, 2017 8:50 AM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>;
> devel@linuxdriverproject.org; netdev@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] hv_netvsc: make const array ver_list static, reduces
> object code size
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate const array ver_list on the stack, instead make it
> static. Makes the object code smaller by over 400 bytes:
>
> Before:
> text data bss dec hex filename
> 18444 3168 320 21932 55ac
> drivers/net/hyperv/netvsc.o
>
> After:
> text data bss dec hex filename
> 17950 3224 320 21494 53f6
> drivers/net/hyperv/netvsc.o
>
> (gcc 6.3.0, x86-64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
^ permalink raw reply
* [net-next] net: remove MTU limits for dummy and ifb device
From: Zhang Shengju @ 2017-09-22 15:57 UTC (permalink / raw)
To: davem, sd, edumazet, netdev
These two drivers (dummy and ifb) call ether_setup(), after commit
61e84623ace3 ("net: centralize net_device min/max MTU checking"), the
range of mtu is [min_mtu, max_mtu], which is [68, 1500] by default.
These two devices should not have limits on MTU. This patch set their
min_mtu/max_mtu to 0. So that dev_set_mtu() will not check the mtu range,
and can be set with any value.
CC: Eric Dumazet <edumazet@google.com>
CC: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
drivers/net/dummy.c | 2 +-
drivers/net/ifb.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index e31ab3b..58483af 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -353,7 +353,7 @@ static void dummy_setup(struct net_device *dev)
eth_hw_addr_random(dev);
dev->min_mtu = 0;
- dev->max_mtu = ETH_MAX_MTU;
+ dev->max_mtu = 0;
}
static int dummy_validate(struct nlattr *tb[], struct nlattr *data[],
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 8870bd2..0008da7 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -231,6 +231,9 @@ static void ifb_setup(struct net_device *dev)
eth_hw_addr_random(dev);
dev->needs_free_netdev = true;
dev->priv_destructor = ifb_dev_free;
+
+ dev->min_mtu = 0;
+ dev->max_mtu = 0;
}
static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
--
1.8.3.1
^ permalink raw reply related
* [PATCH] hv_netvsc: make const array ver_list static, reduces object code size
From: Colin King @ 2017-09-22 15:50 UTC (permalink / raw)
To: K . Y . Srinivasan, Haiyang Zhang, Stephen Hemminger, devel,
netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate const array ver_list on the stack, instead make it
static. Makes the object code smaller by over 400 bytes:
Before:
text data bss dec hex filename
18444 3168 320 21932 55ac drivers/net/hyperv/netvsc.o
After:
text data bss dec hex filename
17950 3224 320 21494 53f6 drivers/net/hyperv/netvsc.o
(gcc 6.3.0, x86-64)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/hyperv/netvsc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8d5077fb0492..b0d323e24978 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -484,7 +484,7 @@ static int netvsc_connect_vsp(struct hv_device *device,
struct netvsc_device *net_device,
const struct netvsc_device_info *device_info)
{
- const u32 ver_list[] = {
+ static const u32 ver_list[] = {
NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
};
--
2.14.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox