From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9wh8-0000sA-Et for qemu-devel@nongnu.org; Tue, 30 Jun 2015 10:39:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9wh3-00075a-Fs for qemu-devel@nongnu.org; Tue, 30 Jun 2015 10:39:30 -0400 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:33666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9wh3-00075W-7M for qemu-devel@nongnu.org; Tue, 30 Jun 2015 10:39:25 -0400 Received: by pdjd13 with SMTP id d13so7371817pdj.0 for ; Tue, 30 Jun 2015 07:39:24 -0700 (PDT) From: sfeldma@gmail.com Date: Tue, 30 Jun 2015 07:41:32 -0700 Message-Id: <1435675292-1298-1-git-send-email-sfeldma@gmail.com> Subject: [Qemu-devel] [PATCH] rocker: don't queue receive pkts when port is disabled List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, jiri@resnulli.us, stefanha@redhat.com From: Scott Feldman 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 --- 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..ac53c13 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 iov_size(iov, iovcnt); + } + 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