Skip to content

Commit

Permalink
ibmveth: Detect unsupported packets before sending to the hypervisor
Browse files Browse the repository at this point in the history
Currently, when ibmveth receive a loopback packet, it reports an
ambiguous error message "tx: h_send_logical_lan failed with rc=-4"
because the hypervisor rejects those types of packets. This fix
detects loopback packet and assures the source packet's MAC address
matches the driver's MAC address before transmitting to the
hypervisor.

Signed-off-by: Cris Forno <cforno12@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Cris Forno authored and davem330 committed Nov 15, 2019
1 parent 01db923 commit 6f22754
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions drivers/net/ethernet/ibm/ibmveth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,29 @@ static int ibmveth_send(struct ibmveth_adapter *adapter,
return 0;
}

static int ibmveth_is_packet_unsupported(struct sk_buff *skb,
struct net_device *netdev)
{
struct ethhdr *ether_header;
int ret = 0;

ether_header = eth_hdr(skb);

if (ether_addr_equal(ether_header->h_dest, netdev->dev_addr)) {
netdev_dbg(netdev, "veth doesn't support loopback packets, dropping packet.\n");
netdev->stats.tx_dropped++;
ret = -EOPNOTSUPP;
}

if (!ether_addr_equal(ether_header->h_source, netdev->dev_addr)) {
netdev_dbg(netdev, "source packet MAC address does not match veth device's, dropping packet.\n");
netdev->stats.tx_dropped++;
ret = -EOPNOTSUPP;
}

return ret;
}

static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
struct net_device *netdev)
{
Expand All @@ -1022,6 +1045,9 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
dma_addr_t dma_addr;
unsigned long mss = 0;

if (ibmveth_is_packet_unsupported(skb, netdev))
goto out;

/* veth doesn't handle frag_list, so linearize the skb.
* When GRO is enabled SKB's can have frag_list.
*/
Expand Down

0 comments on commit 6f22754

Please sign in to comment.