* [PATCH net] sunvnet: only use connected ports when sending
@ 2014-07-25 14:30 David L Stevens
2014-07-29 0:30 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: David L Stevens @ 2014-07-25 14:30 UTC (permalink / raw)
To: David Miller; +Cc: netdev
The sunvnet driver doesn't check whether or not a port is connected when
transmitting packets, which results in failures if a port fails to connect
(e.g., due to a version mismatch). The original code also assumes
unnecessarily that the first port is up and a switch, even though there is
a flag for switch ports.
This patch only matches a port if it is connected, and otherwise uses the
switch_port flag to send the packet to a switch port that is up.
Signed-off-by: David L Stevens <david.stevens@oracle.com>
---
drivers/net/ethernet/sun/sunvnet.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index fd411d6..d813bfb 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -610,6 +610,13 @@ static int __vnet_tx_trigger(struct vnet_port *port)
return err;
}
+static inline bool port_is_up(struct vnet_port *vnet)
+{
+ struct vio_driver_state *vio = &vnet->vio;
+
+ return !!(vio->hs_state & VIO_HS_COMPLETE);
+}
+
struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb)
{
unsigned int hash = vnet_hashfn(skb->data);
@@ -617,14 +624,19 @@ struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb)
struct vnet_port *port;
hlist_for_each_entry(port, hp, hash) {
+ if (!port_is_up(port))
+ continue;
if (ether_addr_equal(port->raddr, skb->data))
return port;
}
- port = NULL;
- if (!list_empty(&vp->port_list))
- port = list_entry(vp->port_list.next, struct vnet_port, list);
-
- return port;
+ list_for_each_entry(port, &vp->port_list, list) {
+ if (!port->switch_port)
+ continue;
+ if (!port_is_up(port))
+ continue;
+ return port;
+ }
+ return NULL;
}
struct vnet_port *tx_port_find(struct vnet *vp, struct sk_buff *skb)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] sunvnet: only use connected ports when sending
2014-07-25 14:30 [PATCH net] sunvnet: only use connected ports when sending David L Stevens
@ 2014-07-29 0:30 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-07-29 0:30 UTC (permalink / raw)
To: david.stevens; +Cc: netdev
From: David L Stevens <david.stevens@oracle.com>
Date: Fri, 25 Jul 2014 10:30:11 -0400
> The sunvnet driver doesn't check whether or not a port is connected when
> transmitting packets, which results in failures if a port fails to connect
> (e.g., due to a version mismatch). The original code also assumes
> unnecessarily that the first port is up and a switch, even though there is
> a flag for switch ports.
>
> This patch only matches a port if it is connected, and otherwise uses the
> switch_port flag to send the packet to a switch port that is up.
>
> Signed-off-by: David L Stevens <david.stevens@oracle.com>
Applied and queued up for -stable, thanks David.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-29 0:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 14:30 [PATCH net] sunvnet: only use connected ports when sending David L Stevens
2014-07-29 0:30 ` David Miller
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).