* [PATCH v2 6/7] usbnet: smsc95xx: don't recover device if suspend fails in system sleep
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei, Steve Glendinning
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei@canonical.com>
If suspend callback fails in system sleep context, usb core will
ignore the failure and let system sleep go ahead further, so
this patch doesn't recover device under this situation.
Also add comments on the case.
Cc: Steve Glendinning <steve.glendinning@shawell.net>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/smsc95xx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index e6d2dea..3f38ba8 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1660,7 +1660,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
ret = smsc95xx_enter_suspend0(dev);
done:
- if (ret)
+ /*
+ * TODO: resume() might need to handle the suspend failure
+ * in system sleep
+ */
+ if (ret && PMSG_IS_AUTO(message))
usbnet_resume(intf);
return ret;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 5/7] usbnet: qmi_wwan: comments on suspend failure
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Ming Lei, Bjørn Mork
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
If suspend callback fails in system sleep context, usb core will
ignore the failure and let system sleep go ahead further, so
this patch comments on the case and requires that both
usbnet_suspend() and subdriver->suspend() MUST return 0 in
system sleep context.
Cc: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/net/usb/qmi_wwan.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index efb5c7c..8a60bdd 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -288,6 +288,11 @@ static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
struct qmi_wwan_state *info = (void *)&dev->data;
int ret;
+ /*
+ * Both usbnet_suspend() and subdriver->suspend() MUST return 0
+ * in system sleep context, otherwise, the resume callback has
+ * to recover device from previous suspend failure.
+ */
ret = usbnet_suspend(intf, message);
if (ret < 0)
goto err;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v2 4/7] usbnet: cdc_mbim: comments on suspend failure
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Ming Lei, Bjørn Mork
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
If suspend callback fails in system sleep context, usb core will
ignore the failure and let system sleep go ahead further, so
this patch comments on the case and requires that both
usbnet_suspend() and subdriver->suspend() MUST return 0 in
system sleep context.
Cc: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/net/usb/cdc_mbim.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 248d2dc..406a34d 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -332,6 +332,11 @@ static int cdc_mbim_suspend(struct usb_interface *intf, pm_message_t message)
goto error;
}
+ /*
+ * Both usbnet_suspend() and subdriver->suspend() MUST return 0
+ * in system sleep context, otherwise, the resume callback has
+ * to recover device from previous suspend failure.
+ */
ret = usbnet_suspend(intf, message);
if (ret < 0)
goto error;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v2 3/7] USBHID: don't recover device if suspend fails in system sleep
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei@canonical.com>
If suspend callback fails in system sleep context, usb core will
ignore the failure and let the system sleep go ahead further, so this
patch doesn't recover device under this situation, otherwise
may cause resume() confused.
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/hid/usbhid/hid-core.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 8e0c4bf94..1f9e56b 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1493,7 +1493,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
{
struct hid_device *hid = usb_get_intfdata(intf);
struct usbhid_device *usbhid = hid->driver_data;
- int status;
+ int status = 0;
bool driver_suspended = false;
if (PMSG_IS_AUTO(message)) {
@@ -1520,19 +1520,15 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
}
} else {
- if (hid->driver && hid->driver->suspend) {
+ /* TODO: resume() might need to handle suspend failure */
+ if (hid->driver && hid->driver->suspend)
status = hid->driver->suspend(hid, message);
- if (status < 0)
- return status;
- }
driver_suspended = true;
spin_lock_irq(&usbhid->lock);
set_bit(HID_SUSPENDED, &usbhid->iofl);
spin_unlock_irq(&usbhid->lock);
- if (usbhid_wait_io(hid) < 0) {
+ if (usbhid_wait_io(hid) < 0)
status = -EIO;
- goto failed;
- }
}
hid_cancel_delayed_stuff(usbhid);
@@ -1544,7 +1540,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
goto failed;
}
dev_dbg(&intf->dev, "suspend\n");
- return 0;
+ return status;
failed:
hid_resume_common(hid, driver_suspended);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei, Johan Hovold
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei@canonical.com>
This patch kills traffic even though type->suspend returns
failure inside usb_serial_suspend from system sleep context
because USB core ignores the failiure and lets system sleep
go ahread, so the serial URB traffic need to be killed
in this case.
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/serial/usb-serial.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a19ed74..9d0b9c8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
if (serial->type->suspend) {
r = serial->type->suspend(serial, message);
- if (r < 0) {
+ if (r < 0 && PMSG_IS_AUTO(message)) {
serial->suspending = 0;
goto err_out;
}
+ /* TODO: resume() might need to handle suspend failure */
}
for (i = 0; i < serial->num_ports; ++i) {
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/7] USB: adds comment on suspend callback
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Ming Lei
In-Reply-To: <1362672924-22975-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case and let resume/reset_resume callback
handle the suspend failure if needed.
Also kerneldoc for usb_suspend_both() is updated with the
fact.
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/usb/core/driver.c | 11 ++++++++---
include/linux/usb.h | 7 ++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d938b2b..eb1d00a 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1196,9 +1196,14 @@ done:
*
* This is the central routine for suspending USB devices. It calls the
* suspend methods for all the interface drivers in @udev and then calls
- * the suspend method for @udev itself. If an error occurs at any stage,
- * all the interfaces which were suspended are resumed so that they remain
- * in the same state as the device.
+ * the suspend method for @udev itself. When the routine is called in
+ * autosuspend, if an error occurs at any stage, all the interfaces
+ * which were suspended are resumed so that they remain in the same
+ * state as the device, but when called from system sleep, all error
+ * from suspend methods of interfaces and the non-root-hub device itself
+ * are simply ignored, so all suspended interfaces are only resumed
+ * to the device's state when @udev is root-hub and its suspend method
+ * returns failure.
*
* Autosuspend requests originating from a child device or an interface
* driver may be made without the protection of @udev's device lock, but
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 4d22d0f..f82ce57 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -978,7 +978,12 @@ struct usbdrv_wrap {
* the "usbfs" filesystem. This lets devices provide ways to
* expose information to user space regardless of where they
* do (or don't) show up otherwise in the filesystem.
- * @suspend: Called when the device is going to be suspended by the system.
+ * @suspend: Called when the device is going to be suspended by the
+ * system either from system sleep or runtime suspend context. The
+ * return value will be ignored in system sleep context, so do NOT
+ * try to continue using the device if suspend fails in this case.
+ * Instead, let the resume or reset-resume routine recover from
+ * the failure.
* @resume: Called when the device is being resumed by the system.
* @reset_resume: Called when the suspended device has been reset instead
* of being resumed.
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v2 0/7] USB: don't recover device if suspend fails in system sleep
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input
Hi,
Sorry for my broken email client just now.
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case, otherwise the recovery things may confuse
resume().
Also fixes the USB serial, HID and several usbnet drivers
which may recover device in suspend failure path of system sleep.
v2:
- improve comments on suspend callback as suggested by Alan
- update kerneldoc for usb_suspend_both as suggested by Alan
- remove previous check of PMSG_IS_AUTO(message) in cdc_mbim/
qmi_wwan and add comments on suspend failure case, since Bjørn
doesn't like the check.
- add comments on smsc95xx/smsc75xx
v1:
- fix compile failure
- add comments about handling suspend failure in resume()
drivers/hid/usbhid/hid-core.c | 14 +++++---------
drivers/net/usb/cdc_mbim.c | 5 +++++
drivers/net/usb/qmi_wwan.c | 5 +++++
drivers/net/usb/smsc75xx.c | 6 +++++-
drivers/net/usb/smsc95xx.c | 6 +++++-
drivers/usb/core/driver.c | 11 ++++++++---
drivers/usb/serial/usb-serial.c | 3 ++-
include/linux/usb.h | 7 ++++++-
8 files changed, 41 insertions(+), 16 deletions(-)
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 2/3] arm: dts: am33xx: add default ethtool slave to cpsw node
From: Tony Lindgren @ 2013-03-07 16:13 UTC (permalink / raw)
To: Mugunthan V N; +Cc: netdev, devicetree-discuss, linux-omap, davem
In-Reply-To: <1362659421-11884-3-git-send-email-mugunthanvnm@ti.com>
* Mugunthan V N <mugunthanvnm@ti.com> [130307 04:35]:
Can you please add a description and send this separately
so Benoit can queue it.
Thanks,
Tony
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
> arch/arm/boot/dts/am33xx.dtsi | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
> index 0957645..f8c83a1 100644
> --- a/arch/arm/boot/dts/am33xx.dtsi
> +++ b/arch/arm/boot/dts/am33xx.dtsi
> @@ -352,6 +352,7 @@
> cpts_active_slave = <0>;
> cpts_clock_mult = <0x80000000>;
> cpts_clock_shift = <29>;
> + ethtool-active-slave = <0>;
> reg = <0x4a100000 0x800
> 0x4a101200 0x100>;
> #address-cells = <1>;
> --
> 1.7.9.5
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply
* [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei, Johan Hovold
In-Reply-To: <1362672472-22680-1-git-send-email-ming.lei@canonical.com>
This patch kills traffic even though type->suspend returns
failure inside usb_serial_suspend from system sleep context
because USB core ignores the failiure and lets system sleep
go ahread, so the serial URB traffic need to be killed
in this case.
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/serial/usb-serial.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a19ed74..9d0b9c8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
if (serial->type->suspend) {
r = serial->type->suspend(serial, message);
- if (r < 0) {
+ if (r < 0 && PMSG_IS_AUTO(message)) {
serial->suspending = 0;
goto err_out;
}
+ /* TODO: resume() might need to handle suspend failure */
}
for (i = 0; i < serial->num_ports; ++i) {
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/7] USB: adds comment on suspend callback
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei
In-Reply-To: <1362672472-22680-1-git-send-email-ming.lei@canonical.com>
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case and let resume/reset_resume callback
handle the suspend failure if needed.
Also kerneldoc for usb_suspend_both() is updated with the
fact.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/core/driver.c | 11 ++++++++---
include/linux/usb.h | 7 ++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d938b2b..eb1d00a 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1196,9 +1196,14 @@ done:
*
* This is the central routine for suspending USB devices. It calls the
* suspend methods for all the interface drivers in @udev and then calls
- * the suspend method for @udev itself. If an error occurs at any stage,
- * all the interfaces which were suspended are resumed so that they remain
- * in the same state as the device.
+ * the suspend method for @udev itself. When the routine is called in
+ * autosuspend, if an error occurs at any stage, all the interfaces
+ * which were suspended are resumed so that they remain in the same
+ * state as the device, but when called from system sleep, all error
+ * from suspend methods of interfaces and the non-root-hub device itself
+ * are simply ignored, so all suspended interfaces are only resumed
+ * to the device's state when @udev is root-hub and its suspend method
+ * returns failure.
*
* Autosuspend requests originating from a child device or an interface
* driver may be made without the protection of @udev's device lock, but
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 4d22d0f..f82ce57 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -978,7 +978,12 @@ struct usbdrv_wrap {
* the "usbfs" filesystem. This lets devices provide ways to
* expose information to user space regardless of where they
* do (or don't) show up otherwise in the filesystem.
- * @suspend: Called when the device is going to be suspended by the system.
+ * @suspend: Called when the device is going to be suspended by the
+ * system either from system sleep or runtime suspend context. The
+ * return value will be ignored in system sleep context, so do NOT
+ * try to continue using the device if suspend fails in this case.
+ * Instead, let the resume or reset-resume routine recover from
+ * the failure.
* @resume: Called when the device is being resumed by the system.
* @reset_resume: Called when the suspended device has been reset instead
* of being resumed.
--
1.7.9.5
^ permalink raw reply related
* (unknown),
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input
Hi,
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case, otherwise the recovery things may confuse
resume().
Also fixes the USB serial, HID and several usbnet drivers
which may recover device in suspend failure path of system sleep.
v2:
- improve comments on suspend callback as suggested by Alan
- update kerneldoc for usb_suspend_both as suggested by Alan
- remove previous check of PMSG_IS_AUTO(message) in cdc_mbim/
qmi_wwan and add comments on suspend failure case, since Bjørn
doesn't like the check.
- add comments on smsc95xx/smsc75xx
v1:
- fix compile failure
- add comments about handling suspend failure in resume()
drivers/hid/usbhid/hid-core.c | 14 +++++---------
drivers/net/usb/cdc_mbim.c | 5 +++++
drivers/net/usb/qmi_wwan.c | 5 +++++
drivers/net/usb/smsc75xx.c | 6 +++++-
drivers/net/usb/smsc95xx.c | 6 +++++-
drivers/usb/core/driver.c | 11 ++++++++---
drivers/usb/serial/usb-serial.c | 3 ++-
include/linux/usb.h | 7 ++++++-
8 files changed, 41 insertions(+), 16 deletions(-)
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] 8139too: send NETDEV_CHANGE manually when autoneg is disabled
From: Ben Hutchings @ 2013-03-07 15:52 UTC (permalink / raw)
To: Veaceslav Falico
Cc: David Miller, netdev, wfp5p, jasowang, junchangwang, greearb,
ivecera
In-Reply-To: <20130307102740.GB31105@redhat.com>
On Thu, 2013-03-07 at 11:27 +0100, Veaceslav Falico wrote:
> On Wed, Mar 06, 2013 at 03:53:23PM -0500, David Miller wrote:
> >From: Ben Hutchings <bhutchings@solarflare.com>
> >Date: Wed, 6 Mar 2013 20:22:52 +0000
> >
> >> On Wed, 2013-03-06 at 20:06 +0100, Veaceslav Falico wrote:
> >>> When setting autoneg off (with any additional parameters, like
> >>> speed/duplex), 8139too doesn't do an interface reset, and thus doesn't
> >>> notify anyone that its speed/duplex might have changed (bonding and bridge
> >>> will not see the speed changes, per example).
> >>>
> >>> Verify if we've force_media and send notification manually, so that the
> >>> listeners have a chance to see the changes. It's quite ugly, however I
> >>> don't see anything better.
> >>
> >> Isn't this really a bug in mii_check_media()? It shouldn't shortcut the
> >> calls to netif_carrier_{off,on}() just because mii->force_media is set.
> >
> >I think mii_check_media() is responsible for handling this too.
>
> The mii_check_media() doesn't get called, AFAIK. The problem here is that,
> after we call ethtool -s eth0 autoneg off speed X, with eth0 being
> 8139too, the speed/autoneg options are changed via mii_ethtool_sset(),
> however the interface itself isn't down'ed/up'ed, and thus no NETDEV_
> notifications are sent.
Does the hardware not send link interrupts if autoneg is disabled?
> Other drivers either explicitly reset the interface after
> ethtool.set_settings() call (like netxen_nic using ndo_close()/ndo_open()),
> do it on the logic level (tg3) without involving mii_ethtool_sset(), or
> just reset on their own (e100 iirc), so that most of them are responsible
> for somehow triggering these events.
>
> Silently changing speed can break things a bit - bonding relies on
> interface speeds for 802.3ad/alb/tlb/active-backup iirc, bridge relies on
> stp port cost etc. and they all get it via NETDEV_ notifications. So
> without them, they would end up with outdated data, per example (eth2 being
> 8139too):
[...]
Yes, I get it. But on real hardware, changing speed/duplex is always
going to break the link if it's up. The link change notification should
result in kernel and userland notifications via linkwatch_do_dev().
(If you're testing against QEMU rather than real hardware, there could
be a bug in the emulation of link interrupts.)
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [RFC PATCH net-next 0/3] Allow bridge to function in non-promisc mode
From: Vlad Yasevich @ 2013-03-07 15:35 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, bridge
In-Reply-To: <CAOaVG17iZu3r9no5FtNU-6ZwW2UdR3QBE6O3EKm6-JXAmEyuyA@mail.gmail.com>
On 03/07/2013 02:19 AM, Stephen Hemminger wrote:
> I understand the desire to add more functionality, but in this case it
> would introduce lots more problems. STP would break and it doesn't seem to
> gain anything that can't be done by other means.
>
> Turning bridge into macvlan seems unnecessary. Combining apples and bananas
> doesn't always make a tasty smoothy, sometimes it is just a mess.
>
> Maybe adding a little more to macvlan to do what you want would be simpler.
>
It's not really a macvlan over the bridge. I would agree that
particular setup would be a bit odd. This work enables VMs to manage
their mac addresses and to reduce the load on the host by keeping the
bridge in promisc mode.
Sadly, most kvm network configs still use bridging and have not
transitioned to OVS. macvlan has some limitations as well and I working
to address those, but there is a desire for non-promisc bridge. In
this case VMs can manage their mac addresses and can write that data to
the bridge.
STP is not broken as STP uses multicast mac and we set IFF_ALLMULTI thus
continuing to receive and process STP BPDUs.
The one thing that would appear to suffer from this is VLAN reception,
but the bridge does allow vlan config now and that would have to be
configured if VMs wish to use vlans.
I am not changing default operation of the bridge. Default is still
promisc. In fact, one can switch back and forth without any network
outages. This simply adds another mode the the bridge operation.
-vlad
^ permalink raw reply
* [PATCH] VSOCK: Split vm_sockets.h into kernel/uapi
From: Andy King @ 2013-03-07 15:26 UTC (permalink / raw)
To: netdev, linux-kernel, virtualization
Cc: dhowells, gregkh, pv-drivers, Andy King, davem
Split the vSockets header into kernel and UAPI parts. The former gets the bits
that used to be in __KERNEL__ guards, while the latter gets everything that is
user-visible. Tested by compiling vsock (+transport) and a simple user-mode
vSockets application.
Reported-by: David Howells <dhowells@redhat.com>
Acked-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Andy King <acking@vmware.com>
---
include/linux/vm_sockets.h | 23 +++++++++++++++++++++++
include/uapi/linux/vm_sockets.h | 23 ++++++++---------------
2 files changed, 31 insertions(+), 15 deletions(-)
create mode 100644 include/linux/vm_sockets.h
diff --git a/include/linux/vm_sockets.h b/include/linux/vm_sockets.h
new file mode 100644
index 0000000..0805eec
--- /dev/null
+++ b/include/linux/vm_sockets.h
@@ -0,0 +1,23 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
+ *
+ * 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 version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef _VM_SOCKETS_H
+#define _VM_SOCKETS_H
+
+#include <uapi/linux/vm_sockets.h>
+
+int vm_sockets_get_local_cid(void);
+
+#endif /* _VM_SOCKETS_H */
diff --git a/include/uapi/linux/vm_sockets.h b/include/uapi/linux/vm_sockets.h
index df91301..b4ed5d8 100644
--- a/include/uapi/linux/vm_sockets.h
+++ b/include/uapi/linux/vm_sockets.h
@@ -13,12 +13,10 @@
* more details.
*/
-#ifndef _VM_SOCKETS_H_
-#define _VM_SOCKETS_H_
+#ifndef _UAPI_VM_SOCKETS_H
+#define _UAPI_VM_SOCKETS_H
-#if !defined(__KERNEL__)
-#include <sys/socket.h>
-#endif
+#include <linux/socket.h>
/* Option name for STREAM socket buffer size. Use as the option name in
* setsockopt(3) or getsockopt(3) to set or get an unsigned long long that
@@ -137,14 +135,13 @@
#define VM_SOCKETS_VERSION_MINOR(_v) (((_v) & 0x0000FFFF))
/* Address structure for vSockets. The address family should be set to
- * whatever vmci_sock_get_af_value_fd() returns. The structure members should
- * all align on their natural boundaries without resorting to compiler packing
- * directives. The total size of this structure should be exactly the same as
- * that of struct sockaddr.
+ * AF_VSOCK. The structure members should all align on their natural
+ * boundaries without resorting to compiler packing directives. The total size
+ * of this structure should be exactly the same as that of struct sockaddr.
*/
struct sockaddr_vm {
- sa_family_t svm_family;
+ __kernel_sa_family_t svm_family;
unsigned short svm_reserved1;
unsigned int svm_port;
unsigned int svm_cid;
@@ -156,8 +153,4 @@ struct sockaddr_vm {
#define IOCTL_VM_SOCKETS_GET_LOCAL_CID _IO(7, 0xb9)
-#if defined(__KERNEL__)
-int vm_sockets_get_local_cid(void);
-#endif
-
-#endif
+#endif /* _UAPI_VM_SOCKETS_H */
--
1.7.4.1
^ permalink raw reply related
* Re: [Patch net] bridge: add missing vid to br_mdb_get()
From: Vlad Yasevich @ 2013-03-07 15:18 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Stephen Hemminger, David S. Miller
In-Reply-To: <1362661533-29192-1-git-send-email-amwang@redhat.com>
On 03/07/2013 08:05 AM, Cong Wang wrote:
> From: Cong Wang <amwang@redhat.com>
>
> Obviously, vid should be considered when searching for multicast
> group.
>
> Cc: Vlad Yasevich <vyasevic@redhat.com>
Don't know how I missied that...
Acked-by: Vlad Yasevich <vyasevich@redhat.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>
>
> ---
> diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
> index d5f1d3f..314c73e 100644
> --- a/net/bridge/br_device.c
> +++ b/net/bridge/br_device.c
> @@ -66,7 +66,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
> goto out;
> }
>
> - mdst = br_mdb_get(br, skb);
> + mdst = br_mdb_get(br, skb, vid);
> if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb))
> br_multicast_deliver(mdst, skb);
> else
> diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
> index 4803301..828e2bc 100644
> --- a/net/bridge/br_input.c
> +++ b/net/bridge/br_input.c
> @@ -97,7 +97,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
> if (is_broadcast_ether_addr(dest))
> skb2 = skb;
> else if (is_multicast_ether_addr(dest)) {
> - mdst = br_mdb_get(br, skb);
> + mdst = br_mdb_get(br, skb, vid);
> if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) {
> if ((mdst && mdst->mglist) ||
> br_multicast_is_router(br))
> diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
> index 10e6fce..923fbea 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -132,7 +132,7 @@ static struct net_bridge_mdb_entry *br_mdb_ip6_get(
> #endif
>
> struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
> - struct sk_buff *skb)
> + struct sk_buff *skb, u16 vid)
> {
> struct net_bridge_mdb_htable *mdb = rcu_dereference(br->mdb);
> struct br_ip ip;
> @@ -144,6 +144,7 @@ struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
> return NULL;
>
> ip.proto = skb->protocol;
> + ip.vid = vid;
>
> switch (skb->protocol) {
> case htons(ETH_P_IP):
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 6d314c4..3cbf5be 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -442,7 +442,7 @@ extern int br_multicast_rcv(struct net_bridge *br,
> struct net_bridge_port *port,
> struct sk_buff *skb);
> extern struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
> - struct sk_buff *skb);
> + struct sk_buff *skb, u16 vid);
> extern void br_multicast_add_port(struct net_bridge_port *port);
> extern void br_multicast_del_port(struct net_bridge_port *port);
> extern void br_multicast_enable_port(struct net_bridge_port *port);
> @@ -504,7 +504,7 @@ static inline int br_multicast_rcv(struct net_bridge *br,
> }
>
> static inline struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
> - struct sk_buff *skb)
> + struct sk_buff *skb, u16 vid)
> {
> return NULL;
> }
>
^ permalink raw reply
* [resent][iputils][patch 01-07] setuid/capabilities fixups
From: Yuriy Kaminskiy @ 2013-03-07 15:13 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
Yuriy Kaminskiy wrote:
> Run ping, look at /proc/`pidof ping`/status -> oops (capabilities are not
> [permanently] dropped, some of uids are not dropped, etc). Fix assorted issues
> with setuid and capabilities drop. Limited testing only, please review/check
> carefully.
[-- Attachment #2: 0001-arping-ping-ping6-traceroute2-clockdiff-drop-fsuid-a.patch --]
[-- Type: text/x-diff, Size: 2800 bytes --]
>From fd8a9b6fa39a7fa926b105e477fc9a133b6ac862 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 01:43:01 +0400
Subject: [PATCH 1/7] arping, ping, ping6, traceroute2, clockdiff: drop fsuid
at start
Prevent ignoring netfilter -m owner checks. With this patch ping
correctly blocked by iptables rules, e.g.:
$ sudo iptables -I OUTPUT -m owner --uid-owner $UID -j DROP
$ ping www.google.com
---
arping.c | 9 +++++++++
clockdiff.c | 8 ++++++++
ping_common.c | 9 +++++++++
traceroute6.c | 8 ++++++++
4 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/arping.c b/arping.c
index 35408c1..bdf81e9 100644
--- a/arping.c
+++ b/arping.c
@@ -27,6 +27,9 @@
#include <sys/prctl.h>
#include <sys/capability.h>
#endif
+#ifdef __linux__
+#include <sys/fsuid.h>
+#endif
#include <netdb.h>
#include <unistd.h>
@@ -229,6 +232,12 @@ int modify_capability_raw(int on)
perror("arping: setuid");
return -1;
}
+#ifdef __linux__
+ if (on) {
+ /* FIXME: error handling? setfsuid() have weird return code */
+ setfsuid(getuid());
+ }
+#endif
#endif
return 0;
}
diff --git a/clockdiff.c b/clockdiff.c
index 7c1ea1b..f12da2d 100644
--- a/clockdiff.c
+++ b/clockdiff.c
@@ -3,6 +3,9 @@
#include <sys/param.h>
#include <stdio.h>
#include <unistd.h>
+#ifdef __linux__
+#include <sys/fsuid.h>
+#endif
#include <stdlib.h>
#include <math.h>
#include <string.h>
@@ -561,6 +564,11 @@ main(int argc, char *argv[])
usage();
}
+#ifdef __linux__
+ // FIXME: error handling? setfsuid() have weird return code
+ setfsuid(getuid());
+#endif
+
sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
s_errno = errno;
diff --git a/ping_common.c b/ping_common.c
index 8d6b145..1d0012a 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -2,6 +2,9 @@
#include <ctype.h>
#include <sched.h>
#include <math.h>
+#ifdef __linux__
+#include <sys/fsuid.h>
+#endif
int options;
@@ -175,6 +178,12 @@ int modify_capability(int on)
perror("seteuid");
return -1;
}
+#ifdef __linux__
+ if (on) {
+ /* FIXME: error handling? setfsuid() have weird return code */
+ setfsuid(uid);
+ }
+#endif
return 0;
}
diff --git a/traceroute6.c b/traceroute6.c
index 0538d4b..a14ddb6 100644
--- a/traceroute6.c
+++ b/traceroute6.c
@@ -266,6 +266,9 @@ char copyright[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifdef __linux__
+#include <sys/fsuid.h>
+#endif
#include "SNAPSHOT.h"
@@ -343,6 +346,11 @@ int main(int argc, char *argv[])
int ch, i, on, probe, seq, tos, ttl;
int socket_errno;
+#ifdef __linux__
+ // FIXME: error handling? setfsuid() have weird return code
+ setfsuid(getuid());
+#endif
+
icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
socket_errno = errno;
--
1.7.6.3
[-- Attachment #3: 0002-ping-permanently-drop-capabilities-before-entering-m.patch --]
[-- Type: text/x-diff, Size: 554 bytes --]
>From 550366b0d5ba7498c6f102a0f7da08f6119028c7 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 01:44:49 +0400
Subject: [PATCH 2/7] ping: permanently drop capabilities before entering main
loop
---
ping.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/ping.c b/ping.c
index c0366cd..7ac1217 100644
--- a/ping.c
+++ b/ping.c
@@ -587,6 +587,8 @@ main(int argc, char **argv)
setup(icmp_sock);
+ drop_capabilities();
+
main_loop(icmp_sock, packet, packlen);
}
--
1.7.6.3
[-- Attachment #4: 0003-arping-use-seteuid-for-temporal-uid-changes.patch --]
[-- Type: text/x-diff, Size: 609 bytes --]
>From 0f1a605b1b7838749f2dd315c588b939380ccbd0 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 01:46:44 +0400
Subject: [PATCH 3/7] arping: use seteuid for temporal uid changes
---
arping.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arping.c b/arping.c
index bdf81e9..a35fafd 100644
--- a/arping.c
+++ b/arping.c
@@ -228,7 +228,7 @@ int modify_capability_raw(int on)
cap_free(cap_p);
#else
- if (setuid(on ? euid : getuid())) {
+ if (seteuid(on ? euid : getuid())) {
perror("arping: setuid");
return -1;
}
--
1.7.6.3
[-- Attachment #5: 0004-arping-ping_common-reset-euid-before-permanent-drop.patch --]
[-- Type: text/x-diff, Size: 1025 bytes --]
>From b0025d82ce5592f8e8da51cf4b94ceea51073cbe Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 01:53:39 +0400
Subject: [PATCH 4/7] arping, ping_common: reset euid before permanent drop
setuid drop saved uid only if euid is 0
---
arping.c | 4 ++++
ping_common.c | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arping.c b/arping.c
index a35fafd..0033f33 100644
--- a/arping.c
+++ b/arping.c
@@ -269,6 +269,10 @@ void drop_capabilities(void)
cap_free(cap_p);
#else
+ if (seteuid(euid)) {
+ perror("arping: setuid");
+ return -1;
+ }
if (setuid(getuid()) < 0) {
perror("arping: setuid");
exit(-1);
diff --git a/ping_common.c b/ping_common.c
index 1d0012a..4a184ee 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -199,6 +199,10 @@ void drop_capabilities(void)
}
cap_free(cap);
#else
+ if (seteuid(euid)) {
+ perror("seteuid");
+ exit(-1);
+ }
if (setuid(getuid())) {
perror("ping: setuid");
exit(-1);
--
1.7.6.3
[-- Attachment #6: 0005-ping-ping6-arping-clockdiff-Fix-CAP_SETUID-setuid-in.patch --]
[-- Type: text/x-diff, Size: 2783 bytes --]
>From dcb8828342f2591ee29f1be2fda2f225aee5efa9 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 01:56:07 +0400
Subject: [PATCH 5/7] ping, ping6, arping, clockdiff: Fix CAP_SETUID <->
setuid() interaction
setuid() only drops saved uid if process have CAP_SETUID.
Drop capabilities only after setuid().
---
arping.c | 30 +++++++++++++++---------------
clockdiff.c | 8 +++++---
ping_common.c | 30 +++++++++++++++---------------
3 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/arping.c b/arping.c
index 0033f33..3c02abf 100644
--- a/arping.c
+++ b/arping.c
@@ -161,6 +161,21 @@ void limit_capabilities(void)
#ifdef CAPABILITIES
cap_t cap_p;
+ if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
+ perror("arping: prctl");
+ exit(-1);
+ }
+
+ if (setuid(getuid()) < 0) {
+ perror("arping: setuid");
+ exit(-1);
+ }
+
+ if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
+ perror("arping: prctl");
+ exit(-1);
+ }
+
cap_p = cap_get_proc();
if (!cap_p) {
perror("arping: cap_get_proc");
@@ -184,21 +199,6 @@ void limit_capabilities(void)
}
}
- if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
- perror("arping: prctl");
- exit(-1);
- }
-
- if (setuid(getuid()) < 0) {
- perror("arping: setuid");
- exit(-1);
- }
-
- if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
- perror("arping: prctl");
- exit(-1);
- }
-
cap_free(cap_p);
#else
euid = geteuid();
diff --git a/clockdiff.c b/clockdiff.c
index f12da2d..540366d 100644
--- a/clockdiff.c
+++ b/clockdiff.c
@@ -536,6 +536,11 @@ usage() {
}
void drop_rights(void) {
+ if (setuid(getuid())) {
+ perror("clockdiff: setuid");
+ exit(-1);
+ }
+ {
#ifdef CAPABILITIES
cap_t caps = cap_init();
if (cap_set_proc(caps)) {
@@ -544,9 +549,6 @@ void drop_rights(void) {
}
cap_free(caps);
#endif
- if (setuid(getuid())) {
- perror("clockdiff: setuid");
- exit(-1);
}
}
diff --git a/ping_common.c b/ping_common.c
index 4a184ee..b2344a7 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -80,6 +80,21 @@ void limit_capabilities(void)
cap_t cap_p;
cap_flag_value_t cap_ok;
+ if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
+ perror("ping: prctl");
+ exit(-1);
+ }
+
+ if (setuid(getuid()) < 0) {
+ perror("setuid");
+ exit(-1);
+ }
+
+ if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
+ perror("ping: prctl");
+ exit(-1);
+ }
+
cap_cur_p = cap_get_proc();
if (!cap_cur_p) {
perror("ping: cap_get_proc");
@@ -109,21 +124,6 @@ void limit_capabilities(void)
exit(-1);
}
- if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
- perror("ping: prctl");
- exit(-1);
- }
-
- if (setuid(getuid()) < 0) {
- perror("setuid");
- exit(-1);
- }
-
- if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
- perror("ping: prctl");
- exit(-1);
- }
-
cap_free(cap_p);
cap_free(cap_cur_p);
#endif
--
1.7.6.3
[-- Attachment #7: 0006-ninfod-use-u-without-capabilities-too.patch --]
[-- Type: text/x-diff, Size: 662 bytes --]
>From fdabf4869f868fe8ea0994910cc4944ebfd0b098 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 02:57:15 +0400
Subject: [PATCH 6/7] ninfod: use -u without capabilities too
---
ninfod/ninfod.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/ninfod/ninfod.c b/ninfod/ninfod.c
index 5ff6993..f1db977 100644
--- a/ninfod/ninfod.c
+++ b/ninfod/ninfod.c
@@ -589,7 +589,7 @@ static void drop_capabilities(void)
cap_free(cap_p);
#else
- if (setuid(getuid()) < 0) {
+ if (setuid(opt_u ? opt_u : getuid()) < 0) {
DEBUG(LOG_ERR, "setuid: %s\n", strerror(errno));
exit(-1);
}
--
1.7.6.3
[-- Attachment #8: 0007-ninfod-fix-capabilities-setting.patch --]
[-- Type: text/x-diff, Size: 3184 bytes --]
>From 4298d3af86b881ef7abb61a36f83a610fc8bb772 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 2 Jan 2013 03:08:30 +0400
Subject: [PATCH 7/7] ninfod: fix capabilities setting
1) -u option failed to change real uid too (likely leaving it as root);
2) it failed to drop saved uid;
---
ninfod/ninfod.c | 58 +++++++++++++++++-------------------------------------
1 files changed, 18 insertions(+), 40 deletions(-)
diff --git a/ninfod/ninfod.c b/ninfod/ninfod.c
index f1db977..7f6a2fa 100644
--- a/ninfod/ninfod.c
+++ b/ninfod/ninfod.c
@@ -497,16 +497,28 @@ static void do_daemonize(void)
/* --------- */
#ifdef HAVE_LIBCAP
static const cap_value_t cap_net_raw = CAP_NET_RAW;
-static const cap_value_t cap_setuid = CAP_SETUID;
-static cap_flag_value_t cap_ok;
-#else
-static uid_t euid;
#endif
static void limit_capabilities(void)
{
#ifdef HAVE_LIBCAP
cap_t cap_p, cap_cur_p;
+ cap_flag_value_t cap_ok;
+
+ if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
+ DEBUG(LOG_ERR, "prctl: %s\n", strerror(errno));
+ exit(-1);
+ }
+
+ if (setuid(opt_u ? opt_u : getuid()) < 0) {
+ DEBUG(LOG_ERR, "setuid: %s\n", strerror(errno));
+ exit(-1);
+ }
+
+ if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
+ DEBUG(LOG_ERR, "prctl: %s\n", strerror(errno));
+ exit(-1);
+ }
cap_p = cap_init();
if (!cap_p) {
@@ -520,32 +532,20 @@ static void limit_capabilities(void)
exit(-1);
}
- /* net_raw + setuid / net_raw */
cap_get_flag(cap_cur_p, CAP_NET_RAW, CAP_PERMITTED, &cap_ok);
if (cap_ok != CAP_CLEAR) {
cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_net_raw, CAP_SET);
cap_set_flag(cap_p, CAP_EFFECTIVE, 1, &cap_net_raw, CAP_SET);
}
- cap_get_flag(cap_cur_p, CAP_SETUID, CAP_PERMITTED, &cap_ok);
- if (cap_ok != CAP_CLEAR)
- cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuid, CAP_SET);
-
if (cap_set_proc(cap_p) < 0) {
DEBUG(LOG_ERR, "cap_set_proc: %s\n", strerror(errno));
if (errno != EPERM)
exit(-1);
}
- if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
- DEBUG(LOG_ERR, "prctl: %s\n", strerror(errno));
- exit(-1);
- }
-
cap_free(cap_cur_p);
cap_free(cap_p);
-#else
- euid = geteuid();
#endif
}
@@ -560,28 +560,6 @@ static void drop_capabilities(void)
exit(-1);
}
- /* setuid / setuid */
- if (cap_ok != CAP_CLEAR) {
- cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuid, CAP_SET);
- cap_set_flag(cap_p, CAP_EFFECTIVE, 1, &cap_setuid, CAP_SET);
-
- if (cap_set_proc(cap_p) < 0) {
- DEBUG(LOG_ERR, "cap_set_proc: %s\n", strerror(errno));
- exit(-1);
- }
- }
-
- if (seteuid(opt_u ? opt_u : getuid()) < 0) {
- DEBUG(LOG_ERR, "setuid: %s\n", strerror(errno));
- exit(-1);
- }
-
- if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
- DEBUG(LOG_ERR, "prctl: %s\n", strerror(errno));
- exit(-1);
- }
-
- cap_clear(cap_p);
if (cap_set_proc(cap_p) < 0) {
DEBUG(LOG_ERR, "cap_set_proc: %s\n", strerror(errno));
exit(-1);
@@ -667,14 +645,14 @@ int main (int argc, char **argv)
appname = argv[0];
set_logfile();
+ parse_args(argc, argv);
+
limit_capabilities();
sock = open_sock();
if (sock < 0)
sock_errno = errno;
- parse_args(argc, argv);
-
drop_capabilities();
if (opt_h || opt_v)
--
1.7.6.3
^ permalink raw reply related
* Re: [RFC PATCH net-next 3/3] bridge: Implement IFF_UNICAST_FLT
From: Vlad Yasevich @ 2013-03-07 15:08 UTC (permalink / raw)
To: John Fastabend; +Cc: netdev, bridge
In-Reply-To: <51380542.4020601@gmail.com>
On 03/06/2013 10:10 PM, John Fastabend wrote:
> On 03/06/2013 06:31 PM, Vlad Yasevich wrote:
>> Implement IFF_UNICAST_FLT on the bridge. Unicast addresses added
>> to the bridge device are synched to the uplink devices. This
>> allows for uplink devices to change while preserving mac assignment.
>>
>> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
>> ---
>
> [...]
>
>> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
>> index b0812c9..ef7b51e 100644
>> --- a/net/bridge/br_fdb.c
>> +++ b/net/bridge/br_fdb.c
>> @@ -677,6 +677,9 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr
>> *tb[],
>> struct net_port_vlans *pv;
>> unsigned short vid = VLAN_N_VID;
>>
>> + if ((ndm->ndm_flags & NTF_SELF) && (dev->priv_flags & IFF_EBRIDGE))
>> + return ndo_dflt_fdb_add(ndm, tb, dev, addr, nlh_flags);
>> +
>> if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) {
>> pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n",
>> ndm->ndm_state);
>> return -EINVAL;
>> @@ -774,6 +777,9 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr
>> *tb[],
>> struct net_port_vlans *pv;
>> unsigned short vid = VLAN_N_VID;
>>
>> + if ((ndm->ndm_flags & NTF_SELF) && (dev->priv_flags & IFF_EBRIDGE))
>> + return ndo_dflt_fdb_del(ndm, tb, dev, addr);
>> +
>> if (tb[NDA_VLAN]) {
>> if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
>> pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
>>
>
> How is this different then calling the fdb op from rtnetlink.c when the
> NTF_SELF bit is set after your previous patch
>
> net: generic fdb support for drivers without ndo_fdb_<op>
>
> the generic routine gets called if a specific op is not supplied via
> ndo ops anyways right?
>
> Also I suspect if the driver supplies a specific ndo_fdb_<op> we should
> use it over the generic one.
>
> What am I missing?
The bridge provides the ndo_fdb_<add|del>, so it will be used. The
bridge op assumes that the dev passed to it is a port. This code adds
support for when dev is the bridge.
In fact this patch is counting that rtnetlink will call into the bridge
and lets bridge do the work.
-vlad
>
> Thanks,
> John
>
^ permalink raw reply
* Re: upgrade to 3.8.1 : BUG Scheduling while atomic in bonding driver:
From: Veaceslav Falico @ 2013-03-07 14:59 UTC (permalink / raw)
To: Michael Wang
Cc: Linda Walsh, Eric Dumazet, Linux-Kernel, netdev, Jay Vosburgh,
Jeff Kirsher, Cong Wang, Andy Gospodarek
In-Reply-To: <513862DA.20704@linux.vnet.ibm.com>
On Thu, Mar 7, 2013 at 10:50 AM, Michael Wang
<wangyun@linux.vnet.ibm.com> wrote:
> On 03/07/2013 04:50 PM, Linda Walsh wrote:
>>
>> I am *not* seeing the bug in 3.8.2 with the 2nd patch applied (in
>> addition to the first)...
>
> So that means bond lock is the reason, nice, but this is really not a
> good fix if we just unlock it...
You're right, we can't unlock bond->lock while in bond_for_each_slave(),
however I think we don't even need that bond_update_speed_duplex() in
bond_miimon_commit() - cause the speed/duplex on interface state change
were already updated via NETDEV_UP/CHANGE event in
bond_slave_netdev_event() - and if not, it's not our fault, but the
driver's that he didn't call the notifiers.
So, maybe something like this would work (any feedback welcome, it's
definitely not the first time we hit the wall with sleeping in
bond_update_speed_duplex):
Subject: [PATCH] bonding: don't call update_speed_duplex() under spinlocks
bond_update_speed_duplex() might sleep while calling underlying slave's
routines. Move it out of atomic context in bond_enslave() and remove it
from bond_miimon_commit() - it was introduced by commit 546add79, however
when the slave interfaces go up/change state it's their responsability to
fire NETDEV_UP/NETDEV_CHANGE events so that bonding can properly update
their speed.
---
drivers/net/bonding/bond_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7bd068a..c63a33c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1746,6 +1746,8 @@ int bond_enslave(struct net_device *bond_dev,
struct net_device *slave_dev)
bond_compute_features(bond);
+ bond_update_speed_duplex(new_slave);
+
read_lock(&bond->lock);
new_slave->last_arp_rx = jiffies -
@@ -1798,8 +1800,6 @@ int bond_enslave(struct net_device *bond_dev,
struct net_device *slave_dev)
new_slave->link == BOND_LINK_DOWN ? "DOWN" :
(new_slave->link == BOND_LINK_UP ? "UP" : "BACK"));
- bond_update_speed_duplex(new_slave);
-
if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) {
/* if there is a primary slave, remember it */
if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
@@ -2373,8 +2373,6 @@ static void bond_miimon_commit(struct bonding *bond)
bond_set_backup_slave(slave);
}
- bond_update_speed_duplex(slave);
-
pr_info("%s: link status definitely up for interface %s, %u Mbps
%s duplex.\n",
bond->dev->name, slave->dev->name,
slave->speed, slave->duplex ? "full" : "half");
--
1.7.1
>
> The better way is to move the cycle wait logical out of the
> bond_update_speed_duplex() IMO, I think we need the folk who work on
> this driver to make the decision ;-)
>
> Regards,
> Michael Wang
>
>>
>>
>> Michael Wang wrote:
>>>
>>>
>>> And both bond_enslave() and bond_mii_monitor() are using bond_update_speed_duplex()
>>> with preempt disabled.
>>>
>>> Along with the changes in bond_enslave(), I think you also need this (untested):
>>>
>>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>>> index 11d01d6..9af143a 100644
>>> --- a/drivers/net/bonding/bond_main.c
>>> +++ b/drivers/net/bonding/bond_main.c
>>> @@ -2373,7 +2373,9 @@ static void bond_miimon_commit(struct bonding *bond)
>>> bond_set_backup_slave(slave);
>>> }
>>>
>>> + read_unlock(&bond->lock);
>>> bond_update_speed_duplex(slave);
>>> + read_lock(&bond->lock);
>>>
>>> pr_info("%s: link status definitely up for interface %s, %u Mbps %s duplex.\n",
>>> bond->dev->name, slave->dev->name,
>>>
>>>
>>> Regards,
>>> Michael Wang
>>>
>>>
>>>
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best regards,
Veaceslav Falico
^ permalink raw reply related
* Re: [PATCH] netconsole: release the spinlock before __netpoll_cleanup()
From: Neil Horman @ 2013-03-07 14:43 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, amwang, davem
In-Reply-To: <20130307100325.GA31105@redhat.com>
On Thu, Mar 07, 2013 at 11:03:25AM +0100, Veaceslav Falico wrote:
> On Wed, Mar 06, 2013 at 07:08:24PM -0500, Neil Horman wrote:
> >On Wed, Mar 06, 2013 at 03:46:43PM +0100, Veaceslav Falico wrote:
> >>Commit 3335f0ca130c201f8680e97f63612053fbc16e22 removed spinlock unlocking
> >>before __netpoll_cleanup() in netconsole_netdev_event(), however we still
> >>might sleep in __netpoll_cleanup() - via synchronize_srcu(). Revert it and
> >>add a comment.
> >>
> >>Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> >>---
> >> drivers/net/netconsole.c | 10 ++++++++++
> >> 1 files changed, 10 insertions(+), 0 deletions(-)
> >>
> >>diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> >>index 37add21..dd62b4c 100644
> >>--- a/drivers/net/netconsole.c
> >>+++ b/drivers/net/netconsole.c
> >>@@ -680,7 +680,17 @@ static int netconsole_netdev_event(struct notifier_block *this,
> >> * rtnl_lock already held
> >> */
> >> if (nt->np.dev) {
> >>+ /*
> >>+ * we still might sleep in
> >>+ * __netpoll_cleanup(), so release
> >>+ * the lock
> >>+ */
> >>+ spin_unlock_irqrestore(
> >>+ &target_list_lock,
> >>+ flags);
> >> __netpoll_cleanup(&nt->np);
> >>+ spin_lock_irqsave(&target_list_lock,
> >>+ flags);
> >> dev_put(nt->np.dev);
> >> nt->np.dev = NULL;
> >> }
> >>--
> >>1.7.1
> >>
> >Thanks for noticing this Vaeceslav, but you can't just drop and re-acquire the
> >lock like this, as it protect the list_for_each_entry loop that you're in. You
> >can drop the lock in the above if clause, but then, after the nt->np.dev = NULL,
> >go back an re-aquire the lock, and start the for loop. I thought we had already
> >done this for some other purpose in this code using a label and a goto, but I
> >suppose I was mistaken
>
> You're right, I somehow missed that restart goto, which was removed
> earlier. Does that feel right (I've also added back the
> netconsole_target_put()):
>
> Subject: [PATCH] netconsole: release the spinlock before __netpoll_cleanup()
>
> __netpoll_cleanup() might sleep in synchronize_srcu(), which was added to
> avoid race in another situation, so we can't call it with the spinlock
> target_list_lock held.
>
> Add spin_unlock/lock before/after it and restart the loop.
>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> ---
> drivers/net/netconsole.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 37add21..267c26b 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -666,6 +666,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
> goto done;
> spin_lock_irqsave(&target_list_lock, flags);
> +restart:
> list_for_each_entry(nt, &target_list, list) {
> netconsole_target_get(nt);
> if (nt->np.dev == dev) {
> @@ -680,9 +681,21 @@ static int netconsole_netdev_event(struct notifier_block *this,
> * rtnl_lock already held
> */
> if (nt->np.dev) {
> + /*
> + * we still might sleep in
> + * __netpoll_cleanup(), so release
> + * the lock and restart
> + */
> + spin_unlock_irqrestore(
> + &target_list_lock,
> + flags);
> __netpoll_cleanup(&nt->np);
> + spin_lock_irqsave(&target_list_lock,
> + flags);
> dev_put(nt->np.dev);
> nt->np.dev = NULL;
> + netconsole_target_put(nt);
> + goto restart;
> }
> nt->enabled = 0;
> stopped = true;
> --
> 1.7.1
>
Yes, this looks better, thank you.
Acked-by: Neil Horman <nhorman@tuxdriver.com>
^ permalink raw reply
* [PATCH net-next] ipv6 flowlabel: add __rcu annotations
From: Eric Dumazet @ 2013-03-07 14:20 UTC (permalink / raw)
To: David Miller; +Cc: netdev, YOSHIFUJI Hideaki
From: Eric Dumazet <edumazet@google.com>
Commit 18367681a10b (ipv6 flowlabel: Convert np->ipv6_fl_list to RCU.)
omitted proper __rcu annotations.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
include/net/ipv6.h | 8 ++++----
net/ipv6/ip6_flowlabel.c | 11 ++++++++---
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 64d12e7..988c9f2 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -217,7 +217,7 @@ struct ipv6_txoptions {
};
struct ip6_flowlabel {
- struct ip6_flowlabel *next;
+ struct ip6_flowlabel __rcu *next;
__be32 label;
atomic_t users;
struct in6_addr dst;
@@ -238,9 +238,9 @@ struct ip6_flowlabel {
#define IPV6_FLOWLABEL_MASK cpu_to_be32(0x000FFFFF)
struct ipv6_fl_socklist {
- struct ipv6_fl_socklist *next;
- struct ip6_flowlabel *fl;
- struct rcu_head rcu;
+ struct ipv6_fl_socklist __rcu *next;
+ struct ip6_flowlabel *fl;
+ struct rcu_head rcu;
};
extern struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label);
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index b973ed3..46e8843 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -144,7 +144,9 @@ static void ip6_fl_gc(unsigned long dummy)
spin_lock(&ip6_fl_lock);
for (i=0; i<=FL_HASH_MASK; i++) {
- struct ip6_flowlabel *fl, **flp;
+ struct ip6_flowlabel *fl;
+ struct ip6_flowlabel __rcu **flp;
+
flp = &fl_ht[i];
while ((fl = rcu_dereference_protected(*flp,
lockdep_is_held(&ip6_fl_lock))) != NULL) {
@@ -179,7 +181,9 @@ static void __net_exit ip6_fl_purge(struct net *net)
spin_lock(&ip6_fl_lock);
for (i = 0; i <= FL_HASH_MASK; i++) {
- struct ip6_flowlabel *fl, **flp;
+ struct ip6_flowlabel *fl;
+ struct ip6_flowlabel __rcu **flp;
+
flp = &fl_ht[i];
while ((fl = rcu_dereference_protected(*flp,
lockdep_is_held(&ip6_fl_lock))) != NULL) {
@@ -506,7 +510,8 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_flowlabel_req freq;
struct ipv6_fl_socklist *sfl1=NULL;
- struct ipv6_fl_socklist *sfl, **sflp;
+ struct ipv6_fl_socklist *sfl;
+ struct ipv6_fl_socklist __rcu **sflp;
struct ip6_flowlabel *fl, *fl1 = NULL;
^ permalink raw reply related
* [PATCH net 6/6] net/mlx4_en: Disable RFS when running in SRIOV mode
From: Or Gerlitz @ 2013-03-07 13:46 UTC (permalink / raw)
To: davem; +Cc: netdev, amirv, Kleber Sacilotto de Souza, Or Gerlitz
In-Reply-To: <1362664017-30275-1-git-send-email-ogerlitz@mellanox.com>
From: Amir Vadai <amirv@mellanox.com>
Commit 37706996 "mlx4_en: fix allocation of CPU affinity reverse-map" fixed
a bug when mlx4_dev->caps.comp_pool is larger from the device rx rings, but
introduced a regression.
When the mlx4_core is activating its "legacy mode" (e.g when running in SRIOV
mode) w.r.t to EQs/IRQs usage, comp_pool becomes zero and we're crashing on
divide by zero alloc_cpu_rmap.
Fix that by enabling RFS only when running in non-legacy mode.
Reported-by: Yan Burman <yanb@mellanox.com>
Cc: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
This regression was introduced in 3.9-rc1 but actually present also in the
3.8 -stable series. It turns out that a slightly different fix is needed there and
we will generate and submit it there.
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 7fd0936..995d4b6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1833,9 +1833,11 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
}
#ifdef CONFIG_RFS_ACCEL
- priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->mdev->dev->caps.comp_pool);
- if (!priv->dev->rx_cpu_rmap)
- goto err;
+ if (priv->mdev->dev->caps.comp_pool) {
+ priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->mdev->dev->caps.comp_pool);
+ if (!priv->dev->rx_cpu_rmap)
+ goto err;
+ }
#endif
return 0;
--
1.7.1
^ permalink raw reply related
* [PATCH net 3/6] net/mlx4_core: Fix endianness bug in set_param_l
From: Or Gerlitz @ 2013-03-07 13:46 UTC (permalink / raw)
To: davem; +Cc: netdev, amirv, Jack Morgenstein, Or Gerlitz
In-Reply-To: <1362664017-30275-1-git-send-email-ogerlitz@mellanox.com>
From: Jack Morgenstein <jackm@dev.mellanox.co.il>
The set_param_l function assumes casting a u64 pointer to a u32 pointer
allows to access the lower 32bits, but it results in writing the upper
32 bits on big endian systems.
The fixed function reads the upper 32 bits of the 64 argument, and or's
them with the 32 bits of the 32-bit value passed to the function.
Since this is now a "read-modify-write" operation, we got many
"unintialized variable" warnings which needed to be fixed as well.
Reported-by: Alexander Schmidt <alexschm@de.ibm.com>.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/cq.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/mlx4.h | 2 +-
drivers/net/ethernet/mellanox/mlx4/mr.c | 10 +++++-----
drivers/net/ethernet/mellanox/mlx4/pd.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/port.c | 8 ++++----
drivers/net/ethernet/mellanox/mlx4/qp.c | 8 ++++----
drivers/net/ethernet/mellanox/mlx4/srq.c | 2 +-
8 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c
index 7e64033..0706623 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cq.c
@@ -226,7 +226,7 @@ void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn)
static void mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn)
{
- u64 in_param;
+ u64 in_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index d180bc4..16abde2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1555,7 +1555,7 @@ void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
void mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
{
- u64 in_param;
+ u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, idx);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index cf88334..d738454 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -1235,7 +1235,7 @@ int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
static inline void set_param_l(u64 *arg, u32 val)
{
- *((u32 *)arg) = val;
+ *arg = (*arg & 0xffffffff00000000ULL) | (u64) val;
}
static inline void set_param_h(u64 *arg, u32 val)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 602ca9b..f91719a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -183,7 +183,7 @@ u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order)
static u32 mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order)
{
- u64 in_param;
+ u64 in_param = 0;
u64 out_param;
int err;
@@ -240,7 +240,7 @@ void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 offset, int order)
static void mlx4_free_mtt_range(struct mlx4_dev *dev, u32 offset, int order)
{
- u64 in_param;
+ u64 in_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
@@ -351,7 +351,7 @@ void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index)
static void mlx4_mpt_release(struct mlx4_dev *dev, u32 index)
{
- u64 in_param;
+ u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, index);
@@ -374,7 +374,7 @@ int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index)
static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index)
{
- u64 param;
+ u64 param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(¶m, index);
@@ -395,7 +395,7 @@ void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index)
static void mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index)
{
- u64 in_param;
+ u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, index);
diff --git a/drivers/net/ethernet/mellanox/mlx4/pd.c b/drivers/net/ethernet/mellanox/mlx4/pd.c
index 1ac8863..00f223a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/pd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/pd.c
@@ -101,7 +101,7 @@ void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn)
void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn)
{
- u64 in_param;
+ u64 in_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index 719ead1..10c57c8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -175,7 +175,7 @@ EXPORT_SYMBOL_GPL(__mlx4_register_mac);
int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
{
- u64 out_param;
+ u64 out_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
@@ -222,7 +222,7 @@ EXPORT_SYMBOL_GPL(__mlx4_unregister_mac);
void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac)
{
- u64 out_param;
+ u64 out_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&out_param, port);
@@ -361,7 +361,7 @@ out:
int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
{
- u64 out_param;
+ u64 out_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
@@ -406,7 +406,7 @@ out:
void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index)
{
- u64 in_param;
+ u64 in_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index 81e2abe..e891b05 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -222,7 +222,7 @@ int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base)
{
- u64 in_param;
+ u64 in_param = 0;
u64 out_param;
int err;
@@ -255,7 +255,7 @@ void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
{
- u64 in_param;
+ u64 in_param = 0;
int err;
if (mlx4_is_mfunc(dev)) {
@@ -319,7 +319,7 @@ err_out:
static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
{
- u64 param;
+ u64 param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(¶m, qpn);
@@ -344,7 +344,7 @@ void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
static void mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
{
- u64 in_param;
+ u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, qpn);
diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
index feda6c0..e329fe1 100644
--- a/drivers/net/ethernet/mellanox/mlx4/srq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
@@ -149,7 +149,7 @@ void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn)
static void mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn)
{
- u64 in_param;
+ u64 in_param = 0;
if (mlx4_is_mfunc(dev)) {
set_param_l(&in_param, srqn);
--
1.7.1
^ permalink raw reply related
* [PATCH net 0/6] Mellanox Core and Ethernet driver fixes 2013-03-07
From: Or Gerlitz @ 2013-03-07 13:46 UTC (permalink / raw)
To: davem; +Cc: netdev, amirv, Or Gerlitz
Hi Dave,
Here's a batch of fixes to the mlx4 core and ethernet drivers for 3.9
The commit that disabled RFS when running in SRIOV mode fixes a regression which was
introduced in 3.9-rc1 but actually present also in the 3.8 -stable series. It turns out
that a slightly different fix is needed there and we will generate and submit it there.
Patches done against net commit 66d29cbc59433 "benet: Wait f/w POST until timeout"
Or.
Amir Vadai (1):
net/mlx4_en: Disable RFS when running in SRIOV mode
Jack Morgenstein (3):
net/mlx4_core: Disable mlx4_QP_ATTACH calls from guests if the host uses flow steering
net/mlx4_core: Turn off device-managed FS bit in dev-cap wrapper if DMFS is not enabled
net/mlx4_core: Fix endianness bug in set_param_l
Yan Burman (2):
net/mlx4_en: Fix race when setting the device MAC address
net/mlx4_en: Cleanup MAC resources on module unload or port stop
drivers/net/ethernet/mellanox/mlx4/cq.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 86 +++++++++++---------
drivers/net/ethernet/mellanox/mlx4/fw.c | 8 ++
drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/mlx4.h | 2 +-
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 -
drivers/net/ethernet/mellanox/mlx4/mr.c | 10 +-
drivers/net/ethernet/mellanox/mlx4/pd.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/port.c | 8 +-
drivers/net/ethernet/mellanox/mlx4/qp.c | 8 +-
.../net/ethernet/mellanox/mlx4/resource_tracker.c | 3 +
drivers/net/ethernet/mellanox/mlx4/srq.c | 2 +-
12 files changed, 75 insertions(+), 59 deletions(-)
^ permalink raw reply
* [PATCH net 2/6] net/mlx4_core: Turn off device-managed FS bit in dev-cap wrapper if DMFS is not enabled
From: Or Gerlitz @ 2013-03-07 13:46 UTC (permalink / raw)
To: davem; +Cc: netdev, amirv, Jack Morgenstein, Or Gerlitz
In-Reply-To: <1362664017-30275-1-git-send-email-ogerlitz@mellanox.com>
From: Jack Morgenstein <jackm@dev.mellanox.co.il>
Older kernels detect DMFS (device-managed flow steering) from the HCA
device capability directly, regardless of whether the capability was
enabled in INIT_HCA, this is fixed by commit 7b8157bed "mlx4_core: Adjustments
to Flow Steering activation logic for SR-IOV"
To protect against guests running kernels without this fix, the host driver
should turn off the DMFS capability bit in mlx4_QUERY_DEV_CAP_wrapper.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/fw.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 50917eb..f624557 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -787,6 +787,14 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
bmme_flags &= ~MLX4_BMME_FLAG_TYPE_2_WIN;
MLX4_PUT(outbox->buf, bmme_flags, QUERY_DEV_CAP_BMME_FLAGS_OFFSET);
+ /* turn off device-managed steering capability if not enabled */
+ if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) {
+ MLX4_GET(field, outbox->buf,
+ QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET);
+ field &= 0x7f;
+ MLX4_PUT(outbox->buf, field,
+ QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET);
+ }
return 0;
}
--
1.7.1
^ permalink raw reply related
* [PATCH net 1/6] net/mlx4_core: Disable mlx4_QP_ATTACH calls from guests if the host uses flow steering
From: Or Gerlitz @ 2013-03-07 13:46 UTC (permalink / raw)
To: davem; +Cc: netdev, amirv, Jack Morgenstein, Or Gerlitz
In-Reply-To: <1362664017-30275-1-git-send-email-ogerlitz@mellanox.com>
From: Jack Morgenstein <jackm@dev.mellanox.co.il>
Guests kernels may not correctly detect if DMFS (device-enabled flow steering) is
activated by the host. If DMFS is activated, the master should return error to guests
which try to use the B0-steering flow calls (mlx4_QP_ATTACH).
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
.../net/ethernet/mellanox/mlx4/resource_tracker.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 083fb48..2995687 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2990,6 +2990,9 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
u8 steer_type_mask = 2;
enum mlx4_steer_type type = (gid[7] & steer_type_mask) >> 1;
+ if (dev->caps.steering_mode != MLX4_STEERING_MODE_B0)
+ return -EINVAL;
+
qpn = vhcr->in_modifier & 0xffffff;
err = get_res(dev, slave, qpn, RES_QP, &rqp);
if (err)
--
1.7.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