Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_debugfs.c | 26 +++++++------ bat_sysfs.c | 112 +++++++++++++++++++++++++++--------------------------- gateway_client.c | 12 +++--- vis.c | 18 +++++---- 4 files changed, 87 insertions(+), 81 deletions(-)
diff --git a/bat_debugfs.c b/bat_debugfs.c index 87349f4..095e6e8 100644 --- a/bat_debugfs.c +++ b/bat_debugfs.c @@ -35,14 +35,14 @@ static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG -#define LOG_BUFF_MASK (batadv_log_buff_len - 1) -#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK]) +#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) +#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
static int batadv_log_buff_len = LOG_BUF_LEN;
static void batadv_emit_log_char(struct debug_log *debug_log, char c) { - LOG_BUFF(debug_log->log_end) = c; + BATADV_LOG_BUFF(debug_log->log_end) = c; debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) @@ -133,7 +133,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
while ((!error) && (i < count) && (debug_log->log_start != debug_log->log_end)) { - c = LOG_BUFF(debug_log->log_start); + c = BATADV_LOG_BUFF(debug_log->log_start);
debug_log->log_start++;
@@ -270,7 +270,7 @@ struct bat_debuginfo { const struct file_operations fops; };
-#define BAT_DEBUGINFO(_name, _mode, _open) \ +#define BATADV_DEBUGINFO(_name, _mode, _open) \ struct bat_debuginfo batadv_debuginfo_##_name = { \ .attr = { .name = __stringify(_name), \ .mode = _mode, }, \ @@ -282,15 +282,17 @@ struct bat_debuginfo batadv_debuginfo_##_name = { \ } \ };
-static BAT_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); -static BAT_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); -static BAT_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); -static BAT_DEBUGINFO(transtable_global, S_IRUGO, batadv_transtable_global_open); +static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); +static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); +static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); +static BATADV_DEBUGINFO(transtable_global, S_IRUGO, + batadv_transtable_global_open); #ifdef CONFIG_BATMAN_ADV_BLA -static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); +static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); #endif -static BAT_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); -static BAT_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); +static BATADV_DEBUGINFO(transtable_local, S_IRUGO, + batadv_transtable_local_open); +static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
static struct bat_debuginfo *batadv_mesh_debuginfos[] = { &batadv_debuginfo_originators, diff --git a/bat_sysfs.c b/bat_sysfs.c index 07fde83..109c537 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -38,9 +38,9 @@ static struct bat_priv *batadv_kobj_to_batpriv(struct kobject *obj) return netdev_priv(net_dev); }
-#define UEV_TYPE_VAR "BATTYPE=" -#define UEV_ACTION_VAR "BATACTION=" -#define UEV_DATA_VAR "BATDATA=" +#define BATADV_UEV_TYPE_VAR "BATTYPE=" +#define BATADV_UEV_ACTION_VAR "BATACTION=" +#define BATADV_UEV_DATA_VAR "BATDATA="
static char *batadv_uev_action_str[] = { "add", @@ -53,15 +53,15 @@ static char *batadv_uev_type_str[] = { };
/* Use this, if you have customized show and store functions */ -#define BAT_ATTR(_name, _mode, _show, _store) \ -struct bat_attribute batadv_attr_##_name = { \ - .attr = {.name = __stringify(_name), \ - .mode = _mode }, \ - .show = _show, \ - .store = _store, \ +#define BATADV_ATTR(_name, _mode, _show, _store) \ +struct bat_attribute batadv_attr_##_name = { \ + .attr = {.name = __stringify(_name), \ + .mode = _mode }, \ + .show = _show, \ + .store = _store, \ };
-#define BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ +#define BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \ ssize_t batadv_store_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff, \ size_t count) \ @@ -72,7 +72,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ &bat_priv->_name, net_dev); \ }
-#define BAT_ATTR_SIF_SHOW_BOOL(_name) \ +#define BATADV_ATTR_SIF_SHOW_BOOL(_name) \ ssize_t batadv_show_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff) \ { \ @@ -85,14 +85,14 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \ /* Use this, if you are going to turn a [name] in the soft-interface * (bat_priv) on or off */ -#define BAT_ATTR_SIF_BOOL(_name, _mode, _post_func) \ - static BAT_ATTR_SIF_STORE_BOOL(_name, _post_func) \ - static BAT_ATTR_SIF_SHOW_BOOL(_name) \ - static BAT_ATTR(_name, _mode, batadv_show_##_name, \ - batadv_store_##_name) +#define BATADV_ATTR_SIF_BOOL(_name, _mode, _post_func) \ + static BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \ + static BATADV_ATTR_SIF_SHOW_BOOL(_name) \ + static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ + batadv_store_##_name)
-#define BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ +#define BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ ssize_t batadv_store_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff, \ size_t count) \ @@ -104,7 +104,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ &bat_priv->_name, net_dev); \ }
-#define BAT_ATTR_SIF_SHOW_UINT(_name) \ +#define BATADV_ATTR_SIF_SHOW_UINT(_name) \ ssize_t batadv_show_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff) \ { \ @@ -115,14 +115,14 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \ /* Use this, if you are going to set [name] in the soft-interface * (bat_priv) to an unsigned integer value */ -#define BAT_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ - static BAT_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ - static BAT_ATTR_SIF_SHOW_UINT(_name) \ - static BAT_ATTR(_name, _mode, batadv_show_##_name, \ +#define BATADV_ATTR_SIF_UINT(_name, _mode, _min, _max, _post_func) \ + static BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func)\ + static BATADV_ATTR_SIF_SHOW_UINT(_name) \ + static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ batadv_store_##_name)
-#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ +#define BATADV_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ ssize_t batadv_store_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff, \ size_t count) \ @@ -142,7 +142,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ return length; \ }
-#define BAT_ATTR_HIF_SHOW_UINT(_name) \ +#define BATADV_ATTR_HIF_SHOW_UINT(_name) \ ssize_t batadv_show_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff) \ { \ @@ -163,11 +163,11 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \ /* Use this, if you are going to set [name] in hard_iface to an * unsigned integer value */ -#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ - static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ - static BAT_ATTR_HIF_SHOW_UINT(_name) \ - static BAT_ATTR(_name, _mode, batadv_show_##_name, \ - batadv_store_##_name) +#define BATADV_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ + static BATADV_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func)\ + static BATADV_ATTR_HIF_SHOW_UINT(_name) \ + static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ + batadv_store_##_name)
static int batadv_store_bool_attr(char *buff, size_t count, @@ -453,26 +453,27 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj, return batadv_gw_bandwidth_set(net_dev, buff, count); }
-BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); -BAT_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); #ifdef CONFIG_BATMAN_ADV_BLA -BAT_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); +BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL); #endif -BAT_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); -BAT_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); -static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, - batadv_store_vis_mode); -static BAT_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); -static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, - batadv_store_gw_mode); -BAT_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); -BAT_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); -BAT_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, - batadv_post_gw_deselect); -static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, - batadv_store_gw_bwidth); +BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu); +BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); +static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, + batadv_store_vis_mode); +static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); +static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, + batadv_store_gw_mode); +BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, + NULL); +BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); +BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, + batadv_post_gw_deselect); +static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, + batadv_store_gw_bwidth); #ifdef CONFIG_BATMAN_ADV_DEBUG -BAT_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); +BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); #endif
static struct bat_attribute *batadv_mesh_attrs[] = { @@ -655,9 +656,9 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj, return length; }
-static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR, - batadv_show_mesh_iface, batadv_store_mesh_iface); -static BAT_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL); +static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface, + batadv_store_mesh_iface); +static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);
static struct bat_attribute *batadv_batman_attrs[] = { &batadv_attr_mesh_iface, @@ -719,31 +720,32 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
bat_kobj = &primary_if->soft_iface->dev.kobj;
- uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) + + uevent_env[0] = kmalloc(strlen(BATADV_UEV_TYPE_VAR) + strlen(batadv_uev_type_str[type]) + 1, GFP_ATOMIC); if (!uevent_env[0]) goto out;
- sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, batadv_uev_type_str[type]); + sprintf(uevent_env[0], "%s%s", BATADV_UEV_TYPE_VAR, + batadv_uev_type_str[type]);
- uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) + + uevent_env[1] = kmalloc(strlen(BATADV_UEV_ACTION_VAR) + strlen(batadv_uev_action_str[action]) + 1, GFP_ATOMIC); if (!uevent_env[1]) goto out;
- sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, + sprintf(uevent_env[1], "%s%s", BATADV_UEV_ACTION_VAR, batadv_uev_action_str[action]);
/* If the event is DEL, ignore the data field */ if (action != UEV_DEL) { - uevent_env[2] = kmalloc(strlen(UEV_DATA_VAR) + + uevent_env[2] = kmalloc(strlen(BATADV_UEV_DATA_VAR) + strlen(data) + 1, GFP_ATOMIC); if (!uevent_env[2]) goto out;
- sprintf(uevent_env[2], "%s%s", UEV_DATA_VAR, data); + sprintf(uevent_env[2], "%s%s", BATADV_UEV_DATA_VAR, data); }
ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); diff --git a/gateway_client.c b/gateway_client.c index fe7d846..7d186a7 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -33,8 +33,8 @@ /* This is the offset of the options field in a dhcp packet starting at * the beginning of the dhcp header */ -#define DHCP_OPTIONS_OFFSET 240 -#define DHCP_REQUEST 3 +#define BATADV_DHCP_OPTIONS_OFFSET 240 +#define BATADV_DHCP_REQUEST 3
static void batadv_gw_node_free_ref(struct gw_node *gw_node) { @@ -521,11 +521,11 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
pkt_len = skb_headlen(skb);
- if (pkt_len < header_len + DHCP_OPTIONS_OFFSET + 1) + if (pkt_len < header_len + BATADV_DHCP_OPTIONS_OFFSET + 1) goto out;
- p = skb->data + header_len + DHCP_OPTIONS_OFFSET; - pkt_len -= header_len + DHCP_OPTIONS_OFFSET + 1; + p = skb->data + header_len + BATADV_DHCP_OPTIONS_OFFSET; + pkt_len -= header_len + BATADV_DHCP_OPTIONS_OFFSET + 1;
/* Access the dhcp option lists. Each entry is made up by: * - octet 1: option type @@ -543,7 +543,7 @@ static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len) p += 2;
/* check if the message type is what we need */ - if (*p == DHCP_REQUEST) + if (*p == BATADV_DHCP_REQUEST) ret = true; break; } else if (*p == 0) { diff --git a/vis.c b/vis.c index 3095c41..7dc7506 100644 --- a/vis.c +++ b/vis.c @@ -26,7 +26,7 @@ #include "hash.h" #include "originator.h"
-#define MAX_VIS_PACKET_SIZE 1000 +#define BATADV_MAX_VIS_PACKET_SIZE 1000
static void batadv_start_vis_timer(struct bat_priv *bat_priv);
@@ -544,10 +544,12 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, static bool batadv_vis_packet_full(const struct vis_info *info) { const struct vis_packet *packet; - packet = (struct vis_packet *)info->skb_packet->data; + size_t num_items;
- if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry) - < packet->entries + 1) + packet = (struct vis_packet *)info->skb_packet->data; + num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); + + if (num_items < packet->entries + 1) return true; return false; } @@ -838,6 +840,7 @@ int batadv_vis_init(struct bat_priv *bat_priv) { struct vis_packet *packet; int hash_added; + unsigned int len;
if (bat_priv->vis_hash) return 0; @@ -850,13 +853,12 @@ int batadv_vis_init(struct bat_priv *bat_priv) goto err; }
- bat_priv->my_vis_info = kmalloc(MAX_VIS_PACKET_SIZE, GFP_ATOMIC); + bat_priv->my_vis_info = kmalloc(BATADV_MAX_VIS_PACKET_SIZE, GFP_ATOMIC); if (!bat_priv->my_vis_info) goto err;
- bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) + - MAX_VIS_PACKET_SIZE + - ETH_HLEN); + len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE + ETH_HLEN; + bat_priv->my_vis_info->skb_packet = dev_alloc_skb(len); if (!bat_priv->my_vis_info->skb_packet) goto free_info;
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_debugfs.c | 2 +- bat_debugfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bat_debugfs.c b/bat_debugfs.c index 095e6e8..c28b9de 100644 --- a/bat_debugfs.c +++ b/bat_debugfs.c @@ -311,7 +311,7 @@ void batadv_debugfs_init(void) struct bat_debuginfo *bat_debug; struct dentry *file;
- batadv_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); + batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); if (batadv_debugfs == ERR_PTR(-ENODEV)) batadv_debugfs = NULL;
diff --git a/bat_debugfs.h b/bat_debugfs.h index eb0d576..3319e1f 100644 --- a/bat_debugfs.h +++ b/bat_debugfs.h @@ -20,7 +20,7 @@ #ifndef _NET_BATMAN_ADV_DEBUGFS_H_ #define _NET_BATMAN_ADV_DEBUGFS_H_
-#define DEBUGFS_BAT_SUBDIR "batman_adv" +#define BATADV_DEBUGFS_SUBDIR "batman_adv"
void batadv_debugfs_init(void); void batadv_debugfs_destroy(void);
On Monday, June 04, 2012 04:19:08 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_debugfs.c | 2 +- bat_debugfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision 3270299.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_sysfs.c | 14 +++++++------- bat_sysfs.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/bat_sysfs.c b/bat_sysfs.c index 109c537..937f61f 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -504,11 +504,11 @@ int batadv_sysfs_add_meshif(struct net_device *dev) struct bat_attribute **bat_attr; int err;
- bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, + bat_priv->mesh_obj = kobject_create_and_add(BATADV_SYSFS_IF_MESH_SUBDIR, batif_kobject); if (!bat_priv->mesh_obj) { batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, - SYSFS_IF_MESH_SUBDIR); + BATADV_SYSFS_IF_MESH_SUBDIR); goto out; }
@@ -517,7 +517,7 @@ int batadv_sysfs_add_meshif(struct net_device *dev) &((*bat_attr)->attr)); if (err) { batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n", - dev->name, SYSFS_IF_MESH_SUBDIR, + dev->name, BATADV_SYSFS_IF_MESH_SUBDIR, ((*bat_attr)->attr).name); goto rem_attr; } @@ -672,12 +672,12 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) struct bat_attribute **bat_attr; int err;
- *hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR, - hardif_kobject); + *hardif_obj = kobject_create_and_add(BATADV_SYSFS_IF_BAT_SUBDIR, + hardif_kobject);
if (!*hardif_obj) { batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, - SYSFS_IF_BAT_SUBDIR); + BATADV_SYSFS_IF_BAT_SUBDIR); goto out; }
@@ -685,7 +685,7 @@ int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); if (err) { batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n", - dev->name, SYSFS_IF_BAT_SUBDIR, + dev->name, BATADV_SYSFS_IF_BAT_SUBDIR, ((*bat_attr)->attr).name); goto rem_attr; } diff --git a/bat_sysfs.h b/bat_sysfs.h index 3672277..23a8390 100644 --- a/bat_sysfs.h +++ b/bat_sysfs.h @@ -20,8 +20,8 @@ #ifndef _NET_BATMAN_ADV_SYSFS_H_ #define _NET_BATMAN_ADV_SYSFS_H_
-#define SYSFS_IF_MESH_SUBDIR "mesh" -#define SYSFS_IF_BAT_SUBDIR "batman_adv" +#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh" +#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
struct bat_attribute { struct attribute attr;
On Monday, June 04, 2012 04:19:09 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_sysfs.c | 14 +++++++------- bat_sysfs.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-)
Applied in revision 999b994.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bridge_loop_avoidance.c | 4 ++-- bridge_loop_avoidance.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 0592d2b..42b8a20 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -237,7 +237,7 @@ static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw) }
/* all claims gone, intialize CRC */ - backbone_gw->crc = BLA_CRC_INIT; + backbone_gw->crc = BATADV_BLA_CRC_INIT; }
/* @bat_priv: the bat priv with all the soft interface information @@ -375,7 +375,7 @@ static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv,
entry->vid = vid; entry->lasttime = jiffies; - entry->crc = BLA_CRC_INIT; + entry->crc = BATADV_BLA_CRC_INIT; entry->bat_priv = bat_priv; atomic_set(&entry->request_sent, 0); memcpy(entry->orig, orig, ETH_ALEN); diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 9818b1e..58563f0 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -36,7 +36,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv, int batadv_bla_init(struct bat_priv *bat_priv); void batadv_bla_free(struct bat_priv *bat_priv);
-#define BLA_CRC_INIT 0 +#define BATADV_BLA_CRC_INIT 0 #else /* ifdef CONFIG_BATMAN_ADV_BLA */
static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
On Monday, June 04, 2012 04:19:10 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bridge_loop_avoidance.c | 4 ++-- bridge_loop_avoidance.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Applied in revision f8de625.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_sysfs.c | 26 +++++++++++++++----------- gateway_common.h | 6 +++--- 2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/bat_sysfs.c b/bat_sysfs.c index 937f61f..24881d8 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -360,13 +360,16 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
switch (atomic_read(&bat_priv->gw_mode)) { case GW_MODE_CLIENT: - bytes_written = sprintf(buff, "%s\n", GW_MODE_CLIENT_NAME); + bytes_written = sprintf(buff, "%s\n", + BATADV_GW_MODE_CLIENT_NAME); break; case GW_MODE_SERVER: - bytes_written = sprintf(buff, "%s\n", GW_MODE_SERVER_NAME); + bytes_written = sprintf(buff, "%s\n", + BATADV_GW_MODE_SERVER_NAME); break; default: - bytes_written = sprintf(buff, "%s\n", GW_MODE_OFF_NAME); + bytes_written = sprintf(buff, "%s\n", + BATADV_GW_MODE_OFF_NAME); break; }
@@ -385,15 +388,16 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, if (buff[count - 1] == '\n') buff[count - 1] = '\0';
- if (strncmp(buff, GW_MODE_OFF_NAME, strlen(GW_MODE_OFF_NAME)) == 0) + if (strncmp(buff, BATADV_GW_MODE_OFF_NAME, + strlen(BATADV_GW_MODE_OFF_NAME)) == 0) gw_mode_tmp = GW_MODE_OFF;
- if (strncmp(buff, GW_MODE_CLIENT_NAME, - strlen(GW_MODE_CLIENT_NAME)) == 0) + if (strncmp(buff, BATADV_GW_MODE_CLIENT_NAME, + strlen(BATADV_GW_MODE_CLIENT_NAME)) == 0) gw_mode_tmp = GW_MODE_CLIENT;
- if (strncmp(buff, GW_MODE_SERVER_NAME, - strlen(GW_MODE_SERVER_NAME)) == 0) + if (strncmp(buff, BATADV_GW_MODE_SERVER_NAME, + strlen(BATADV_GW_MODE_SERVER_NAME)) == 0) gw_mode_tmp = GW_MODE_SERVER;
if (gw_mode_tmp < 0) { @@ -408,13 +412,13 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
switch (atomic_read(&bat_priv->gw_mode)) { case GW_MODE_CLIENT: - curr_gw_mode_str = GW_MODE_CLIENT_NAME; + curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME; break; case GW_MODE_SERVER: - curr_gw_mode_str = GW_MODE_SERVER_NAME; + curr_gw_mode_str = BATADV_GW_MODE_SERVER_NAME; break; default: - curr_gw_mode_str = GW_MODE_OFF_NAME; + curr_gw_mode_str = BATADV_GW_MODE_OFF_NAME; break; }
diff --git a/gateway_common.h b/gateway_common.h index 6f8a4d0..31bbc3c 100644 --- a/gateway_common.h +++ b/gateway_common.h @@ -26,9 +26,9 @@ enum gw_modes { GW_MODE_SERVER, };
-#define GW_MODE_OFF_NAME "off" -#define GW_MODE_CLIENT_NAME "client" -#define GW_MODE_SERVER_NAME "server" +#define BATADV_GW_MODE_OFF_NAME "off" +#define BATADV_GW_MODE_CLIENT_NAME "client" +#define BATADV_GW_MODE_SERVER_NAME "server"
void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up); ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
On Monday, June 04, 2012 04:19:11 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_sysfs.c | 26 +++++++++++++++----------- gateway_common.h | 6 +++--- 2 files changed, 18 insertions(+), 14 deletions(-)
Applied in revision 00a0c7e.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- icmp_socket.c | 2 +- icmp_socket.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/icmp_socket.c b/icmp_socket.c index 8960ee6..1f6df39 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -282,7 +282,7 @@ int batadv_socket_setup(struct bat_priv *bat_priv) if (!bat_priv->debug_dir) goto err;
- d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, + d = debugfs_create_file(BATADV_ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, bat_priv->debug_dir, bat_priv, &batadv_fops); if (d) goto err; diff --git a/icmp_socket.h b/icmp_socket.h index a62ab80..f88f9f0 100644 --- a/icmp_socket.h +++ b/icmp_socket.h @@ -20,7 +20,7 @@ #ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ #define _NET_BATMAN_ADV_ICMP_SOCKET_H_
-#define ICMP_SOCKET "socket" +#define BATADV_ICMP_SOCKET "socket"
void batadv_socket_init(void); int batadv_socket_setup(struct bat_priv *bat_priv);
On Monday, June 04, 2012 04:19:12 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
icmp_socket.c | 2 +- icmp_socket.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision 22d4128.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 20 ++++++++++---------- hard-interface.c | 3 ++- icmp_socket.c | 4 ++-- main.c | 4 ++-- packet.h | 12 ++++++------ routing.c | 4 ++-- send.c | 4 ++-- soft-interface.c | 12 +++++++----- translation-table.c | 8 ++++---- unicast.c | 4 ++-- vis.c | 2 +- 11 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 9e83f35..825054a 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -64,7 +64,7 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface) get_random_bytes(&random_seqno, sizeof(random_seqno)); atomic_set(&hard_iface->seqno, random_seqno);
- hard_iface->packet_len = BATMAN_OGM_HLEN; + hard_iface->packet_len = BATADV_OGM_HLEN; hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
if (!hard_iface->packet_buff) @@ -72,7 +72,7 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; batman_ogm_packet->header.packet_type = BAT_IV_OGM; - batman_ogm_packet->header.version = COMPAT_VERSION; + batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; batman_ogm_packet->header.ttl = 2; batman_ogm_packet->flags = NO_FLAGS; batman_ogm_packet->tq = TQ_MAX_VALUE; @@ -139,7 +139,7 @@ static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, { int next_buff_pos = 0;
- next_buff_pos += buff_pos + BATMAN_OGM_HLEN; + next_buff_pos += buff_pos + BATADV_OGM_HLEN; next_buff_pos += batadv_tt_len(tt_num_changes);
return (next_buff_pos <= packet_len) && @@ -191,7 +191,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, batman_ogm_packet->ttvn, hard_iface->net_dev->name, hard_iface->net_dev->dev_addr);
- buff_pos += BATMAN_OGM_HLEN; + buff_pos += BATADV_OGM_HLEN; buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); packet_num++; batman_ogm_packet = (struct batman_ogm_packet *) @@ -561,7 +561,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->flags &= ~DIRECTLINK;
batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, - BATMAN_OGM_HLEN + batadv_tt_len(tt_num_changes), + BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes), if_incoming, 0, batadv_iv_ogm_fwd_send_time()); }
@@ -579,7 +579,7 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) tt_num_changes = batadv_tt_append_diff(bat_priv, &hard_iface->packet_buff, &hard_iface->packet_len, - BATMAN_OGM_HLEN); + BATADV_OGM_HLEN);
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
@@ -1025,7 +1025,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, } rcu_read_unlock();
- if (batman_ogm_packet->header.version != COMPAT_VERSION) { + if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { batadv_dbg(DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", batman_ogm_packet->header.version); @@ -1227,7 +1227,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, unsigned char *tt_buff, *packet_buff; bool ret;
- ret = batadv_check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN); + ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN); if (!ret) return NET_RX_DROP;
@@ -1248,12 +1248,12 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
/* unpack the aggregated packets and process them one by one */ do { - tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; + tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff, if_incoming);
- buff_pos += BATMAN_OGM_HLEN; + buff_pos += BATADV_OGM_HLEN; buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes);
batman_ogm_packet = (struct batman_ogm_packet *) diff --git a/hard-interface.c b/hard-interface.c index ef81f01..1db2d05 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -263,6 +263,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, { struct bat_priv *bat_priv; struct net_device *soft_iface; + __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); int ret;
if (hard_iface->if_status != IF_NOT_IN_USE) @@ -309,7 +310,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, hard_iface->if_status = IF_INACTIVE; batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
- hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN); + hard_iface->batman_adv_ptype.type = ethertype; hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; dev_add_pack(&hard_iface->batman_adv_ptype); diff --git a/icmp_socket.c b/icmp_socket.c index 1f6df39..319235d 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -203,9 +203,9 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
icmp_packet->uid = socket_client->index;
- if (icmp_packet->header.version != COMPAT_VERSION) { + if (icmp_packet->header.version != BATADV_COMPAT_VERSION) { icmp_packet->msg_type = PARAMETER_PROBLEM; - icmp_packet->header.version = COMPAT_VERSION; + icmp_packet->header.version = BATADV_COMPAT_VERSION; batadv_socket_add_packet(socket_client, icmp_packet, packet_len); goto free_skb; diff --git a/main.c b/main.c index 9cf0b38..986be72 100644 --- a/main.c +++ b/main.c @@ -72,7 +72,7 @@ static int __init batadv_init(void) register_netdevice_notifier(&batadv_hard_if_notifier);
pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", - SOURCE_VERSION, COMPAT_VERSION); + SOURCE_VERSION, BATADV_COMPAT_VERSION);
return 0; } @@ -238,7 +238,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
- if (batman_ogm_packet->header.version != COMPAT_VERSION) { + if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { batadv_dbg(DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", batman_ogm_packet->header.version); diff --git a/packet.h b/packet.h index c90219c..e562414 100644 --- a/packet.h +++ b/packet.h @@ -20,7 +20,7 @@ #ifndef _NET_BATMAN_ADV_PACKET_H_ #define _NET_BATMAN_ADV_PACKET_H_
-#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ +#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype { BAT_IV_OGM = 0x01, @@ -34,7 +34,7 @@ enum bat_packettype { };
/* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 14 +#define BATADV_COMPAT_VERSION 14
enum batman_iv_flags { NOT_BEST_NEXT_HOP = 1 << 3, @@ -65,7 +65,7 @@ enum unicast_frag_flags { };
/* TT_QUERY subtypes */ -#define TT_QUERY_TYPE_MASK 0x3 +#define BATADV_TT_QUERY_TYPE_MASK 0x3
enum tt_query_packettype { TT_REQUEST = 0, @@ -126,7 +126,7 @@ struct batman_ogm_packet { __be16 tt_crc; } __packed;
-#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet) +#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet)
struct icmp_packet { struct batman_header header; @@ -138,7 +138,7 @@ struct icmp_packet { uint8_t reserved; } __packed;
-#define BAT_RR_LEN 16 +#define BATADV_RR_LEN 16
/* icmp_packet_rr must start with all fields from imcp_packet * as this is assumed by code that handles ICMP packets @@ -151,7 +151,7 @@ struct icmp_packet_rr { __be16 seqno; uint8_t uid; uint8_t rr_cur; - uint8_t rr[BAT_RR_LEN][ETH_ALEN]; + uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; } __packed;
struct unicast_packet { diff --git a/routing.c b/routing.c index c0737fa..f62fd85 100644 --- a/routing.c +++ b/routing.c @@ -423,7 +423,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
/* add record route information if not full */ if ((hdr_size == sizeof(struct icmp_packet_rr)) && - (icmp_packet->rr_cur < BAT_RR_LEN)) { + (icmp_packet->rr_cur < BATADV_RR_LEN)) { memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), ethhdr->h_dest, ETH_ALEN); icmp_packet->rr_cur++; @@ -603,7 +603,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
tt_query = (struct tt_query_packet *)skb->data;
- switch (tt_query->flags & TT_QUERY_TYPE_MASK) { + switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { case TT_REQUEST: batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
diff --git a/send.c b/send.c index 3d725e0..72542cb 100644 --- a/send.c +++ b/send.c @@ -58,11 +58,11 @@ int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, ethhdr = (struct ethhdr *)skb_mac_header(skb); memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); - ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); + ethhdr->h_proto = __constant_htons(BATADV_ETH_P_BATMAN);
skb_set_network_header(skb, ETH_HLEN); skb->priority = TC_PRIO_CONTROL; - skb->protocol = __constant_htons(ETH_P_BATMAN); + skb->protocol = __constant_htons(BATADV_ETH_P_BATMAN);
skb->dev = hard_iface->net_dev;
diff --git a/soft-interface.c b/soft-interface.c index 2de1d74..e726419 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -135,6 +135,7 @@ static int batadv_interface_tx(struct sk_buff *skb, struct hard_iface *primary_if = NULL; struct bcast_packet *bcast_packet; struct vlan_ethhdr *vhdr; + __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}; unsigned int header_len = 0; @@ -152,11 +153,11 @@ static int batadv_interface_tx(struct sk_buff *skb, vhdr = (struct vlan_ethhdr *)skb->data; vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
- if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) + if (vhdr->h_vlan_encapsulated_proto != ethertype) break;
/* fall through */ - case ETH_P_BATMAN: + case BATADV_ETH_P_BATMAN: goto dropped; }
@@ -208,7 +209,7 @@ static int batadv_interface_tx(struct sk_buff *skb, goto dropped;
bcast_packet = (struct bcast_packet *)skb->data; - bcast_packet->header.version = COMPAT_VERSION; + bcast_packet->header.version = BATADV_COMPAT_VERSION; bcast_packet->header.ttl = TTL;
/* batman packet type: broadcast */ @@ -266,6 +267,7 @@ void batadv_interface_rx(struct net_device *soft_iface, struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; short vid __maybe_unused = -1; + __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
/* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) @@ -281,11 +283,11 @@ void batadv_interface_rx(struct net_device *soft_iface, vhdr = (struct vlan_ethhdr *)skb->data; vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
- if (ntohs(vhdr->h_vlan_encapsulated_proto) != ETH_P_BATMAN) + if (vhdr->h_vlan_encapsulated_proto != ethertype) break;
/* fall through */ - case ETH_P_BATMAN: + case BATADV_ETH_P_BATMAN: goto dropped; }
diff --git a/translation-table.c b/translation-table.c index c03c479..d6363a4 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1441,7 +1441,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, sizeof(struct tt_query_packet));
tt_request->header.packet_type = BAT_TT_QUERY; - tt_request->header.version = COMPAT_VERSION; + tt_request->header.version = BATADV_COMPAT_VERSION; memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); tt_request->header.ttl = TTL; @@ -1575,7 +1575,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, }
tt_response->header.packet_type = BAT_TT_QUERY; - tt_response->header.version = COMPAT_VERSION; + tt_response->header.version = BATADV_COMPAT_VERSION; tt_response->header.ttl = TTL; memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); @@ -1696,7 +1696,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, }
tt_response->header.packet_type = BAT_TT_QUERY; - tt_response->header.version = COMPAT_VERSION; + tt_response->header.version = BATADV_COMPAT_VERSION; tt_response->header.ttl = TTL; memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); @@ -2008,7 +2008,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, sizeof(struct roam_adv_packet));
roam_adv_packet->header.packet_type = BAT_ROAM_ADV; - roam_adv_packet->header.version = COMPAT_VERSION; + roam_adv_packet->header.version = BATADV_COMPAT_VERSION; roam_adv_packet->header.ttl = TTL; primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) diff --git a/unicast.c b/unicast.c index f7a8cde..bafbbbf 100644 --- a/unicast.c +++ b/unicast.c @@ -253,7 +253,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
frag1->header.ttl--; - frag1->header.version = COMPAT_VERSION; + frag1->header.version = BATADV_COMPAT_VERSION; frag1->header.packet_type = BAT_UNICAST_FRAG;
memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); @@ -321,7 +321,7 @@ find_router:
unicast_packet = (struct unicast_packet *)skb->data;
- unicast_packet->header.version = COMPAT_VERSION; + unicast_packet->header.version = BATADV_COMPAT_VERSION; /* batman packet type: unicast */ unicast_packet->header.packet_type = BAT_UNICAST; /* set unicast ttl */ diff --git a/vis.c b/vis.c index 7dc7506..596eacc 100644 --- a/vis.c +++ b/vis.c @@ -873,7 +873,7 @@ int batadv_vis_init(struct bat_priv *bat_priv) INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); kref_init(&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; - packet->header.version = COMPAT_VERSION; + packet->header.version = BATADV_COMPAT_VERSION; packet->header.packet_type = BAT_VIS; packet->header.ttl = TTL; packet->seqno = 0;
On Monday, June 04, 2012 04:19:13 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 20 ++++++++++---------- hard-interface.c | 3 ++- icmp_socket.c | 4 ++-- main.c | 4 ++-- packet.h | 12 ++++++------ routing.c | 4 ++-- send.c | 4 ++-- soft-interface.c | 12 +++++++----- translation-table.c | 8 ++++---- unicast.c | 4 ++-- vis.c | 2 +- 11 files changed, 40 insertions(+), 37 deletions(-)
Applied in revision 2bff7e2.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- hard-interface.c | 11 ++++++----- soft-interface.c | 2 +- types.h | 9 ++++----- 3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c index 1db2d05..3bf426a 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -196,7 +196,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface) if (hard_iface->soft_iface != soft_iface) continue;
- min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN, + min_mtu = min_t(int, + hard_iface->net_dev->mtu - BATADV_HEADER_LEN, min_mtu); } rcu_read_unlock(); @@ -320,18 +321,18 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, hard_iface->net_dev->name);
if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < - ETH_DATA_LEN + BAT_HEADER_LEN) + ETH_DATA_LEN + BATADV_HEADER_LEN) batadv_info(hard_iface->soft_iface, "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + BAT_HEADER_LEN); + ETH_DATA_LEN + BATADV_HEADER_LEN);
if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < - ETH_DATA_LEN + BAT_HEADER_LEN) + ETH_DATA_LEN + BATADV_HEADER_LEN) batadv_info(hard_iface->soft_iface, "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + BAT_HEADER_LEN); + ETH_DATA_LEN + BATADV_HEADER_LEN);
if (batadv_hardif_is_iface_up(hard_iface)) batadv_hardif_activate_interface(hard_iface); diff --git a/soft-interface.c b/soft-interface.c index e726419..bbbc9a9 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -351,7 +351,7 @@ static void batadv_interface_setup(struct net_device *dev) */ dev->mtu = ETH_DATA_LEN; /* reserve more space in the skbuff for our header */ - dev->hard_header_len = BAT_HEADER_LEN; + dev->hard_header_len = BATADV_HEADER_LEN;
/* generate random address */ eth_hw_addr_random(dev); diff --git a/types.h b/types.h index 053c5d4..e4ba4dc 100644 --- a/types.h +++ b/types.h @@ -22,12 +22,11 @@
#include "packet.h" #include "bitarray.h" +#include "linux/kernel.h"
-#define BAT_HEADER_LEN (ETH_HLEN + \ - ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \ - sizeof(struct unicast_packet) : \ - sizeof(struct bcast_packet)))) - +#define BATADV_HEADER_LEN \ + (ETH_HLEN + max(sizeof(struct unicast_packet), \ + sizeof(struct bcast_packet)))
struct hard_iface { struct list_head list;
On Monday, June 04, 2012 04:19:14 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
hard-interface.c | 11 ++++++----- soft-interface.c | 2 +- types.h | 9 ++++----- 3 files changed, 11 insertions(+), 11 deletions(-)
Applied in revision dfaf026.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- originator.c | 2 +- unicast.c | 2 +- unicast.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/originator.c b/originator.c index bf9ec39..1980696 100644 --- a/originator.c +++ b/originator.c @@ -370,7 +370,7 @@ static void _batadv_purge_orig(struct bat_priv *bat_priv) }
if (batadv_has_timed_out(orig_node->last_frag_packet, - FRAG_TIMEOUT)) + BATADV_FRAG_TIMEOUT)) batadv_frag_list_free(&orig_node->frag_list); } spin_unlock_bh(list_lock); diff --git a/unicast.c b/unicast.c index bafbbbf..39b4f10 100644 --- a/unicast.c +++ b/unicast.c @@ -98,7 +98,7 @@ static int batadv_frag_create_buffer(struct list_head *head) int i; struct frag_packet_list_entry *tfp;
- for (i = 0; i < FRAG_BUFFER_SIZE; i++) { + for (i = 0; i < BATADV_FRAG_BUFFER_SIZE; i++) { tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); if (!tfp) { batadv_frag_list_free(head); diff --git a/unicast.h b/unicast.h index 9257b83..936287f 100644 --- a/unicast.h +++ b/unicast.h @@ -22,8 +22,8 @@
#include "packet.h"
-#define FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ -#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ +#define BATADV_FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ +#define BATADV_FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, struct sk_buff **new_skb);
On Monday, June 04, 2012 04:19:15 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
originator.c | 2 +- unicast.c | 2 +- unicast.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
Applied in revision 5a614ef.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- vis.c | 2 +- vis.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/vis.c b/vis.c index 596eacc..a439ed6 100644 --- a/vis.c +++ b/vis.c @@ -674,7 +674,7 @@ static void batadv_purge_vis_packets(struct bat_priv *bat_priv) continue;
if (batadv_has_timed_out(info->first_seen, - VIS_TIMEOUT)) { + BATADV_VIS_TIMEOUT)) { hlist_del(node); batadv_send_list_del(info); kref_put(&info->refcount, batadv_free_info); diff --git a/vis.h b/vis.h index dad5958..16a1a6b 100644 --- a/vis.h +++ b/vis.h @@ -21,7 +21,7 @@ #define _NET_BATMAN_ADV_VIS_H_
/* timeout of vis packets in miliseconds */ -#define VIS_TIMEOUT 200000 +#define BATADV_VIS_TIMEOUT 200000
int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
On Monday, June 04, 2012 04:19:16 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
vis.c | 2 +- vis.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision c782c5a.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- Makefile | 2 +- bat_debugfs.c | 2 +- bat_iv_ogm.c | 101 ++++++++++++++++++++++++++++------------------- bat_sysfs.c | 7 ++-- bitarray.c | 20 +++++----- bitarray.h | 4 +- bridge_loop_avoidance.c | 20 +++++----- gateway_client.c | 18 ++++----- hard-interface.c | 2 +- main.c | 13 +++--- main.h | 81 ++++++++++++++++++------------------- originator.c | 32 ++++++++------- ring_buffer.c | 4 +- routing.c | 20 +++++----- soft-interface.c | 10 ++--- translation-table.c | 84 ++++++++++++++++++++++----------------- types.h | 10 ++--- unicast.c | 2 +- vis.c | 11 +++--- 19 files changed, 242 insertions(+), 201 deletions(-)
diff --git a/Makefile b/Makefile index 9d59175..bd8d30c 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ REVISION= $(shell if [ -d "$(PWD)/.git" ]; then \ CONFIG_BATMAN_ADV=m batman-adv-y += compat.o ifneq ($(REVISION),) -ccflags-y += -DSOURCE_VERSION="$(REVISION)" +ccflags-y += -DBATADV_SOURCE_VERSION="$(REVISION)" endif include $(PWD)/Makefile.kbuild
diff --git a/bat_debugfs.c b/bat_debugfs.c index c28b9de..2693be0 100644 --- a/bat_debugfs.c +++ b/bat_debugfs.c @@ -38,7 +38,7 @@ static struct dentry *batadv_debugfs; #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) #define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
-static int batadv_log_buff_len = LOG_BUF_LEN; +static int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static void batadv_emit_log_char(struct debug_log *debug_log, char c) { diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 825054a..454b3d8 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -74,8 +74,8 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface) batman_ogm_packet->header.packet_type = BAT_IV_OGM; batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; batman_ogm_packet->header.ttl = 2; - batman_ogm_packet->flags = NO_FLAGS; - batman_ogm_packet->tq = TQ_MAX_VALUE; + batman_ogm_packet->flags = BATADV_NO_FLAGS; + batman_ogm_packet->tq = BATADV_TQ_MAX_VALUE; batman_ogm_packet->tt_num_changes = 0; batman_ogm_packet->ttvn = 0;
@@ -108,29 +108,37 @@ static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; - batman_ogm_packet->header.ttl = TTL; + batman_ogm_packet->header.ttl = BATADV_TTL; }
/* when do we schedule our own ogm to be sent */ static unsigned long batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) { - return jiffies + msecs_to_jiffies( - atomic_read(&bat_priv->orig_interval) - - JITTER + (random32() % 2*JITTER)); + unsigned int msecs; + + msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER; + msecs += (random32() % 2 * BATADV_JITTER); + + return jiffies + msecs_to_jiffies(msecs); }
/* when do we schedule a ogm packet to be sent */ static unsigned long batadv_iv_ogm_fwd_send_time(void) { - return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); + return jiffies + msecs_to_jiffies(random32() % (BATADV_JITTER / 2)); }
/* apply hop penalty for a normal link */ static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) { int hop_penalty = atomic_read(&bat_priv->hop_penalty); - return (tq * (TQ_MAX_VALUE - hop_penalty)) / (TQ_MAX_VALUE); + int new_tq; + + new_tq = tq * (BATADV_TQ_MAX_VALUE - hop_penalty); + new_tq /= BATADV_TQ_MAX_VALUE; + + return new_tq; }
/* is there another aggregated packet here? */ @@ -143,7 +151,7 @@ static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, next_buff_pos += batadv_tt_len(tt_num_changes);
return (next_buff_pos <= packet_len) && - (next_buff_pos <= MAX_AGGREGATION_BYTES); + (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES); }
/* send a batman ogm to a given interface */ @@ -290,8 +298,11 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, int aggregated_bytes = forw_packet->packet_len + packet_len; struct hard_iface *primary_if = NULL; bool res = false; + unsigned long aggregation_end_time;
batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; + aggregation_end_time = send_time; + aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
/* we can aggregate the current packet to this aggregated packet * if: @@ -301,9 +312,8 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, * MAX_AGGREGATION_BYTES */ if (time_before(send_time, forw_packet->send_time) && - time_after_eq(send_time + msecs_to_jiffies(MAX_AGGREGATION_MS), - forw_packet->send_time) && - (aggregated_bytes <= MAX_AGGREGATION_BYTES)) { + time_after_eq(aggregation_end_time, forw_packet->send_time) && + (aggregated_bytes <= BATADV_MAX_AGGREGATION_BYTES)) {
/* check aggregation compatibility * -> direct link packets are broadcasted on @@ -367,6 +377,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct forw_packet *forw_packet_aggr; unsigned char *skb_buff; + unsigned int skb_size;
if (!atomic_inc_not_zero(&if_incoming->refcount)) return; @@ -388,12 +399,12 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, }
if ((atomic_read(&bat_priv->aggregated_ogms)) && - (packet_len < MAX_AGGREGATION_BYTES)) - forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES + - ETH_HLEN); + (packet_len < BATADV_MAX_AGGREGATION_BYTES)) + skb_size = BATADV_MAX_AGGREGATION_BYTES + ETH_HLEN; else - forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN); + skb_size = packet_len + ETH_HLEN;
+ forw_packet_aggr->skb = dev_alloc_skb(skb_size); if (!forw_packet_aggr->skb) { if (!own_packet) atomic_inc(&bat_priv->batman_queue_left); @@ -411,7 +422,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, forw_packet_aggr->own = own_packet; forw_packet_aggr->if_incoming = if_incoming; forw_packet_aggr->num_packets = 0; - forw_packet_aggr->direct_link_flags = NO_FLAGS; + forw_packet_aggr->direct_link_flags = BATADV_NO_FLAGS; forw_packet_aggr->send_time = send_time;
/* save packet direct link flag status */ @@ -466,9 +477,11 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv, struct hlist_node *tmp_node; struct batman_ogm_packet *batman_ogm_packet; bool direct_link; + unsigned long max_aggregation_jiffies;
batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0; + max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
/* find position for the packet in the forward queue */ spin_lock_bh(&bat_priv->forw_bat_list_lock); @@ -498,9 +511,8 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv, * we hold it back for a while, so that it might be aggregated * later on */ - if ((!own_packet) && - (atomic_read(&bat_priv->aggregated_ogms))) - send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); + if (!own_packet && atomic_read(&bat_priv->aggregated_ogms)) + send_time += max_aggregation_jiffies;
batadv_iv_ogm_aggregate_new(packet_buff, packet_len, send_time, direct_link, @@ -603,7 +615,7 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) batman_ogm_packet->gw_flags = (uint8_t)atomic_read(&bat_priv->gw_bandwidth); else - batman_ogm_packet->gw_flags = NO_FLAGS; + batman_ogm_packet->gw_flags = BATADV_NO_FLAGS;
batadv_slide_own_bcast_window(hard_iface); batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, @@ -772,8 +784,10 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, struct neigh_node *neigh_node = NULL, *tmp_neigh_node; struct hlist_node *node; uint8_t total_count; - uint8_t orig_eq_count, neigh_rq_count, tq_own; - int tq_asym_penalty, ret = 0; + uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; + unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; + int tq_asym_penalty, inv_asym_penalty, ret = 0; + unsigned int combined_tq;
/* find corresponding one hop neighbor */ rcu_read_lock(); @@ -824,32 +838,33 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, /* if we have too few packets (too less data) we set tq_own to zero * if we receive too few packets it is not considered bidirectional */ - if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) || - (neigh_rq_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM)) + if (total_count < BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM || + neigh_rq_count < BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM) tq_own = 0; else /* neigh_node->real_packet_count is never zero as we * only purge old information when getting new * information */ - tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count; + tq_own = (BATADV_TQ_MAX_VALUE * total_count) / neigh_rq_count;
/* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does * affect the nearly-symmetric links only a little, but * punishes asymmetric links more. This will give a value * between 0 and TQ_MAX_VALUE */ - tq_asym_penalty = TQ_MAX_VALUE - (TQ_MAX_VALUE * - (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count) * - (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count) * - (TQ_LOCAL_WINDOW_SIZE - neigh_rq_count)) / - (TQ_LOCAL_WINDOW_SIZE * - TQ_LOCAL_WINDOW_SIZE * - TQ_LOCAL_WINDOW_SIZE); + neigh_rq_inv = BATADV_TQ_LOCAL_WINDOW_SIZE - neigh_rq_count; + neigh_rq_inv_cube = neigh_rq_inv * neigh_rq_inv * neigh_rq_inv; + neigh_rq_max_cube = BATADV_TQ_LOCAL_WINDOW_SIZE * + BATADV_TQ_LOCAL_WINDOW_SIZE * + BATADV_TQ_LOCAL_WINDOW_SIZE; + inv_asym_penalty = BATADV_TQ_MAX_VALUE * neigh_rq_inv_cube; + inv_asym_penalty /= neigh_rq_max_cube; + tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty;
- batman_ogm_packet->tq = ((batman_ogm_packet->tq * tq_own - * tq_asym_penalty) / - (TQ_MAX_VALUE * TQ_MAX_VALUE)); + combined_tq = batman_ogm_packet->tq * tq_own * tq_asym_penalty; + combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE; + batman_ogm_packet->tq = combined_tq;
batadv_dbg(DBG_BATMAN, bat_priv, "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", @@ -860,7 +875,7 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, /* if link has the minimum required transmission quality * consider it bidirectional */ - if (batman_ogm_packet->tq >= TQ_TOTAL_BIDRECT_LIMIT) + if (batman_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT) ret = 1;
out: @@ -928,7 +943,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
tmp_neigh_node->real_packet_count = bitmap_weight(tmp_neigh_node->real_bits, - TQ_LOCAL_WINDOW_SIZE); + BATADV_TQ_LOCAL_WINDOW_SIZE); } rcu_read_unlock();
@@ -1050,6 +1065,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, unsigned long *word; int offset; int32_t bit_pos; + int16_t if_num; + uint8_t *weight;
orig_neigh_node = batadv_get_orig_node(bat_priv, ethhdr->h_source); @@ -1063,15 +1080,17 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, if (has_directlink_flag && batadv_compare_eth(if_incoming->net_dev->dev_addr, batman_ogm_packet->orig)) { - offset = if_incoming->if_num * NUM_WORDS; + if_num = if_incoming->if_num; + offset = if_num * BATADV_NUM_WORDS;
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); word = &(orig_neigh_node->bcast_own[offset]); bit_pos = if_incoming_seqno - 2; bit_pos -= ntohl(batman_ogm_packet->seqno); batadv_set_bit(word, bit_pos); - orig_neigh_node->bcast_own_sum[if_incoming->if_num] = - bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); + weight = &orig_neigh_node->bcast_own_sum[if_num]; + *weight = bitmap_weight(word, + BATADV_TQ_LOCAL_WINDOW_SIZE); spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); }
diff --git a/bat_sysfs.c b/bat_sysfs.c index 24881d8..74aed8d 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -469,10 +469,11 @@ static BATADV_ATTR(vis_mode, S_IRUGO | S_IWUSR, batadv_show_vis_mode, static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL); static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode, batadv_store_gw_mode); -BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, +BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER, + INT_MAX, NULL); +BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE, NULL); -BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); -BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, +BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE, batadv_post_gw_deselect); static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, batadv_store_gw_bwidth); diff --git a/bitarray.c b/bitarray.c index e195b9e..4a009b5 100644 --- a/bitarray.c +++ b/bitarray.c @@ -25,10 +25,10 @@ /* shift the packet array by n places. */ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) { - if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE) + if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE) return;
- bitmap_shift_left(seq_bits, seq_bits, n, TQ_LOCAL_WINDOW_SIZE); + bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE); }
@@ -46,7 +46,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, /* sequence number is slightly older. We already got a sequence number * higher than this one, so we just mark it. */ - if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) { + if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) { if (set_mark) batadv_set_bit(seq_bits, -seq_num_diff); return 0; @@ -55,7 +55,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, /* sequence number is slightly newer, so we shift the window and * set the mark if required */ - if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) { + if (seq_num_diff > 0 && seq_num_diff < BATADV_TQ_LOCAL_WINDOW_SIZE) { batadv_bitmap_shift_left(seq_bits, seq_num_diff);
if (set_mark) @@ -64,12 +64,12 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, }
/* sequence number is much newer, probably missed a lot of packets */ - if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && - (seq_num_diff < EXPECTED_SEQNO_RANGE)) { + if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE && + seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) { batadv_dbg(DBG_BATMAN, bat_priv, "We missed a lot of packets (%i) !\n", seq_num_diff - 1); - bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); + bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); if (set_mark) batadv_set_bit(seq_bits, 0); return 1; @@ -80,13 +80,13 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, * packet should be dropped without calling this function if the * seqno window is protected. */ - if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || - (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { + if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || + seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
batadv_dbg(DBG_BATMAN, bat_priv, "Other host probably restarted!\n");
- bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE); + bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); if (set_mark) batadv_set_bit(seq_bits, 0);
diff --git a/bitarray.h b/bitarray.h index 7954ba8..a081ce1 100644 --- a/bitarray.h +++ b/bitarray.h @@ -29,7 +29,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, int32_t diff;
diff = last_seqno - curr_seqno; - if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) + if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE) return 0; else return test_bit(diff, seq_bits); @@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n) { /* if too old, just drop it */ - if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE) + if (n < 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE) return;
set_bit(n, seq_bits); /* turn the position on */ diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 42b8a20..ee75fa6 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -949,7 +949,7 @@ static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) if (now) goto purge_now; if (!batadv_has_timed_out(backbone_gw->lasttime, - BLA_BACKBONE_TIMEOUT)) + BATADV_BLA_BACKBONE_TIMEOUT)) continue;
batadv_dbg(DBG_BLA, backbone_gw->bat_priv, @@ -1001,7 +1001,7 @@ static void batadv_bla_purge_claims(struct bat_priv *bat_priv, primary_if->net_dev->dev_addr)) continue; if (!batadv_has_timed_out(claim->lasttime, - BLA_CLAIM_TIMEOUT)) + BATADV_BLA_CLAIM_TIMEOUT)) continue;
batadv_dbg(DBG_BLA, bat_priv, @@ -1075,7 +1075,7 @@ static void batadv_bla_start_timer(struct bat_priv *bat_priv) { INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work); queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, - msecs_to_jiffies(BLA_PERIOD_LENGTH)); + msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); }
/* periodic work to do: @@ -1162,9 +1162,9 @@ int batadv_bla_init(struct bat_priv *bat_priv) }
/* initialize the duplicate list */ - for (i = 0; i < DUPLIST_SIZE; i++) + for (i = 0; i < BATADV_DUPLIST_SIZE; i++) bat_priv->bcast_duplist[i].entrytime = - jiffies - msecs_to_jiffies(DUPLIST_TIMEOUT); + jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT); bat_priv->bcast_duplist_curr = 0;
if (bat_priv->claim_hash) @@ -1216,14 +1216,15 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, /* calculate the crc ... */ crc = crc16(0, content, length);
- for (i = 0 ; i < DUPLIST_SIZE; i++) { - curr = (bat_priv->bcast_duplist_curr + i) % DUPLIST_SIZE; + for (i = 0 ; i < BATADV_DUPLIST_SIZE; i++) { + curr = (bat_priv->bcast_duplist_curr + i) % BATADV_DUPLIST_SIZE; entry = &bat_priv->bcast_duplist[curr];
/* we can stop searching if the entry is too old ; * later entries will be even older */ - if (batadv_has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) + if (batadv_has_timed_out(entry->entrytime, + BATADV_DUPLIST_TIMEOUT)) break;
if (entry->crc != crc) @@ -1238,7 +1239,8 @@ int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, return 1; } /* not found, add a new entry (overwrite the oldest entry) */ - curr = (bat_priv->bcast_duplist_curr + DUPLIST_SIZE - 1) % DUPLIST_SIZE; + curr = (bat_priv->bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1); + curr %= BATADV_DUPLIST_SIZE; entry = &bat_priv->bcast_duplist[curr]; entry->crc = crc; entry->entrytime = jiffies; diff --git a/gateway_client.c b/gateway_client.c index 7d186a7..ae8b4e6 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -138,8 +138,8 @@ static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv)
tmp_gw_factor = (router->tq_avg * router->tq_avg * down * 100 * 100) / - (TQ_LOCAL_WINDOW_SIZE * - TQ_LOCAL_WINDOW_SIZE * 64); + (BATADV_TQ_LOCAL_WINDOW_SIZE * + BATADV_TQ_LOCAL_WINDOW_SIZE * 64);
if ((tmp_gw_factor > max_gw_factor) || ((tmp_gw_factor == max_gw_factor) && @@ -354,7 +354,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
gw_node->deleted = 0;
- if (new_gwflags == NO_FLAGS) { + if (new_gwflags == BATADV_NO_FLAGS) { gw_node->deleted = jiffies; batadv_dbg(DBG_BATMAN, bat_priv, "Gateway %pM removed from gateway list\n", @@ -367,7 +367,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, goto unlock; }
- if (new_gwflags == NO_FLAGS) + if (new_gwflags == BATADV_NO_FLAGS) goto unlock;
batadv_gw_node_add(bat_priv, orig_node, new_gwflags); @@ -392,7 +392,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) { struct gw_node *gw_node, *curr_gw; struct hlist_node *node, *node_tmp; - unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); + unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); int do_deselect = 0;
curr_gw = batadv_gw_get_selected_gw_node(bat_priv); @@ -484,8 +484,8 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", - "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", - SOURCE_VERSION, primary_if->net_dev->name, + "Gateway", "#", BATADV_TQ_MAX_VALUE, "Nexthop", "outgoingIF", + BATADV_SOURCE_VERSION, primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name);
rcu_read_lock(); @@ -667,7 +667,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, /* If we are a GW then we are our best GW. We can artificially * set the tq towards ourself as the maximum value */ - curr_tq_avg = TQ_MAX_VALUE; + curr_tq_avg = BATADV_TQ_MAX_VALUE; break; case GW_MODE_CLIENT: curr_gw = batadv_gw_get_selected_gw_node(bat_priv); @@ -698,7 +698,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, if (!neigh_old) goto out;
- if (curr_tq_avg - neigh_old->tq_avg > GW_THRESHOLD) + if (curr_tq_avg - neigh_old->tq_avg > BATADV_GW_THRESHOLD) out_of_range = true;
out: diff --git a/hard-interface.c b/hard-interface.c index 3bf426a..a8f5af8 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -548,7 +548,7 @@ bool batadv_is_wifi_iface(int ifindex) struct net_device *net_device = NULL; bool ret = false;
- if (ifindex == NULL_IFINDEX) + if (ifindex == BATADV_NULL_IFINDEX) goto out;
net_device = dev_get_by_index(&init_net, ifindex); diff --git a/main.c b/main.c index 986be72..df7335c 100644 --- a/main.c +++ b/main.c @@ -72,7 +72,7 @@ static int __init batadv_init(void) register_netdevice_notifier(&batadv_hard_if_notifier);
pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", - SOURCE_VERSION, BATADV_COMPAT_VERSION); + BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
return 0; } @@ -120,7 +120,8 @@ int batadv_mesh_init(struct net_device *soft_iface) if (ret < 0) goto err;
- batadv_tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); + batadv_tt_local_add(soft_iface, soft_iface->dev_addr, + BATADV_NULL_IFINDEX);
ret = batadv_vis_init(bat_priv); if (ret < 0) @@ -420,7 +421,7 @@ module_exit(batadv_exit);
MODULE_LICENSE("GPL");
-MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); -MODULE_VERSION(SOURCE_VERSION); +MODULE_AUTHOR(BATADV_DRIVER_AUTHOR); +MODULE_DESCRIPTION(BATADV_DRIVER_DESC); +MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE); +MODULE_VERSION(BATADV_SOURCE_VERSION); diff --git a/main.h b/main.h index e447f73..b796714 100644 --- a/main.h +++ b/main.h @@ -20,79 +20,80 @@ #ifndef _NET_BATMAN_ADV_MAIN_H_ #define _NET_BATMAN_ADV_MAIN_H_
-#define DRIVER_AUTHOR "Marek Lindner lindner_marek@yahoo.de, " \ - "Simon Wunderlich siwu@hrz.tu-chemnitz.de" -#define DRIVER_DESC "B.A.T.M.A.N. advanced" -#define DRIVER_DEVICE "batman-adv" +#define BATADV_DRIVER_AUTHOR "Marek Lindner lindner_marek@yahoo.de, " \ + "Simon Wunderlich siwu@hrz.tu-chemnitz.de" +#define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced" +#define BATADV_DRIVER_DEVICE "batman-adv"
-#ifndef SOURCE_VERSION -#define SOURCE_VERSION "2012.2.0" +#ifndef BATADV_SOURCE_VERSION +#define BATADV_SOURCE_VERSION "2012.2.0" #endif
/* B.A.T.M.A.N. parameters */
-#define TQ_MAX_VALUE 255 -#define JITTER 20 +#define BATADV_TQ_MAX_VALUE 255 +#define BATADV_JITTER 20
/* Time To Live of broadcast messages */ -#define TTL 50 +#define BATADV_TTL 50
/* purge originators after time in seconds if no valid packet comes in - * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE + * -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE */ -#define PURGE_TIMEOUT 200000 /* 200 seconds */ -#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ -#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ +#define BATADV_PURGE_TIMEOUT 200000 /* 200 seconds */ +#define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ +#define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ /* 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 BATADV_TQ_LOCAL_WINDOW_SIZE 64 /* miliseconds we have to keep pending tt_req */ -#define TT_REQUEST_TIMEOUT 3000 +#define BATADV_TT_REQUEST_TIMEOUT 3000
-#define TQ_GLOBAL_WINDOW_SIZE 5 -#define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 -#define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 -#define TQ_TOTAL_BIDRECT_LIMIT 1 +#define BATADV_TQ_GLOBAL_WINDOW_SIZE 5 +#define BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 +#define BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 +#define BATADV_TQ_TOTAL_BIDRECT_LIMIT 1
-#define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ +/* number of OGMs sent with the last tt diff */ +#define BATADV_TT_OGM_APPEND_MAX 3
/* Time in which a client can roam at most ROAMING_MAX_COUNT times in * miliseconds */ -#define ROAMING_MAX_TIME 20000 -#define ROAMING_MAX_COUNT 5 +#define BATADV_ROAMING_MAX_TIME 20000 +#define BATADV_ROAMING_MAX_COUNT 5
-#define NO_FLAGS 0 +#define BATADV_NO_FLAGS 0
-#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ +#define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
-#define NUM_WORDS BITS_TO_LONGS(TQ_LOCAL_WINDOW_SIZE) +#define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE)
-#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ +#define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */
-#define VIS_INTERVAL 5000 /* 5 seconds */ +#define BATADV_VIS_INTERVAL 5000 /* 5 seconds */
/* how much worse secondary interfaces may be to be considered as bonding * candidates */ -#define BONDING_TQ_THRESHOLD 50 +#define BATADV_BONDING_TQ_THRESHOLD 50
/* should not be bigger than 512 bytes or change the size of * forw_packet->direct_link_flags */ -#define MAX_AGGREGATION_BYTES 512 -#define MAX_AGGREGATION_MS 100 +#define BATADV_MAX_AGGREGATION_BYTES 512 +#define BATADV_MAX_AGGREGATION_MS 100
-#define BLA_PERIOD_LENGTH 10000 /* 10 seconds */ -#define BLA_BACKBONE_TIMEOUT (BLA_PERIOD_LENGTH * 3) -#define BLA_CLAIM_TIMEOUT (BLA_PERIOD_LENGTH * 10) +#define BATADV_BLA_PERIOD_LENGTH 10000 /* 10 seconds */ +#define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 3) +#define BATADV_BLA_CLAIM_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 10)
-#define DUPLIST_SIZE 16 -#define DUPLIST_TIMEOUT 500 /* 500 ms */ +#define BATADV_DUPLIST_SIZE 16 +#define BATADV_DUPLIST_TIMEOUT 500 /* 500 ms */ /* don't reset again within 30 seconds */ -#define RESET_PROTECTION_MS 30000 -#define EXPECTED_SEQNO_RANGE 65536 +#define BATADV_RESET_PROTECTION_MS 30000 +#define BATADV_EXPECTED_SEQNO_RANGE 65536
enum mesh_state { MESH_INACTIVE, @@ -100,8 +101,8 @@ enum mesh_state { MESH_DEACTIVATING };
-#define BCAST_QUEUE_LEN 256 -#define BATMAN_QUEUE_LEN 256 +#define BATADV_BCAST_QUEUE_LEN 256 +#define BATADV_BATMAN_QUEUE_LEN 256
enum uev_action { UEV_ADD = 0, @@ -113,7 +114,7 @@ enum uev_type { UEV_GW = 0 };
-#define GW_THRESHOLD 50 +#define BATADV_GW_THRESHOLD 50
/* Debug Messages */ #ifdef pr_fmt diff --git a/originator.c b/originator.c index 1980696..f04f591 100644 --- a/originator.c +++ b/originator.c @@ -194,6 +194,7 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, struct orig_node *orig_node; int size; int hash_added; + unsigned long reset_time;
orig_node = batadv_orig_hash_find(bat_priv, addr); if (orig_node) @@ -226,14 +227,13 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, orig_node->tt_buff = NULL; orig_node->tt_buff_len = 0; atomic_set(&orig_node->tt_size, 0); - orig_node->bcast_seqno_reset = jiffies - 1 - - msecs_to_jiffies(RESET_PROTECTION_MS); - orig_node->batman_seqno_reset = jiffies - 1 - - msecs_to_jiffies(RESET_PROTECTION_MS); + reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); + orig_node->bcast_seqno_reset = reset_time; + orig_node->batman_seqno_reset = reset_time;
atomic_set(&orig_node->bond_candidates, 0);
- size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS; + size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS;
orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); if (!orig_node->bcast_own) @@ -285,7 +285,7 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, last_seen = neigh_node->last_seen; if_incoming = neigh_node->if_incoming;
- if ((batadv_has_timed_out(last_seen, PURGE_TIMEOUT)) || + if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) || (if_incoming->if_status == IF_INACTIVE) || (if_incoming->if_status == IF_NOT_IN_USE) || (if_incoming->if_status == IF_TO_BE_REMOVED)) { @@ -324,7 +324,8 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv, { struct neigh_node *best_neigh_node;
- if (batadv_has_timed_out(orig_node->last_seen, 2 * PURGE_TIMEOUT)) { + if (batadv_has_timed_out(orig_node->last_seen, + 2 * BATADV_PURGE_TIMEOUT)) { batadv_dbg(DBG_BATMAN, bat_priv, "Originator timeout: originator %pM, last_seen %u\n", orig_node->orig, @@ -429,11 +430,11 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) }
seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", - SOURCE_VERSION, primary_if->net_dev->name, + BATADV_SOURCE_VERSION, primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", - "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", - "outgoingIF", "Potential nexthops"); + "Originator", "last-seen", "#", BATADV_TQ_MAX_VALUE, + "Nexthop", "outgoingIF", "Potential nexthops");
for (i = 0; i < hash->size; i++) { head = &hash->table[i]; @@ -486,14 +487,15 @@ out: static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num) { void *data_ptr; + size_t data_size, old_size;
- data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, - GFP_ATOMIC); + data_size = max_if_num * sizeof(unsigned long) * BATADV_NUM_WORDS; + old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS; + data_ptr = kmalloc(data_size, GFP_ATOMIC); if (!data_ptr) return -ENOMEM;
- memcpy(data_ptr, orig_node->bcast_own, - (max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS); + memcpy(data_ptr, orig_node->bcast_own, old_size); kfree(orig_node->bcast_own); orig_node->bcast_own = data_ptr;
@@ -554,7 +556,7 @@ static int batadv_orig_node_del_if(struct orig_node *orig_node, if (max_if_num == 0) goto free_bcast_own;
- chunk_size = sizeof(unsigned long) * NUM_WORDS; + chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS; data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); if (!data_ptr) return -ENOMEM; diff --git a/ring_buffer.c b/ring_buffer.c index aff1ca2..c8f61e3 100644 --- a/ring_buffer.c +++ b/ring_buffer.c @@ -24,7 +24,7 @@ void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, uint8_t value) { lq_recv[*lq_index] = value; - *lq_index = (*lq_index + 1) % TQ_GLOBAL_WINDOW_SIZE; + *lq_index = (*lq_index + 1) % BATADV_TQ_GLOBAL_WINDOW_SIZE; }
uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) @@ -34,7 +34,7 @@ uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
ptr = lq_recv;
- while (i < TQ_GLOBAL_WINDOW_SIZE) { + while (i < BATADV_TQ_GLOBAL_WINDOW_SIZE) { if (*ptr != 0) { count++; sum += *ptr; diff --git a/routing.c b/routing.c index f62fd85..fa0b4ee 100644 --- a/routing.c +++ b/routing.c @@ -42,6 +42,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) unsigned long *word; uint32_t i; size_t word_index; + uint8_t *w;
for (i = 0; i < hash->size; i++) { head = &hash->table[i]; @@ -49,12 +50,12 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) rcu_read_lock(); hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { spin_lock_bh(&orig_node->ogm_cnt_lock); - word_index = hard_iface->if_num * NUM_WORDS; + word_index = hard_iface->if_num * BATADV_NUM_WORDS; word = &(orig_node->bcast_own[word_index]);
batadv_bit_get_packet(bat_priv, word, 1, 0); - orig_node->bcast_own_sum[hard_iface->if_num] = - bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); + w = &orig_node->bcast_own_sum[hard_iface->if_num]; + *w = bitmap_weight(word, BATADV_TQ_LOCAL_WINDOW_SIZE); spin_unlock_bh(&orig_node->ogm_cnt_lock); } rcu_read_unlock(); @@ -160,7 +161,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, goto candidate_del;
/* ... and is good enough to be considered */ - if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) + if (neigh_node->tq_avg < router->tq_avg - BATADV_BONDING_TQ_THRESHOLD) goto candidate_del;
/* check if we have another candidate with the same mac address or @@ -232,9 +233,10 @@ batadv_bonding_save_primary(const struct orig_node *orig_node, int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, unsigned long *last_reset) { - if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || - (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { - if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS)) + if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || + seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { + if (!batadv_has_timed_out(*last_reset, + BATADV_RESET_PROTECTION_MS)) return 1;
*last_reset = jiffies; @@ -316,7 +318,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv, memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = ECHO_REPLY; - icmp_packet->header.ttl = TTL; + icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; @@ -371,7 +373,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = TTL_EXCEEDED; - icmp_packet->header.ttl = TTL; + icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; diff --git a/soft-interface.c b/soft-interface.c index bbbc9a9..c1b2ab2 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -108,7 +108,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { batadv_tt_local_remove(bat_priv, dev->dev_addr, "mac address changed", false); - batadv_tt_local_add(dev, addr->sa_data, NULL_IFINDEX); + batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX); }
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); @@ -210,7 +210,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
bcast_packet = (struct bcast_packet *)skb->data; bcast_packet->header.version = BATADV_COMPAT_VERSION; - bcast_packet->header.ttl = TTL; + bcast_packet->header.ttl = BATADV_TTL;
/* batman packet type: broadcast */ bcast_packet->header.packet_type = BAT_BCAST; @@ -394,8 +394,8 @@ struct net_device *batadv_softif_create(const char *name) atomic_set(&bat_priv->hop_penalty, 30); atomic_set(&bat_priv->log_level, 0); atomic_set(&bat_priv->fragmentation, 1); - atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); - atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); + atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN); + atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); atomic_set(&bat_priv->bcast_seqno, 1); @@ -487,7 +487,7 @@ static void batadv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, "B.A.T.M.A.N. advanced"); - strcpy(info->version, SOURCE_VERSION); + strcpy(info->version, BATADV_SOURCE_VERSION); strcpy(info->fw_version, "N/A"); strcpy(info->bus_info, "batman"); } diff --git a/translation-table.c b/translation-table.c index d6363a4..330a83f 100644 --- a/translation-table.c +++ b/translation-table.c @@ -256,7 +256,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, (uint8_t)atomic_read(&bat_priv->ttvn));
memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); - tt_local_entry->common.flags = NO_FLAGS; + tt_local_entry->common.flags = BATADV_NO_FLAGS; if (batadv_is_wifi_iface(ifindex)) tt_local_entry->common.flags |= TT_CLIENT_WIFI; atomic_set(&tt_local_entry->common.refcount, 2); @@ -492,14 +492,17 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, const char *message, bool roaming) { struct tt_local_entry *tt_local_entry = NULL; + uint16_t flags;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); if (!tt_local_entry) goto out;
- batadv_tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | - (roaming ? TT_CLIENT_ROAM : NO_FLAGS), - message); + flags = TT_CLIENT_DEL; + if (roaming) + flags |= TT_CLIENT_ROAM; + + batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); out: if (tt_local_entry) batadv_tt_local_entry_free_ref(tt_local_entry); @@ -533,7 +536,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv) continue;
if (!batadv_has_timed_out(tt_local_entry->last_seen, - TT_LOCAL_TIMEOUT)) + BATADV_TT_LOCAL_TIMEOUT)) continue;
batadv_tt_local_set_pending(bat_priv, tt_local_entry, @@ -1008,12 +1011,35 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, orig_node->tt_initialised = false; }
-static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) +static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv, + struct hlist_head *head) { - struct hashtable_t *hash = bat_priv->tt_global_hash; struct tt_common_entry *tt_common_entry; struct tt_global_entry *tt_global_entry; struct hlist_node *node, *node_tmp; + + hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head, + hash_entry) { + tt_global_entry = container_of(tt_common_entry, + struct tt_global_entry, common); + if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) + continue; + if (!batadv_has_timed_out(tt_global_entry->roam_at, + BATADV_TT_CLIENT_ROAM_TIMEOUT)) + continue; + + batadv_dbg(DBG_TT, bat_priv, + "Deleting global tt entry (%pM): Roaming timeout\n", + tt_global_entry->common.addr); + + hlist_del_rcu(node); + batadv_tt_global_entry_free_ref(tt_global_entry); + } +} + +static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) +{ + struct hashtable_t *hash = bat_priv->tt_global_hash; struct hlist_head *head; spinlock_t *list_lock; /* protects write access to the hash lists */ uint32_t i; @@ -1023,24 +1049,7 @@ static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) list_lock = &hash->list_locks[i];
spin_lock_bh(list_lock); - hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, - head, hash_entry) { - tt_global_entry = container_of(tt_common_entry, - struct tt_global_entry, - common); - if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) - continue; - if (!batadv_has_timed_out(tt_global_entry->roam_at, - TT_CLIENT_ROAM_TIMEOUT)) - continue; - - batadv_dbg(DBG_TT, bat_priv, - "Deleting global tt entry (%pM): Roaming timeout\n", - tt_global_entry->common.addr); - - hlist_del_rcu(node); - batadv_tt_global_entry_free_ref(tt_global_entry); - } + batadv_tt_global_roam_purge_list(bat_priv, head); spin_unlock_bh(list_lock); }
@@ -1278,7 +1287,8 @@ static void batadv_tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { - if (batadv_has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { + if (batadv_has_timed_out(node->issued_at, + BATADV_TT_REQUEST_TIMEOUT)) { list_del(&node->list); kfree(node); } @@ -1298,7 +1308,7 @@ static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv, list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { if (batadv_compare_eth(tt_req_node_tmp, orig_node) && !batadv_has_timed_out(tt_req_node_tmp->issued_at, - TT_REQUEST_TIMEOUT)) + BATADV_TT_REQUEST_TIMEOUT)) goto unlock; }
@@ -1391,7 +1401,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
memcpy(tt_change->addr, tt_common_entry->addr, ETH_ALEN); - tt_change->flags = NO_FLAGS; + tt_change->flags = BATADV_NO_FLAGS;
tt_count++; tt_change++; @@ -1444,7 +1454,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, tt_request->header.version = BATADV_COMPAT_VERSION; memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); - tt_request->header.ttl = TTL; + tt_request->header.ttl = BATADV_TTL; tt_request->ttvn = ttvn; tt_request->tt_data = htons(tt_crc); tt_request->flags = TT_REQUEST; @@ -1576,7 +1586,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
tt_response->header.packet_type = BAT_TT_QUERY; tt_response->header.version = BATADV_COMPAT_VERSION; - tt_response->header.ttl = TTL; + tt_response->header.ttl = BATADV_TTL; memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@ -1697,7 +1707,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
tt_response->header.packet_type = BAT_TT_QUERY; tt_response->header.version = BATADV_COMPAT_VERSION; - tt_response->header.ttl = TTL; + tt_response->header.ttl = BATADV_TTL; memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@ -1925,7 +1935,8 @@ static void batadv_tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh(&bat_priv->tt_roam_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { - if (!batadv_has_timed_out(node->first_time, ROAMING_MAX_TIME)) + if (!batadv_has_timed_out(node->first_time, + BATADV_ROAMING_MAX_TIME)) continue;
list_del(&node->list); @@ -1955,7 +1966,7 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, continue;
if (batadv_has_timed_out(tt_roam_node->first_time, - ROAMING_MAX_TIME)) + BATADV_ROAMING_MAX_TIME)) continue;
if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter)) @@ -1971,7 +1982,8 @@ static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, goto unlock;
tt_roam_node->first_time = jiffies; - atomic_set(&tt_roam_node->counter, ROAMING_MAX_COUNT - 1); + atomic_set(&tt_roam_node->counter, + BATADV_ROAMING_MAX_COUNT - 1); memcpy(tt_roam_node->addr, client, ETH_ALEN);
list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); @@ -2009,7 +2021,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
roam_adv_packet->header.packet_type = BAT_ROAM_ADV; roam_adv_packet->header.version = BATADV_COMPAT_VERSION; - roam_adv_packet->header.ttl = TTL; + roam_adv_packet->header.ttl = BATADV_TTL; primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out; @@ -2170,7 +2182,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv, bat_priv->tt_poss_change = false;
/* reset the sending counter */ - atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); + atomic_set(&bat_priv->tt_ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX);
return batadv_tt_changes_fill_buff(bat_priv, packet_buff, packet_buff_len, packet_min_len); diff --git a/types.h b/types.h index e4ba4dc..5758615 100644 --- a/types.h +++ b/types.h @@ -85,7 +85,7 @@ struct orig_node { bool tt_poss_change; uint32_t last_real_seqno; uint8_t last_ttl; - DECLARE_BITMAP(bcast_bits, TQ_LOCAL_WINDOW_SIZE); + DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); uint32_t last_bcast_seqno; struct hlist_head neigh_list; struct list_head frag_list; @@ -121,13 +121,13 @@ struct neigh_node { struct hlist_node list; uint8_t addr[ETH_ALEN]; uint8_t real_packet_count; - uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE]; + uint8_t tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE]; uint8_t tq_index; uint8_t tq_avg; uint8_t last_ttl; struct list_head bonding_list; unsigned long last_seen; - DECLARE_BITMAP(real_bits, TQ_LOCAL_WINDOW_SIZE); + DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); atomic_t refcount; struct rcu_head rcu; struct orig_node *orig_node; @@ -209,7 +209,7 @@ struct bat_priv { struct list_head tt_roam_list; struct hashtable_t *vis_hash; #ifdef CONFIG_BATMAN_ADV_BLA - struct bcast_duplist_entry bcast_duplist[DUPLIST_SIZE]; + struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; int bcast_duplist_curr; struct bla_claim_dst claim_dest; #endif @@ -348,7 +348,7 @@ struct if_list_entry { };
struct debug_log { - char log_buff[LOG_BUF_LEN]; + char log_buff[BATADV_LOG_BUF_LEN]; unsigned long log_start; unsigned long log_end; spinlock_t lock; /* protects log_buff, log_start and log_end */ diff --git a/unicast.c b/unicast.c index 39b4f10..d0f00a2 100644 --- a/unicast.c +++ b/unicast.c @@ -325,7 +325,7 @@ find_router: /* batman packet type: unicast */ unicast_packet->header.packet_type = BAT_UNICAST; /* set unicast ttl */ - unicast_packet->header.ttl = TTL; + unicast_packet->header.ttl = BATADV_TTL; /* copy the destination for faster routing */ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); /* set the destination tt version number */ diff --git a/vis.c b/vis.c index a439ed6..7418169 100644 --- a/vis.c +++ b/vis.c @@ -575,7 +575,7 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv) packet->vis_type = atomic_read(&bat_priv->vis_mode);
memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); - packet->header.ttl = TTL; + packet->header.ttl = BATADV_TTL; packet->seqno = htonl(ntohl(packet->seqno) + 1); packet->entries = 0; skb_trim(info->skb_packet, sizeof(*packet)); @@ -841,6 +841,7 @@ int batadv_vis_init(struct bat_priv *bat_priv) struct vis_packet *packet; int hash_added; unsigned int len; + unsigned long first_seen;
if (bat_priv->vis_hash) return 0; @@ -867,15 +868,15 @@ int batadv_vis_init(struct bat_priv *bat_priv) sizeof(*packet));
/* prefill the vis info */ - bat_priv->my_vis_info->first_seen = jiffies - - msecs_to_jiffies(VIS_INTERVAL); + first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); + bat_priv->my_vis_info->first_seen = first_seen; INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list); INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); kref_init(&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; packet->header.version = BATADV_COMPAT_VERSION; packet->header.packet_type = BAT_VIS; - packet->header.ttl = TTL; + packet->header.ttl = BATADV_TTL; packet->seqno = 0; packet->entries = 0;
@@ -936,5 +937,5 @@ static void batadv_start_vis_timer(struct bat_priv *bat_priv) { INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets); queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work, - msecs_to_jiffies(VIS_INTERVAL)); + msecs_to_jiffies(BATADV_VIS_INTERVAL)); }
On Monday, June 04, 2012 04:19:17 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
Makefile | 2 +- bat_debugfs.c | 2 +- bat_iv_ogm.c | 101 ++++++++++++++++++++++++++++------------------- bat_sysfs.c | 7 ++-- bitarray.c | 20 +++++----- bitarray.h | 4 +- bridge_loop_avoidance.c | 20 +++++----- gateway_client.c | 18 ++++----- hard-interface.c | 2 +- main.c | 13 +++--- main.h | 81 ++++++++++++++++++------------------- originator.c | 32 ++++++++------- ring_buffer.c | 4 +- routing.c | 20 +++++----- soft-interface.c | 10 ++--- translation-table.c | 84 ++++++++++++++++++++++----------------- types.h | 10 ++--- unicast.c | 2 +- vis.c | 11 +++--- 19 files changed, 242 insertions(+), 201 deletions(-)
Applied in revision 76eb272.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 4 ++-- bat_sysfs.c | 14 +++++++------- gateway_client.c | 8 ++++---- gateway_common.h | 8 ++++---- soft-interface.c | 10 +++++----- 5 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 454b3d8..110e76f 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -611,7 +611,7 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) batman_ogm_packet->flags &= ~VIS_SERVER;
if ((hard_iface == primary_if) && - (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)) + (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER)) batman_ogm_packet->gw_flags = (uint8_t)atomic_read(&bat_priv->gw_bandwidth); else @@ -760,7 +760,7 @@ update_tt:
/* restart gateway selection if fast or late switching was enabled */ if ((orig_node->gw_flags) && - (atomic_read(&bat_priv->gw_mode) == GW_MODE_CLIENT) && + (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) && (atomic_read(&bat_priv->gw_sel_class) > 2)) batadv_gw_check_election(bat_priv, orig_node);
diff --git a/bat_sysfs.c b/bat_sysfs.c index 74aed8d..2abf7c9 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -359,11 +359,11 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, int bytes_written;
switch (atomic_read(&bat_priv->gw_mode)) { - case GW_MODE_CLIENT: + case BATADV_GW_MODE_CLIENT: bytes_written = sprintf(buff, "%s\n", BATADV_GW_MODE_CLIENT_NAME); break; - case GW_MODE_SERVER: + case BATADV_GW_MODE_SERVER: bytes_written = sprintf(buff, "%s\n", BATADV_GW_MODE_SERVER_NAME); break; @@ -390,15 +390,15 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
if (strncmp(buff, BATADV_GW_MODE_OFF_NAME, strlen(BATADV_GW_MODE_OFF_NAME)) == 0) - gw_mode_tmp = GW_MODE_OFF; + gw_mode_tmp = BATADV_GW_MODE_OFF;
if (strncmp(buff, BATADV_GW_MODE_CLIENT_NAME, strlen(BATADV_GW_MODE_CLIENT_NAME)) == 0) - gw_mode_tmp = GW_MODE_CLIENT; + gw_mode_tmp = BATADV_GW_MODE_CLIENT;
if (strncmp(buff, BATADV_GW_MODE_SERVER_NAME, strlen(BATADV_GW_MODE_SERVER_NAME)) == 0) - gw_mode_tmp = GW_MODE_SERVER; + gw_mode_tmp = BATADV_GW_MODE_SERVER;
if (gw_mode_tmp < 0) { batadv_info(net_dev, @@ -411,10 +411,10 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, return count;
switch (atomic_read(&bat_priv->gw_mode)) { - case GW_MODE_CLIENT: + case BATADV_GW_MODE_CLIENT: curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME; break; - case GW_MODE_SERVER: + case BATADV_GW_MODE_SERVER: curr_gw_mode_str = BATADV_GW_MODE_SERVER_NAME; break; default: diff --git a/gateway_client.c b/gateway_client.c index ae8b4e6..026b181 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -194,7 +194,7 @@ void batadv_gw_election(struct bat_priv *bat_priv) * hear about. This check is based on the daemon's uptime which we * don't have. */ - if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) + if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT) goto out;
if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect)) @@ -663,13 +663,13 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv, goto out;
switch (atomic_read(&bat_priv->gw_mode)) { - case GW_MODE_SERVER: + case BATADV_GW_MODE_SERVER: /* If we are a GW then we are our best GW. We can artificially * set the tq towards ourself as the maximum value */ curr_tq_avg = BATADV_TQ_MAX_VALUE; break; - case GW_MODE_CLIENT: + case BATADV_GW_MODE_CLIENT: curr_gw = batadv_gw_get_selected_gw_node(bat_priv); if (!curr_gw) goto out; @@ -689,7 +689,7 @@ bool batadv_gw_out_of_range(struct bat_priv *bat_priv,
curr_tq_avg = neigh_curr->tq_avg; break; - case GW_MODE_OFF: + case BATADV_GW_MODE_OFF: default: goto out; } diff --git a/gateway_common.h b/gateway_common.h index 31bbc3c..13697f6 100644 --- a/gateway_common.h +++ b/gateway_common.h @@ -20,10 +20,10 @@ #ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_ #define _NET_BATMAN_ADV_GATEWAY_COMMON_H_
-enum gw_modes { - GW_MODE_OFF, - GW_MODE_CLIENT, - GW_MODE_SERVER, +enum batadv_gw_modes { + BATADV_GW_MODE_OFF, + BATADV_GW_MODE_CLIENT, + BATADV_GW_MODE_SERVER, };
#define BATADV_GW_MODE_OFF_NAME "off" diff --git a/soft-interface.c b/soft-interface.c index c1b2ab2..b77e598 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -177,7 +177,7 @@ static int batadv_interface_tx(struct sk_buff *skb, do_bcast = true;
switch (atomic_read(&bat_priv->gw_mode)) { - case GW_MODE_SERVER: + case BATADV_GW_MODE_SERVER: /* gateway servers should not send dhcp * requests into the mesh */ @@ -185,7 +185,7 @@ static int batadv_interface_tx(struct sk_buff *skb, if (ret) goto dropped; break; - case GW_MODE_CLIENT: + case BATADV_GW_MODE_CLIENT: /* gateway clients should send dhcp requests * via unicast to their gateway */ @@ -193,7 +193,7 @@ static int batadv_interface_tx(struct sk_buff *skb, if (ret) do_bcast = false; break; - case GW_MODE_OFF: + case BATADV_GW_MODE_OFF: default: break; } @@ -234,7 +234,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
/* unicast packet */ } else { - if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) { + if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) { ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr); if (ret) goto dropped; @@ -387,7 +387,7 @@ struct net_device *batadv_softif_create(const char *name) atomic_set(&bat_priv->bridge_loop_avoidance, 0); atomic_set(&bat_priv->ap_isolation, 0); atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); - atomic_set(&bat_priv->gw_mode, GW_MODE_OFF); + atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); atomic_set(&bat_priv->gw_sel_class, 20); atomic_set(&bat_priv->gw_bandwidth, 41); atomic_set(&bat_priv->orig_interval, 1000);
On Monday, June 04, 2012 04:19:18 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 4 ++-- bat_sysfs.c | 14 +++++++------- gateway_client.c | 8 ++++---- gateway_common.h | 8 ++++---- soft-interface.c | 10 +++++----- 5 files changed, 22 insertions(+), 22 deletions(-)
Applied in revision d607d89.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 6 +++--- bat_sysfs.c | 27 ++++++++++++++++----------- bridge_loop_avoidance.c | 2 +- gateway_client.c | 2 +- hard-interface.c | 40 ++++++++++++++++++++-------------------- hard-interface.h | 14 +++++++------- icmp_socket.c | 2 +- main.c | 4 ++-- originator.c | 16 ++++++++-------- routing.c | 2 +- send.c | 10 +++++----- translation-table.c | 4 ++-- vis.c | 2 +- 13 files changed, 68 insertions(+), 63 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 110e76f..2fd6bee 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -165,7 +165,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, struct batman_ogm_packet *batman_ogm_packet; struct sk_buff *skb;
- if (hard_iface->if_status != IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) return;
packet_num = 0; @@ -238,7 +238,7 @@ static void batadv_iv_ogm_emit(struct forw_packet *forw_packet) soft_iface = forw_packet->if_incoming->soft_iface; bat_priv = netdev_priv(soft_iface);
- if (forw_packet->if_incoming->if_status != IF_ACTIVE) + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE) goto out;
primary_if = batadv_primary_if_get_selected(bat_priv); @@ -1017,7 +1017,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if (hard_iface->if_status != IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) continue;
if (hard_iface->soft_iface != if_incoming->soft_iface) diff --git a/bat_sysfs.c b/bat_sysfs.c index 2abf7c9..311a327 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -558,12 +558,17 @@ static ssize_t batadv_show_mesh_iface(struct kobject *kobj, struct net_device *net_dev = batadv_kobj_to_netdev(kobj); struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); ssize_t length; + const char *ifname;
if (!hard_iface) return 0;
- length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ? - "none" : hard_iface->soft_iface->name); + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) + ifname = "none"; + else + ifname = hard_iface->soft_iface->name; + + length = sprintf(buff, "%s\n", ifname);
batadv_hardif_free_ref(hard_iface);
@@ -593,9 +598,9 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj, }
if (strncmp(buff, "none", 4) == 0) - status_tmp = IF_NOT_IN_USE; + status_tmp = BATADV_IF_NOT_IN_USE; else - status_tmp = IF_I_WANT_YOU; + status_tmp = BATADV_IF_I_WANT_YOU;
if (hard_iface->if_status == status_tmp) goto out; @@ -609,13 +614,13 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj, goto out; }
- if (status_tmp == IF_NOT_IN_USE) { + if (status_tmp == BATADV_IF_NOT_IN_USE) { batadv_hardif_disable_interface(hard_iface); goto unlock; }
/* if the interface already is in use */ - if (hard_iface->if_status != IF_NOT_IN_USE) + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) batadv_hardif_disable_interface(hard_iface);
ret = batadv_hardif_enable_interface(hard_iface, buff); @@ -638,19 +643,19 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj, return 0;
switch (hard_iface->if_status) { - case IF_TO_BE_REMOVED: + case BATADV_IF_TO_BE_REMOVED: length = sprintf(buff, "disabling\n"); break; - case IF_INACTIVE: + case BATADV_IF_INACTIVE: length = sprintf(buff, "inactive\n"); break; - case IF_ACTIVE: + case BATADV_IF_ACTIVE: length = sprintf(buff, "active\n"); break; - case IF_TO_BE_ACTIVATED: + case BATADV_IF_TO_BE_ACTIVATED: length = sprintf(buff, "enabling\n"); break; - case IF_NOT_IN_USE: + case BATADV_IF_NOT_IN_USE: default: length = sprintf(buff, "not in use\n"); break; diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index ee75fa6..66fd8c1 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1552,7 +1552,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) goto out; }
- if (primary_if->if_status != IF_ACTIVE) { + if (primary_if->if_status != BATADV_IF_ACTIVE) { ret = seq_printf(seq, "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); diff --git a/gateway_client.c b/gateway_client.c index 026b181..6a92035 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -475,7 +475,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) goto out; }
- if (primary_if->if_status != IF_ACTIVE) { + if (primary_if->if_status != BATADV_IF_ACTIVE) { ret = seq_printf(seq, "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); diff --git a/hard-interface.c b/hard-interface.c index a8f5af8..2468e15 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -85,7 +85,7 @@ batadv_hardif_get_active(const struct net_device *soft_iface) if (hard_iface->soft_iface != soft_iface) continue;
- if (hard_iface->if_status == IF_ACTIVE && + if (hard_iface->if_status == BATADV_IF_ACTIVE && atomic_inc_not_zero(&hard_iface->refcount)) goto out; } @@ -157,8 +157,8 @@ static void batadv_check_known_mac_addr(const struct net_device *net_dev)
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if ((hard_iface->if_status != IF_ACTIVE) && - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) continue;
if (hard_iface->net_dev == net_dev) @@ -189,8 +189,8 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if ((hard_iface->if_status != IF_ACTIVE) && - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) continue;
if (hard_iface->soft_iface != soft_iface) @@ -220,13 +220,13 @@ static void batadv_hardif_activate_interface(struct hard_iface *hard_iface) struct bat_priv *bat_priv; struct hard_iface *primary_if = NULL;
- if (hard_iface->if_status != IF_INACTIVE) + if (hard_iface->if_status != BATADV_IF_INACTIVE) goto out;
bat_priv = netdev_priv(hard_iface->soft_iface);
bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); - hard_iface->if_status = IF_TO_BE_ACTIVATED; + hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED;
/* the first active interface becomes our primary interface or * the next active interface after the old primary interface was removed @@ -247,11 +247,11 @@ out:
static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface) { - if ((hard_iface->if_status != IF_ACTIVE) && - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) return;
- hard_iface->if_status = IF_INACTIVE; + hard_iface->if_status = BATADV_IF_INACTIVE;
batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n", hard_iface->net_dev->name); @@ -267,7 +267,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface, __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); int ret;
- if (hard_iface->if_status != IF_NOT_IN_USE) + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) goto out;
if (!atomic_inc_not_zero(&hard_iface->refcount)) @@ -308,7 +308,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface->if_num = bat_priv->num_ifaces; bat_priv->num_ifaces++; - hard_iface->if_status = IF_INACTIVE; + hard_iface->if_status = BATADV_IF_INACTIVE; batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
hard_iface->batman_adv_ptype.type = ethertype; @@ -359,10 +359,10 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct hard_iface *primary_if = NULL;
- if (hard_iface->if_status == IF_ACTIVE) + if (hard_iface->if_status == BATADV_IF_ACTIVE) batadv_hardif_deactivate_interface(hard_iface);
- if (hard_iface->if_status != IF_INACTIVE) + if (hard_iface->if_status != BATADV_IF_INACTIVE) goto out;
batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", @@ -384,7 +384,7 @@ void batadv_hardif_disable_interface(struct hard_iface *hard_iface) }
bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); - hard_iface->if_status = IF_NOT_IN_USE; + hard_iface->if_status = BATADV_IF_NOT_IN_USE;
/* delete all references to this hard_iface */ batadv_purge_orig_ref(bat_priv); @@ -428,7 +428,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) hard_iface->if_num = -1; hard_iface->net_dev = net_dev; hard_iface->soft_iface = NULL; - hard_iface->if_status = IF_NOT_IN_USE; + hard_iface->if_status = BATADV_IF_NOT_IN_USE; INIT_LIST_HEAD(&hard_iface->list); /* extra reference for return */ atomic_set(&hard_iface->refcount, 2); @@ -457,13 +457,13 @@ static void batadv_hardif_remove_interface(struct hard_iface *hard_iface) ASSERT_RTNL();
/* first deactivate interface */ - if (hard_iface->if_status != IF_NOT_IN_USE) + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) batadv_hardif_disable_interface(hard_iface);
- if (hard_iface->if_status != IF_NOT_IN_USE) + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) return;
- hard_iface->if_status = IF_TO_BE_REMOVED; + hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; batadv_sysfs_del_hardif(&hard_iface->hardif_obj); batadv_hardif_free_ref(hard_iface); } @@ -513,7 +513,7 @@ static int batadv_hard_if_event(struct notifier_block *this, batadv_update_min_mtu(hard_iface->soft_iface); break; case NETDEV_CHANGEADDR: - if (hard_iface->if_status == IF_NOT_IN_USE) + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) goto hardif_put;
batadv_check_known_mac_addr(hard_iface->net_dev); diff --git a/hard-interface.h b/hard-interface.h index d66dabd..4b60d58 100644 --- a/hard-interface.h +++ b/hard-interface.h @@ -20,13 +20,13 @@ #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ #define _NET_BATMAN_ADV_HARD_INTERFACE_H_
-enum hard_if_state { - IF_NOT_IN_USE, - IF_TO_BE_REMOVED, - IF_INACTIVE, - IF_ACTIVE, - IF_TO_BE_ACTIVATED, - IF_I_WANT_YOU +enum batadv_hard_if_state { + BATADV_IF_NOT_IN_USE, + BATADV_IF_TO_BE_REMOVED, + BATADV_IF_INACTIVE, + BATADV_IF_ACTIVE, + BATADV_IF_TO_BE_ACTIVATED, + BATADV_IF_I_WANT_YOU, };
extern struct notifier_block batadv_hard_if_notifier; diff --git a/icmp_socket.c b/icmp_socket.c index 319235d..9247d97 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -225,7 +225,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, if (!neigh_node->if_incoming) goto dst_unreach;
- if (neigh_node->if_incoming->if_status != IF_ACTIVE) + if (neigh_node->if_incoming->if_status != BATADV_IF_ACTIVE) goto dst_unreach;
memcpy(icmp_packet->orig, diff --git a/main.c b/main.c index df7335c..23f5c8e 100644 --- a/main.c +++ b/main.c @@ -179,7 +179,7 @@ int batadv_is_my_mac(const uint8_t *addr)
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if (hard_iface->if_status != IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) continue;
if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { @@ -234,7 +234,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, goto err_free;
/* discard frames on not active interfaces */ - if (hard_iface->if_status != IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) goto err_free;
batman_ogm_packet = (struct batman_ogm_packet *)skb->data; diff --git a/originator.c b/originator.c index f04f591..9e60cc0 100644 --- a/originator.c +++ b/originator.c @@ -286,13 +286,13 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, if_incoming = neigh_node->if_incoming;
if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) || - (if_incoming->if_status == IF_INACTIVE) || - (if_incoming->if_status == IF_NOT_IN_USE) || - (if_incoming->if_status == IF_TO_BE_REMOVED)) { + (if_incoming->if_status == BATADV_IF_INACTIVE) || + (if_incoming->if_status == BATADV_IF_NOT_IN_USE) || + (if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) {
- if ((if_incoming->if_status == IF_INACTIVE) || - (if_incoming->if_status == IF_NOT_IN_USE) || - (if_incoming->if_status == IF_TO_BE_REMOVED)) + if ((if_incoming->if_status == BATADV_IF_INACTIVE) || + (if_incoming->if_status == BATADV_IF_NOT_IN_USE) || + (if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) batadv_dbg(DBG_BATMAN, bat_priv, "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", orig_node->orig, neigh_node->addr, @@ -422,7 +422,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) goto out; }
- if (primary_if->if_status != IF_ACTIVE) { + if (primary_if->if_status != BATADV_IF_ACTIVE) { ret = seq_printf(seq, "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); @@ -627,7 +627,7 @@ int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ rcu_read_lock(); list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) { - if (hard_iface_tmp->if_status == IF_NOT_IN_USE) + if (hard_iface_tmp->if_status == BATADV_IF_NOT_IN_USE) continue;
if (hard_iface == hard_iface_tmp) diff --git a/routing.c b/routing.c index fa0b4ee..8085cb5 100644 --- a/routing.c +++ b/routing.c @@ -790,7 +790,7 @@ struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, router = batadv_find_ifalter_router(primary_orig_node, recv_if);
return_router: - if (router && router->if_incoming->if_status != IF_ACTIVE) + if (router && router->if_incoming->if_status != BATADV_IF_ACTIVE) goto err_unlock;
rcu_read_unlock(); diff --git a/send.c b/send.c index 72542cb..8de6e25 100644 --- a/send.c +++ b/send.c @@ -37,7 +37,7 @@ int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, { struct ethhdr *ethhdr;
- if (hard_iface->if_status != IF_ACTIVE) + if (hard_iface->if_status != BATADV_IF_ACTIVE) goto send_skb_err;
if (unlikely(!hard_iface->net_dev)) @@ -80,8 +80,8 @@ void batadv_schedule_bat_ogm(struct hard_iface *hard_iface) { struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
- if ((hard_iface->if_status == IF_NOT_IN_USE) || - (hard_iface->if_status == IF_TO_BE_REMOVED)) + if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) || + (hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)) return;
/* the interface gets activated here to avoid race conditions between @@ -90,8 +90,8 @@ void batadv_schedule_bat_ogm(struct hard_iface *hard_iface) * outdated packets (especially uninitialized mac addresses) in the * packet queue */ - if (hard_iface->if_status == IF_TO_BE_ACTIVATED) - hard_iface->if_status = IF_ACTIVE; + if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED) + hard_iface->if_status = BATADV_IF_ACTIVE;
bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface); } diff --git a/translation-table.c b/translation-table.c index 330a83f..56b714f 100644 --- a/translation-table.c +++ b/translation-table.c @@ -432,7 +432,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) goto out; }
- if (primary_if->if_status != IF_ACTIVE) { + if (primary_if->if_status != BATADV_IF_ACTIVE) { ret = seq_printf(seq, "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); @@ -784,7 +784,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) goto out; }
- if (primary_if->if_status != IF_ACTIVE) { + if (primary_if->if_status != BATADV_IF_ACTIVE) { ret = seq_printf(seq, "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); diff --git a/vis.c b/vis.c index 7418169..c920b4b 100644 --- a/vis.c +++ b/vis.c @@ -599,7 +599,7 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv) if (!batadv_compare_eth(router->addr, orig_node->orig)) goto next;
- if (router->if_incoming->if_status != IF_ACTIVE) + if (router->if_incoming->if_status != BATADV_IF_ACTIVE) goto next;
if (router->tq_avg < 1)
On Monday, June 04, 2012 04:19:19 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 6 +++--- bat_sysfs.c | 27 ++++++++++++++++----------- bridge_loop_avoidance.c | 2 +- gateway_client.c | 2 +- hard-interface.c | 40 ++++++++++++++++++++-------------------- hard-interface.h | 14 +++++++------- icmp_socket.c | 2 +- main.c | 4 ++-- originator.c | 16 ++++++++-------- routing.c | 2 +- send.c | 10 +++++----- translation-table.c | 4 ++-- vis.c | 2 +- 13 files changed, 68 insertions(+), 63 deletions(-)
Applied in revision 5063977.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 8 ++++---- routing.c | 10 +++++----- soft-interface.c | 8 ++++---- translation-table.c | 8 ++++---- types.h | 28 ++++++++++++++-------------- 5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 2fd6bee..a51b4e1 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -209,8 +209,8 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, /* create clone because function is called more than once */ skb = skb_clone(forw_packet->skb, GFP_ATOMIC); if (skb) { - batadv_inc_counter(bat_priv, BAT_CNT_MGMT_TX); - batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, + batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_TX); + batadv_add_counter(bat_priv, BATADV_CNT_MGMT_TX_BYTES, skb->len + ETH_HLEN); batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr); } @@ -1256,8 +1256,8 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, if (bat_priv->bat_algo_ops->bat_ogm_emit != batadv_iv_ogm_emit) return NET_RX_DROP;
- batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX); - batadv_add_counter(bat_priv, BAT_CNT_MGMT_RX_BYTES, + batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); + batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN);
packet_len = skb_headlen(skb); diff --git a/routing.c b/routing.c index 8085cb5..8be9e41 100644 --- a/routing.c +++ b/routing.c @@ -607,7 +607,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { case TT_REQUEST: - batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_RX);
/* If we cannot provide an answer the tt_request is * forwarded @@ -622,7 +622,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) } break; case TT_RESPONSE: - batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_RX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX);
if (batadv_is_my_mac(tt_query->dst)) { /* packet needs to be linearized to access the TT @@ -676,7 +676,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) if (is_broadcast_ether_addr(ethhdr->h_source)) goto out;
- batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_RX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
roam_adv_packet = (struct roam_adv_packet *)skb->data;
@@ -898,8 +898,8 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, unicast_packet->header.ttl--;
/* Update stats counter */ - batadv_inc_counter(bat_priv, BAT_CNT_FORWARD); - batadv_add_counter(bat_priv, BAT_CNT_FORWARD_BYTES, + batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); + batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, skb->len + ETH_HLEN);
/* route it */ diff --git a/soft-interface.c b/soft-interface.c index b77e598..19a80d2 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -366,6 +366,7 @@ struct net_device *batadv_softif_create(const char *name) struct net_device *soft_iface; struct bat_priv *bat_priv; int ret; + size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM;
soft_iface = alloc_netdev(sizeof(*bat_priv), name, batadv_interface_setup); @@ -411,8 +412,7 @@ struct net_device *batadv_softif_create(const char *name) bat_priv->primary_if = NULL; bat_priv->num_ifaces = 0;
- bat_priv->bat_counters = __alloc_percpu(sizeof(uint64_t) * BAT_CNT_NUM, - __alignof__(uint64_t)); + bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); if (!bat_priv->bat_counters) goto unreg_soft_iface;
@@ -542,14 +542,14 @@ static void batadv_get_ethtool_stats(struct net_device *dev, struct bat_priv *bat_priv = netdev_priv(dev); int i;
- for (i = 0; i < BAT_CNT_NUM; i++) + for (i = 0; i < BATADV_CNT_NUM; i++) data[i] = batadv_sum_counter(bat_priv, i); }
static int batadv_get_sset_count(struct net_device *dev, int stringset) { if (stringset == ETH_SS_STATS) - return BAT_CNT_NUM; + return BATADV_CNT_NUM;
return -EOPNOTSUPP; } diff --git a/translation-table.c b/translation-table.c index 56b714f..c8ca694 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1471,7 +1471,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, dst_orig_node->orig, neigh_node->addr, (full_table ? 'F' : '.'));
- batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); ret = 0; @@ -1599,7 +1599,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, res_dst_orig_node->orig, neigh_node->addr, req_dst_orig_node->orig, req_ttvn);
- batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); ret = true; @@ -1720,7 +1720,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, orig_node->orig, neigh_node->addr, (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
- batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); ret = true; @@ -2038,7 +2038,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", orig_node->orig, client, neigh_node->addr);
- batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX); + batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX);
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); ret = 0; diff --git a/types.h b/types.h index 5758615..a3bf40c 100644 --- a/types.h +++ b/types.h @@ -143,20 +143,20 @@ struct bcast_duplist_entry { }; #endif
-enum bat_counters { - BAT_CNT_FORWARD, - BAT_CNT_FORWARD_BYTES, - BAT_CNT_MGMT_TX, - BAT_CNT_MGMT_TX_BYTES, - BAT_CNT_MGMT_RX, - BAT_CNT_MGMT_RX_BYTES, - BAT_CNT_TT_REQUEST_TX, - BAT_CNT_TT_REQUEST_RX, - BAT_CNT_TT_RESPONSE_TX, - BAT_CNT_TT_RESPONSE_RX, - BAT_CNT_TT_ROAM_ADV_TX, - BAT_CNT_TT_ROAM_ADV_RX, - BAT_CNT_NUM, +enum batadv_counters { + BATADV_CNT_FORWARD, + BATADV_CNT_FORWARD_BYTES, + BATADV_CNT_MGMT_TX, + BATADV_CNT_MGMT_TX_BYTES, + BATADV_CNT_MGMT_RX, + BATADV_CNT_MGMT_RX_BYTES, + BATADV_CNT_TT_REQUEST_TX, + BATADV_CNT_TT_REQUEST_RX, + BATADV_CNT_TT_RESPONSE_TX, + BATADV_CNT_TT_RESPONSE_RX, + BATADV_CNT_TT_ROAM_ADV_TX, + BATADV_CNT_TT_ROAM_ADV_RX, + BATADV_CNT_NUM, };
struct bat_priv {
On Monday, June 04, 2012 04:19:20 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 8 ++++---- routing.c | 10 +++++----- soft-interface.c | 8 ++++---- translation-table.c | 8 ++++---- types.h | 28 ++++++++++++++-------------- 5 files changed, 31 insertions(+), 31 deletions(-)
Applied in revision 5fa7d99.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 48 +++++++------ bat_sysfs.c | 24 ++++--- bridge_loop_avoidance.c | 34 ++++----- icmp_socket.c | 8 +-- main.c | 14 ++-- packet.h | 86 +++++++++++------------ routing.c | 35 ++++++---- soft-interface.c | 4 +- translation-table.c | 177 ++++++++++++++++++++++++----------------------- unicast.c | 18 ++--- unicast.h | 4 +- vis.c | 18 ++--- 12 files changed, 246 insertions(+), 224 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index a51b4e1..4ac06a9 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -71,7 +71,7 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface) goto out;
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; - batman_ogm_packet->header.packet_type = BAT_IV_OGM; + batman_ogm_packet->header.packet_type = BATADV_IV_OGM; batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; batman_ogm_packet->header.ttl = 2; batman_ogm_packet->flags = BATADV_NO_FLAGS; @@ -107,7 +107,7 @@ static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) struct batman_ogm_packet *batman_ogm_packet;
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; - batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; + batman_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP; batman_ogm_packet->header.ttl = BATADV_TTL; }
@@ -181,9 +181,9 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, */ if ((forw_packet->direct_link_flags & (1 << packet_num)) && (forw_packet->if_incoming == hard_iface)) - batman_ogm_packet->flags |= DIRECTLINK; + batman_ogm_packet->flags |= BATADV_DIRECTLINK; else - batman_ogm_packet->flags &= ~DIRECTLINK; + batman_ogm_packet->flags &= ~BATADV_DIRECTLINK;
fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? "Sending own" : @@ -194,7 +194,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), batman_ogm_packet->tq, batman_ogm_packet->header.ttl, - (batman_ogm_packet->flags & DIRECTLINK ? + (batman_ogm_packet->flags & BATADV_DIRECTLINK ? "on" : "off"), batman_ogm_packet->ttvn, hard_iface->net_dev->name, hard_iface->net_dev->dev_addr); @@ -228,7 +228,7 @@ static void batadv_iv_ogm_emit(struct forw_packet *forw_packet)
batman_ogm_packet = (struct batman_ogm_packet *) (forw_packet->skb->data); - directlink = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); + directlink = (batman_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0);
if (!forw_packet->if_incoming) { pr_err("Error - can't forward packet: incoming iface not specified\n"); @@ -330,7 +330,7 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, * are flooded through the net */ if ((!directlink) && - (!(batman_ogm_packet->flags & DIRECTLINK)) && + (!(batman_ogm_packet->flags & BATADV_DIRECTLINK)) && (batman_ogm_packet->header.ttl != 1) &&
/* own packets originating non-primary @@ -353,7 +353,7 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, * own secondary interface packets * (= secondary interface packets in general) */ - (batman_ogm_packet->flags & DIRECTLINK || + (batman_ogm_packet->flags & BATADV_DIRECTLINK || (forw_packet->own && forw_packet->if_incoming != primary_if))) { res = true; @@ -480,7 +480,7 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv, unsigned long max_aggregation_jiffies;
batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; - direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0; + direct_link = batman_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0; max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
/* find position for the packet in the forward queue */ @@ -547,7 +547,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node, * simply drop the ogm. */ if (is_single_hop_neigh) - batman_ogm_packet->flags |= NOT_BEST_NEXT_HOP; + batman_ogm_packet->flags |= BATADV_NOT_BEST_NEXT_HOP; else return; } @@ -566,11 +566,11 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
/* switch of primaries first hop flag when forwarding */ - batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP; + batman_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP; if (is_single_hop_neigh) - batman_ogm_packet->flags |= DIRECTLINK; + batman_ogm_packet->flags |= BATADV_DIRECTLINK; else - batman_ogm_packet->flags &= ~DIRECTLINK; + batman_ogm_packet->flags &= ~BATADV_DIRECTLINK;
batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes), @@ -605,10 +605,10 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) if (tt_num_changes >= 0) batman_ogm_packet->tt_num_changes = tt_num_changes;
- if (vis_server == VIS_TYPE_SERVER_SYNC) - batman_ogm_packet->flags |= VIS_SERVER; + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) + batman_ogm_packet->flags |= BATADV_VIS_SERVER; else - batman_ogm_packet->flags &= ~VIS_SERVER; + batman_ogm_packet->flags &= ~BATADV_VIS_SERVER;
if ((hard_iface == primary_if) && (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER)) @@ -746,7 +746,7 @@ update_tt: */ if (((batman_ogm_packet->orig != ethhdr->h_source) && (batman_ogm_packet->header.ttl > 2)) || - (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) + (batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) batadv_tt_update_orig(bat_priv, orig_node, tt_buff, batman_ogm_packet->tt_num_changes, batman_ogm_packet->ttvn, @@ -993,13 +993,16 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, * packet in an aggregation. Here we expect that the padding * is always zero (or not 0x01) */ - if (batman_ogm_packet->header.packet_type != BAT_IV_OGM) + if (batman_ogm_packet->header.packet_type != BATADV_IV_OGM) return;
/* could be changed by schedule_own_packet() */ if_incoming_seqno = atomic_read(&if_incoming->seqno);
- has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); + if (batman_ogm_packet->flags & BATADV_DIRECTLINK) + has_directlink_flag = 1; + else + has_directlink_flag = 0;
if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) is_single_hop_neigh = true; @@ -1107,7 +1110,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, return; }
- if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) { + if (batman_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) { batadv_dbg(DBG_BATMAN, bat_priv, "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", ethhdr->h_source); @@ -1299,7 +1302,8 @@ int __init batadv_iv_init(void) int ret;
/* batman originator packet */ - ret = batadv_recv_handler_register(BAT_IV_OGM, batadv_iv_ogm_receive); + ret = batadv_recv_handler_register(BATADV_IV_OGM, + batadv_iv_ogm_receive); if (ret < 0) goto out;
@@ -1310,7 +1314,7 @@ int __init batadv_iv_init(void) goto out;
handler_unregister: - batadv_recv_handler_unregister(BAT_IV_OGM); + batadv_recv_handler_unregister(BATADV_IV_OGM); out: return ret; } diff --git a/bat_sysfs.c b/bat_sysfs.c index 311a327..03fe431 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -282,10 +282,14 @@ static ssize_t batadv_show_vis_mode(struct kobject *kobj, { struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); int vis_mode = atomic_read(&bat_priv->vis_mode); + const char *mode;
- return sprintf(buff, "%s\n", - vis_mode == VIS_TYPE_CLIENT_UPDATE ? - "client" : "server"); + if (vis_mode == BATADV_VIS_TYPE_CLIENT_UPDATE) + mode = "client"; + else + mode = "server"; + + return sprintf(buff, "%s\n", mode); }
static ssize_t batadv_store_vis_mode(struct kobject *kobj, @@ -300,14 +304,16 @@ static ssize_t batadv_store_vis_mode(struct kobject *kobj,
ret = kstrtoul(buff, 10, &val);
- if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || + if (((count == 2) && (!ret) && + (val == BATADV_VIS_TYPE_CLIENT_UPDATE)) || (strncmp(buff, "client", 6) == 0) || (strncmp(buff, "off", 3) == 0)) - vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE; + vis_mode_tmp = BATADV_VIS_TYPE_CLIENT_UPDATE;
- if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || + if (((count == 2) && (!ret) && + (val == BATADV_VIS_TYPE_SERVER_SYNC)) || (strncmp(buff, "server", 6) == 0)) - vis_mode_tmp = VIS_TYPE_SERVER_SYNC; + vis_mode_tmp = BATADV_VIS_TYPE_SERVER_SYNC;
if (vis_mode_tmp < 0) { if (buff[count - 1] == '\n') @@ -322,12 +328,12 @@ static ssize_t batadv_store_vis_mode(struct kobject *kobj, if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) return count;
- if (atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE) + if (atomic_read(&bat_priv->vis_mode) == BATADV_VIS_TYPE_CLIENT_UPDATE) old_mode = "client"; else old_mode = "server";
- if (vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE) + if (vis_mode_tmp == BATADV_VIS_TYPE_CLIENT_UPDATE) new_mode = "client"; else new_mode = "server"; diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 66fd8c1..6a675fe 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -292,7 +292,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
/* now we pretend that the client would have sent this ... */ switch (claimtype) { - case CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_ADD: /* normal claim frame * set Ethernet SRC to the clients mac */ @@ -300,7 +300,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, batadv_dbg(DBG_BLA, bat_priv, "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); break; - case CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_DEL: /* unclaim frame * set HW SRC to the clients mac */ @@ -309,7 +309,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); break; - case CLAIM_TYPE_ANNOUNCE: + case BATADV_CLAIM_TYPE_ANNOUNCE: /* announcement frame * set HW SRC to the special mac containg the crc */ @@ -318,7 +318,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", ethhdr->h_source, vid); break; - case CLAIM_TYPE_REQUEST: + case BATADV_CLAIM_TYPE_REQUEST: /* request frame * set HW SRC to the special mac containg the crc */ @@ -459,7 +459,7 @@ static void batadv_bla_answer_request(struct bat_priv *bat_priv, continue;
batadv_bla_send_claim(bat_priv, claim->addr, claim->vid, - CLAIM_TYPE_ADD); + BATADV_CLAIM_TYPE_ADD); } rcu_read_unlock(); } @@ -485,7 +485,7 @@ static void batadv_bla_send_request(struct backbone_gw *backbone_gw)
/* send request */ batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, - backbone_gw->vid, CLAIM_TYPE_REQUEST); + backbone_gw->vid, BATADV_CLAIM_TYPE_REQUEST);
/* no local broadcasts should be sent or received, for now. */ if (!atomic_read(&backbone_gw->request_sent)) { @@ -511,7 +511,7 @@ static void batadv_bla_send_announce(struct bat_priv *bat_priv, memcpy(&mac[4], &crc, 2);
batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid, - CLAIM_TYPE_ANNOUNCE); + BATADV_CLAIM_TYPE_ANNOUNCE);
}
@@ -694,7 +694,7 @@ static int batadv_handle_unclaim(struct bat_priv *bat_priv, if (primary_if && batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) batadv_bla_send_claim(bat_priv, claim_addr, vid, - CLAIM_TYPE_DEL); + BATADV_CLAIM_TYPE_DEL);
backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
@@ -730,7 +730,7 @@ static int batadv_handle_claim(struct bat_priv *bat_priv, batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) batadv_bla_send_claim(bat_priv, claim_addr, vid, - CLAIM_TYPE_ADD); + BATADV_CLAIM_TYPE_ADD);
/* TODO: we could call something like tt_local_del() here. */
@@ -773,12 +773,12 @@ static int batadv_check_claim_group(struct bat_priv *bat_priv, * otherwise assume it is in the hw_src */ switch (bla_dst->type) { - case CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_ADD: backbone_addr = hw_src; break; - case CLAIM_TYPE_REQUEST: - case CLAIM_TYPE_ANNOUNCE: - case CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_REQUEST: + case BATADV_CLAIM_TYPE_ANNOUNCE: + case BATADV_CLAIM_TYPE_DEL: backbone_addr = ethhdr->h_source; break; default: @@ -894,23 +894,23 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv,
/* check for the different types of claim frames ... */ switch (bla_dst->type) { - case CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_ADD: if (batadv_handle_claim(bat_priv, primary_if, hw_src, ethhdr->h_source, vid)) return 1; break; - case CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_DEL: if (batadv_handle_unclaim(bat_priv, primary_if, ethhdr->h_source, hw_src, vid)) return 1; break;
- case CLAIM_TYPE_ANNOUNCE: + case BATADV_CLAIM_TYPE_ANNOUNCE: if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source, vid)) return 1; break; - case CLAIM_TYPE_REQUEST: + case BATADV_CLAIM_TYPE_REQUEST: if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr, vid)) return 1; diff --git a/icmp_socket.c b/icmp_socket.c index 9247d97..2e90673 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -187,14 +187,14 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, goto free_skb; }
- if (icmp_packet->header.packet_type != BAT_ICMP) { + if (icmp_packet->header.packet_type != BATADV_ICMP) { batadv_dbg(DBG_BATMAN, bat_priv, "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); len = -EINVAL; goto free_skb; }
- if (icmp_packet->msg_type != ECHO_REQUEST) { + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { batadv_dbg(DBG_BATMAN, bat_priv, "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); len = -EINVAL; @@ -204,7 +204,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, icmp_packet->uid = socket_client->index;
if (icmp_packet->header.version != BATADV_COMPAT_VERSION) { - icmp_packet->msg_type = PARAMETER_PROBLEM; + icmp_packet->msg_type = BATADV_PARAMETER_PROBLEM; icmp_packet->header.version = BATADV_COMPAT_VERSION; batadv_socket_add_packet(socket_client, icmp_packet, packet_len); @@ -239,7 +239,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, goto out;
dst_unreach: - icmp_packet->msg_type = DESTINATION_UNREACHABLE; + icmp_packet->msg_type = BATADV_DESTINATION_UNREACHABLE; batadv_socket_add_packet(socket_client, icmp_packet, packet_len); free_skb: kfree_skb(skb); diff --git a/main.c b/main.c index 23f5c8e..b3f0a2e 100644 --- a/main.c +++ b/main.c @@ -275,19 +275,19 @@ static void batadv_recv_handler_init(void) batadv_rx_handler[i] = batadv_recv_unhandled_packet;
/* batman icmp packet */ - batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet; + batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; /* unicast packet */ - batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet; + batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; /* fragmented unicast packet */ - batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; + batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; /* broadcast packet */ - batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet; + batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; /* vis packet */ - batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet; + batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet; /* Translation table query (request or response) */ - batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query; + batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query; /* Roaming advertisement */ - batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv; + batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv; }
int batadv_recv_handler_register(uint8_t packet_type, diff --git a/packet.h b/packet.h index e562414..2ca6819 100644 --- a/packet.h +++ b/packet.h @@ -22,80 +22,80 @@
#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
-enum bat_packettype { - BAT_IV_OGM = 0x01, - BAT_ICMP = 0x02, - BAT_UNICAST = 0x03, - BAT_BCAST = 0x04, - BAT_VIS = 0x05, - BAT_UNICAST_FRAG = 0x06, - BAT_TT_QUERY = 0x07, - BAT_ROAM_ADV = 0x08 +enum batadv_packettype { + BATADV_IV_OGM = 0x01, + BATADV_ICMP = 0x02, + BATADV_UNICAST = 0x03, + BATADV_BCAST = 0x04, + BATADV_VIS = 0x05, + BATADV_UNICAST_FRAG = 0x06, + BATADV_TT_QUERY = 0x07, + BATADV_ROAM_ADV = 0x08, };
/* this file is included by batctl which needs these defines */ #define BATADV_COMPAT_VERSION 14
-enum batman_iv_flags { - NOT_BEST_NEXT_HOP = 1 << 3, - PRIMARIES_FIRST_HOP = 1 << 4, - VIS_SERVER = 1 << 5, - DIRECTLINK = 1 << 6 +enum batadv_iv_flags { + BATADV_NOT_BEST_NEXT_HOP = 1 << 3, + BATADV_PRIMARIES_FIRST_HOP = 1 << 4, + BATADV_VIS_SERVER = 1 << 5, + BATADV_DIRECTLINK = 1 << 6, };
/* ICMP message types */ -enum icmp_packettype { - ECHO_REPLY = 0, - DESTINATION_UNREACHABLE = 3, - ECHO_REQUEST = 8, - TTL_EXCEEDED = 11, - PARAMETER_PROBLEM = 12 +enum batadv_icmp_packettype { + BATADV_ECHO_REPLY = 0, + BATADV_DESTINATION_UNREACHABLE = 3, + BATADV_ECHO_REQUEST = 8, + BATADV_TTL_EXCEEDED = 11, + BATADV_PARAMETER_PROBLEM = 12, };
/* vis defines */ -enum vis_packettype { - VIS_TYPE_SERVER_SYNC = 0, - VIS_TYPE_CLIENT_UPDATE = 1 +enum batadv_vis_packettype { + BATADV_VIS_TYPE_SERVER_SYNC = 0, + BATADV_VIS_TYPE_CLIENT_UPDATE = 1, };
/* fragmentation defines */ -enum unicast_frag_flags { - UNI_FRAG_HEAD = 1 << 0, - UNI_FRAG_LARGETAIL = 1 << 1 +enum batadv_unicast_frag_flags { + BATADV_UNI_FRAG_HEAD = 1 << 0, + BATADV_UNI_FRAG_LARGETAIL = 1 << 1, };
/* TT_QUERY subtypes */ #define BATADV_TT_QUERY_TYPE_MASK 0x3
-enum tt_query_packettype { - TT_REQUEST = 0, - TT_RESPONSE = 1 +enum batadv_tt_query_packettype { + BATADV_TT_REQUEST = 0, + BATADV_TT_RESPONSE = 1, };
/* TT_QUERY flags */ -enum tt_query_flags { - TT_FULL_TABLE = 1 << 2 +enum batadv_tt_query_flags { + BATADV_TT_FULL_TABLE = 1 << 2, };
/* TT_CLIENT flags. * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to * 1 << 15 are used for local computation only */ -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 +enum batadv_tt_client_flags { + BATADV_TT_CLIENT_DEL = 1 << 0, + BATADV_TT_CLIENT_ROAM = 1 << 1, + BATADV_TT_CLIENT_WIFI = 1 << 2, + BATADV_TT_CLIENT_NOPURGE = 1 << 8, + BATADV_TT_CLIENT_NEW = 1 << 9, + BATADV_TT_CLIENT_PENDING = 1 << 10, };
/* claim frame types for the bridge loop avoidance */ -enum bla_claimframe { - CLAIM_TYPE_ADD = 0x00, - CLAIM_TYPE_DEL = 0x01, - CLAIM_TYPE_ANNOUNCE = 0x02, - CLAIM_TYPE_REQUEST = 0x03 +enum batadv_bla_claimframe { + BATADV_CLAIM_TYPE_ADD = 0x00, + BATADV_CLAIM_TYPE_DEL = 0x01, + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02, + BATADV_CLAIM_TYPE_REQUEST = 0x03, };
/* the destination hardware field in the ARP frame is used to diff --git a/routing.c b/routing.c index 8be9e41..6e96c53 100644 --- a/routing.c +++ b/routing.c @@ -219,7 +219,7 @@ batadv_bonding_save_primary(const struct orig_node *orig_node, struct orig_node *orig_neigh_node, const struct batman_ogm_packet *batman_ogm_packet) { - if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) + if (!(batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) return;
memcpy(orig_neigh_node->primary_addr, orig_node->orig, ETH_ALEN); @@ -290,7 +290,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv, icmp_packet = (struct icmp_packet_rr *)skb->data;
/* add data to device queue */ - if (icmp_packet->msg_type != ECHO_REQUEST) { + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { batadv_socket_receive_packet(icmp_packet, icmp_len); goto out; } @@ -317,7 +317,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); - icmp_packet->msg_type = ECHO_REPLY; + icmp_packet->msg_type = BATADV_ECHO_REPLY; icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); @@ -345,7 +345,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, icmp_packet = (struct icmp_packet *)skb->data;
/* send TTL exceeded if packet is an echo request (traceroute) */ - if (icmp_packet->msg_type != ECHO_REQUEST) { + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n", icmp_packet->orig, icmp_packet->dst); goto out; @@ -372,7 +372,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); - icmp_packet->msg_type = TTL_EXCEEDED; + icmp_packet->msg_type = BATADV_TTL_EXCEEDED; icmp_packet->header.ttl = BATADV_TTL;
batadv_send_skb_packet(skb, router->if_incoming, router->addr); @@ -606,14 +606,18 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) tt_query = (struct tt_query_packet *)skb->data;
switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { - case TT_REQUEST: + case BATADV_TT_REQUEST: batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_RX);
/* If we cannot provide an answer the tt_request is * forwarded */ if (!batadv_send_tt_response(bat_priv, tt_query)) { - tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; + if (tt_query->flags & BATADV_TT_FULL_TABLE) + tt_flag = 'F'; + else + tt_flag = '.'; + batadv_dbg(DBG_TT, bat_priv, "Routing TT_REQUEST to %pM [%c]\n", tt_query->dst, @@ -621,7 +625,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) return batadv_route_unicast_packet(skb, recv_if); } break; - case TT_RESPONSE: + case BATADV_TT_RESPONSE: batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX);
if (batadv_is_my_mac(tt_query->dst)) { @@ -640,7 +644,10 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
batadv_handle_tt_response(bat_priv, tt_query); } else { - tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; + if (tt_query->flags & BATADV_TT_FULL_TABLE) + tt_flag = 'F'; + else + tt_flag = '.'; batadv_dbg(DBG_TT, bat_priv, "Routing TT_RESPONSE to %pM [%c]\n", tt_query->dst, @@ -699,7 +706,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) roam_adv_packet->src, roam_adv_packet->client);
batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, - TT_CLIENT_ROAM, + BATADV_TT_CLIENT_ROAM, atomic_read(&orig_node->last_ttvn) + 1);
/* Roaming phase starts: I have new information but the ttvn has not @@ -866,7 +873,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
unicast_packet = (struct unicast_packet *)skb->data;
- if (unicast_packet->header.packet_type == BAT_UNICAST && + if (unicast_packet->header.packet_type == BATADV_UNICAST && atomic_read(&bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { ret = batadv_frag_send_skb(skb, bat_priv, @@ -875,7 +882,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, goto out; }
- if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && + if (unicast_packet->header.packet_type == BATADV_UNICAST_FRAG && batadv_frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) {
@@ -1174,12 +1181,12 @@ int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if) return NET_RX_DROP;
switch (vis_packet->vis_type) { - case VIS_TYPE_SERVER_SYNC: + case BATADV_VIS_TYPE_SERVER_SYNC: batadv_receive_server_sync_packet(bat_priv, vis_packet, skb_headlen(skb)); break;
- case VIS_TYPE_CLIENT_UPDATE: + case BATADV_VIS_TYPE_CLIENT_UPDATE: batadv_receive_client_update_packet(bat_priv, vis_packet, skb_headlen(skb)); break; diff --git a/soft-interface.c b/soft-interface.c index 19a80d2..3aae91d 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -213,7 +213,7 @@ static int batadv_interface_tx(struct sk_buff *skb, bcast_packet->header.ttl = BATADV_TTL;
/* batman packet type: broadcast */ - bcast_packet->header.packet_type = BAT_BCAST; + bcast_packet->header.packet_type = BATADV_BCAST;
/* hw address of first interface is the orig mac because only * this mac is known throughout the mesh @@ -387,7 +387,7 @@ struct net_device *batadv_softif_create(const char *name) atomic_set(&bat_priv->bonding, 0); atomic_set(&bat_priv->bridge_loop_avoidance, 0); atomic_set(&bat_priv->ap_isolation, 0); - atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); + atomic_set(&bat_priv->vis_mode, BATADV_VIS_TYPE_CLIENT_UPDATE); atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); atomic_set(&bat_priv->gw_sel_class, 20); atomic_set(&bat_priv->gw_bandwidth, 41); diff --git a/translation-table.c b/translation-table.c index c8ca694..ef3a76d 100644 --- a/translation-table.c +++ b/translation-table.c @@ -168,7 +168,7 @@ static void batadv_tt_local_event(struct bat_priv *bat_priv, tt_change_node->change.flags = flags; memcpy(tt_change_node->change.addr, addr, ETH_ALEN);
- del_op_requested = flags & TT_CLIENT_DEL; + del_op_requested = flags & BATADV_TT_CLIENT_DEL;
/* check for ADD+DEL or DEL+ADD events */ spin_lock_bh(&bat_priv->tt_changes_list_lock); @@ -184,7 +184,7 @@ static void batadv_tt_local_event(struct bat_priv *bat_priv, * now possible due to automatically recognition of "temporary" * clients */ - del_op_entry = entry->change.flags & TT_CLIENT_DEL; + del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL; if (!del_op_requested && del_op_entry) goto del; if (del_op_requested && !del_op_entry) @@ -243,7 +243,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, if (tt_local_entry) { tt_local_entry->last_seen = jiffies; /* possibly unset the TT_CLIENT_PENDING flag */ - tt_local_entry->common.flags &= ~TT_CLIENT_PENDING; + tt_local_entry->common.flags &= ~BATADV_TT_CLIENT_PENDING; goto out; }
@@ -258,19 +258,19 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); tt_local_entry->common.flags = BATADV_NO_FLAGS; if (batadv_is_wifi_iface(ifindex)) - tt_local_entry->common.flags |= TT_CLIENT_WIFI; + tt_local_entry->common.flags |= BATADV_TT_CLIENT_WIFI; atomic_set(&tt_local_entry->common.refcount, 2); tt_local_entry->last_seen = jiffies;
/* the batman interface mac address should never be purged */ if (batadv_compare_eth(addr, soft_iface->dev_addr)) - tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; + tt_local_entry->common.flags |= BATADV_TT_CLIENT_NOPURGE;
/* The local entry has to be marked as NEW to avoid to send it in * a full table response going out before the next ttvn increment * (consistency check) */ - tt_local_entry->common.flags |= TT_CLIENT_NEW; + tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW;
hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt, batadv_choose_orig, @@ -304,7 +304,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, /* The global entry has to be marked as ROAMING and * has to be kept for consistency purpose */ - tt_global_entry->common.flags |= TT_CLIENT_ROAM; + tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; tt_global_entry->roam_at = jiffies; } out: @@ -452,15 +452,15 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) seq_printf(seq, " * %pM [%c%c%c%c%c]\n", tt_common_entry->addr, (tt_common_entry->flags & - TT_CLIENT_ROAM ? 'R' : '.'), + BATADV_TT_CLIENT_ROAM ? 'R' : '.'), (tt_common_entry->flags & - TT_CLIENT_NOPURGE ? 'P' : '.'), + BATADV_TT_CLIENT_NOPURGE ? 'P' : '.'), (tt_common_entry->flags & - TT_CLIENT_NEW ? 'N' : '.'), + BATADV_TT_CLIENT_NEW ? 'N' : '.'), (tt_common_entry->flags & - TT_CLIENT_PENDING ? 'X' : '.'), + BATADV_TT_CLIENT_PENDING ? 'X' : '.'), (tt_common_entry->flags & - TT_CLIENT_WIFI ? 'W' : '.')); + BATADV_TT_CLIENT_WIFI ? 'W' : '.')); } rcu_read_unlock(); } @@ -481,7 +481,7 @@ static void batadv_tt_local_set_pending(struct bat_priv *bat_priv, * to be kept in the table in order to send it in a full table * response issued before the net ttvn increment (consistency check) */ - tt_local_entry->common.flags |= TT_CLIENT_PENDING; + tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING;
batadv_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: %s\n", @@ -498,9 +498,9 @@ void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, if (!tt_local_entry) goto out;
- flags = TT_CLIENT_DEL; + flags = BATADV_TT_CLIENT_DEL; if (roaming) - flags |= TT_CLIENT_ROAM; + flags |= BATADV_TT_CLIENT_ROAM;
batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); out: @@ -508,12 +508,36 @@ out: batadv_tt_local_entry_free_ref(tt_local_entry); }
-static void batadv_tt_local_purge(struct bat_priv *bat_priv) +static void batadv_tt_local_purge_list(struct bat_priv *bat_priv, + struct hlist_head *head) { - struct hashtable_t *hash = bat_priv->tt_local_hash; struct tt_local_entry *tt_local_entry; struct tt_common_entry *tt_common_entry; struct hlist_node *node, *node_tmp; + + hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head, + hash_entry) { + tt_local_entry = container_of(tt_common_entry, + struct tt_local_entry, common); + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE) + continue; + + /* entry already marked for deletion */ + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) + continue; + + if (!batadv_has_timed_out(tt_local_entry->last_seen, + BATADV_TT_LOCAL_TIMEOUT)) + continue; + + batadv_tt_local_set_pending(bat_priv, tt_local_entry, + BATADV_TT_CLIENT_DEL, "timed out"); + } +} + +static void batadv_tt_local_purge(struct bat_priv *bat_priv) +{ + struct hashtable_t *hash = bat_priv->tt_local_hash; struct hlist_head *head; spinlock_t *list_lock; /* protects write access to the hash lists */ uint32_t i; @@ -523,25 +547,7 @@ static void batadv_tt_local_purge(struct bat_priv *bat_priv) list_lock = &hash->list_locks[i];
spin_lock_bh(list_lock); - hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, - head, hash_entry) { - tt_local_entry = container_of(tt_common_entry, - struct tt_local_entry, - common); - if (tt_local_entry->common.flags & TT_CLIENT_NOPURGE) - continue; - - /* entry already marked for deletion */ - if (tt_local_entry->common.flags & TT_CLIENT_PENDING) - continue; - - if (!batadv_has_timed_out(tt_local_entry->last_seen, - BATADV_TT_LOCAL_TIMEOUT)) - continue; - - batadv_tt_local_set_pending(bat_priv, tt_local_entry, - TT_CLIENT_DEL, "timed out"); - } + batadv_tt_local_purge_list(bat_priv, head); spin_unlock_bh(list_lock); }
@@ -707,9 +713,9 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, * We should first delete the old originator before adding the * new one. */ - if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { + if (tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM) { batadv_tt_global_del_orig_list(tt_global_entry); - tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; + tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM; tt_global_entry->roam_at = 0; }
@@ -726,7 +732,8 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, out_remove: /* remove address from local hash if present */ batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, - "global tt received", flags & TT_CLIENT_ROAM); + "global tt received", + flags & BATADV_TT_CLIENT_ROAM); ret = 1; out: if (tt_global_entry) @@ -758,8 +765,8 @@ batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry, seq_printf(seq, " * %pM (%3u) via %pM (%3u) [%c%c]\n", tt_global_entry->common.addr, orig_entry->ttvn, orig_entry->orig_node->orig, last_ttvn, - (flags & TT_CLIENT_ROAM ? 'R' : '.'), - (flags & TT_CLIENT_WIFI ? 'W' : '.')); + (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'), + (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.')); } }
@@ -902,7 +909,7 @@ batadv_tt_global_del_roaming(struct bat_priv *bat_priv,
if (last_entry) { /* its the last one, mark for roaming. */ - tt_global_entry->common.flags |= TT_CLIENT_ROAM; + tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; tt_global_entry->roam_at = jiffies; } else /* there is another entry, we can simply delete this @@ -1022,7 +1029,7 @@ static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv, hash_entry) { tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, common); - if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) + if (!(tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM)) continue; if (!batadv_has_timed_out(tt_global_entry->roam_at, BATADV_TT_CLIENT_ROAM_TIMEOUT)) @@ -1096,8 +1103,8 @@ static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry, { bool ret = false;
- if (tt_local_entry->common.flags & TT_CLIENT_WIFI && - tt_global_entry->common.flags & TT_CLIENT_WIFI) + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI && + tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI) ret = true;
return ret; @@ -1167,7 +1174,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, { uint16_t total = 0, total_one; struct hashtable_t *hash = bat_priv->tt_global_hash; - struct tt_common_entry *tt_common_entry; + struct tt_common_entry *tt_common; struct tt_global_entry *tt_global_entry; struct hlist_node *node; struct hlist_head *head; @@ -1178,9 +1185,8 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, head = &hash->table[i];
rcu_read_lock(); - hlist_for_each_entry_rcu(tt_common_entry, node, - head, hash_entry) { - tt_global_entry = container_of(tt_common_entry, + hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) { + tt_global_entry = container_of(tt_common, struct tt_global_entry, common); /* Roaming clients are in the global table for @@ -1188,7 +1194,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, * taken into account while computing the * global crc */ - if (tt_global_entry->common.flags & TT_CLIENT_ROAM) + if (tt_common->flags & BATADV_TT_CLIENT_ROAM) continue;
/* find out if this global entry is announced by this @@ -1201,7 +1207,7 @@ static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, total_one = 0; for (j = 0; j < ETH_ALEN; j++) total_one = crc16_byte(total_one, - tt_global_entry->common.addr[j]); + tt_common->addr[j]); total ^= total_one; } rcu_read_unlock(); @@ -1215,7 +1221,7 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv) { uint16_t total = 0, total_one; struct hashtable_t *hash = bat_priv->tt_local_hash; - struct tt_common_entry *tt_common_entry; + struct tt_common_entry *tt_common; struct hlist_node *node; struct hlist_head *head; uint32_t i; @@ -1225,17 +1231,16 @@ static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv) head = &hash->table[i];
rcu_read_lock(); - hlist_for_each_entry_rcu(tt_common_entry, node, - head, hash_entry) { + hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) { /* not yet committed clients have not to be taken into * account while computing the CRC */ - if (tt_common_entry->flags & TT_CLIENT_NEW) + if (tt_common->flags & BATADV_TT_CLIENT_NEW) continue; total_one = 0; for (j = 0; j < ETH_ALEN; j++) total_one = crc16_byte(total_one, - tt_common_entry->addr[j]); + tt_common->addr[j]); total ^= total_one; } rcu_read_unlock(); @@ -1331,7 +1336,7 @@ static int batadv_tt_local_valid_entry(const void *entry_ptr, { const struct tt_common_entry *tt_common_entry = entry_ptr;
- if (tt_common_entry->flags & TT_CLIENT_NEW) + if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW) return 0; return 1; } @@ -1343,7 +1348,7 @@ static int batadv_tt_global_valid(const void *entry_ptr, const struct tt_global_entry *tt_global_entry; const struct orig_node *orig_node = data_ptr;
- if (tt_common_entry->flags & TT_CLIENT_ROAM) + if (tt_common_entry->flags & BATADV_TT_CLIENT_ROAM) return 0;
tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, @@ -1450,17 +1455,17 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, tt_request = (struct tt_query_packet *)skb_put(skb, sizeof(struct tt_query_packet));
- tt_request->header.packet_type = BAT_TT_QUERY; + tt_request->header.packet_type = BATADV_TT_QUERY; tt_request->header.version = BATADV_COMPAT_VERSION; memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); tt_request->header.ttl = BATADV_TTL; tt_request->ttvn = ttvn; tt_request->tt_data = htons(tt_crc); - tt_request->flags = TT_REQUEST; + tt_request->flags = BATADV_TT_REQUEST;
if (full_table) - tt_request->flags |= TT_FULL_TABLE; + tt_request->flags |= BATADV_TT_FULL_TABLE;
neigh_node = batadv_orig_node_get_router(dst_orig_node); if (!neigh_node) @@ -1509,7 +1514,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, batadv_dbg(DBG_TT, bat_priv, "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", tt_request->src, tt_request->ttvn, tt_request->dst, - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); + (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
/* Let's get the orig node of the REAL destination */ req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst); @@ -1537,7 +1542,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, goto out;
/* If the full table has been explicitly requested */ - if (tt_request->flags & TT_FULL_TABLE || + if (tt_request->flags & BATADV_TT_FULL_TABLE || !req_dst_orig_node->tt_buff) full_table = true; else @@ -1584,15 +1589,15 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, tt_response = (struct tt_query_packet *)skb->data; }
- tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.packet_type = BATADV_TT_QUERY; tt_response->header.version = BATADV_COMPAT_VERSION; tt_response->header.ttl = BATADV_TTL; memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); - tt_response->flags = TT_RESPONSE; + tt_response->flags = BATADV_TT_RESPONSE;
if (full_table) - tt_response->flags |= TT_FULL_TABLE; + tt_response->flags |= BATADV_TT_FULL_TABLE;
batadv_dbg(DBG_TT, bat_priv, "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", @@ -1639,7 +1644,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, batadv_dbg(DBG_TT, bat_priv, "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", tt_request->src, tt_request->ttvn, - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); + (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); @@ -1660,7 +1665,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, /* If the full table has been explicitly requested or the gap * is too big send the whole local translation table */ - if (tt_request->flags & TT_FULL_TABLE || my_ttvn != req_ttvn || + if (tt_request->flags & BATADV_TT_FULL_TABLE || my_ttvn != req_ttvn || !bat_priv->tt_buff) full_table = true; else @@ -1705,20 +1710,20 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, tt_response = (struct tt_query_packet *)skb->data; }
- tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.packet_type = BATADV_TT_QUERY; tt_response->header.version = BATADV_COMPAT_VERSION; tt_response->header.ttl = BATADV_TTL; memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); - tt_response->flags = TT_RESPONSE; + tt_response->flags = BATADV_TT_RESPONSE;
if (full_table) - tt_response->flags |= TT_FULL_TABLE; + tt_response->flags |= BATADV_TT_FULL_TABLE;
batadv_dbg(DBG_TT, bat_priv, "Sending TT_RESPONSE to %pM via %pM [%c]\n", orig_node->orig, neigh_node->addr, - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); + (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX);
@@ -1764,8 +1769,8 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv, int roams;
for (i = 0; i < tt_num_changes; i++) { - if ((tt_change + i)->flags & TT_CLIENT_DEL) { - roams = (tt_change + i)->flags & TT_CLIENT_ROAM; + if ((tt_change + i)->flags & BATADV_TT_CLIENT_DEL) { + roams = (tt_change + i)->flags & BATADV_TT_CLIENT_ROAM; batadv_tt_global_del(bat_priv, orig_node, (tt_change + i)->addr, "tt removed by changes", @@ -1840,7 +1845,7 @@ bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) /* Check if the client has been logically deleted (but is kept for * consistency purpose) */ - if (tt_local_entry->common.flags & TT_CLIENT_PENDING) + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) goto out; ret = true; out: @@ -1859,7 +1864,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", tt_response->src, tt_response->ttvn, ntohs(tt_response->tt_data), - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); + (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
/* we should have never asked a backbone gw */ if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) @@ -1869,7 +1874,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, if (!orig_node) goto out;
- if (tt_response->flags & TT_FULL_TABLE) + if (tt_response->flags & BATADV_TT_FULL_TABLE) batadv_tt_fill_gtable(bat_priv, tt_response); else batadv_tt_update_changes(bat_priv, orig_node, @@ -2019,7 +2024,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, sizeof(struct roam_adv_packet));
- roam_adv_packet->header.packet_type = BAT_ROAM_ADV; + roam_adv_packet->header.packet_type = BATADV_ROAM_ADV; roam_adv_packet->header.version = BATADV_COMPAT_VERSION; roam_adv_packet->header.ttl = BATADV_TTL; primary_if = batadv_primary_if_get_selected(bat_priv); @@ -2121,7 +2126,7 @@ out: static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) { struct hashtable_t *hash = bat_priv->tt_local_hash; - struct tt_common_entry *tt_common_entry; + struct tt_common_entry *tt_common; struct tt_local_entry *tt_local_entry; struct hlist_node *node, *node_tmp; struct hlist_head *head; @@ -2136,18 +2141,18 @@ static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) list_lock = &hash->list_locks[i];
spin_lock_bh(list_lock); - hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, - head, hash_entry) { - if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) + hlist_for_each_entry_safe(tt_common, node, node_tmp, head, + hash_entry) { + if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING)) continue;
batadv_dbg(DBG_TT, bat_priv, "Deleting local tt entry (%pM): pending\n", - tt_common_entry->addr); + tt_common->addr);
atomic_dec(&bat_priv->num_local_tt); hlist_del_rcu(node); - tt_local_entry = container_of(tt_common_entry, + tt_local_entry = container_of(tt_common, struct tt_local_entry, common); batadv_tt_local_entry_free_ref(tt_local_entry); @@ -2167,7 +2172,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv, return -ENOENT;
changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash, - TT_CLIENT_NEW, false); + BATADV_TT_CLIENT_NEW, false);
/* all reset entries have to be counted as local entries */ atomic_add(changed_num, &bat_priv->num_local_tt); @@ -2325,7 +2330,7 @@ bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, if (!tt_global_entry) goto out;
- ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; + ret = tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM; batadv_tt_global_entry_free_ref(tt_global_entry); out: return ret; diff --git a/unicast.c b/unicast.c index d0f00a2..1bf192b 100644 --- a/unicast.c +++ b/unicast.c @@ -42,7 +42,7 @@ batadv_frag_merge_packet(struct list_head *head, int uni_diff = sizeof(*up) - hdr_len;
/* set skb to the first part and tmp_skb to the second part */ - if (up->flags & UNI_FRAG_HEAD) { + if (up->flags & BATADV_UNI_FRAG_HEAD) { tmp_skb = tfp->skb; } else { tmp_skb = skb; @@ -66,7 +66,7 @@ batadv_frag_merge_packet(struct list_head *head,
memmove(skb->data + uni_diff, skb->data, hdr_len); unicast_packet = (struct unicast_packet *)skb_pull(skb, uni_diff); - unicast_packet->header.packet_type = BAT_UNICAST; + unicast_packet->header.packet_type = BATADV_UNICAST;
return skb;
@@ -121,7 +121,7 @@ batadv_frag_search_packet(struct list_head *head, struct unicast_frag_packet *tmp_up = NULL; uint16_t search_seqno;
- if (up->flags & UNI_FRAG_HEAD) + if (up->flags & BATADV_UNI_FRAG_HEAD) search_seqno = ntohs(up->seqno)+1; else search_seqno = ntohs(up->seqno)-1; @@ -138,8 +138,8 @@ batadv_frag_search_packet(struct list_head *head,
if (tfp->seqno == search_seqno) {
- if ((tmp_up->flags & UNI_FRAG_HEAD) != - (up->flags & UNI_FRAG_HEAD)) + if ((tmp_up->flags & BATADV_UNI_FRAG_HEAD) != + (up->flags & BATADV_UNI_FRAG_HEAD)) return tfp; else goto mov_tail; @@ -254,15 +254,15 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
frag1->header.ttl--; frag1->header.version = BATADV_COMPAT_VERSION; - frag1->header.packet_type = BAT_UNICAST_FRAG; + frag1->header.packet_type = BATADV_UNICAST_FRAG;
memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(frag2, frag1, sizeof(*frag2));
if (data_len & 1) - large_tail = UNI_FRAG_LARGETAIL; + large_tail = BATADV_UNI_FRAG_LARGETAIL;
- frag1->flags = UNI_FRAG_HEAD | large_tail; + frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail; frag2->flags = large_tail;
seqno = atomic_add_return(2, &hard_iface->frag_seqno); @@ -323,7 +323,7 @@ find_router:
unicast_packet->header.version = BATADV_COMPAT_VERSION; /* batman packet type: unicast */ - unicast_packet->header.packet_type = BAT_UNICAST; + unicast_packet->header.packet_type = BATADV_UNICAST; /* set unicast ttl */ unicast_packet->header.ttl = BATADV_TTL; /* copy the destination for faster routing */ diff --git a/unicast.h b/unicast.h index 936287f..510e23f 100644 --- a/unicast.h +++ b/unicast.h @@ -41,8 +41,8 @@ static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
unicast_packet = (struct unicast_frag_packet *)skb->data;
- if (unicast_packet->flags & UNI_FRAG_LARGETAIL) { - if (unicast_packet->flags & UNI_FRAG_HEAD) + if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) { + if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD) uneven_correction = 1; else uneven_correction = -1; diff --git a/vis.c b/vis.c index c920b4b..f5692ee 100644 --- a/vis.c +++ b/vis.c @@ -256,7 +256,7 @@ int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) if (!primary_if) goto out;
- if (vis_server == VIS_TYPE_CLIENT_UPDATE) + if (vis_server == BATADV_VIS_TYPE_CLIENT_UPDATE) goto out;
spin_lock_bh(&bat_priv->vis_hash_lock); @@ -437,7 +437,7 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, int is_new, make_broadcast; int vis_server = atomic_read(&bat_priv->vis_mode);
- make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); + make_broadcast = (vis_server == BATADV_VIS_TYPE_SERVER_SYNC);
spin_lock_bh(&bat_priv->vis_hash_lock); info = batadv_add_packet(bat_priv, vis_packet, vis_info_len, @@ -448,7 +448,7 @@ void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, /* only if we are server ourselves and packet is newer than the one in * hash. */ - if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && is_new) batadv_send_list_add(bat_priv, info); end: spin_unlock_bh(&bat_priv->vis_hash_lock); @@ -470,7 +470,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv, return;
/* Are we the target for this VIS packet? */ - if (vis_server == VIS_TYPE_SERVER_SYNC && + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && batadv_is_my_mac(vis_packet->target_orig)) are_target = 1;
@@ -486,7 +486,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
/* send only if we're the target server or ... */ if (are_target && is_new) { - packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ + packet->vis_type = BATADV_VIS_TYPE_SERVER_SYNC; /* upgrade! */ batadv_send_list_add(bat_priv, info);
/* ... we're not the recipient (and thus need to forward). */ @@ -526,7 +526,7 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv, if (!router) continue;
- if ((orig_node->flags & VIS_SERVER) && + if ((orig_node->flags & BATADV_VIS_SERVER) && (router->tq_avg > best_tq)) { best_tq = router->tq_avg; memcpy(packet->target_orig, orig_node->orig, @@ -580,7 +580,7 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv) packet->entries = 0; skb_trim(info->skb_packet, sizeof(*packet));
- if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { + if (packet->vis_type == BATADV_VIS_TYPE_CLIENT_UPDATE) { best_tq = batadv_find_best_vis_server(bat_priv, info);
if (best_tq < 0) @@ -707,7 +707,7 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv, rcu_read_lock(); hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { /* if it's a vis server and reachable, send it. */ - if (!(orig_node->flags & VIS_SERVER)) + if (!(orig_node->flags & BATADV_VIS_SERVER)) continue;
router = batadv_orig_node_get_router(orig_node); @@ -875,7 +875,7 @@ int batadv_vis_init(struct bat_priv *bat_priv) kref_init(&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; packet->header.version = BATADV_COMPAT_VERSION; - packet->header.packet_type = BAT_VIS; + packet->header.packet_type = BATADV_VIS; packet->header.ttl = BATADV_TTL; packet->seqno = 0; packet->entries = 0;
On Monday, June 04, 2012 04:19:21 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 48 +++++++------ bat_sysfs.c | 24 ++++--- bridge_loop_avoidance.c | 34 ++++----- icmp_socket.c | 8 +-- main.c | 14 ++-- packet.h | 86 +++++++++++------------ routing.c | 35 ++++++---- soft-interface.c | 4 +- translation-table.c | 177 ++++++++++++++++++++++++----------------------- unicast.c | 18 ++--- unicast.h | 4 +- vis.c | 18 ++--- 12 files changed, 246 insertions(+), 224 deletions(-)
Applied in revision e85015c.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- bat_iv_ogm.c | 48 +++++++++++++++++++++++------------------------ bat_sysfs.c | 12 ++++++------ bat_sysfs.h | 4 ++-- bitarray.c | 4 ++-- bridge_loop_avoidance.c | 46 ++++++++++++++++++++++----------------------- gateway_client.c | 25 +++++++++++++----------- icmp_socket.c | 8 ++++---- main.c | 10 +++++----- main.h | 36 +++++++++++++++++------------------ originator.c | 12 ++++++------ routing.c | 18 +++++++++--------- send.c | 11 ++++++----- soft-interface.c | 6 +++--- translation-table.c | 35 +++++++++++++++++----------------- 14 files changed, 140 insertions(+), 135 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 4ac06a9..aed8aeb 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -188,7 +188,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? "Sending own" : "Forwarding")); - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", fwd_str, (packet_num > 0 ? "aggregated " : ""), batman_ogm_packet->orig, @@ -252,7 +252,7 @@ static void batadv_iv_ogm_emit(struct forw_packet *forw_packet) (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
/* FIXME: what about aggregated packets ? */ - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", (forw_packet->own ? "Sending own" : "Forwarding"), batman_ogm_packet->orig, @@ -385,7 +385,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, /* own packet should always be scheduled */ if (!own_packet) { if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "batman packet queue full\n"); goto out; } @@ -535,7 +535,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node, uint8_t tt_num_changes;
if (batman_ogm_packet->header.ttl <= 1) { - batadv_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n"); return; }
@@ -561,7 +561,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->tq = batadv_hop_penalty(batman_ogm_packet->tq, bat_priv);
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Forwarding packet: tq: %i, ttl: %i\n", batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
@@ -642,7 +642,7 @@ batadv_iv_ogm_orig_update(struct bat_priv *bat_priv, uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; uint8_t *neigh_addr;
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "update_originator(): Searching and updating originator entry of received packet\n");
rcu_read_lock(); @@ -685,7 +685,7 @@ batadv_iv_ogm_orig_update(struct bat_priv *bat_priv, if (!neigh_node) goto unlock; } else - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Updating existing last-hop neighbor of originator\n");
rcu_read_unlock(); @@ -866,7 +866,7 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE; batman_ogm_packet->tq = combined_tq;
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", orig_node->orig, orig_neigh_node->orig, total_count, neigh_rq_count, tq_own, @@ -948,7 +948,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, rcu_read_unlock();
if (need_update) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "updating last_seqno: old %u, new %u\n", orig_node->last_real_seqno, seqno); orig_node->last_real_seqno = seqno; @@ -1007,7 +1007,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) is_single_hop_neigh = true;
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, @@ -1044,21 +1044,21 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, rcu_read_unlock();
if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", batman_ogm_packet->header.version); return; }
if (is_my_addr) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: received my own broadcast (sender: %pM)\n", ethhdr->h_source); return; }
if (is_broadcast) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", ethhdr->h_source); return; @@ -1097,21 +1097,21 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); }
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: originator packet from myself (via neighbor)\n"); batadv_orig_node_free_ref(orig_neigh_node); return; }
if (is_my_oldorig) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", ethhdr->h_source); return; }
if (batman_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", ethhdr->h_source); return; @@ -1125,14 +1125,14 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, if_incoming);
if (is_duplicate == -1) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: packet within seqno protection time (sender: %pM)\n", ethhdr->h_source); goto out; }
if (batman_ogm_packet->tq == 0) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: originator packet with tq equal 0\n"); goto out; } @@ -1151,7 +1151,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, (batadv_compare_eth(router->addr, prev_sender)) && !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) && (batadv_compare_eth(router->addr, router_router->addr))) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", ethhdr->h_source); goto out; @@ -1172,7 +1172,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, * don't route towards it */ if (!is_single_hop_neigh && (!orig_neigh_router)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: OGM via unknown neighbor!\n"); goto out_neigh; } @@ -1201,25 +1201,25 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, is_single_hop_neigh, is_from_best_next_hop, if_incoming);
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); goto out_neigh; }
/* multihop originator */ if (!is_bidirect) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: not received via bidirectional link\n"); goto out_neigh; }
if (is_duplicate) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: duplicate packet received\n"); goto out_neigh; }
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Forwarding packet: rebroadcast originator packet\n"); batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, is_single_hop_neigh, is_from_best_next_hop, diff --git a/bat_sysfs.c b/bat_sysfs.c index 03fe431..887c35f 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -484,7 +484,7 @@ BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE, static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, batadv_store_gw_bwidth); #ifdef CONFIG_BATMAN_ADV_DEBUG -BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); +BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); #endif
static struct bat_attribute *batadv_mesh_attrs[] = { @@ -722,8 +722,8 @@ void batadv_sysfs_del_hardif(struct kobject **hardif_obj) *hardif_obj = NULL; }
-int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, - enum uev_action action, const char *data) +int batadv_throw_uevent(struct bat_priv *bat_priv, enum batadv_uev_type type, + enum batadv_uev_action action, const char *data) { int ret = -ENOMEM; struct hard_iface *primary_if = NULL; @@ -755,7 +755,7 @@ int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, batadv_uev_action_str[action]);
/* If the event is DEL, ignore the data field */ - if (action != UEV_DEL) { + if (action != BATADV_UEV_DEL) { uevent_env[2] = kmalloc(strlen(BATADV_UEV_DATA_VAR) + strlen(data) + 1, GFP_ATOMIC); if (!uevent_env[2]) @@ -774,10 +774,10 @@ out: batadv_hardif_free_ref(primary_if);
if (ret) - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", batadv_uev_type_str[type], batadv_uev_action_str[action], - (action == UEV_DEL ? "NULL" : data), ret); + (action == BATADV_UEV_DEL ? "NULL" : data), ret); return ret; } diff --git a/bat_sysfs.h b/bat_sysfs.h index 23a8390..28c2948 100644 --- a/bat_sysfs.h +++ b/bat_sysfs.h @@ -36,7 +36,7 @@ void batadv_sysfs_del_meshif(struct net_device *dev); int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); void batadv_sysfs_del_hardif(struct kobject **hardif_obj); -int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, - enum uev_action action, const char *data); +int batadv_throw_uevent(struct bat_priv *bat_priv, enum batadv_uev_type type, + enum batadv_uev_action action, const char *data);
#endif /* _NET_BATMAN_ADV_SYSFS_H_ */ diff --git a/bitarray.c b/bitarray.c index 4a009b5..835d3b6 100644 --- a/bitarray.c +++ b/bitarray.c @@ -66,7 +66,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, /* sequence number is much newer, probably missed a lot of packets */ if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE && seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "We missed a lot of packets (%i) !\n", seq_num_diff - 1); bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); @@ -83,7 +83,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Other host probably restarted!\n");
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 6a675fe..bda92e0 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -297,7 +297,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, * set Ethernet SRC to the clients mac */ memcpy(ethhdr->h_source, mac, ETH_ALEN); - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); break; case BATADV_CLAIM_TYPE_DEL: @@ -305,7 +305,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, * set HW SRC to the clients mac */ memcpy(hw_src, mac, ETH_ALEN); - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); break; @@ -314,7 +314,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, * set HW SRC to the special mac containg the crc */ memcpy(hw_src, mac, ETH_ALEN); - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", ethhdr->h_source, vid); break; @@ -324,7 +324,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, */ memcpy(hw_src, mac, ETH_ALEN); memcpy(ethhdr->h_dest, mac, ETH_ALEN); - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", ethhdr->h_source, ethhdr->h_dest, vid); break; @@ -365,7 +365,7 @@ static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv, if (entry) return entry;
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", orig, vid);
@@ -439,7 +439,7 @@ static void batadv_bla_answer_request(struct bat_priv *bat_priv, struct backbone_gw *backbone_gw; int i;
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_answer_request(): received a claim request, send all of our own claims again\n");
backbone_gw = batadv_backbone_hash_find(bat_priv, @@ -480,8 +480,8 @@ static void batadv_bla_send_request(struct backbone_gw *backbone_gw) /* first, remove all old entries */ batadv_bla_del_backbone_claims(backbone_gw);
- batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n", - backbone_gw->orig); + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, + "Sending REQUEST to %pM\n", backbone_gw->orig);
/* send request */ batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, @@ -546,7 +546,7 @@ static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, claim->backbone_gw = backbone_gw;
atomic_set(&claim->refcount, 2); - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", mac, vid); hash_added = batadv_hash_add(bat_priv->claim_hash, @@ -565,7 +565,7 @@ static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, /* no need to register a new backbone */ goto claim_free_ref;
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_add_claim(): changing ownership for %pM, vid %d\n", mac, vid);
@@ -599,8 +599,8 @@ static void batadv_bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac, if (!claim) return;
- batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, - vid); + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", + mac, vid);
batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim, batadv_choose_claim, claim); @@ -633,12 +633,12 @@ static int batadv_handle_announce(struct bat_priv *bat_priv, backbone_gw->lasttime = jiffies; crc = ntohs(*((__be16 *)(&an_addr[4])));
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", vid, backbone_gw->orig, crc);
if (backbone_gw->crc != crc) { - batadv_dbg(DBG_BLA, backbone_gw->bat_priv, + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", backbone_gw->orig, backbone_gw->vid, backbone_gw->crc, crc); @@ -674,7 +674,7 @@ static int batadv_handle_request(struct bat_priv *bat_priv, if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) return 1;
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "handle_request(): REQUEST vid %d (sent by %pM)...\n", vid, ethhdr->h_source);
@@ -702,7 +702,7 @@ static int batadv_handle_unclaim(struct bat_priv *bat_priv, return 1;
/* this must be an UNCLAIM frame */ - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", claim_addr, vid, backbone_gw->orig);
@@ -804,7 +804,7 @@ static int batadv_check_claim_group(struct bat_priv *bat_priv,
/* if our mesh friends mac is bigger, use it for ourselves. */ if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "taking other backbones claim group: %04x\n", ntohs(bla_dst->group)); bla_dst_own->group = bla_dst->group; @@ -882,7 +882,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv, ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, ethhdr); if (ret == 1) - batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", ethhdr->h_source, vid, hw_src, hw_dst);
@@ -917,7 +917,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv, break; }
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", ethhdr->h_source, vid, hw_src, hw_dst); return 1; @@ -952,7 +952,7 @@ static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) BATADV_BLA_BACKBONE_TIMEOUT)) continue;
- batadv_dbg(DBG_BLA, backbone_gw->bat_priv, + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, "bla_purge_backbone_gw(): backbone gw %pM timed out\n", backbone_gw->orig);
@@ -1004,7 +1004,7 @@ static void batadv_bla_purge_claims(struct bat_priv *bat_priv, BATADV_BLA_CLAIM_TIMEOUT)) continue;
- batadv_dbg(DBG_BLA, bat_priv, + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_purge_claims(): %pM, vid %d, time out\n", claim->addr, claim->vid);
@@ -1146,7 +1146,7 @@ int batadv_bla_init(struct bat_priv *bat_priv) uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; struct hard_iface *primary_if;
- batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n"); + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");
/* setting claim destination address */ memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); @@ -1181,7 +1181,7 @@ int batadv_bla_init(struct bat_priv *bat_priv) batadv_hash_set_lock_class(bat_priv->backbone_hash, &batadv_backbone_hash_lock_class_key);
- batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
batadv_bla_start_timer(bat_priv); return 0; diff --git a/gateway_client.c b/gateway_client.c index 6a92035..f674029 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -218,21 +218,24 @@ void batadv_gw_election(struct bat_priv *bat_priv) }
if ((curr_gw) && (!next_gw)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Removing selected gateway - no gateway in range\n"); - batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, + NULL); } else if ((!curr_gw) && (next_gw)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", next_gw->orig_node->orig, next_gw->orig_node->gw_flags, router->tq_avg); - batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD, + gw_addr); } else { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", next_gw->orig_node->orig, next_gw->orig_node->gw_flags, router->tq_avg); - batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE, + gw_addr); }
batadv_gw_select(bat_priv, next_gw); @@ -283,7 +286,7 @@ void batadv_gw_check_election(struct bat_priv *bat_priv, (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) goto out;
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", gw_tq_avg, orig_tq_avg);
@@ -320,7 +323,7 @@ static void batadv_gw_node_add(struct bat_priv *bat_priv, spin_unlock_bh(&bat_priv->gw_list_lock);
batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up); - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", orig_node->orig, new_gwflags, (down > 2048 ? down / 1024 : down), @@ -347,7 +350,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv, if (gw_node->orig_node != orig_node) continue;
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Gateway class of originator %pM changed from %i to %i\n", orig_node->orig, gw_node->orig_node->gw_flags, new_gwflags); @@ -356,7 +359,7 @@ void batadv_gw_node_update(struct bat_priv *bat_priv,
if (new_gwflags == BATADV_NO_FLAGS) { gw_node->deleted = jiffies; - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Gateway %pM removed from gateway list\n", orig_node->orig);
@@ -403,7 +406,7 @@ void batadv_gw_node_purge(struct bat_priv *bat_priv) &bat_priv->gw_list, list) { if (((!gw_node->deleted) || (time_before(jiffies, gw_node->deleted + timeout))) && - atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) + atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) continue;
if (curr_gw == gw_node) diff --git a/icmp_socket.c b/icmp_socket.c index 2e90673..f4de133 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -158,7 +158,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, size_t packet_len = sizeof(struct icmp_packet);
if (len < sizeof(struct icmp_packet)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Error - can't send packet from char device: invalid packet size\n"); return -EINVAL; } @@ -188,14 +188,14 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, }
if (icmp_packet->header.packet_type != BATADV_ICMP) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); len = -EINVAL; goto free_skb; }
if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); len = -EINVAL; goto free_skb; @@ -211,7 +211,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, goto free_skb; }
- if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) goto dst_unreach;
orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst); diff --git a/main.c b/main.c index b3f0a2e..24d651d 100644 --- a/main.c +++ b/main.c @@ -132,7 +132,7 @@ int batadv_mesh_init(struct net_device *soft_iface) goto err;
atomic_set(&bat_priv->gw_reselect, 0); - atomic_set(&bat_priv->mesh_state, MESH_ACTIVE); + atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
return 0;
@@ -145,7 +145,7 @@ void batadv_mesh_free(struct net_device *soft_iface) { struct bat_priv *bat_priv = netdev_priv(soft_iface);
- atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING); + atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
batadv_purge_outstanding_packets(bat_priv, NULL);
@@ -160,7 +160,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
free_percpu(bat_priv->bat_counters);
- atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); + atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); }
void batadv_inc_module_count(void) @@ -230,7 +230,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
bat_priv = netdev_priv(hard_iface->soft_iface);
- if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) goto err_free;
/* discard frames on not active interfaces */ @@ -240,7 +240,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", batman_ogm_packet->header.version); goto err_free; diff --git a/main.h b/main.h index b796714..72dca13 100644 --- a/main.h +++ b/main.h @@ -95,23 +95,23 @@ #define BATADV_RESET_PROTECTION_MS 30000 #define BATADV_EXPECTED_SEQNO_RANGE 65536
-enum mesh_state { - MESH_INACTIVE, - MESH_ACTIVE, - MESH_DEACTIVATING +enum batadv_mesh_state { + BATADV_MESH_INACTIVE, + BATADV_MESH_ACTIVE, + BATADV_MESH_DEACTIVATING, };
#define BATADV_BCAST_QUEUE_LEN 256 #define BATADV_BATMAN_QUEUE_LEN 256
-enum uev_action { - UEV_ADD = 0, - UEV_DEL, - UEV_CHANGE +enum batadv_uev_action { + BATADV_UEV_ADD = 0, + BATADV_UEV_DEL, + BATADV_UEV_CHANGE, };
-enum uev_type { - UEV_GW = 0 +enum batadv_uev_type { + BATADV_UEV_GW = 0, };
#define BATADV_GW_THRESHOLD 50 @@ -124,12 +124,12 @@ enum uev_type { #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* all messages related to routing / flooding / broadcasting / etc */ -enum dbg_level { - DBG_BATMAN = 1 << 0, - DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ - DBG_TT = 1 << 2, /* translation table operations */ - DBG_BLA = 1 << 3, /* bridge loop avoidance */ - DBG_ALL = 15 +enum batadv_dbg_level { + BATADV_DBG_BATMAN = 1 << 0, + BATADV_DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ + BATADV_DBG_TT = 1 << 2, /* translation table operations */ + BATADV_DBG_BLA = 1 << 3, /* bridge loop avoidance */ + BATADV_DBG_ALL = 15, };
/* Kernel headers */ @@ -197,14 +197,14 @@ static inline void batadv_dbg(int type __always_unused, do { \ struct net_device *_netdev = (net_dev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \ - batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ pr_info("%s: " fmt, _netdev->name, ## arg); \ } while (0) #define batadv_err(net_dev, fmt, arg...) \ do { \ struct net_device *_netdev = (net_dev); \ struct bat_priv *_batpriv = netdev_priv(_netdev); \ - batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ + batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ pr_err("%s: " fmt, _netdev->name, ## arg); \ } while (0)
diff --git a/originator.c b/originator.c index 9e60cc0..4ddea31 100644 --- a/originator.c +++ b/originator.c @@ -102,7 +102,7 @@ struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, /* extra reference for return */ atomic_set(&neigh_node->refcount, 2);
- batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Creating new neighbor %pM, initial seqno %d\n", neigh_addr, seqno);
@@ -200,8 +200,8 @@ struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, if (orig_node) return orig_node;
- batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n", - addr); + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, + "Creating new originator: %pM\n", addr);
orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); if (!orig_node) @@ -293,12 +293,12 @@ static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, if ((if_incoming->if_status == BATADV_IF_INACTIVE) || (if_incoming->if_status == BATADV_IF_NOT_IN_USE) || (if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", orig_node->orig, neigh_node->addr, if_incoming->net_dev->name); else - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", orig_node->orig, neigh_node->addr, jiffies_to_msecs(last_seen)); @@ -326,7 +326,7 @@ static bool batadv_purge_orig_node(struct bat_priv *bat_priv,
if (batadv_has_timed_out(orig_node->last_seen, 2 * BATADV_PURGE_TIMEOUT)) { - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Originator timeout: originator %pM, last_seen %u\n", orig_node->orig, jiffies_to_msecs(orig_node->last_seen)); diff --git a/routing.c b/routing.c index 6e96c53..e3859ab 100644 --- a/routing.c +++ b/routing.c @@ -72,20 +72,20 @@ static void _batadv_update_route(struct bat_priv *bat_priv,
/* route deleted */ if ((curr_router) && (!neigh_node)) { - batadv_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", - orig_node->orig); + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, + "Deleting route towards: %pM\n", orig_node->orig); batadv_tt_global_del_orig(bat_priv, orig_node, "Deleted route towards originator");
/* route added */ } else if ((!curr_router) && (neigh_node)) {
- batadv_dbg(DBG_ROUTES, bat_priv, + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, "Adding route towards: %pM (via %pM)\n", orig_node->orig, neigh_node->addr); /* route changed */ } else if (neigh_node && curr_router) { - batadv_dbg(DBG_ROUTES, bat_priv, + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, "Changing route towards: %pM (now via %pM - was via %pM)\n", orig_node->orig, neigh_node->addr, curr_router->addr); @@ -240,7 +240,7 @@ int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, return 1;
*last_reset = jiffies; - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "old packet received, start protection\n"); }
@@ -618,7 +618,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) else tt_flag = '.';
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Routing TT_REQUEST to %pM [%c]\n", tt_query->dst, tt_flag); @@ -648,7 +648,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) tt_flag = 'F'; else tt_flag = '.'; - batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Routing TT_RESPONSE to %pM [%c]\n", tt_query->dst, tt_flag); @@ -701,7 +701,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) if (!orig_node) goto out;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Received ROAMING_ADV from %pM (client %pM)\n", roam_adv_packet->src, roam_adv_packet->client);
@@ -990,7 +990,7 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, batadv_orig_node_free_ref(orig_node); }
- batadv_dbg(DBG_ROUTES, bat_priv, + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, unicast_packet->dest); diff --git a/send.c b/send.c index 8de6e25..aad9818 100644 --- a/send.c +++ b/send.c @@ -142,7 +142,8 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *newskb;
if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { - batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, + "bcast packet queue full\n"); goto out; }
@@ -199,7 +200,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work) hlist_del(&forw_packet->list); spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
- if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) goto out;
/* rebroadcast packet */ @@ -243,7 +244,7 @@ void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work) hlist_del(&forw_packet->list); spin_unlock_bh(&bat_priv->forw_bat_list_lock);
- if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) goto out;
bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet); @@ -271,11 +272,11 @@ void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, bool pending;
if (hard_iface) - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "purge_outstanding_packets(): %s\n", hard_iface->net_dev->name); else - batadv_dbg(DBG_BATMAN, bat_priv, + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "purge_outstanding_packets()\n");
/* free bcast list */ diff --git a/soft-interface.c b/soft-interface.c index 3aae91d..0a00324 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -105,7 +105,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) return -EADDRNOTAVAIL;
/* only modify transtable if it has been initialized before */ - if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) { batadv_tt_local_remove(bat_priv, dev->dev_addr, "mac address changed", false); batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX); @@ -143,7 +143,7 @@ static int batadv_interface_tx(struct sk_buff *skb, short vid __maybe_unused = -1; bool do_bcast = false;
- if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) goto dropped;
soft_iface->trans_start = jiffies; @@ -398,7 +398,7 @@ struct net_device *batadv_softif_create(const char *name) atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN); atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
- atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); + atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); atomic_set(&bat_priv->bcast_seqno, 1); atomic_set(&bat_priv->ttvn, 0); atomic_set(&bat_priv->tt_local_changes, 0); diff --git a/translation-table.c b/translation-table.c index ef3a76d..baeead6 100644 --- a/translation-table.c +++ b/translation-table.c @@ -251,7 +251,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, if (!tt_local_entry) goto out;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Creating new local tt entry: %pM (ttvn: %d)\n", addr, (uint8_t)atomic_read(&bat_priv->ttvn));
@@ -483,7 +483,7 @@ static void batadv_tt_local_set_pending(struct bat_priv *bat_priv, */ tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: %s\n", tt_local_entry->common.addr, message); } @@ -725,7 +725,7 @@ int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, orig_node, ttvn); }
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Creating new global tt entry: %pM (via %pM)\n", tt_global_entry->common.addr, orig_node->orig);
@@ -855,7 +855,7 @@ batadv_tt_global_del_orig_entry(struct bat_priv *bat_priv, head = &tt_global_entry->orig_list; hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { if (orig_entry->orig_node == orig_node) { - batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Deleting %pM from global tt entry %pM: %s\n", orig_node->orig, tt_global_entry->common.addr, message); @@ -870,7 +870,8 @@ static void batadv_tt_global_del_struct(struct bat_priv *bat_priv, struct tt_global_entry *tt_global_entry, const char *message) { - batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", + batadv_dbg(BATADV_DBG_TT, bat_priv, + "Deleting global tt entry %pM: %s\n", tt_global_entry->common.addr, message);
batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt, @@ -1005,7 +1006,7 @@ void batadv_tt_global_del_orig(struct bat_priv *bat_priv, orig_node, message);
if (hlist_empty(&global_entry->orig_list)) { - batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", global_entry->common.addr, message); hlist_del_rcu(node); @@ -1035,7 +1036,7 @@ static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv, BATADV_TT_CLIENT_ROAM_TIMEOUT)) continue;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Deleting global tt entry (%pM): Roaming timeout\n", tt_global_entry->common.addr);
@@ -1471,7 +1472,7 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv, if (!neigh_node) goto out;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending TT_REQUEST to %pM via %pM [%c]\n", dst_orig_node->orig, neigh_node->addr, (full_table ? 'F' : '.')); @@ -1511,7 +1512,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, struct sk_buff *skb = NULL; struct tt_query_packet *tt_response;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", tt_request->src, tt_request->ttvn, tt_request->dst, (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); @@ -1599,7 +1600,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, if (full_table) tt_response->flags |= BATADV_TT_FULL_TABLE;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", res_dst_orig_node->orig, neigh_node->addr, req_dst_orig_node->orig, req_ttvn); @@ -1641,7 +1642,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, struct sk_buff *skb = NULL; struct tt_query_packet *tt_response;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", tt_request->src, tt_request->ttvn, (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); @@ -1720,7 +1721,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, if (full_table) tt_response->flags |= BATADV_TT_FULL_TABLE;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending TT_RESPONSE to %pM via %pM [%c]\n", orig_node->orig, neigh_node->addr, (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); @@ -1860,7 +1861,7 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv, struct tt_req_node *node, *safe; struct orig_node *orig_node = NULL;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", tt_response->src, tt_response->ttvn, ntohs(tt_response->tt_data), @@ -2039,7 +2040,7 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, if (!neigh_node) goto out;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", orig_node->orig, client, neigh_node->addr);
@@ -2146,7 +2147,7 @@ static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING)) continue;
- batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Deleting local tt entry (%pM): pending\n", tt_common->addr);
@@ -2181,7 +2182,7 @@ static int batadv_tt_commit_changes(struct bat_priv *bat_priv,
/* Increment the TTVN only once per OGM interval */ atomic_inc(&bat_priv->ttvn); - batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_DBG_TT, bat_priv, "Local changes committed, updating to ttvn %u\n", (uint8_t)atomic_read(&bat_priv->ttvn)); bat_priv->tt_poss_change = false; @@ -2305,7 +2306,7 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv, if (!orig_node->tt_initialised || ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { request_table: - batadv_dbg(DBG_TT, bat_priv, + batadv_dbg(BATADV_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);
On Monday, June 04, 2012 04:19:22 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_iv_ogm.c | 48 +++++++++++++++++++++++------------------------ bat_sysfs.c | 12 ++++++------ bat_sysfs.h | 4 ++-- bitarray.c | 4 ++-- bridge_loop_avoidance.c | 46 ++++++++++++++++++++++----------------------- gateway_client.c | 25 +++++++++++++----------- icmp_socket.c | 8 ++++---- main.c | 10 +++++----- main.h | 36 +++++++++++++++++------------------ originator.c | 12 ++++++------ routing.c | 18 +++++++++--------- send.c | 11 ++++++----- soft-interface.c | 6 +++--- translation-table.c | 35 +++++++++++++++++----------------- 14 files changed, 140 insertions(+), 135 deletions(-)
Applied in revision 48860a4.
Thanks, Marek
On Monday, June 04, 2012 04:19:07 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
bat_debugfs.c | 26 +++++++------ bat_sysfs.c | 112 +++++++++++++++++++++++++++--------------------------- gateway_client.c | 12 +++--- vis.c | 18 +++++---- 4 files changed, 87 insertions(+), 81 deletions(-)
Applied in revision 44e4434.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org