From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Bo YU <tsu.yubo@gmail.com>
Cc: vfalico@gmail.com, andy@greyhouse.net, davem@davemloft.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
yuzibode@126.com
Subject: Re: [PATCH 1/2] net: bonding: fix restricted __be16 degrades to integer
Date: Fri, 08 Mar 2019 12:54:46 -0800 [thread overview]
Message-ID: <24216.1552078486@famine> (raw)
In-Reply-To: <2a069375f8393bf05a44669e00281714063a8530.1552023000.git.tsu.yubo@gmail.com>
Bo YU <tsu.yubo@gmail.com> wrote:
>There are some warning when:
>
>sudo make C=1 CF=-D__CHECK_ENDIAN__ drivers/net/bonding/
>
>drivers/net/bonding/bond_main.c:2385:26: warning: restricted __be16 degrades to integer
>drivers/net/bonding/bond_main.c:2391:20: warning: restricted __be16 degrades to integer
>...
>drivers/net/bonding/bond_main.c:3241:60: warning: restricted __be16 degrades to integer
>drivers/net/bonding/bond_main.c:3241:60: warning: restricted __be16 degrades to integer
>
>So fix it.
>
>Signed-off-by: Bo YU <tsu.yubo@gmail.com>
>---
> drivers/net/bonding/bond_main.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index b59708c35faf..135fec28daa9 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -2382,13 +2382,13 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op,
> return;
> }
>
>- if (!tags || tags->vlan_proto == VLAN_N_VID)
>+ if (!tags || be16_to_cpu(tags->vlan_proto) == VLAN_N_VID)
> goto xmit;
>
> tags++;
>
> /* Go through all the tags backwards and add them to the packet */
>- while (tags->vlan_proto != VLAN_N_VID) {
>+ while (be16_to_cpu(tags->vlan_proto) != VLAN_N_VID) {
I believe both of the above are incorrect, as vlan_proto is set
explicitly to VLAN_N_VID (in host byte order) by bond_verify_device_path
as a sentinel value. Byte swapping the tags->vlan_proto value would
cause the test or loop to miss the sentinel.
> if (!tags->vlan_id) {
> tags++;
> continue;
>@@ -3238,7 +3238,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
>
> ep = skb_header_pointer(skb, 0, sizeof(hdr_tmp), &hdr_tmp);
> if (ep)
>- return ep->h_dest[5] ^ ep->h_source[5] ^ ep->h_proto;
>+ return ep->h_dest[5] ^ ep->h_source[5] ^ be16_to_cpu(ep->h_proto);
This is probably harmless, other than adding work to the
transmit path.
-J
---
-Jay Vosburgh, jay.vosburgh@canonical.com
next prev parent reply other threads:[~2019-03-08 20:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 5:33 [PATCH 0/2] net: bonding: fix sparse warning Bo YU
2019-03-08 5:33 ` [PATCH 1/2] net: bonding: fix restricted __be16 degrades to integer Bo YU
2019-03-08 20:54 ` Jay Vosburgh [this message]
2019-03-08 5:34 ` [PATCH 2/2] net: bonding: fix incorrect type in assignment Bo YU
2019-03-08 6:51 ` Jay Vosburgh
2019-03-08 8:28 ` Bo YU
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=24216.1552078486@famine \
--to=jay.vosburgh@canonical.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tsu.yubo@gmail.com \
--cc=vfalico@gmail.com \
--cc=yuzibode@126.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.