9 May 2012 06:56

```Add a boolean function to test 2 ethernet addresses for equality

Joe Perches (13):

include/linux/etherdevice.h               |   12 +++++++++
net/802/stp.c                             |    2 +-
net/8021q/vlan.c                          |   10 +++---
net/8021q/vlan_core.c                     |    3 +-
net/8021q/vlan_dev.c                      |   10 +++---
net/atm/lec.c                             |    6 ++--
net/atm/mpc.c                             |    3 +-
net/bluetooth/bnep/core.c                 |    6 ++--
net/bridge/br_device.c                    |    2 +-
net/bridge/br_fdb.c                       |   14 +++++-----
net/bridge/br_input.c                     |    2 +-
net/bridge/br_stp_bpdu.c                  |    2 +-
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 17:07

```On Tue,  8 May 2012 21:56:48 -0700
Joe Perches <joe <at> perches.com> wrote:

> some clarity and reduce the likelihood for misuse
>
> Done via cocci script:
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
> -	!ether_addr_equal(a, b) == 0
>
>  <at>  <at>
> expression a,b;
```

9 May 2012 17:07

```On Tue,  8 May 2012 21:56:48 -0700
Joe Perches <joe <at> perches.com> wrote:

> some clarity and reduce the likelihood for misuse
>
> Done via cocci script:
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
>
>  <at>  <at>
> expression a,b;
>  <at>  <at>
> -	!ether_addr_equal(a, b) == 0
>
>  <at>  <at>
> expression a,b;
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

I removed a conversion from scan.c/cmp_bss_core
that appears to be a sorting function.

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
```

9 May 2012 06:56

```spatch/coccinelle isn't perfect.  It doesn't understand
__aligned(x) and doesn't convert functions it can't parse.

Signed-off-by: Joe Perches <joe <at> perches.com>
---
net/wireless/util.c |    6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/wireless/util.c b/net/wireless/util.c
index 3ba366f..1cd2558 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
<at>  <at>  -370,7 +370,7  <at>  <at>  int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
iftype != NL80211_IFTYPE_P2P_CLIENT &&
iftype != NL80211_IFTYPE_MESH_POINT) ||
return -1;
if (iftype == NL80211_IFTYPE_MESH_POINT) {
struct ieee80211s_hdr *meshdr =
<at>  <at>  -398,9 +398,9  <at>  <at>  int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,

ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
```

9 May 2012 06:56

```spatch/coccinelle isn't perfect.  It doesn't understand
__aligned(x) and doesn't convert functions it can't parse.

Signed-off-by: Joe Perches <joe <at> perches.com>
---
net/mac80211/rx.c       |    4 ++--
net/mac80211/sta_info.h |    2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 26bfd6f..d722c40 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
<at>  <at>  -1714,8 +1714,8  <at>  <at>  static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
* of whether the frame was encrypted or not.
*/
if (ehdr->h_proto == rx->sdata->control_port_protocol &&
return true;

if (ieee80211_802_1x_port_control(rx) ||
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index f75f5d9..e920b22 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse

Done via cocci script:

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>

<at>  <at>
expression a,b;
<at>  <at>
```

9 May 2012 06:56

```Add a boolean function to check if 2 ethernet addresses
are the same.

returning an unsigned, and not being able to use the
compare_ether_addr function for sorting ala memcmp.

Signed-off-by: Joe Perches <joe <at> perches.com>
---
include/linux/etherdevice.h |   12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index c47631f..f330114 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
}

+/**
+ *  <at> addr1: Pointer to a six-byte array containing the Ethernet address
+ *  <at> addr2: Pointer other six-byte array containing the Ethernet address
+ *
+ * Compare two ethernet addresses, returns true if equal
+ */
+{
```

10 May 2012 03:21

```From: Joe Perches <joe <at> perches.com>
Date: Tue,  8 May 2012 21:56:44 -0700

> Add a boolean function to test 2 ethernet addresses for equality

This series looks great, I'll apply all of it.

Thanks Joe.

That case you didn't convert in mac80211 is probably the
bug Johannes was talking about which started this whole
discussion.
```
10 May 2012 03:48

```On Wed, 2012-05-09 at 21:21 -0400, David Miller wrote:
> From: Joe Perches <joe <at> perches.com>
> Date: Tue,  8 May 2012 21:56:44 -0700
>
> > Add a boolean function to test 2 ethernet addresses for equality
>
> This series looks great, I'll apply all of it.

coccinelle is a nifty, better sed, tool.  Thanks Julia et al.

> That case you didn't convert in mac80211 is probably the
> bug Johannes was talking about which started this whole
> discussion.

Looks like it.

Do you want a similar patch/patches for drivers/net?

If I break it out by nominal driver/maintainer,
it'll be a highish number of low density patches.

\$ git grep -w compare_ether_addr drivers/net | wc -l
59
\$ git grep -w -l compare_ether_addr drivers/net | wc -l
31

Maybe just a single patch?

```

10 May 2012 03:53

```From: Joe Perches <joe <at> perches.com>
Date: Wed, 09 May 2012 18:48:04 -0700

> Maybe just a single patch?

Yes, I think high density on this one, it's extremely
mechanical.

> Also the compare_ether_addr_64bits function is
> still used a couple dozen times.  Maybe another

```
10 May 2012 08:48

```On Wed, 2012-05-09 at 21:21 -0400, David Miller wrote:

> That case you didn't convert in mac80211 is probably the
> bug Johannes was talking about which started this whole
> discussion.

The bug case that started it all is in net/wireless/scan.c and Emmanuel
has since changed it back to memcmp(). Not sure if that's the one you
were referring to or not

johannes
```
10 May 2012 08:54

```On Thu, 2012-05-10 at 08:48 +0200, Johannes Berg wrote:
> On Wed, 2012-05-09 at 21:21 -0400, David Miller wrote:
>
> > That case you didn't convert in mac80211 is probably the
> > bug Johannes was talking about which started this whole
> > discussion.
>
> The bug case that started it all is in net/wireless/scan.c and Emmanuel
> has since changed it back to memcmp(). Not sure if that's the one you
> were referring to or not

That's the one that I left alone.

Post patch:
\$ git grep -n -w compare_ether_addr net

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

```
10 May 2012 08:56

```On Wed, 2012-05-09 at 23:54 -0700, Joe Perches wrote:
> On Thu, 2012-05-10 at 08:48 +0200, Johannes Berg wrote:
> > On Wed, 2012-05-09 at 21:21 -0400, David Miller wrote:
> >
> > > That case you didn't convert in mac80211 is probably the
> > > bug Johannes was talking about which started this whole
> > > discussion.
> >
> > The bug case that started it all is in net/wireless/scan.c and Emmanuel
> > has since changed it back to memcmp(). Not sure if that's the one you
> > were referring to or not
>
> That's the one that I left alone.
>
> Post patch:
> \$ git grep -n -w compare_ether_addr net
> net/batman-adv/main.h:198: * note: can't use compare_ether_addr() as it requires aligned memory

Ok, great, then that means the fix from Emmanuel won't conflict when it
gets in.

johannes
```
10 May 2012 09:08

```>> >
>> > > That case you didn't convert in mac80211 is probably the
>> > > bug Johannes was talking about which started this whole
>> > > discussion.
>> >
>> > The bug case that started it all is in net/wireless/scan.c and Emmanuel
>> > has since changed it back to memcmp(). Not sure if that's the one you
>> > were referring to or not
>>
>> That's the one that I left alone.
>>
>> Post patch:
>> \$ git grep -n -w compare_ether_addr net
>> net/batman-adv/main.h:198: * note: can't use compare_ether_addr() as it requires aligned memory
>
> Ok, great, then that means the fix from Emmanuel won't conflict when it
> gets in.
>

Thanks Joe - as Johannes said this won't conflict with my patch. And
yes the code is now more clear.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

```
10 May 2012 09:08

```>> >
>> > > That case you didn't convert in mac80211 is probably the
>> > > bug Johannes was talking about which started this whole
>> > > discussion.
>> >
>> > The bug case that started it all is in net/wireless/scan.c and Emmanuel
>> > has since changed it back to memcmp(). Not sure if that's the one you
>> > were referring to or not
>>
>> That's the one that I left alone.
>>
>> Post patch:
>> \$ git grep -n -w compare_ether_addr net
>> net/batman-adv/main.h:198: * note: can't use compare_ether_addr() as it requires aligned memory
>
> Ok, great, then that means the fix from Emmanuel won't conflict when it
> gets in.
>

Thanks Joe - as Johannes said this won't conflict with my patch. And
yes the code is now more clear.
```
10 May 2012 08:54

```On Thu, 2012-05-10 at 08:48 +0200, Johannes Berg wrote:
> On Wed, 2012-05-09 at 21:21 -0400, David Miller wrote:
>
> > That case you didn't convert in mac80211 is probably the
> > bug Johannes was talking about which started this whole
> > discussion.
>
> The bug case that started it all is in net/wireless/scan.c and Emmanuel
> has since changed it back to memcmp(). Not sure if that's the one you
> were referring to or not

That's the one that I left alone.

Post patch:
\$ git grep -n -w compare_ether_addr net