Skip to content

Commit

Permalink
Revert "staging: batman-adv: Use linux/etherdevice.h address helper f…
Browse files Browse the repository at this point in the history
…unctions"

This reverts commit 5712dc7.

Turns out the batman maintainers didn't like the implementation of it,
and the original author was going to rework it to meet their approval,
and I applied it without fully realizing all of this.

My fault.

Cc: Marek Lindner <lindner_marek@yahoo.de>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Nov 11, 2010
1 parent 3701bef commit 6174c34
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
12 changes: 11 additions & 1 deletion drivers/staging/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void dec_module_count(void)

int compare_orig(void *data1, void *data2)
{
return (compare_ether_addr(data1, data2) == 0 ? 1 : 0);
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
}

/* hashfunction to choose an entry in a hash table of given size */
Expand Down Expand Up @@ -192,6 +192,16 @@ int is_my_mac(uint8_t *addr)

}

int is_bcast(uint8_t *addr)
{
return (addr[0] == (uint8_t)0xff) && (addr[1] == (uint8_t)0xff);
}

int is_mcast(uint8_t *addr)
{
return *addr & 0x01;
}

module_init(batman_init);
module_exit(batman_exit);

Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
#include <linux/mutex.h> /* mutex */
#include <linux/module.h> /* needed by all modules */
#include <linux/netdevice.h> /* netdevice */
#include <linux/etherdevice.h>
#include <linux/if_ether.h> /* ethernet header */
#include <linux/poll.h> /* poll_table */
#include <linux/kthread.h> /* kernel threads */
Expand Down Expand Up @@ -139,6 +138,8 @@ void dec_module_count(void);
int compare_orig(void *data1, void *data2);
int choose_orig(void *data, int32_t size);
int is_my_mac(uint8_t *addr);
int is_bcast(uint8_t *addr);
int is_mcast(uint8_t *addr);

#ifdef CONFIG_BATMAN_ADV_DEBUG
int debug_log(struct bat_priv *bat_priv, char *fmt, ...);
Expand Down
16 changes: 8 additions & 8 deletions drivers/staging/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,11 @@ int recv_bat_packet(struct sk_buff *skb, struct batman_if *batman_if)
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* packet with broadcast indication but unicast recipient */
if (!is_broadcast_ether_addr(ethhdr->h_dest))
if (!is_bcast(ethhdr->h_dest))
return NET_RX_DROP;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
if (is_bcast(ethhdr->h_source))
return NET_RX_DROP;

/* create a copy of the skb, if needed, to modify it. */
Expand Down Expand Up @@ -933,11 +933,11 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* packet with unicast indication but broadcast recipient */
if (is_broadcast_ether_addr(ethhdr->h_dest))
if (is_bcast(ethhdr->h_dest))
return NET_RX_DROP;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
if (is_bcast(ethhdr->h_source))
return NET_RX_DROP;

/* not for me */
Expand Down Expand Up @@ -1107,11 +1107,11 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* packet with unicast indication but broadcast recipient */
if (is_broadcast_ether_addr(ethhdr->h_dest))
if (is_bcast(ethhdr->h_dest))
return -1;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
if (is_bcast(ethhdr->h_source))
return -1;

/* not for me */
Expand Down Expand Up @@ -1283,11 +1283,11 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* packet with broadcast indication but unicast recipient */
if (!is_broadcast_ether_addr(ethhdr->h_dest))
if (!is_bcast(ethhdr->h_dest))
return NET_RX_DROP;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
if (is_bcast(ethhdr->h_source))
return NET_RX_DROP;

/* ignore broadcasts sent by myself */
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/batman-adv/soft-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
hna_local_add(soft_iface, ethhdr->h_source);

/* ethernet packet should be broadcasted */
if (is_multicast_ether_addr(ethhdr->h_dest)) {
if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) {
if (!bat_priv->primary_if)
goto dropped;

Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/batman-adv/vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void receive_client_update_packet(struct bat_priv *bat_priv,
int are_target = 0;

/* clients shall not broadcast. */
if (is_broadcast_ether_addr(vis_packet->target_orig))
if (is_bcast(vis_packet->target_orig))
return;

/* Are we the target for this VIS packet? */
Expand Down Expand Up @@ -746,7 +746,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
ETH_ALEN);
packet->ttl--;

if (is_broadcast_ether_addr(packet->target_orig))
if (is_bcast(packet->target_orig))
broadcast_vis_packet(bat_priv, info);
else
unicast_vis_packet(bat_priv, info);
Expand Down

0 comments on commit 6174c34

Please sign in to comment.