Skip to content

Commit

Permalink
sunvnet: only use connected ports when sending
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David L Stevens authored and David S. Miller committed Jul 29, 2014
1 parent 8356f97 commit 8266f5f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions drivers/net/ethernet/sun/sunvnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,21 +610,33 @@ 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);
struct hlist_head *hp = &vp->port_hash[hash];
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)
Expand Down

0 comments on commit 8266f5f

Please sign in to comment.