aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-08 14:56:49 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-09 20:49:17 -0400
commit9a7b6ef9b9938a1f5cb91ccc0b713b9443edc79f (patch)
tree9fcdd72bb2adb4e481bf30aa0143d65627ebd637
parent171fe5ef140571c7465e625e9cd9fdf3340ad20e (diff)
bridge: Convert compare_ether_addr to ether_addr_equal
Use the new bool function ether_addr_equal to add some clarity and reduce the likelihood for misuse of compare_ether_addr for sorting. Done via cocci script: $ cat compare_ether_addr.cocci @@ expression a,b; @@ - !compare_ether_addr(a, b) + ether_addr_equal(a, b) @@ expression a,b; @@ - compare_ether_addr(a, b) + !ether_addr_equal(a, b) @@ expression a,b; @@ - !ether_addr_equal(a, b) == 0 + ether_addr_equal(a, b) @@ expression a,b; @@ - !ether_addr_equal(a, b) != 0 + !ether_addr_equal(a, b) @@ expression a,b; @@ - ether_addr_equal(a, b) == 0 + !ether_addr_equal(a, b) @@ expression a,b; @@ - ether_addr_equal(a, b) != 0 + ether_addr_equal(a, b) @@ expression a,b; @@ - !!ether_addr_equal(a, b) + ether_addr_equal(a, b) Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/bridge/br_device.c2
-rw-r--r--net/bridge/br_fdb.c14
-rw-r--r--net/bridge/br_input.c2
-rw-r--r--net/bridge/br_stp_bpdu.c2
-rw-r--r--net/bridge/br_stp_if.c11
5 files changed, 15 insertions, 16 deletions
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index d6e5929458b1..929e48aed444 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -170,7 +170,7 @@ static int br_set_mac_address(struct net_device *dev, void *p)
170 return -EADDRNOTAVAIL; 170 return -EADDRNOTAVAIL;
171 171
172 spin_lock_bh(&br->lock); 172 spin_lock_bh(&br->lock);
173 if (compare_ether_addr(dev->dev_addr, addr->sa_data)) { 173 if (!ether_addr_equal(dev->dev_addr, addr->sa_data)) {
174 dev->addr_assign_type &= ~NET_ADDR_RANDOM; 174 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
175 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 175 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
176 br_fdb_change_mac_address(br, addr->sa_data); 176 br_fdb_change_mac_address(br, addr->sa_data);
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 5945c54bc2de..d21f32383517 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -107,8 +107,8 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
107 struct net_bridge_port *op; 107 struct net_bridge_port *op;
108 list_for_each_entry(op, &br->port_list, list) { 108 list_for_each_entry(op, &br->port_list, list) {
109 if (op != p && 109 if (op != p &&
110 !compare_ether_addr(op->dev->dev_addr, 110 ether_addr_equal(op->dev->dev_addr,
111 f->addr.addr)) { 111 f->addr.addr)) {
112 f->dst = op; 112 f->dst = op;
113 goto insert; 113 goto insert;
114 } 114 }
@@ -214,8 +214,8 @@ void br_fdb_delete_by_port(struct net_bridge *br,
214 struct net_bridge_port *op; 214 struct net_bridge_port *op;
215 list_for_each_entry(op, &br->port_list, list) { 215 list_for_each_entry(op, &br->port_list, list) {
216 if (op != p && 216 if (op != p &&
217 !compare_ether_addr(op->dev->dev_addr, 217 ether_addr_equal(op->dev->dev_addr,
218 f->addr.addr)) { 218 f->addr.addr)) {
219 f->dst = op; 219 f->dst = op;
220 goto skip_delete; 220 goto skip_delete;
221 } 221 }
@@ -237,7 +237,7 @@ struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
237 struct net_bridge_fdb_entry *fdb; 237 struct net_bridge_fdb_entry *fdb;
238 238
239 hlist_for_each_entry_rcu(fdb, h, &br->hash[br_mac_hash(addr)], hlist) { 239 hlist_for_each_entry_rcu(fdb, h, &br->hash[br_mac_hash(addr)], hlist) {
240 if (!compare_ether_addr(fdb->addr.addr, addr)) { 240 if (ether_addr_equal(fdb->addr.addr, addr)) {
241 if (unlikely(has_expired(br, fdb))) 241 if (unlikely(has_expired(br, fdb)))
242 break; 242 break;
243 return fdb; 243 return fdb;
@@ -331,7 +331,7 @@ static struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
331 struct net_bridge_fdb_entry *fdb; 331 struct net_bridge_fdb_entry *fdb;
332 332
333 hlist_for_each_entry(fdb, h, head, hlist) { 333 hlist_for_each_entry(fdb, h, head, hlist) {
334 if (!compare_ether_addr(fdb->addr.addr, addr)) 334 if (ether_addr_equal(fdb->addr.addr, addr))
335 return fdb; 335 return fdb;
336 } 336 }
337 return NULL; 337 return NULL;
@@ -344,7 +344,7 @@ static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head,
344 struct net_bridge_fdb_entry *fdb; 344 struct net_bridge_fdb_entry *fdb;
345 345
346 hlist_for_each_entry_rcu(fdb, h, head, hlist) { 346 hlist_for_each_entry_rcu(fdb, h, head, hlist) {
347 if (!compare_ether_addr(fdb->addr.addr, addr)) 347 if (ether_addr_equal(fdb->addr.addr, addr))
348 return fdb; 348 return fdb;
349 } 349 }
350 return NULL; 350 return NULL;
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 5a31731be4d0..76f15fda0212 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -216,7 +216,7 @@ forward:
216 } 216 }
217 /* fall through */ 217 /* fall through */
218 case BR_STATE_LEARNING: 218 case BR_STATE_LEARNING:
219 if (!compare_ether_addr(p->br->dev->dev_addr, dest)) 219 if (ether_addr_equal(p->br->dev->dev_addr, dest))
220 skb->pkt_type = PACKET_HOST; 220 skb->pkt_type = PACKET_HOST;
221 221
222 NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 222 NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index e16aade51ae0..fd30a6022dea 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -167,7 +167,7 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
167 if (p->state == BR_STATE_DISABLED) 167 if (p->state == BR_STATE_DISABLED)
168 goto out; 168 goto out;
169 169
170 if (compare_ether_addr(dest, br->group_addr) != 0) 170 if (!ether_addr_equal(dest, br->group_addr))
171 goto out; 171 goto out;
172 172
173 buf = skb_pull(skb, 3); 173 buf = skb_pull(skb, 3);
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index f494496373d6..9d5a414a3943 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -178,7 +178,7 @@ void br_stp_set_enabled(struct net_bridge *br, unsigned long val)
178/* called under bridge lock */ 178/* called under bridge lock */
179void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr) 179void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
180{ 180{
181 /* should be aligned on 2 bytes for compare_ether_addr() */ 181 /* should be aligned on 2 bytes for ether_addr_equal() */
182 unsigned short oldaddr_aligned[ETH_ALEN >> 1]; 182 unsigned short oldaddr_aligned[ETH_ALEN >> 1];
183 unsigned char *oldaddr = (unsigned char *)oldaddr_aligned; 183 unsigned char *oldaddr = (unsigned char *)oldaddr_aligned;
184 struct net_bridge_port *p; 184 struct net_bridge_port *p;
@@ -191,12 +191,11 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
191 memcpy(br->dev->dev_addr, addr, ETH_ALEN); 191 memcpy(br->dev->dev_addr, addr, ETH_ALEN);
192 192
193 list_for_each_entry(p, &br->port_list, list) { 193 list_for_each_entry(p, &br->port_list, list) {
194 if (!compare_ether_addr(p->designated_bridge.addr, oldaddr)) 194 if (ether_addr_equal(p->designated_bridge.addr, oldaddr))
195 memcpy(p->designated_bridge.addr, addr, ETH_ALEN); 195 memcpy(p->designated_bridge.addr, addr, ETH_ALEN);
196 196
197 if (!compare_ether_addr(p->designated_root.addr, oldaddr)) 197 if (ether_addr_equal(p->designated_root.addr, oldaddr))
198 memcpy(p->designated_root.addr, addr, ETH_ALEN); 198 memcpy(p->designated_root.addr, addr, ETH_ALEN);
199
200 } 199 }
201 200
202 br_configuration_update(br); 201 br_configuration_update(br);
@@ -205,7 +204,7 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
205 br_become_root_bridge(br); 204 br_become_root_bridge(br);
206} 205}
207 206
208/* should be aligned on 2 bytes for compare_ether_addr() */ 207/* should be aligned on 2 bytes for ether_addr_equal() */
209static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1]; 208static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1];
210 209
211/* called under bridge lock */ 210/* called under bridge lock */
@@ -227,7 +226,7 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
227 226
228 } 227 }
229 228
230 if (compare_ether_addr(br->bridge_id.addr, addr) == 0) 229 if (ether_addr_equal(br->bridge_id.addr, addr))
231 return false; /* no change */ 230 return false; /* no change */
232 231
233 br_stp_change_bridge_id(br, addr); 232 br_stp_change_bridge_id(br, addr);