Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jonathan Toppins <jtoppins@redhat.com>
To: Jussi Maki <joamaki@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net, bonding: Disallow vlan+srcmac with XDP
Date: Fri, 13 Aug 2021 15:40:13 -0400	[thread overview]
Message-ID: <296b11ac-dd4b-6c7e-b1ce-506e8929a853@redhat.com> (raw)
In-Reply-To: <20210812145241.12449-1-joamaki@gmail.com>

On 8/12/21 10:52 AM, Jussi Maki wrote:
> The new vlan+srcmac xmit policy is not implementable with XDP since
> in many cases the 802.1Q payload is not present in the packet. This
> can be for example due to hardware offload or in the case of veth
> due to use of skbuffs internally.
> 
> This also fixes the NULL deref with the vlan+srcmac xmit policy
> reported by Jonathan Toppins by additionally checking the skb
> pointer.
> 
> Fixes: a815bde56b15 ("net, bonding: Refactor bond_xmit_hash for use with xdp_buff")
> Reported-by: Jonathan Toppins <jtoppins@redhat.com>
> Signed-off-by: Jussi Maki <joamaki@gmail.com>

Looks good, thanks.

Reviewed-by: Jonathan Toppins <jtoppins@redhat.com>

> ---
>   drivers/net/bonding/bond_main.c | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index c0db4e2b2462..04158a8368e4 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -322,9 +322,15 @@ static bool bond_xdp_check(struct bonding *bond)
>   	switch (BOND_MODE(bond)) {
>   	case BOND_MODE_ROUNDROBIN:
>   	case BOND_MODE_ACTIVEBACKUP:
> +		return true;
>   	case BOND_MODE_8023AD:
>   	case BOND_MODE_XOR:
> -		return true;
> +		/* vlan+srcmac is not supported with XDP as in most cases the 802.1q
> +		 * payload is not in the packet due to hardware offload.
> +		 */
> +		if (bond->params.xmit_policy != BOND_XMIT_POLICY_VLAN_SRCMAC)
> +			return true;
> +		fallthrough;
>   	default:
>   		return false;
>   	}
> @@ -3744,9 +3750,9 @@ static bool bond_flow_ip(struct sk_buff *skb, struct flow_keys *fk, const void *
>   
>   static u32 bond_vlan_srcmac_hash(struct sk_buff *skb, const void *data, int mhoff, int hlen)
>   {
> -	struct ethhdr *mac_hdr;
>   	u32 srcmac_vendor = 0, srcmac_dev = 0;
> -	u16 vlan;
> +	struct ethhdr *mac_hdr;
> +	u16 vlan = 0;
>   	int i;
>   
>   	data = bond_pull_data(skb, data, hlen, mhoff + sizeof(struct ethhdr));
> @@ -3760,10 +3766,8 @@ static u32 bond_vlan_srcmac_hash(struct sk_buff *skb, const void *data, int mhof
>   	for (i = 3; i < ETH_ALEN; i++)
>   		srcmac_dev = (srcmac_dev << 8) | mac_hdr->h_source[i];
>   
> -	if (!skb_vlan_tag_present(skb))
> -		return srcmac_vendor ^ srcmac_dev;
> -
> -	vlan = skb_vlan_tag_get(skb);
> +	if (skb && skb_vlan_tag_present(skb))
> +		vlan = skb_vlan_tag_get(skb);
>   
>   	return vlan ^ srcmac_vendor ^ srcmac_dev;
>   }
> 


  parent reply	other threads:[~2021-08-13 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 14:52 [PATCH net-next] net, bonding: Disallow vlan+srcmac with XDP Jussi Maki
2021-08-12 15:01 ` Nikolay Aleksandrov
2021-08-12 15:12   ` Jussi Maki
2021-08-12 15:21     ` Nikolay Aleksandrov
2021-08-13 19:40 ` Jonathan Toppins [this message]
2021-08-13 21:10 ` patchwork-bot+netdevbpf

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=296b11ac-dd4b-6c7e-b1ce-506e8929a853@redhat.com \
    --to=jtoppins@redhat.com \
    --cc=joamaki@gmail.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).