Skip to content

Commit

Permalink
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Browse files Browse the repository at this point in the history
Included changes:
- introduction of the new Network Coding component. This new mechanism aims to
  increase throughput by fusing multiple packets in one transmission.
- minor cleanups

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Mar 14, 2013
2 parents 7cc1638 + 2df5278 commit 1e32b0c
Show file tree
Hide file tree
Showing 19 changed files with 2,259 additions and 65 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 @@ -67,6 +67,14 @@ Description:
Defines the penalty which will be applied to an
originator message's tq-field on every hop.

What: /sys/class/net/<mesh_iface>/mesh/network_coding
Date: Nov 2012
Contact: Martin Hundeboll <[email protected]>
Description:
Controls whether Network Coding (using some magic
to send fewer wifi packets but still the same
content) is enabled or not.

What: /sys/class/net/<mesh_iface>/mesh/orig_interval
Date: May 2010
Contact: Marek Lindner <[email protected]>
Expand Down
14 changes: 14 additions & 0 deletions net/batman-adv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ config BATMAN_ADV_DAT
mesh networks. If you think that your network does not need
this option you can safely remove it and save some space.

config BATMAN_ADV_NC
bool "Network Coding"
depends on BATMAN_ADV
default n
help
This option enables network coding, a mechanism that aims to
increase the overall network throughput by fusing multiple
packets in one transmission.
Note that interfaces controlled by batman-adv must be manually
configured to have promiscuous mode enabled in order to make
network coding work.
If you think that your network does not need this feature you
can safely disable it and save some space.

config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
depends on BATMAN_ADV
Expand Down
1 change: 1 addition & 0 deletions net/batman-adv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ batman-adv-y += hard-interface.o
batman-adv-y += hash.o
batman-adv-y += icmp_socket.o
batman-adv-y += main.o
batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
batman-adv-y += originator.o
batman-adv-y += ring_buffer.o
batman-adv-y += routing.o
Expand Down
5 changes: 5 additions & 0 deletions net/batman-adv/bat_iv_ogm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "hard-interface.h"
#include "send.h"
#include "bat_algo.h"
#include "network-coding.h"

static struct batadv_neigh_node *
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
Expand Down Expand Up @@ -1185,6 +1186,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
if (!orig_neigh_node)
goto out;

/* Update nc_nodes of the originator */
batadv_nc_update_nc_node(bat_priv, orig_node, orig_neigh_node,
batadv_ogm_packet, is_single_hop_neigh);

orig_neigh_router = batadv_orig_node_get_router(orig_neigh_node);

/* drop packet if sender is not a direct neighbor and if we
Expand Down
18 changes: 18 additions & 0 deletions net/batman-adv/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "icmp_socket.h"
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h"
#include "network-coding.h"

static struct dentry *batadv_debugfs;

Expand Down Expand Up @@ -310,6 +311,14 @@ struct batadv_debuginfo {
const struct file_operations fops;
};

#ifdef CONFIG_BATMAN_ADV_NC
static int batadv_nc_nodes_open(struct inode *inode, struct file *file)
{
struct net_device *net_dev = (struct net_device *)inode->i_private;
return single_open(file, batadv_nc_nodes_seq_print_text, net_dev);
}
#endif

#define BATADV_DEBUGINFO(_name, _mode, _open) \
struct batadv_debuginfo batadv_debuginfo_##_name = { \
.attr = { .name = __stringify(_name), \
Expand Down Expand Up @@ -348,6 +357,9 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open);
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
batadv_transtable_local_open);
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
#ifdef CONFIG_BATMAN_ADV_NC
static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);
#endif

static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
&batadv_debuginfo_originators,
Expand All @@ -362,6 +374,9 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
#endif
&batadv_debuginfo_transtable_local,
&batadv_debuginfo_vis_data,
#ifdef CONFIG_BATMAN_ADV_NC
&batadv_debuginfo_nc_nodes,
#endif
NULL,
};

Expand Down Expand Up @@ -431,6 +446,9 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
}
}

if (batadv_nc_init_debugfs(bat_priv) < 0)
goto rem_attr;

return 0;
rem_attr:
debugfs_remove_recursive(bat_priv->debug_dir);
Expand Down
22 changes: 4 additions & 18 deletions net/batman-adv/distributed-arp-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
bool ret = false;
struct batadv_dat_entry *dat_entry = NULL;
struct sk_buff *skb_new;
struct batadv_hard_iface *primary_if = NULL;

if (!atomic_read(&bat_priv->distributed_arp_table))
goto out;
Expand All @@ -838,22 +837,18 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,

dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst);
if (dat_entry) {
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;

skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src,
primary_if->soft_iface, ip_dst, hw_src,
bat_priv->soft_iface, ip_dst, hw_src,
dat_entry->mac_addr, hw_src);
if (!skb_new)
goto out;

skb_reset_mac_header(skb_new);
skb_new->protocol = eth_type_trans(skb_new,
primary_if->soft_iface);
bat_priv->soft_iface);
bat_priv->stats.rx_packets++;
bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
primary_if->soft_iface->last_rx = jiffies;
bat_priv->soft_iface->last_rx = jiffies;

netif_rx(skb_new);
batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
Expand All @@ -866,8 +861,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
out:
if (dat_entry)
batadv_dat_entry_free_ref(dat_entry);
if (primary_if)
batadv_hardif_free_ref(primary_if);
return ret;
}

Expand All @@ -887,7 +880,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
__be32 ip_src, ip_dst;
uint8_t *hw_src;
struct sk_buff *skb_new;
struct batadv_hard_iface *primary_if = NULL;
struct batadv_dat_entry *dat_entry = NULL;
bool ret = false;
int err;
Expand All @@ -912,12 +904,8 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
if (!dat_entry)
goto out;

primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
goto out;

skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src,
primary_if->soft_iface, ip_dst, hw_src,
bat_priv->soft_iface, ip_dst, hw_src,
dat_entry->mac_addr, hw_src);

if (!skb_new)
Expand All @@ -941,8 +929,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
out:
if (dat_entry)
batadv_dat_entry_free_ref(dat_entry);
if (primary_if)
batadv_hardif_free_ref(primary_if);
if (ret)
kfree_skb(skb);
return ret;
Expand Down
6 changes: 6 additions & 0 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "vis.h"
#include "hash.h"
#include "bat_algo.h"
#include "network-coding.h"


/* List manipulations on hardif_list have to be rtnl_lock()'ed,
Expand Down Expand Up @@ -135,6 +136,10 @@ int batadv_mesh_init(struct net_device *soft_iface)
if (ret < 0)
goto err;

ret = batadv_nc_init(bat_priv);
if (ret < 0)
goto err;

atomic_set(&bat_priv->gw.reselect, 0);
atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);

Expand All @@ -157,6 +162,7 @@ void batadv_mesh_free(struct net_device *soft_iface)

batadv_gw_node_purge(bat_priv);
batadv_originator_free(bat_priv);
batadv_nc_free(bat_priv);

batadv_tt_free(bat_priv);

Expand Down
12 changes: 11 additions & 1 deletion net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
#define BATADV_RESET_PROTECTION_MS 30000
#define BATADV_EXPECTED_SEQNO_RANGE 65536

#define BATADV_NC_NODE_TIMEOUT 10000 /* Milliseconds */

enum batadv_mesh_state {
BATADV_MESH_INACTIVE,
BATADV_MESH_ACTIVE,
Expand Down Expand Up @@ -185,6 +187,7 @@ __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
* @BATADV_DBG_TT: translation table messages
* @BATADV_DBG_BLA: bridge loop avoidance messages
* @BATADV_DBG_DAT: ARP snooping and DAT related messages
* @BATADV_DBG_NC: network coding related messages
* @BATADV_DBG_ALL: the union of all the above log levels
*/
enum batadv_dbg_level {
Expand All @@ -193,7 +196,8 @@ enum batadv_dbg_level {
BATADV_DBG_TT = BIT(2),
BATADV_DBG_BLA = BIT(3),
BATADV_DBG_DAT = BIT(4),
BATADV_DBG_ALL = 31,
BATADV_DBG_NC = BIT(5),
BATADV_DBG_ALL = 63,
};

#ifdef CONFIG_BATMAN_ADV_DEBUG
Expand Down Expand Up @@ -298,4 +302,10 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,
return sum;
}

/* Define a macro to reach the control buffer of the skb. The members of the
* control buffer are defined in struct batadv_skb_cb in types.h.
* The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h.
*/
#define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0]))

#endif /* _NET_BATMAN_ADV_MAIN_H_ */
Loading

0 comments on commit 1e32b0c

Please sign in to comment.