qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled
@ 2015-07-01  2:25 sfeldma
  2015-07-01  2:52 ` Fam Zheng
  2015-07-02 13:04 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: sfeldma @ 2015-07-01  2:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: famz, jiri, stefanha

From: Scott Feldman <sfeldma@gmail.com>

Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the
semantics around .can_receive for sockets to now require the device to
flush queued pkts when transitioning to a .can_receive=true state.  Rocker
device was not flushing the queue on .can_receive=true transition, so the
receiver was stuck.

But, turns out we really don't want any queuing at all on the port when the
port is disabled, otherwise when the port transitions to enabled, we'd
receive and forward stale pkts that really should have been dropped.  So,
let's remove .can_receive so avoid queuing and drop the pkt in .receive if
the port is disabled.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
---
v2: return -1 to drop pkt, review comment from famz@redhat.com

 hw/net/rocker/rocker_fp.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
index d8d934c..c693ae5 100644
--- a/hw/net/rocker/rocker_fp.c
+++ b/hw/net/rocker/rocker_fp.c
@@ -125,18 +125,21 @@ int fp_port_eg(FpPort *port, const struct iovec *iov, int iovcnt)
     return ROCKER_OK;
 }
 
-static int fp_port_can_receive(NetClientState *nc)
-{
-    FpPort *port = qemu_get_nic_opaque(nc);
-
-    return port->enabled;
-}
-
 static ssize_t fp_port_receive_iov(NetClientState *nc, const struct iovec *iov,
                                    int iovcnt)
 {
     FpPort *port = qemu_get_nic_opaque(nc);
 
+    /* If the port is disabled, we want to drop this pkt
+     * now rather than queing it for later.  We don't want
+     * any stale pkts getting into the device when the port
+     * transitions to enabled.
+     */
+
+    if (!port->enabled) {
+        return -1;
+    }
+
     return world_ingress(port->world, port->pport, iov, iovcnt);
 }
 
@@ -165,7 +168,6 @@ static void fp_port_set_link_status(NetClientState *nc)
 static NetClientInfo fp_port_info = {
     .type = NET_CLIENT_OPTIONS_KIND_NIC,
     .size = sizeof(NICState),
-    .can_receive = fp_port_can_receive,
     .receive = fp_port_receive,
     .receive_iov = fp_port_receive_iov,
     .cleanup = fp_port_cleanup,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled
  2015-07-01  2:25 [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled sfeldma
@ 2015-07-01  2:52 ` Fam Zheng
  2015-07-02 13:04 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2015-07-01  2:52 UTC (permalink / raw)
  To: sfeldma; +Cc: jiri, qemu-devel, stefanha

On Tue, 06/30 19:25, sfeldma@gmail.com wrote:
> From: Scott Feldman <sfeldma@gmail.com>
> 
> Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the
> semantics around .can_receive for sockets to now require the device to
> flush queued pkts when transitioning to a .can_receive=true state.  Rocker
> device was not flushing the queue on .can_receive=true transition, so the
> receiver was stuck.
> 
> But, turns out we really don't want any queuing at all on the port when the
> port is disabled, otherwise when the port transitions to enabled, we'd
> receive and forward stale pkts that really should have been dropped.  So,
> let's remove .can_receive so avoid queuing and drop the pkt in .receive if
> the port is disabled.
> 
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> ---
> v2: return -1 to drop pkt, review comment from famz@redhat.com
> 
>  hw/net/rocker/rocker_fp.c |   18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
> index d8d934c..c693ae5 100644
> --- a/hw/net/rocker/rocker_fp.c
> +++ b/hw/net/rocker/rocker_fp.c
> @@ -125,18 +125,21 @@ int fp_port_eg(FpPort *port, const struct iovec *iov, int iovcnt)
>      return ROCKER_OK;
>  }
>  
> -static int fp_port_can_receive(NetClientState *nc)
> -{
> -    FpPort *port = qemu_get_nic_opaque(nc);
> -
> -    return port->enabled;
> -}
> -
>  static ssize_t fp_port_receive_iov(NetClientState *nc, const struct iovec *iov,
>                                     int iovcnt)
>  {
>      FpPort *port = qemu_get_nic_opaque(nc);
>  
> +    /* If the port is disabled, we want to drop this pkt
> +     * now rather than queing it for later.  We don't want
> +     * any stale pkts getting into the device when the port
> +     * transitions to enabled.
> +     */
> +
> +    if (!port->enabled) {
> +        return -1;
> +    }
> +
>      return world_ingress(port->world, port->pport, iov, iovcnt);
>  }
>  
> @@ -165,7 +168,6 @@ static void fp_port_set_link_status(NetClientState *nc)
>  static NetClientInfo fp_port_info = {
>      .type = NET_CLIENT_OPTIONS_KIND_NIC,
>      .size = sizeof(NICState),
> -    .can_receive = fp_port_can_receive,
>      .receive = fp_port_receive,
>      .receive_iov = fp_port_receive_iov,
>      .cleanup = fp_port_cleanup,
> -- 
> 1.7.10.4
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled
  2015-07-01  2:25 [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled sfeldma
  2015-07-01  2:52 ` Fam Zheng
@ 2015-07-02 13:04 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-07-02 13:04 UTC (permalink / raw)
  To: sfeldma; +Cc: famz, jiri, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

On Tue, Jun 30, 2015 at 07:25:53PM -0700, sfeldma@gmail.com wrote:
> From: Scott Feldman <sfeldma@gmail.com>
> 
> Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the
> semantics around .can_receive for sockets to now require the device to
> flush queued pkts when transitioning to a .can_receive=true state.  Rocker
> device was not flushing the queue on .can_receive=true transition, so the
> receiver was stuck.
> 
> But, turns out we really don't want any queuing at all on the port when the
> port is disabled, otherwise when the port transitions to enabled, we'd
> receive and forward stale pkts that really should have been dropped.  So,
> let's remove .can_receive so avoid queuing and drop the pkt in .receive if
> the port is disabled.
> 
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> ---
> v2: return -1 to drop pkt, review comment from famz@redhat.com
> 
>  hw/net/rocker/rocker_fp.c |   18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-02 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01  2:25 [Qemu-devel] [PATCH v2] rocker: don't queue receive pkts when port is disabled sfeldma
2015-07-01  2:52 ` Fam Zheng
2015-07-02 13:04 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).