netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Falcon <tlfalcon@linux.ibm.com>
To: Cris Forno <cforno12@linux.vnet.ibm.com>, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] ibmveth: Detect unsupported packets before sending to the hypervisor
Date: Wed, 13 Nov 2019 11:21:07 -0600	[thread overview]
Message-ID: <6a3b6d64-8f12-7be7-6e0d-e158474f1d8c@linux.ibm.com> (raw)
In-Reply-To: <20191113154407.50653-1-cforno12@linux.vnet.ibm.com>

On 11/13/19 9:44 AM, Cris Forno wrote:
> 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>

Thanks, Cris!

Reviewed-by: Thomas Falcon <tlfalcon@linux.ibm.com>

> ---
>   drivers/net/ethernet/ibm/ibmveth.c | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
>
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index d654c23..e8bb6c7 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -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)
> +{
> +	int ret = 0;
> +	struct ethhdr *ether_header;
> +
> +	ether_header = eth_hdr(skb);
> +
> +	if (ether_addr_equal(ether_header->h_dest, netdev->dev_addr)) {
> +		netdev_err(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_err(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)
>   {
> @@ -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.
>   	 */

  reply	other threads:[~2019-11-13 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 15:44 [PATCH net-next] ibmveth: Detect unsupported packets before sending to the hypervisor Cris Forno
2019-11-13 17:21 ` Thomas Falcon [this message]
2019-11-13 20:23 ` David Miller
2019-11-13 20:28 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a3b6d64-8f12-7be7-6e0d-e158474f1d8c@linux.ibm.com \
    --to=tlfalcon@linux.ibm.com \
    --cc=cforno12@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).