netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bridge: Fix setting a flag in br_fill_ifvlaninfo_range().
@ 2015-05-15 14:27 Rami Rosen
  2015-05-15 18:45 ` Arad, Ronen
  0 siblings, 1 reply; 3+ messages in thread
From: Rami Rosen @ 2015-05-15 14:27 UTC (permalink / raw)
  To: davem; +Cc: netdev, roopa, ronen.arad, Rami Rosen

This patch fixes setting of vinfo.flags in the br_fill_ifvlaninfo_range(). The  
assignment of vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN has no effect without 
this patch, as vinfo.flags value is overriden by the 
vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END assignement,  which follows 
it immedialtely.

Signed-off-by: Rami Rosen <rami.rosen@intel.com>
---
 net/bridge/br_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 6b67ed3..fec65bb 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -167,7 +167,7 @@ static int br_fill_ifvlaninfo_range(struct sk_buff *skb, u16 vid_start,
 		vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
 
 		vinfo.vid = vid_end;
-		vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END;
+		vinfo.flags &= flags | BRIDGE_VLAN_INFO_RANGE_END;
 		if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
 			    sizeof(vinfo), &vinfo))
 			goto nla_put_failure;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next] bridge: Fix setting a flag in br_fill_ifvlaninfo_range().
  2015-05-15 14:27 [PATCH net-next] bridge: Fix setting a flag in br_fill_ifvlaninfo_range() Rami Rosen
@ 2015-05-15 18:45 ` Arad, Ronen
  2015-05-15 19:11   ` roopa
  0 siblings, 1 reply; 3+ messages in thread
From: Arad, Ronen @ 2015-05-15 18:45 UTC (permalink / raw)
  To: Rosen, Rami, davem@davemloft.net, netdev@vger.kernel.org
  Cc: roopa@cumulusnetworks.com



>-----Original Message-----
>From: Rosen, Rami
>Sent: Friday, May 15, 2015 7:27 AM
>To: davem@davemloft.net
>Cc: netdev@vger.kernel.org; roopa@cumulusnetworks.com; Arad, Ronen; Rosen,
>Rami
>Subject: [PATCH net-next] bridge: Fix setting a flag in
>br_fill_ifvlaninfo_range().
>
>This patch fixes setting of vinfo.flags in the br_fill_ifvlaninfo_range(). The
>assignment of vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN has no effect
>without
>this patch, as vinfo.flags value is overriden by the
>vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END assignement,  which follows
>it immedialtely.
>
>Signed-off-by: Rami Rosen <rami.rosen@intel.com>
>---
> net/bridge/br_netlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
>index 6b67ed3..fec65bb 100644
>--- a/net/bridge/br_netlink.c
>+++ b/net/bridge/br_netlink.c
>@@ -167,7 +167,7 @@ static int br_fill_ifvlaninfo_range(struct sk_buff *skb,
>u16 vid_start,
> 		vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
>
> 		vinfo.vid = vid_end;
>-		vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END;
>+		vinfo.flags &= flags | BRIDGE_VLAN_INFO_RANGE_END;
> 		if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
> 			    sizeof(vinfo), &vinfo))
> 			goto nla_put_failure;


The first part of " &= flags " has no impact as it reverts vinfo.flags to
just the bits set in the flags argument. This is exactly what
"vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN" does.

If original code was intended to indicate that the same flags are used for 
both start and end attributes except for the RANGE_BEGIN/RANGE_END flags
it would be sufficient to keep the line that clears RANGE_BEGIN bit and 
OR vinfo.flags with RANGE_END for the end attribute:

vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_END;

If we want the code to show what is actually been written into each
attribute, the fix should be to just delete the line which clears 
RANGE_BEGIN flag.

In either case the code as exists today is working as expected. A fix is
only needed to improve readability.
 
>--
>1.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] bridge: Fix setting a flag in br_fill_ifvlaninfo_range().
  2015-05-15 18:45 ` Arad, Ronen
@ 2015-05-15 19:11   ` roopa
  0 siblings, 0 replies; 3+ messages in thread
From: roopa @ 2015-05-15 19:11 UTC (permalink / raw)
  To: Arad, Ronen; +Cc: Rosen, Rami, davem@davemloft.net, netdev@vger.kernel.org

On 5/15/15, 11:45 AM, Arad, Ronen wrote:
>
>> -----Original Message-----
>> From: Rosen, Rami
>> Sent: Friday, May 15, 2015 7:27 AM
>> To: davem@davemloft.net
>> Cc: netdev@vger.kernel.org; roopa@cumulusnetworks.com; Arad, Ronen; Rosen,
>> Rami
>> Subject: [PATCH net-next] bridge: Fix setting a flag in
>> br_fill_ifvlaninfo_range().
>>
>> This patch fixes setting of vinfo.flags in the br_fill_ifvlaninfo_range(). The
>> assignment of vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN has no effect
>> without
>> this patch, as vinfo.flags value is overriden by the
>> vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END assignement,  which follows
>> it immedialtely.
>>
>> Signed-off-by: Rami Rosen <rami.rosen@intel.com>
>> ---
>> net/bridge/br_netlink.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
>> index 6b67ed3..fec65bb 100644
>> --- a/net/bridge/br_netlink.c
>> +++ b/net/bridge/br_netlink.c
>> @@ -167,7 +167,7 @@ static int br_fill_ifvlaninfo_range(struct sk_buff *skb,
>> u16 vid_start,
>> 		vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
>>
>> 		vinfo.vid = vid_end;
>> -		vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END;
>> +		vinfo.flags &= flags | BRIDGE_VLAN_INFO_RANGE_END;
>> 		if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
>> 			    sizeof(vinfo), &vinfo))
>> 			goto nla_put_failure;
>
> The first part of " &= flags " has no impact as it reverts vinfo.flags to
> just the bits set in the flags argument. This is exactly what
> "vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN" does.
>
> If original code was intended to indicate that the same flags are used for
> both start and end attributes except for the RANGE_BEGIN/RANGE_END flags
> it would be sufficient to keep the line that clears RANGE_BEGIN bit and
> OR vinfo.flags with RANGE_END for the end attribute:
>
> vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_END;
>
> If we want the code to show what is actually been written into each
> attribute, the fix should be to just delete the line which clears
> RANGE_BEGIN flag.
I would prefer the fix to just delete the line that clears RANGE_BEGIN 
because as you and this patch points out that it is a no-op.

>
> In either case the code as exists today is working as expected. A fix is
> only needed to improve readability.
agreed.

In any case Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>

thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-15 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 14:27 [PATCH net-next] bridge: Fix setting a flag in br_fill_ifvlaninfo_range() Rami Rosen
2015-05-15 18:45 ` Arad, Ronen
2015-05-15 19:11   ` roopa

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).