Skip to content

Commit

Permalink
Merge branch 'batman-adv/next' of git://git.open-mesh.org/linux-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davem330 committed Aug 24, 2011
2 parents 131ea66 + a943cac commit 0e43182
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 148 deletions.
8 changes: 8 additions & 0 deletions Documentation/ABI/testing/sysfs-class-net-mesh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Description:
mesh will be fragmented or silently discarded if the
packet size exceeds the outgoing interface MTU.

What: /sys/class/net/<mesh_iface>/mesh/ap_isolation
Date: May 2011
Contact: Antonio Quartulli <ordex@autistici.org>
Description:
Indicates whether the data traffic going from a
wireless client to another wireless client will be
silently dropped.

What: /sys/class/net/<mesh_iface>/mesh/gw_bandwidth
Date: October 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
static inline int aggregated_packet(int buff_pos, int packet_len,
int tt_num_changes)
{
int next_buff_pos = buff_pos + BAT_PACKET_LEN + (tt_num_changes *
sizeof(struct tt_change));
int next_buff_pos = buff_pos + BAT_PACKET_LEN + tt_len(tt_num_changes);

return (next_buff_pos <= packet_len) &&
(next_buff_pos <= MAX_AGGREGATION_BYTES);
Expand Down
2 changes: 2 additions & 0 deletions net/batman-adv/bat_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
BAT_ATTR_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
Expand All @@ -396,6 +397,7 @@ static struct bat_attribute *mesh_attrs[] = {
&bat_attr_aggregated_ogms,
&bat_attr_bonding,
&bat_attr_fragmentation,
&bat_attr_ap_isolation,
&bat_attr_vis_mode,
&bat_attr_gw_mode,
&bat_attr_orig_interval,
Expand Down
6 changes: 3 additions & 3 deletions net/batman-adv/bitarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ static void bit_shift(unsigned long *seq_bits, int32_t n)
(seq_bits[i - word_num - 1] >>
(WORD_BIT_SIZE-word_offset));
/* and the upper part of the right half and shift it left to
* it's position */
* its position */
/* for our example that would be: word[0] = 9800 + 0076 =
* 9876 */
}
/* now for our last word, i==word_num, we only have the it's "left"
* half. that's the 1000 word in our example.*/
/* now for our last word, i==word_num, we only have its "left" half.
* that's the 1000 word in our example.*/

seq_bits[i] = (seq_bits[i - word_num] << word_offset);

Expand Down
10 changes: 5 additions & 5 deletions net/batman-adv/gateway_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,14 @@ static bool is_type_dhcprequest(struct sk_buff *skb, int header_len)
pkt_len -= header_len + DHCP_OPTIONS_OFFSET + 1;

/* Access the dhcp option lists. Each entry is made up by:
* - octect 1: option type
* - octect 2: option data len (only if type != 255 and 0)
* - octect 3: option data */
* - octet 1: option type
* - octet 2: option data len (only if type != 255 and 0)
* - octet 3: option data */
while (*p != 255 && !ret) {
/* p now points to the first octect: option type */
/* p now points to the first octet: option type */
if (*p == 53) {
/* type 53 is the message type option.
* Jump the len octect and go to the data octect */
* Jump the len octet and go to the data octet */
if (pkt_len < 2)
goto out;
p += 2;
Expand Down
34 changes: 32 additions & 2 deletions net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)

/**
* the first active interface becomes our primary interface or
* the next active interface after the old primay interface was removed
* the next active interface after the old primary interface was removed
*/
primary_if = primary_if_get_selected(bat_priv);
if (!primary_if)
Expand Down Expand Up @@ -573,7 +573,7 @@ static int hard_if_event(struct notifier_block *this,
return NOTIFY_DONE;
}

/* receive a packet with the batman ethertype coming on a hard
/* incoming packets with the batman ethertype received on any active hard
* interface */
static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
Expand Down Expand Up @@ -681,6 +681,36 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
return NET_RX_DROP;
}

/* This function returns true if the interface represented by ifindex is a
* 802.11 wireless device */
bool is_wifi_iface(int ifindex)
{
struct net_device *net_device = NULL;
bool ret = false;

if (ifindex == NULL_IFINDEX)
goto out;

net_device = dev_get_by_index(&init_net, ifindex);
if (!net_device)
goto out;

#ifdef CONFIG_WIRELESS_EXT
/* pre-cfg80211 drivers have to implement WEXT, so it is possible to
* check for wireless_handlers != NULL */
if (net_device->wireless_handlers)
ret = true;
else
#endif
/* cfg80211 drivers have to set ieee80211_ptr */
if (net_device->ieee80211_ptr)
ret = true;
out:
if (net_device)
dev_put(net_device);
return ret;
}

struct notifier_block hard_if_notifier = {
.notifier_call = hard_if_event,
};
1 change: 1 addition & 0 deletions net/batman-adv/hard-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void hardif_remove_interfaces(void);
int hardif_min_mtu(struct net_device *soft_iface);
void update_min_mtu(struct net_device *soft_iface);
void hardif_free_rcu(struct rcu_head *rcu);
bool is_wifi_iface(int ifindex);

static inline void hardif_free_ref(struct hard_iface *hard_iface)
{
Expand Down
25 changes: 19 additions & 6 deletions net/batman-adv/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,30 @@ static inline void hash_delete(struct hashtable_t *hash,
hash_destroy(hash);
}

/* adds data to the hashtable. returns 0 on success, -1 on error */
/**
* hash_add - adds data to the hashtable
* @hash: storage hash table
* @compare: callback to determine if 2 hash elements are identical
* @choose: callback calculating the hash index
* @data: data passed to the aforementioned callbacks as argument
* @data_node: to be added element
*
* Returns 0 on success, 1 if the element already is in the hash
* and -1 on error.
*/

static inline int hash_add(struct hashtable_t *hash,
hashdata_compare_cb compare,
hashdata_choose_cb choose,
const void *data, struct hlist_node *data_node)
{
int index;
int index, ret = -1;
struct hlist_head *head;
struct hlist_node *node;
spinlock_t *list_lock; /* spinlock to protect write access */

if (!hash)
goto err;
goto out;

index = choose(data, hash->size);
head = &hash->table[index];
Expand All @@ -99,6 +110,7 @@ static inline int hash_add(struct hashtable_t *hash,
if (!compare(node, data))
continue;

ret = 1;
goto err_unlock;
}
rcu_read_unlock();
Expand All @@ -108,12 +120,13 @@ static inline int hash_add(struct hashtable_t *hash,
hlist_add_head_rcu(data_node, head);
spin_unlock_bh(list_lock);

return 0;
ret = 0;
goto out;

err_unlock:
rcu_read_unlock();
err:
return -1;
out:
return ret;
}

/* removes data from hash, if found. returns pointer do data on success, so you
Expand Down
2 changes: 1 addition & 1 deletion net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int mesh_init(struct net_device *soft_iface)
if (tt_init(bat_priv) < 1)
goto err;

tt_local_add(soft_iface, soft_iface->dev_addr);
tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);

if (vis_init(bat_priv) < 1)
goto err;
Expand Down
6 changes: 4 additions & 2 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define PURGE_TIMEOUT 200
#define TT_LOCAL_TIMEOUT 3600 /* in seconds */
#define TT_CLIENT_ROAM_TIMEOUT 600
/* sliding packet range of received originator messages in squence numbers
/* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) */
#define TQ_LOCAL_WINDOW_SIZE 64
#define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */
Expand All @@ -62,6 +62,8 @@

#define NO_FLAGS 0

#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */

#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)

#define LOG_BUF_LEN 8192 /* has to be a power of 2 */
Expand Down Expand Up @@ -133,7 +135,7 @@ enum dbg_level {
#include <linux/mutex.h> /* mutex */
#include <linux/module.h> /* needed by all modules */
#include <linux/netdevice.h> /* netdevice */
#include <linux/etherdevice.h> /* ethernet address classifaction */
#include <linux/etherdevice.h> /* ethernet address classification */
#include <linux/if_ether.h> /* ethernet header */
#include <linux/poll.h> /* poll_table */
#include <linux/kthread.h> /* kernel threads */
Expand Down
2 changes: 1 addition & 1 deletion net/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)

hash_added = hash_add(bat_priv->orig_hash, compare_orig,
choose_orig, orig_node, &orig_node->hash_entry);
if (hash_added < 0)
if (hash_added != 0)
goto free_bcast_own_sum;

return orig_node;
Expand Down
1 change: 1 addition & 0 deletions net/batman-adv/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum tt_query_flags {
enum tt_client_flags {
TT_CLIENT_DEL = 1 << 0,
TT_CLIENT_ROAM = 1 << 1,
TT_CLIENT_WIFI = 1 << 2,
TT_CLIENT_NOPURGE = 1 << 8,
TT_CLIENT_NEW = 1 << 9,
TT_CLIENT_PENDING = 1 << 10
Expand Down
77 changes: 8 additions & 69 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,66 +64,6 @@ void slide_own_bcast_window(struct hard_iface *hard_iface)
}
}

static void update_transtable(struct bat_priv *bat_priv,
struct orig_node *orig_node,
const unsigned char *tt_buff,
uint8_t tt_num_changes, uint8_t ttvn,
uint16_t tt_crc)
{
uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
bool full_table = true;

/* the ttvn increased by one -> we can apply the attached changes */
if (ttvn - orig_ttvn == 1) {
/* the OGM could not contain the changes because they were too
* many to fit in one frame or because they have already been
* sent TT_OGM_APPEND_MAX times. In this case send a tt
* request */
if (!tt_num_changes) {
full_table = false;
goto request_table;
}

tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn,
(struct tt_change *)tt_buff);

/* Even if we received the crc into the OGM, we prefer
* to recompute it to spot any possible inconsistency
* in the global table */
orig_node->tt_crc = tt_global_crc(bat_priv, orig_node);

/* The ttvn alone is not enough to guarantee consistency
* because a single value could repesent different states
* (due to the wrap around). Thus a node has to check whether
* the resulting table (after applying the changes) is still
* consistent or not. E.g. a node could disconnect while its
* ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case
* checking the CRC value is mandatory to detect the
* inconsistency */
if (orig_node->tt_crc != tt_crc)
goto request_table;

/* Roaming phase is over: tables are in sync again. I can
* unset the flag */
orig_node->tt_poss_change = false;
} else {
/* if we missed more than one change or our tables are not
* in sync anymore -> request fresh tt data */
if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) {
request_table:
bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. "
"Need to retrieve the correct information "
"(ttvn: %u last_ttvn: %u crc: %u last_crc: "
"%u num_changes: %u)\n", orig_node->orig, ttvn,
orig_ttvn, tt_crc, orig_node->tt_crc,
tt_num_changes);
send_tt_request(bat_priv, orig_node, ttvn, tt_crc,
full_table);
return;
}
}
}

static void update_route(struct bat_priv *bat_priv,
struct orig_node *orig_node,
struct neigh_node *neigh_node)
Expand Down Expand Up @@ -228,7 +168,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
if (!neigh_node)
goto out;

/* if orig_node is direct neighbour update neigh_node last_valid */
/* if orig_node is direct neighbor update neigh_node last_valid */
if (orig_node == orig_neigh_node)
neigh_node->last_valid = jiffies;

Expand Down Expand Up @@ -473,7 +413,7 @@ static void update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
if (router && (router->tq_avg > neigh_node->tq_avg))
goto update_tt;

/* if the TQ is the same and the link not more symetric we
/* if the TQ is the same and the link not more symmetric we
* won't consider it either */
if (router && (neigh_node->tq_avg == router->tq_avg)) {
orig_node_tmp = router->orig_node;
Expand All @@ -500,10 +440,9 @@ static void update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
if (((batman_packet->orig != ethhdr->h_source) &&
(batman_packet->ttl > 2)) ||
(batman_packet->flags & PRIMARIES_FIRST_HOP))
update_transtable(bat_priv, orig_node, tt_buff,
batman_packet->tt_num_changes,
batman_packet->ttvn,
batman_packet->tt_crc);
tt_update_orig(bat_priv, orig_node, tt_buff,
batman_packet->tt_num_changes,
batman_packet->ttvn, batman_packet->tt_crc);

if (orig_node->gw_flags != batman_packet->gw_flags)
gw_node_update(bat_priv, orig_node, batman_packet->gw_flags);
Expand Down Expand Up @@ -1243,7 +1182,7 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
}
break;
case TT_RESPONSE:
/* packet needs to be linearised to access the TT changes */
/* packet needs to be linearized to access the TT changes */
if (skb_linearize(skb) < 0)
goto out;

Expand Down Expand Up @@ -1300,7 +1239,7 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
roam_adv_packet->client);

tt_global_add(bat_priv, orig_node, roam_adv_packet->client,
atomic_read(&orig_node->last_ttvn) + 1, true);
atomic_read(&orig_node->last_ttvn) + 1, true, false);

/* Roaming phase starts: I have new information but the ttvn has not
* been incremented yet. This flag will make me check all the incoming
Expand Down Expand Up @@ -1536,7 +1475,7 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv,

ethhdr = (struct ethhdr *)(skb->data +
sizeof(struct unicast_packet));
orig_node = transtable_search(bat_priv, ethhdr->h_dest);
orig_node = transtable_search(bat_priv, NULL, ethhdr->h_dest);

if (!orig_node) {
if (!is_my_client(bat_priv, ethhdr->h_dest))
Expand Down
Loading

0 comments on commit 0e43182

Please sign in to comment.