[B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (2)
by Sven Eckelmann
Hi,
here are patches targetted for 2.6.36. All patches needed for that patchset are
already part of your staging-next tree.
All patches are cleanup patches and no new feature is added.
thanks,
Sven
Antonio Quartulli (1):
Staging: batman-adv: Convert names from Java to C style
Linus Lüssing (1):
Staging: batman-adv: Avoid rounding issues for local hna timeout
Marek Lindner (4):
Staging: batman-adv: replace manual calculation by msecs_to_jiffies() for better readability
Staging: batman-adv: Add sysfs abi documentation about bonding
Staging: batman-adv: adapting source version to revised versioning scheme
Staging: batman-adv: fix early debugfs deinitialization
Simon Wunderlich (1):
Staging: batman-adv: Lower resolution for timeouts
Sven Eckelmann (1):
Staging: batman-adv: Add include guards to all header files
drivers/staging/batman-adv/aggregation.h | 5 +++++
drivers/staging/batman-adv/bat_debugfs.h | 6 +++---
drivers/staging/batman-adv/bat_sysfs.h | 6 +++---
drivers/staging/batman-adv/bitarray.h | 4 ++++
drivers/staging/batman-adv/hard-interface.h | 5 +++++
drivers/staging/batman-adv/hash.h | 8 +++++---
drivers/staging/batman-adv/icmp_socket.h | 5 +++++
drivers/staging/batman-adv/main.c | 4 ++--
drivers/staging/batman-adv/main.h | 13 +++++++++----
drivers/staging/batman-adv/originator.c | 6 ++----
drivers/staging/batman-adv/originator.h | 5 +++++
drivers/staging/batman-adv/packet.h | 5 +++++
drivers/staging/batman-adv/ring_buffer.h | 5 +++++
drivers/staging/batman-adv/routing.c | 6 +++---
drivers/staging/batman-adv/routing.h | 5 +++++
drivers/staging/batman-adv/send.c | 14 +++++++-------
drivers/staging/batman-adv/send.h | 5 +++++
drivers/staging/batman-adv/soft-interface.c | 6 +++---
drivers/staging/batman-adv/soft-interface.h | 7 ++++++-
drivers/staging/batman-adv/sysfs-class-net-mesh | 8 ++++++++
drivers/staging/batman-adv/translation-table.c | 3 +--
drivers/staging/batman-adv/translation-table.h | 5 +++++
drivers/staging/batman-adv/types.h | 6 +++---
drivers/staging/batman-adv/vis.c | 14 +++++++-------
drivers/staging/batman-adv/vis.h | 7 ++++++-
25 files changed, 117 insertions(+), 46 deletions(-)
12 years, 6 months
[B.A.T.M.A.N.] batman adv unicast fragmentation
by Andreas Langer
Hi,
things that changed since the last patch:
- with fragmentation enabled the mtu of batX is always ETH_DATA_LEN
- fragment if mtu of the outgoing interface is smaller the needed size
- add a new packet type for fragmentation
- new recv function for fragmented packets
- new route unicast packet function to share routing code
- increase compat number to 12
regards,
andreas
12 years, 7 months
[B.A.T.M.A.N.] [PATCH] batman-adv: Add last-seen in originator table
by Linus Lüssing
From: mesh-node <mesh-node(a)mesh-node1.(none)>
Right now, there is no easy/intuitive way to find out whether a node
might have vanished. This commit adds the time when a node was last seen
to the originator table output, so that a common user is able to tell
whether a node might have gone without having to wait PURGE_TIMEOUT
seconds until that node gets "garbe-collected".
Signed-off-by: Linus Lüssing <linus.luessing(a)web.de>
---
originator.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/originator.c b/originator.c
index c28c4f5..5343ab2 100644
--- a/originator.c
+++ b/originator.c
@@ -296,6 +296,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
struct orig_node *orig_node;
struct neigh_node *neigh_node;
int batman_count = 0;
+ int last_seen_secs;
+ int last_seen_msecs;
unsigned long flags;
char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];
@@ -312,12 +314,13 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
}
rcu_read_lock();
- seq_printf(seq, " %-14s (%s/%i) %17s [%10s]: %20s "
- "... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
- "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
- "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
+ seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
+ SOURCE_VERSION, REVISION_VERSION_STR,
bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
net_dev->name);
+ seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
+ "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
+ "outgoingIF", "Potential nexthops");
rcu_read_unlock();
spin_lock_irqsave(&orig_hash_lock, flags);
@@ -334,9 +337,14 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
addr_to_string(orig_str, orig_node->orig);
addr_to_string(router_str, orig_node->router->addr);
-
- seq_printf(seq, "%-17s (%3i) %17s [%10s]:",
- orig_str, orig_node->router->tq_avg, router_str,
+ last_seen_secs = jiffies_to_msecs(jiffies -
+ orig_node->last_valid) / 1000;
+ last_seen_msecs = jiffies_to_msecs(jiffies -
+ orig_node->last_valid) % 1000;
+
+ seq_printf(seq, "%-17s %4i.%03is (%3i) %17s [%10s]:",
+ orig_str, last_seen_secs, last_seen_msecs,
+ orig_node->router->tq_avg, router_str,
orig_node->router->if_incoming->dev);
list_for_each_entry(neigh_node, &orig_node->neigh_list, list) {
--
1.7.1
12 years, 7 months
[B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators
by Linus Lüssing
This commit introduces the -t switch for originator table output. It
makes use of the new last-seen field in batman-adv, the user can specify
a timeout interval in seconds (with 3 digits precision before and after
a possible dot) if he/she considers a node as dead after this time.
(of course this is just influencing the displaying and not actually
declearing a node as dead for routing decisions)
Signed-off-by: Linus Lüssing <linus.luessing(a)web.de>
---
batctl/debug.c | 35 ++++++++++++++++++++++++++++++++---
batctl/functions.c | 14 +++++++++++++-
batctl/functions.h | 3 ++-
batctl/sys.c | 8 ++++----
4 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/batctl/debug.c b/batctl/debug.c
index c57355a..04d2ebc 100644
--- a/batctl/debug.c
+++ b/batctl/debug.c
@@ -40,6 +40,7 @@ void originators_usage(void)
printf(" \t -h print this help\n");
printf(" \t -n don't replace mac addresses with bat-host names\n");
printf(" \t -w watch mode - refresh the originator table continuously\n");
+ printf(" \t -t timeout interval - don't print originators not seen for xxx.xxx seconds \n");
}
void trans_local_usage(void)
@@ -74,8 +75,13 @@ int handle_debug_table(int argc, char **argv, char *file_path, void table_usage(
int optchar, read_opt = USE_BAT_HOSTS;
char full_path[MAX_PATH+1];
char *debugfs_mnt;
+ int orig_timeout_secs;
+ int orig_timeout_msecs;
+ char msecs_buff[4];
+ memset(msecs_buff, '0', sizeof(msecs_buff));
+ msecs_buff[3] = '\0';
- while ((optchar = getopt(argc, argv, "hnw")) != -1) {
+ while ((optchar = getopt(argc, argv, "hnwt:")) != -1) {
switch (optchar) {
case 'h':
table_usage();
@@ -86,6 +92,29 @@ int handle_debug_table(int argc, char **argv, char *file_path, void table_usage(
case 'w':
read_opt |= CLR_CONT_READ;
break;
+ case 't':
+ if (table_usage != originators_usage) {
+ table_usage();
+ return EXIT_FAILURE;
+ }
+
+ read_opt |= NO_OLD_ORIGS;
+ if (sscanf(optarg, "%3d.%3s", &orig_timeout_secs,
+ msecs_buff) == 2) {
+ if (strlen(msecs_buff) < 3)
+ msecs_buff[strlen(msecs_buff)] = '0';
+ sscanf(msecs_buff, "%d", &orig_timeout_msecs);
+ orig_timeout_msecs += 1000 * orig_timeout_secs;
+ }
+ else if (sscanf(optarg, "%3d", &orig_timeout_secs) == 1) { ; }
+ else {
+ printf("Error - provided argument of -t is not a number\n");
+ return EXIT_FAILURE;
+ }
+ break;
+ case '?':
+ if (optopt == 't' && table_usage == originators_usage)
+ return EXIT_FAILURE;
default:
table_usage();
return EXIT_FAILURE;
@@ -99,7 +128,7 @@ int handle_debug_table(int argc, char **argv, char *file_path, void table_usage(
}
debugfs_make_path(DEBUG_BATIF_PATH "/", full_path, sizeof(full_path));
- return read_file(full_path, file_path, read_opt);
+ return read_file(full_path, file_path, read_opt, orig_timeout_msecs);
}
static void log_usage(void)
@@ -137,7 +166,7 @@ int log_print(int argc, char **argv)
}
debugfs_make_path(DEBUG_BATIF_PATH "/", full_path, sizeof(full_path));
- res = read_file(full_path, DEBUG_LOG, read_opt);
+ res = read_file(full_path, DEBUG_LOG, read_opt, 0);
if ((res != EXIT_SUCCESS) && (errno == ENOENT))
printf("To read the debug log you need to compile the module with debugging enabled (see the README)\n");
diff --git a/batctl/functions.c b/batctl/functions.c
index 9b697b3..272e08b 100644
--- a/batctl/functions.c
+++ b/batctl/functions.c
@@ -117,11 +117,13 @@ static int check_sys_dir(char *dir)
return EXIT_FAILURE;
}
-int read_file(char *dir, char *fname, int read_opt)
+int read_file(char *dir, char *fname, int read_opt, int orig_timeout)
{
struct ether_addr *mac_addr;
struct bat_host *bat_host;
int res = EXIT_FAILURE;
+ int last_seen_secs;
+ int last_seen_msecs;
char full_path[500], *buff_ptr, *space_ptr, extra_char;
size_t len = 0;
ssize_t read;
@@ -157,6 +159,16 @@ read:
if (read_opt & USE_READ_BUFF)
break;
+ /* skip timed out originators */
+ if (read_opt & NO_OLD_ORIGS) {
+ if (sscanf(line_ptr, "%*s %3d.%3d",
+ &last_seen_secs, &last_seen_msecs) == 2) {
+ last_seen_msecs += 1000 * last_seen_secs;
+ if (last_seen_msecs > orig_timeout)
+ continue;
+ }
+ }
+
if (!(read_opt & USE_BAT_HOSTS)) {
printf("%s", line_ptr);
continue;
diff --git a/batctl/functions.h b/batctl/functions.h
index 885df34..10903e0 100644
--- a/batctl/functions.h
+++ b/batctl/functions.h
@@ -33,7 +33,7 @@ double end_timer(void);
char *ether_ntoa_long(const struct ether_addr *addr);
char *get_name_by_macaddr(struct ether_addr *mac_addr, int read_opt);
char *get_name_by_macstr(char *mac_str, int read_opt);
-int read_file(char *dir, char *path, int read_opt);
+int read_file(char *dir, char *path, int read_opt, int orig_timeout);
int write_file(char *dir, char *fname, char *arg1, char *arg2);
extern char *line_ptr;
@@ -46,4 +46,5 @@ enum {
LOG_MODE = 0x08,
USE_READ_BUFF = 0x10,
SILENCE_ERRORS = 0x20,
+ NO_OLD_ORIGS = 0x40,
};
diff --git a/batctl/sys.c b/batctl/sys.c
index 321dfc9..7135841 100644
--- a/batctl/sys.c
+++ b/batctl/sys.c
@@ -79,7 +79,7 @@ static int print_interfaces(void)
while ((iface_dir = readdir(iface_base_dir)) != NULL) {
snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name);
- res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS);
+ res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS, 0);
if (res != EXIT_SUCCESS)
continue;
@@ -93,7 +93,7 @@ static int print_interfaces(void)
line_ptr = NULL;
snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name);
- res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS);
+ res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS, 0);
if (res != EXIT_SUCCESS) {
printf("<error reading status>\n");
continue;
@@ -196,7 +196,7 @@ int handle_loglevel(int argc, char **argv)
goto out;
}
- res = read_file(SYS_BATIF_PATH, SYS_LOG_LEVEL, SINGLE_READ | USE_READ_BUFF);
+ res = read_file(SYS_BATIF_PATH, SYS_LOG_LEVEL, SINGLE_READ | USE_READ_BUFF, 0);
if (res != EXIT_SUCCESS)
goto out;
@@ -271,7 +271,7 @@ int handle_sys_setting(int argc, char **argv,
}
if (argc == 1)
- return read_file(SYS_BATIF_PATH, file_path, SINGLE_READ);
+ return read_file(SYS_BATIF_PATH, file_path, SINGLE_READ, 0);
if (!sysfs_param)
goto write_file;
--
1.5.6.5
12 years, 7 months
[B.A.T.M.A.N.] Multicast video over 2 node mesh
by Nathan Wharton
I am having problems getting multicast video over my 2 node mesh. I
am building under openwrt and the version is 0.3.0-alpha rv1715.
I have a lan bridge on each side. If I directly add ath0 to the lan
bridge the video works fine. But since I want to mesh, I put ath0
into bat0 instead, and then I put bat0 into the bridge. This works
for all my traffic that put across it so far except the multicast
video. A tcpdump comparison of both sides shows that after about 32
packets data starts getting dropped. The video is about 1Mbs.
Given this thousand foot view of the problem, is there something
obvious I might be missing? I've set the mtu on ath0 to 1524.
Everything else seems to work fine, including copying a file over the
mesh setup that is 20MB at a speed of 578.9KB/s and the md5sum was
right.
12 years, 7 months
[B.A.T.M.A.N.] PATCH fragmentation of unicast packets
by Andreas Langer
If fragmentation is on, the mtu of the bat interface will be set to 1500 and bigger packets will be
splitted in two parts. The receiver stores the packets in a buffer list for each originator, which
will be created with the first fragmented packet. For this handling i added a sequenznumber and the
orig address to the unicast_packet definition.
regards,
Andreas
Signed-off-by: Andreas Langer <an.langer at gmx.de>
---
batman-adv/Makefile.kbuild | 2 +-
batman-adv/bat_sysfs.c | 55 ++++++++++++++++
batman-adv/fragmentation.c | 148 +++++++++++++++++++++++++++++++++++++++++++
batman-adv/fragmentation.h | 34 ++++++++++
batman-adv/hard-interface.c | 15 ++++-
batman-adv/originator.c | 13 ++++
batman-adv/packet.h | 7 ++
batman-adv/routing.c | 35 ++++++++++
batman-adv/soft-interface.c | 88 ++++++++++++++++++++++----
batman-adv/types.h | 9 +++
10 files changed, 390 insertions(+), 16 deletions(-)
create mode 100644 batman-adv/fragmentation.c
create mode 100644 batman-adv/fragmentation.h
diff --git a/batman-adv/Makefile.kbuild b/batman-adv/Makefile.kbuild
index 762ee4e..3e99ba5 100644
--- a/batman-adv/Makefile.kbuild
+++ b/batman-adv/Makefile.kbuild
@@ -32,4 +32,4 @@ EXTRA_CFLAGS += -DREVISION_VERSION=\"$(REVISION)\"
endif
obj-m += batman-adv.o
-batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o
icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o
aggregation.o originator.o gateway_common.o gateway_client.o $(shell [ "2" -eq "$(VERSION)" ] 2>&-
&& [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo bat_printk.o)
+batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o
icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o
aggregation.o originator.o gateway_common.o gateway_client.o fragmentation.o $(shell [ "2" -eq
"$(VERSION)" ] 2>&- && [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo
bat_printk.o) diff --git a/batman-adv/bat_sysfs.c b/batman-adv/bat_sysfs.c index 68ce453..74d388a
100644 --- a/batman-adv/bat_sysfs.c +++ b/batman-adv/bat_sysfs.c @@ -136,6 +136,58 @@ static
ssize_t store_bond(struct kobject *kobj, struct attribute *attr, return count; } +static ssize_t
show_frag(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int frag_status = atomic_read(&bat_priv->frag_enabled);
+
+ return sprintf(buff, "%s\n",
+ frag_status == 0 ? "disabled" : "enabled");
+}
+
+static ssize_t store_frag(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ int frag_enabled_tmp = -1;
+
+ if (((count == 2) && (buff[0] == '1')) ||
+ (strncmp(buff, "enable", 6) == 0))
+ frag_enabled_tmp = 1;
+
+ if (((count == 2) && (buff[0] == '0')) ||
+ (strncmp(buff, "disable", 7) == 0))
+ frag_enabled_tmp = 0;
+
+ if (frag_enabled_tmp < 0) {
+ if (buff[count - 1] == '\n')
+ buff[count - 1] = '\0';
+
+ printk(KERN_ERR "batman-adv:Invalid parameter for 'frag' setting on mesh %s
received: %s\n",
+ net_dev->name, buff);
+ return -EINVAL;
+ }
+
+ if (atomic_read(&bat_priv->frag_enabled) == frag_enabled_tmp)
+ return count;
+
+ printk(KERN_INFO "batman-adv:Changing frag from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->frag_enabled) == 1 ?
+ "enabled" : "disabled",
+ frag_enabled_tmp == 1 ? "enabled" : "disabled",
+ net_dev->name);
+
+ atomic_set(&bat_priv->frag_enabled, (unsigned)frag_enabled_tmp);
+
+ update_min_mtu();
+
+ return count;
+}
+
static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff)
{
@@ -279,6 +331,7 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,
static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR,
show_aggr_ogms, store_aggr_ogms);
static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond);
+static BAT_ATTR(fragmentation, S_IRUGO | S_IWUSR, show_frag, store_frag);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR,
@@ -287,6 +340,7 @@ static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR,
static struct bat_attribute *mesh_attrs[] = {
&bat_attr_aggregated_ogms,
&bat_attr_bonding,
+ &bat_attr_fragmentation,
&bat_attr_vis_mode,
&bat_attr_gw_mode,
&bat_attr_orig_interval,
@@ -304,6 +358,7 @@ int sysfs_add_meshif(struct net_device *dev)
routine as soon as we have it */
atomic_set(&bat_priv->aggregation_enabled, 1);
atomic_set(&bat_priv->bonding_enabled, 0);
+ atomic_set(&bat_priv->frag_enabled, 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_class, 0);
diff --git a/batman-adv/fragmentation.c b/batman-adv/fragmentation.c
new file mode 100644
index 0000000..a0513da
--- /dev/null
+++ b/batman-adv/fragmentation.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
+ *
+ * Andreas Langer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+#include "main.h"
+#include "fragmentation.h"
+
+
+struct sk_buff *merge_frag_packet(struct list_head *head,
+ struct frag_packet_list_entry *tfp,
+ struct sk_buff *skb) {
+
+ struct unicast_packet *up = (struct unicast_packet *) skb->data;
+ struct sk_buff *tmp_skb;
+
+ /* skb is alsways the first packet,tmp_skb always the second */
+ if (up->flags & UNI_FRAG_HEAD) {
+ tmp_skb = tfp->skb;
+ } else {
+ tmp_skb = skb;
+ skb = tfp->skb;
+ }
+
+ /* move free entry to end */
+ tfp->skb = NULL;
+ tfp->seqno = 0;
+ list_move_tail(&tfp->list, head);
+
+ skb_pull(tmp_skb, sizeof(struct unicast_packet));
+ pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC);
+ memcpy(skb_put(skb, tmp_skb->len), tmp_skb->data, tmp_skb->len);
+ kfree_skb(tmp_skb);
+ return skb;
+}
+
+void create_frag_entry(struct list_head *head, struct sk_buff *skb)
+{
+ struct frag_packet_list_entry *tfp;
+ struct unicast_packet *up = (struct unicast_packet *) skb->data;
+
+ /* free and oldest packets stand at the end */
+ tfp = list_entry((head)->prev, typeof(*tfp), list);
+
+ if (tfp->skb)
+ kfree_skb(tfp->skb);
+
+ tfp->seqno = ntohs(up->seqno);
+ tfp->skb = skb;
+ list_move(&tfp->list, head);
+ return;
+}
+
+void create_frag_buffer(struct list_head *head)
+{
+ int i;
+ struct frag_packet_list_entry *tfp;
+
+ for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
+ tfp = kmalloc(sizeof(struct frag_packet_list_entry),
+ GFP_ATOMIC);
+ tfp->skb = NULL;
+ tfp->seqno = 0;
+ INIT_LIST_HEAD(&tfp->list);
+ list_add(&tfp->list, head);
+ }
+
+ return;
+}
+
+struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
+ struct unicast_packet *up) {
+
+ struct frag_packet_list_entry *tfp;
+ struct unicast_packet *tmp_up = NULL;
+ uint16_t tmp_seq;
+
+ list_for_each_entry(tfp, head, list) {
+
+ if (tfp->seqno == ntohs(up->seqno))
+ goto mov_tail;
+
+ if (tfp->skb)
+ tmp_up = (struct unicast_packet *) tfp->skb->data;
+
+ if (up->flags & UNI_FRAG_HEAD) {
+ tmp_seq = ntohs(up->seqno) ==
+ FRAG_MAX_SEQ ? 1 : ntohs(up->seqno)+1;
+
+ if (tfp->seqno == tmp_seq) {
+ if (tmp_up->flags & UNI_FRAG_HEAD)
+ goto mov_tail;
+ else
+ goto ret_tfp;
+ }
+ } else {
+ tmp_seq = ntohs(up->seqno) ==
+ 1 ? FRAG_MAX_SEQ : ntohs(up->seqno)-1;
+
+ if (tfp->seqno == tmp_seq) {
+ if (tmp_up->flags & UNI_FRAG_HEAD)
+ goto ret_tfp;
+ else
+ goto mov_tail;
+ }
+ }
+ }
+ goto ret_null;
+
+ret_tfp:
+ return tfp;
+mov_tail:
+ list_move_tail(&tfp->list, head);
+ret_null:
+ return NULL;
+}
+
+void frag_list_free(struct list_head *head)
+{
+
+ struct frag_packet_list_entry *pf, *tmp_pf;
+
+ if (!list_empty(head)) {
+
+ list_for_each_entry_safe(pf, tmp_pf, head, list) {
+ if (pf->skb)
+ kfree_skb(pf->skb);
+ list_del(&pf->list);
+ kfree(pf);
+ }
+ }
+ return;
+}
diff --git a/batman-adv/fragmentation.h b/batman-adv/fragmentation.h
new file mode 100644
index 0000000..36afb7b
--- /dev/null
+++ b/batman-adv/fragmentation.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
+ *
+ * Andreas Langer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#define FRAG_TIMEOUT 60000 /* purge frag list entrys after time in ms */
+#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
+#define FRAG_MAX_SEQ 65535
+
+extern struct sk_buff *merge_frag_packet(struct list_head *head,
+ struct frag_packet_list_entry *tfp,
+ struct sk_buff *skb);
+
+extern void create_frag_entry(struct list_head *head, struct sk_buff *skb);
+extern void create_frag_buffer(struct list_head *head);
+extern struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
+ struct unicast_packet *up);
+extern void frag_list_free(struct list_head *head);
diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index 0773420..7f07baa 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -168,13 +168,20 @@ int hardif_min_mtu(void)
/* allow big frames if all devices are capable to do so
* (have MTU > 1500 + BAT_HEADER_LEN) */
int min_mtu = ETH_DATA_LEN;
+ /* FIXME: each batman_if will be attached to a softif */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
rcu_read_lock();
list_for_each_entry_rcu(batman_if, &if_list, list) {
if ((batman_if->if_status == IF_ACTIVE) ||
- (batman_if->if_status == IF_TO_BE_ACTIVATED))
- min_mtu = MIN(batman_if->net_dev->mtu - BAT_HEADER_LEN,
- min_mtu);
+ (batman_if->if_status == IF_TO_BE_ACTIVATED)) {
+
+ if (atomic_read(&bat_priv->frag_enabled))
+ min_mtu = MIN(batman_if->net_dev->mtu, min_mtu);
+ else
+ min_mtu = MIN(batman_if->net_dev->mtu -
+ BAT_HEADER_LEN, min_mtu);
+ }
}
rcu_read_unlock();
@@ -189,6 +196,7 @@ void update_min_mtu(void)
min_mtu = hardif_min_mtu();
if (soft_device->mtu != min_mtu)
soft_device->mtu = min_mtu;
+
}
static void hardif_activate_interface(struct bat_priv *bat_priv,
@@ -268,6 +276,7 @@ int hardif_enable_interface(struct batman_if *batman_if)
orig_hash_add_if(batman_if, bat_priv->num_ifaces);
atomic_set(&batman_if->seqno, 1);
+ atomic_set(&batman_if->frag_seqno, 1);
printk(KERN_INFO "batman-adv:Adding interface: %s\n", batman_if->dev);
if (hardif_is_iface_up(batman_if))
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index d276afd..87c3dc9 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -29,6 +29,7 @@
#include "compat.h"
#include "gateway_client.h"
#include "hard-interface.h"
+#include "fragmentation.h"
static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
@@ -58,6 +59,7 @@ err:
return 0;
}
+
struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming)
@@ -94,6 +96,7 @@ static void free_orig_node(void *data)
kfree(neigh_node);
}
+ frag_list_free(&orig_node->frag_list);
hna_global_del_orig(orig_node, "originator timed out");
kfree(orig_node->bcast_own);
@@ -155,6 +158,10 @@ struct orig_node *get_orig_node(uint8_t *addr)
size = bat_priv->num_ifaces * sizeof(uint8_t);
orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
+
+ INIT_LIST_HEAD(&orig_node->frag_list);
+ orig_node->last_frag_packet = 0;
+
if (!orig_node->bcast_own_sum)
goto free_bcast_own;
@@ -269,6 +276,12 @@ void purge_orig(struct work_struct *work)
hash_remove_bucket(orig_hash, &hashit);
free_orig_node(orig_node);
}
+
+ if (time_after(jiffies, (orig_node->last_frag_packet +
+ msecs_to_jiffies(FRAG_TIMEOUT))))
+ frag_list_free(&orig_node->frag_list);
+
+
}
spin_unlock_irqrestore(&orig_hash_lock, flags);
diff --git a/batman-adv/packet.h b/batman-adv/packet.h
index e94960d..65c1771 100644
--- a/batman-adv/packet.h
+++ b/batman-adv/packet.h
@@ -47,6 +47,10 @@
#define VIS_TYPE_SERVER_SYNC 0
#define VIS_TYPE_CLIENT_UPDATE 1
+/* fragmentation defines */
+#define UNI_IS_FRAG 0x01
+#define UNI_FRAG_HEAD 0x02
+
struct batman_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
@@ -95,7 +99,10 @@ struct unicast_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t dest[6];
+ uint8_t orig[6];
uint8_t ttl;
+ uint8_t flags;
+ uint16_t seqno;
} __attribute__((packed));
struct bcast_packet {
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index a37c288..5de6197 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -34,6 +34,7 @@
#include "aggregation.h"
#include "compat.h"
#include "gateway_client.h"
+#include "fragmentation.h"
static DECLARE_WAIT_QUEUE_HEAD(thread_wait);
@@ -1100,6 +1101,7 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
struct ethhdr *ethhdr;
struct batman_if *batman_if;
struct sk_buff *skb_old;
+ struct frag_packet_list_entry *tmp_frag_entry;
uint8_t dstaddr[ETH_ALEN];
int hdr_size = sizeof(struct unicast_packet);
unsigned long flags;
@@ -1126,6 +1128,39 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
/* packet for me */
if (is_my_mac(unicast_packet->dest)) {
+
+ /* check if unicast packet fragmented */
+
+ if (unicast_packet->flags & UNI_IS_FRAG) {
+
+ /* TODO: spinlock ??? */
+ orig_node = ((struct orig_node *)
+ hash_find(orig_hash, unicast_packet->orig));
+
+ if (!orig_node) {
+ printk(KERN_WARNING
+ "frag: couldn't find orig node\n");
+ return NET_RX_DROP;
+ }
+
+ orig_node->last_frag_packet = jiffies;
+
+ if (list_empty(&orig_node->frag_list))
+ create_frag_buffer(&orig_node->frag_list);
+
+ tmp_frag_entry =
+ search_frag_packet(&orig_node->frag_list,
+ unicast_packet);
+
+ if (!tmp_frag_entry) {
+ create_frag_entry(&orig_node->frag_list, skb);
+ return NET_RX_SUCCESS;
+ }
+
+ skb = merge_frag_packet(&orig_node->frag_list,
+ tmp_frag_entry, skb);
+ }
+
interface_rx(skb, hdr_size);
return NET_RX_SUCCESS;
}
diff --git a/batman-adv/soft-interface.c b/batman-adv/soft-interface.c
index 0d89597..96cdba9 100644
--- a/batman-adv/soft-interface.c
+++ b/batman-adv/soft-interface.c
@@ -32,6 +32,7 @@
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include "compat.h"
+#include "fragmentation.h"
static uint32_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid
* broadcast storms */
@@ -130,6 +131,7 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu)
int interface_tx(struct sk_buff *skb, struct net_device *dev)
{
struct unicast_packet *unicast_packet;
+ struct unicast_packet *unicast_packet_frag;
struct bcast_packet *bcast_packet;
struct orig_node *orig_node;
struct neigh_node *router;
@@ -137,9 +139,11 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
struct bat_priv *priv = netdev_priv(dev);
struct batman_if *batman_if;
struct bat_priv *bat_priv;
+ struct sk_buff *frag_skb;
uint8_t dstaddr[6];
int data_len = skb->len;
unsigned long flags;
+ int hdr_len;
bool bcast_dst = false, do_bcast = true;
if (atomic_read(&module_state) != MODULE_ACTIVE)
@@ -216,20 +220,80 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
if (batman_if->if_status != IF_ACTIVE)
goto dropped;
- if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
- goto dropped;
+ if (atomic_read(&bat_priv->frag_enabled) &&
+ data_len > dev->mtu) {
+
+ hdr_len = sizeof(struct unicast_packet);
+
+ frag_skb = dev_alloc_skb(data_len / 2 + hdr_len + 1);
+ skb_split(skb, frag_skb, data_len/2);
+
+ if (!(my_skb_push(frag_skb, hdr_len) >= 0 &&
+ my_skb_push(skb, hdr_len) >= 0)) {
+
+ kfree_skb(frag_skb);
+ goto dropped;
+ }
+
+ unicast_packet = (struct unicast_packet *)skb->data;
+ unicast_packet_frag =
+ (struct unicast_packet *)frag_skb->data;
+
+ unicast_packet->version = COMPAT_VERSION;
+ unicast_packet->packet_type = BAT_UNICAST;
+ unicast_packet->ttl = TTL;
+ unicast_packet->flags |= UNI_IS_FRAG;
+ memcpy(unicast_packet->orig,
+ batman_if->net_dev->dev_addr, ETH_ALEN);
+ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
+
+ memcpy(unicast_packet_frag, unicast_packet,
+ sizeof(struct unicast_packet));
+
+ unicast_packet->flags |= UNI_FRAG_HEAD;
+ unicast_packet_frag->flags &= ~UNI_FRAG_HEAD;
- unicast_packet = (struct unicast_packet *)skb->data;
+ /* no zero at seqno */
+ if (atomic_read(&batman_if->frag_seqno) == FRAG_MAX_SEQ)
+ atomic_set(&batman_if->frag_seqno, 0);
- unicast_packet->version = COMPAT_VERSION;
- /* batman packet type: unicast */
- unicast_packet->packet_type = BAT_UNICAST;
- /* set unicast ttl */
- unicast_packet->ttl = TTL;
- /* copy the destination for faster routing */
- memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
+ unicast_packet->seqno =
+ htons((uint16_t)atomic_inc_return(
+ &batman_if->frag_seqno));
- send_skb_packet(skb, batman_if, dstaddr);
+ if (atomic_read(&batman_if->frag_seqno) == FRAG_MAX_SEQ)
+ atomic_set(&batman_if->frag_seqno, 0);
+
+ unicast_packet_frag->seqno =
+ htons((uint16_t)atomic_inc_return(
+ &batman_if->frag_seqno));
+
+ send_skb_packet(skb, batman_if, dstaddr);
+ send_skb_packet(frag_skb, batman_if, dstaddr);
+
+ } else {
+
+ if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
+ goto dropped;
+
+ unicast_packet = (struct unicast_packet *)skb->data;
+
+ unicast_packet->version = COMPAT_VERSION;
+ /* batman packet type: unicast */
+ unicast_packet->packet_type = BAT_UNICAST;
+ /* set unicast ttl */
+ unicast_packet->ttl = TTL;
+ /* set fragmentation */
+ unicast_packet->flags &= ~UNI_IS_FRAG;
+ /* copy the destination for faster routing */
+ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
+ memcpy(unicast_packet->orig,
+ batman_if->net_dev->dev_addr, ETH_ALEN);
+
+ unicast_packet->seqno = 0;
+
+ send_skb_packet(skb, batman_if, dstaddr);
+ }
}
priv->stats.tx_packets++;
@@ -370,4 +434,4 @@ static u32 bat_get_rx_csum(struct net_device *dev)
static int bat_set_rx_csum(struct net_device *dev, u32 data)
{
return -EOPNOTSUPP;
-}
+}
\ No newline at end of file
diff --git a/batman-adv/types.h b/batman-adv/types.h
index 1daebed..0539515 100644
--- a/batman-adv/types.h
+++ b/batman-adv/types.h
@@ -43,6 +43,7 @@ struct batman_if {
char addr_str[ETH_STR_LEN];
struct net_device *net_dev;
atomic_t seqno;
+ atomic_t frag_seqno;
unsigned char *packet_buff;
int packet_len;
struct kobject *hardif_obj;
@@ -84,6 +85,8 @@ struct orig_node {
TYPE_OF_WORD bcast_bits[NUM_WORDS];
uint32_t last_bcast_seqno;
struct list_head neigh_list;
+ struct list_head frag_list;
+ unsigned long last_frag_packet;
struct {
uint8_t candidates;
struct neigh_node *selected;
@@ -120,6 +123,7 @@ struct bat_priv {
struct net_device_stats stats;
atomic_t aggregation_enabled;
atomic_t bonding_enabled;
+ atomic_t frag_enabled;
atomic_t vis_mode;
atomic_t gw_mode;
atomic_t gw_class;
@@ -184,4 +188,9 @@ struct if_list_entry {
struct hlist_node list;
};
+struct frag_packet_list_entry {
+ struct list_head list;
+ uint16_t seqno;
+ struct sk_buff *skb;
+};
#endif /* _NET_BATMAN_ADV_TYPES_H_ */
--
1.7.0.4
12 years, 7 months
[B.A.T.M.A.N.] [PATCH] batman-adv: Move printk to pr_* macros
by Sven Eckelmann
Reported-by: Joe Perches <joe(a)perches.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
---
batman-adv/bat_debugfs.c | 7 ++--
batman-adv/bat_sysfs.c | 74 +++++++++++++++++++--------------------
batman-adv/compat.h | 13 +++++++
batman-adv/gateway_common.c | 30 ++++++----------
batman-adv/hard-interface.c | 29 ++++++----------
batman-adv/icmp_socket.c | 5 +--
batman-adv/main.c | 15 +++-----
batman-adv/main.h | 2 +
batman-adv/originator.c | 15 +++-----
batman-adv/routing.c | 14 +++----
batman-adv/send.c | 10 ++---
batman-adv/translation-table.c | 6 +--
batman-adv/vis.c | 9 ++---
13 files changed, 106 insertions(+), 123 deletions(-)
diff --git a/batman-adv/bat_debugfs.c b/batman-adv/bat_debugfs.c
index 4f99c5c..48521d9 100644
--- a/batman-adv/bat_debugfs.c
+++ b/batman-adv/bat_debugfs.c
@@ -19,9 +19,10 @@
*
*/
+#include "main.h"
+
#include <linux/debugfs.h>
-#include "main.h"
#include "bat_debugfs.h"
#include "translation-table.h"
#include "originator.h"
@@ -317,8 +318,8 @@ int debugfs_add_meshif(struct net_device *dev)
bat_priv->debug_dir,
dev, &(*bat_debug)->fops);
if (!file) {
- printk(KERN_ERR "batman-adv:Can't add debugfs file: "
- "%s/%s\n", dev->name, ((*bat_debug)->attr).name);
+ pr_err("Can't add debugfs file: %s/%s\n", dev->name,
+ ((*bat_debug)->attr).name);
goto rem_attr;
}
}
diff --git a/batman-adv/bat_sysfs.c b/batman-adv/bat_sysfs.c
index 68ce453..b81572a 100644
--- a/batman-adv/bat_sysfs.c
+++ b/batman-adv/bat_sysfs.c
@@ -70,18 +70,18 @@ static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
- printk(KERN_INFO "batman-adv:Invalid parameter for 'aggregate OGM' setting on mesh %s received: %s\n",
- net_dev->name, buff);
+ pr_info("Invalid parameter for 'aggregate OGM' setting on mesh "
+ "%s received: %s\n", net_dev->name, buff);
return -EINVAL;
}
if (atomic_read(&bat_priv->aggregation_enabled) == aggr_tmp)
return count;
- printk(KERN_INFO "batman-adv:Changing aggregation from: %s to: %s on mesh: %s\n",
- atomic_read(&bat_priv->aggregation_enabled) == 1 ?
- "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled",
- net_dev->name);
+ pr_info("Changing aggregation from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->aggregation_enabled) == 1 ?
+ "enabled" : "disabled", aggr_tmp == 1 ? "enabled" : "disabled",
+ net_dev->name);
atomic_set(&bat_priv->aggregation_enabled, (unsigned)aggr_tmp);
return count;
@@ -118,19 +118,19 @@ static ssize_t store_bond(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
- printk(KERN_ERR "batman-adv:Invalid parameter for 'bonding' setting on mesh %s received: %s\n",
- net_dev->name, buff);
+ pr_err("Invalid parameter for 'bonding' setting on mesh %s "
+ "received: %s\n", net_dev->name, buff);
return -EINVAL;
}
if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp)
return count;
- printk(KERN_INFO "batman-adv:Changing bonding from: %s to: %s on mesh: %s\n",
- atomic_read(&bat_priv->bonding_enabled) == 1 ?
- "enabled" : "disabled",
- bonding_enabled_tmp == 1 ? "enabled" : "disabled",
- net_dev->name);
+ pr_info("Changing bonding from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->bonding_enabled) == 1 ?
+ "enabled" : "disabled",
+ bonding_enabled_tmp == 1 ? "enabled" : "disabled",
+ net_dev->name);
atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp);
return count;
@@ -172,18 +172,18 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
- printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
- net_dev->name, buff);
+ pr_info("Invalid parameter for 'vis mode' setting on mesh %s "
+ "received: %s\n", net_dev->name, buff);
return -EINVAL;
}
if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
return count;
- printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n",
- atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
- "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
- "client" : "server", net_dev->name);
+ pr_info("Changing vis mode from: %s to: %s on mesh: %s\n",
+ atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
+ "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
+ "client" : "server", net_dev->name);
atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
return count;
@@ -254,23 +254,23 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr,
ret = strict_strtoul(buff, 10, &orig_interval_tmp);
if (ret) {
- printk(KERN_INFO "batman-adv:Invalid parameter for 'orig_interval' setting on mesh %s received: %s\n",
- net_dev->name, buff);
+ pr_info("Invalid parameter for 'orig_interval' setting on mesh "
+ "%s received: %s\n", net_dev->name, buff);
return -EINVAL;
}
if (orig_interval_tmp < JITTER * 2) {
- printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n",
- orig_interval_tmp, JITTER * 2);
+ pr_info("New originator interval too small: %li (min: %i)\n",
+ orig_interval_tmp, JITTER * 2);
return -EINVAL;
}
if (atomic_read(&bat_priv->orig_interval) == orig_interval_tmp)
return count;
- printk(KERN_INFO "batman-adv:Changing originator interval from: %i to: %li on mesh: %s\n",
- atomic_read(&bat_priv->orig_interval),
- orig_interval_tmp, net_dev->name);
+ pr_info("Changing originator interval from: %i to: %li on mesh: %s\n",
+ atomic_read(&bat_priv->orig_interval),
+ orig_interval_tmp, net_dev->name);
atomic_set(&bat_priv->orig_interval, orig_interval_tmp);
return count;
@@ -317,8 +317,8 @@ int sysfs_add_meshif(struct net_device *dev)
bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
batif_kobject);
if (!bat_priv->mesh_obj) {
- printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n",
- dev->name, SYSFS_IF_MESH_SUBDIR);
+ pr_err("Can't add sysfs directory: %s/%s\n", dev->name,
+ SYSFS_IF_MESH_SUBDIR);
goto out;
}
@@ -326,9 +326,8 @@ int sysfs_add_meshif(struct net_device *dev)
err = sysfs_create_file(bat_priv->mesh_obj,
&((*bat_attr)->attr));
if (err) {
- printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n",
- dev->name, SYSFS_IF_MESH_SUBDIR,
- ((*bat_attr)->attr).name);
+ pr_err("Can't add sysfs file: %s/%s/%s\n", dev->name,
+ SYSFS_IF_MESH_SUBDIR, ((*bat_attr)->attr).name);
goto rem_attr;
}
}
@@ -393,8 +392,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
- printk(KERN_ERR "batman-adv:Invalid parameter for 'mesh_iface' setting received: %s\n",
- buff);
+ pr_err("Invalid parameter for 'mesh_iface' setting received: "
+ "%s\n", buff);
return -EINVAL;
}
@@ -456,17 +455,16 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev)
hardif_kobject);
if (!*hardif_obj) {
- printk(KERN_ERR "batman-adv:Can't add sysfs directory: %s/%s\n",
- dev->name, SYSFS_IF_BAT_SUBDIR);
+ pr_err("Can't add sysfs directory: %s/%s\n", dev->name,
+ SYSFS_IF_BAT_SUBDIR);
goto out;
}
for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) {
err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
if (err) {
- printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n",
- dev->name, SYSFS_IF_BAT_SUBDIR,
- ((*bat_attr)->attr).name);
+ pr_err("Can't add sysfs file: %s/%s/%s\n", dev->name,
+ SYSFS_IF_BAT_SUBDIR, ((*bat_attr)->attr).name);
goto rem_attr;
}
}
diff --git a/batman-adv/compat.h b/batman-adv/compat.h
index 8302a58..58ae850 100644
--- a/batman-adv/compat.h
+++ b/batman-adv/compat.h
@@ -60,6 +60,19 @@ static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len)
#endif /* < KERNEL_VERSION(2, 6, 23) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+#define pr_err(fmt, ...) \
+ printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning(fmt, ...) \
+ printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+
+#endif /* < KERNEL_VERSION(2, 6, 24) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
#define strict_strtoul(cp, base, res) \
diff --git a/batman-adv/gateway_common.c b/batman-adv/gateway_common.c
index 270cf3d..ff4bc82 100644
--- a/batman-adv/gateway_common.c
+++ b/batman-adv/gateway_common.c
@@ -87,16 +87,14 @@ static bool parse_gw_mode_tok(char *tokptr, long *gw_mode_tmp,
case GW_MODE_CLIENT:
ret = strict_strtoul(tokptr, 10, gw_class_tmp);
if (ret) {
- printk(KERN_ERR "batman-adv: "
- "Client class of gateway mode invalid: %s\n",
+ pr_err("Client class of gateway mode invalid: %s\n",
tokptr);
return false;
}
if (*gw_class_tmp > TQ_MAX_VALUE) {
- printk(KERN_ERR "batman-adv: Client class of gateway "
- "mode greater than %i: %ld\n",
- TQ_MAX_VALUE, *gw_class_tmp);
+ pr_err("Client class of gateway mode greater than %i: "
+ "%ld\n", TQ_MAX_VALUE, *gw_class_tmp);
return false;
}
@@ -121,8 +119,7 @@ static bool parse_gw_mode_tok(char *tokptr, long *gw_mode_tmp,
ret = strict_strtoul(tokptr, 10, down);
if (ret) {
- printk(KERN_ERR "batman-adv: "
- "Download speed of gateway mode invalid: %s\n",
+ pr_err("Download speed of gateway mode invalid: %s\n",
tokptr);
return false;
}
@@ -147,9 +144,8 @@ static bool parse_gw_mode_tok(char *tokptr, long *gw_mode_tmp,
ret = strict_strtoul(slash_ptr + 1, 10, up);
if (ret) {
- printk(KERN_ERR "batman-adv: Upload speed of "
- "gateway mode invalid: %s\n",
- slash_ptr + 1);
+ pr_err("Upload speed of gateway mode invalid: "
+ "%s\n", slash_ptr + 1);
return false;
}
@@ -217,8 +213,7 @@ next:
}
if (!gw_mode_tmp_str) {
- printk(KERN_INFO "batman-adv: "
- "Gateway mode can only be set to: '%s', '%s' or '%s' - "
+ pr_info("Gateway mode can only be set to: '%s', '%s' or '%s' - "
"given value: %s\n",
GW_MODE_OFF_NAME, GW_MODE_CLIENT_NAME,
GW_MODE_SERVER_NAME, buff);
@@ -242,8 +237,7 @@ next:
if ((gw_mode_tmp == GW_MODE_CLIENT) && (!gw_class_tmp))
gw_class_tmp = 20;
- printk(KERN_INFO "batman-adv: "
- "Changing gateway mode from: '%s' to: '%s' "
+ pr_info("Changing gateway mode from: '%s' to: '%s' "
"(gw_class: %ld)\n",
gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp);
break;
@@ -265,8 +259,7 @@ next:
(int *)&down, (int *)&up);
gw_deselect();
- printk(KERN_INFO
- "batman-adv: Changing gateway mode from: '%s' to: '%s' "
+ pr_info("Changing gateway mode from: '%s' to: '%s' "
"(gw_class: %ld -> propagating: %ld%s/%ld%s)\n",
gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp,
(down > 2048 ? down / 1024 : down),
@@ -275,9 +268,8 @@ next:
(up > 2048 ? "MBit" : "KBit"));
break;
default:
- printk(KERN_INFO "batman-adv: "
- "Changing gateway mode from: '%s' to: '%s'\n",
- gw_mode_curr_str, gw_mode_tmp_str);
+ pr_info("Changing gateway mode from: '%s' to: '%s'\n",
+ gw_mode_curr_str, gw_mode_tmp_str);
break;
}
diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index fe07c0e..ed2f637 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -152,12 +152,10 @@ static void check_known_mac_addr(uint8_t *addr)
if (!compare_orig(batman_if->net_dev->dev_addr, addr))
continue;
- printk(KERN_WARNING "batman-adv:"
- "The newly added mac address (%pM) already exists on: %s\n",
- addr, batman_if->dev);
- printk(KERN_WARNING "batman-adv:"
- "It is strongly recommended to keep mac addresses unique"
- "to avoid problems!\n");
+ pr_warning("The newly added mac address (%pM) already exists "
+ "on: %s\n", addr, batman_if->dev);
+ pr_warning("It is strongly recommended to keep mac addresses "
+ "unique to avoid problems!\n");
}
rcu_read_unlock();
}
@@ -209,8 +207,7 @@ static void hardif_activate_interface(struct bat_priv *bat_priv,
if (!bat_priv->primary_if)
set_primary_if(bat_priv, batman_if);
- printk(KERN_INFO "batman-adv:Interface activated: %s\n",
- batman_if->dev);
+ pr_info("Interface activated: %s\n", batman_if->dev);
if (atomic_read(&module_state) == MODULE_INACTIVE)
activate_module();
@@ -229,8 +226,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
batman_if->if_status = IF_INACTIVE;
- printk(KERN_INFO "batman-adv:Interface deactivated: %s\n",
- batman_if->dev);
+ pr_info("Interface deactivated: %s\n", batman_if->dev);
update_min_mtu();
}
@@ -248,8 +244,7 @@ int hardif_enable_interface(struct batman_if *batman_if)
batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
if (!batman_if->packet_buff) {
- printk(KERN_ERR "batman-adv:"
- "Can't add interface packet (%s): out of memory\n",
+ pr_err("Can't add interface packet (%s): out of memory\n",
batman_if->dev);
goto err;
}
@@ -268,13 +263,12 @@ int hardif_enable_interface(struct batman_if *batman_if)
orig_hash_add_if(batman_if, bat_priv->num_ifaces);
atomic_set(&batman_if->seqno, 1);
- printk(KERN_INFO "batman-adv:Adding interface: %s\n", batman_if->dev);
+ pr_info("Adding interface: %s\n", batman_if->dev);
if (hardif_is_iface_up(batman_if))
hardif_activate_interface(bat_priv, batman_if);
else
- printk(KERN_ERR "batman-adv:"
- "Not using interface %s "
+ pr_err("Not using interface %s "
"(retrying later): interface not active\n",
batman_if->dev);
@@ -299,7 +293,7 @@ void hardif_disable_interface(struct batman_if *batman_if)
if (batman_if->if_status != IF_INACTIVE)
return;
- printk(KERN_INFO "batman-adv:Removing interface: %s\n", batman_if->dev);
+ pr_info("Removing interface: %s\n", batman_if->dev);
bat_priv->num_ifaces--;
orig_hash_del_if(batman_if, bat_priv->num_ifaces);
@@ -326,8 +320,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
if (!batman_if) {
- printk(KERN_ERR "batman-adv:"
- "Can't add interface (%s): out of memory\n",
+ pr_err("Can't add interface (%s): out of memory\n",
net_dev->name);
goto out;
}
diff --git a/batman-adv/icmp_socket.c b/batman-adv/icmp_socket.c
index 484f021..a84e84d 100644
--- a/batman-adv/icmp_socket.c
+++ b/batman-adv/icmp_socket.c
@@ -19,9 +19,9 @@
*
*/
+#include "main.h"
#include <linux/debugfs.h>
#include <linux/slab.h>
-#include "main.h"
#include "icmp_socket.h"
#include "send.h"
#include "types.h"
@@ -60,8 +60,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
}
if (i == ARRAY_SIZE(socket_client_hash)) {
- printk(KERN_ERR "batman-adv:"
- "Error - can't add another packet client: "
+ pr_err("Error - can't add another packet client: "
"maximum number of clients reached\n");
kfree(socket_client);
return -EXFULL;
diff --git a/batman-adv/main.c b/batman-adv/main.c
index dec1607..e3d4766 100644
--- a/batman-adv/main.c
+++ b/batman-adv/main.c
@@ -94,16 +94,14 @@ int init_module(void)
interface_setup);
if (!soft_device) {
- printk(KERN_ERR "batman-adv:"
- "Unable to allocate the batman interface\n");
+ pr_err("Unable to allocate the batman interface\n");
goto end;
}
retval = register_netdev(soft_device);
if (retval < 0) {
- printk(KERN_ERR "batman-adv:"
- "Unable to register the batman interface: %i\n", retval);
+ pr_err("Unable to register the batman interface: %i\n", retval);
goto free_soft_device;
}
@@ -120,9 +118,9 @@ int init_module(void)
register_netdevice_notifier(&hard_if_notifier);
dev_add_pack(&batman_adv_packet_type);
- printk(KERN_INFO "batman-adv:"
- "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
- SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
+ pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) "
+ "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR,
+ COMPAT_VERSION);
return 0;
@@ -182,8 +180,7 @@ void activate_module(void)
goto end;
err:
- printk(KERN_ERR "batman-adv:"
- "Unable to allocate memory for mesh information structures: "
+ pr_err("Unable to allocate memory for mesh information structures: "
"out of mem ?\n");
deactivate_module();
end:
diff --git a/batman-adv/main.h b/batman-adv/main.h
index 38e48e2..1cf402a 100644
--- a/batman-adv/main.h
+++ b/batman-adv/main.h
@@ -90,6 +90,8 @@
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* Append 'batman-adv: ' before
+ * kernel messages */
/*
* Vis
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index 363a412..ec52a38 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -169,8 +169,7 @@ struct orig_node *get_orig_node(uint8_t *addr)
swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL)
- printk(KERN_ERR
- "batman-adv:Couldn't resize orig hash table\n");
+ pr_err("Couldn't resize orig hash table\n");
else
orig_hash = swaphash;
}
@@ -364,8 +363,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
GFP_ATOMIC);
if (!data_ptr) {
- printk(KERN_ERR
- "batman-adv:Can't resize orig: out of memory\n");
+ pr_err("Can't resize orig: out of memory\n");
return -1;
}
@@ -376,8 +374,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) {
- printk(KERN_ERR
- "batman-adv:Can't resize orig: out of memory\n");
+ pr_err("Can't resize orig: out of memory\n");
return -1;
}
@@ -426,8 +423,7 @@ static int orig_node_del_if(struct orig_node *orig_node,
chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
if (!data_ptr) {
- printk(KERN_ERR
- "batman-adv:Can't resize orig: out of memory\n");
+ pr_err("Can't resize orig: out of memory\n");
return -1;
}
@@ -448,8 +444,7 @@ free_bcast_own:
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) {
- printk(KERN_ERR
- "batman-adv:Can't resize orig: out of memory\n");
+ pr_err("Can't resize orig: out of memory\n");
return -1;
}
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index b629d8b..5dd4295 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -871,10 +871,9 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
/* send TTL exceeded if packet is an echo request (traceroute) */
if (icmp_packet->msg_type != ECHO_REQUEST) {
- printk(KERN_WARNING "batman-adv:"
- "Warning - can't forward icmp packet from %pM to %pM: "
- "ttl exceeded\n",
- icmp_packet->orig, icmp_packet->dst);
+ pr_warning("Warning - can't forward icmp packet from %pM to "
+ "%pM: ttl exceeded\n", icmp_packet->orig,
+ icmp_packet->dst);
return NET_RX_DROP;
}
@@ -1146,10 +1145,9 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
/* TTL exceeded */
if (unicast_packet->ttl < 2) {
- printk(KERN_WARNING "batman-adv:Warning - "
- "can't forward unicast packet from %pM to %pM: "
- "ttl exceeded\n",
- ethhdr->h_source, unicast_packet->dest);
+ pr_warning("Warning - can't forward unicast packet from %pM to "
+ "%pM: ttl exceeded\n", ethhdr->h_source,
+ unicast_packet->dest);
return NET_RX_DROP;
}
diff --git a/batman-adv/send.c b/batman-adv/send.c
index ba032b9..cd6be2b 100644
--- a/batman-adv/send.c
+++ b/batman-adv/send.c
@@ -70,10 +70,8 @@ int send_skb_packet(struct sk_buff *skb,
goto send_skb_err;
if (!(batman_if->net_dev->flags & IFF_UP)) {
- printk(KERN_WARNING
- "batman-adv:Interface %s "
- "is not up - can't send packet via that interface!\n",
- batman_if->dev);
+ pr_warning("Interface %s is not up - can't send packet via "
+ "that interface!\n", batman_if->dev);
goto send_skb_err;
}
@@ -192,8 +190,8 @@ static void send_packet(struct forw_packet *forw_packet)
unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
if (!forw_packet->if_incoming) {
- printk(KERN_ERR "batman-adv: Error - can't forward packet: "
- "incoming iface not specified\n");
+ pr_err("Error - can't forward packet: incoming iface not "
+ "specified\n");
return;
}
diff --git a/batman-adv/translation-table.c b/batman-adv/translation-table.c
index 1223609..1513495 100644
--- a/batman-adv/translation-table.c
+++ b/batman-adv/translation-table.c
@@ -117,8 +117,7 @@ void hna_local_add(uint8_t *addr)
hna_local_hash->size * 2);
if (swaphash == NULL)
- printk(KERN_ERR "batman-adv:"
- "Couldn't resize local hna hash table\n");
+ pr_err("Couldn't resize local hna hash table\n");
else
hna_local_hash = swaphash;
}
@@ -373,8 +372,7 @@ void hna_global_add_orig(struct orig_node *orig_node,
hna_global_hash->size * 2);
if (swaphash == NULL)
- printk(KERN_ERR "batman-adv:"
- "Couldn't resize global hna hash table\n");
+ pr_err("Couldn't resize global hna hash table\n");
else
hna_global_hash = swaphash;
}
diff --git a/batman-adv/vis.c b/batman-adv/vis.c
index 3832043..5c825b5 100644
--- a/batman-adv/vis.c
+++ b/batman-adv/vis.c
@@ -679,7 +679,7 @@ static void send_vis_packet(struct vis_info *info)
int packet_length;
if (info->packet.ttl < 2) {
- printk(KERN_WARNING "batman-adv: Error - can't send vis packet: ttl exceeded\n");
+ pr_warning("Error - can't send vis packet: ttl exceeded\n");
return;
}
@@ -741,13 +741,13 @@ int vis_init(void)
vis_hash = hash_new(256, vis_info_cmp, vis_info_choose);
if (!vis_hash) {
- printk(KERN_ERR "batman-adv:Can't initialize vis_hash\n");
+ pr_err("Can't initialize vis_hash\n");
goto err;
}
my_vis_info = kmalloc(1000, GFP_ATOMIC);
if (!my_vis_info) {
- printk(KERN_ERR "batman-adv:Can't initialize vis packet\n");
+ pr_err("Can't initialize vis packet\n");
goto err;
}
@@ -768,8 +768,7 @@ int vis_init(void)
memcpy(my_vis_info->packet.sender_orig, main_if_addr, ETH_ALEN);
if (hash_add(vis_hash, my_vis_info) < 0) {
- printk(KERN_ERR
- "batman-adv:Can't add own vis packet into hash\n");
+ pr_err("Can't add own vis packet into hash\n");
/* not in hash, need to remove it manually. */
kref_put(&my_vis_info->refcount, free_info);
goto err;
--
1.7.1
12 years, 7 months
[B.A.T.M.A.N.] batman-adv debug logging (v2)
by Marek Lindner
Hi,
I worked through the received feedback (thanks!) my first set of patches
provoked and improved the code. The following changes have been made:
* the log level no longer is a global variable and can be configured for each
mesh individually
* the "unused variable" warnings have been eliminated
* now dead batctl code has been removed
I also considered making the debug log available via the standard kernel
logging facilities but right now I can only see little value in this feature.
We can still add it as soon as somebody complains.
Unless there are futher comments I will go ahead and commit the changes.
Regards,
Marek
12 years, 7 months
[B.A.T.M.A.N.] PATCH batctl fragmentation handling
by Andreas Langer
Added options to enable/disable fragmentation
Signed-off-by: Andreas Langer <an.langer at gmx.de>
---
batctl/main.c | 29 +++++++++++++++++------------
batctl/sys.c | 7 +++++++
batctl/sys.h | 2 ++
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/batctl/main.c b/batctl/main.c
index 0506dce..e2d8545 100644
--- a/batctl/main.c
+++ b/batctl/main.c
@@ -41,24 +41,25 @@
void print_usage(void) {
printf("Usage: batctl [options] commands \n");
printf("commands:\n");
- printf(" \tinterface|if [add|del iface(s)]\tdisplay or modify the interface settings\n");
+ printf(" \tinterface|if [add|del iface(s)]\tdisplay or modify the interface
settings\n"); printf(" \toriginators|o \tdisplay the originator table\n");
- printf(" \tinterval|it [orig_interval] \tdisplay or modify the originator interval
(in ms)\n");
- printf(" \tloglevel|ll [level] \tdisplay or modify the log level\n");
+ printf(" \tinterval|it [orig_interval] \tdisplay or modify the originator interval
(in ms)\n");
+ printf(" \tloglevel|ll [level] \tdisplay or modify the log level\n");
printf(" \tlog|l \tread the log produced by the kernel
module\n");
- printf(" \tgw_mode|gw [mode] \tdisplay or modify the gateway mode\n");
+ printf(" \tgw_mode|gw [mode] \tdisplay or modify the gateway mode\n");
printf(" \tgateways|gwl \tdisplay the gateway server list\n");
printf(" \ttranslocal|tl \tdisplay the local translation table\n");
printf(" \ttransglobal|tg \tdisplay the global translation table\n");
- printf(" \tvis_mode|vm [mode] \tdisplay or modify the status of the VIS
server\n");
- printf(" \tvis_data|vd [dot|JSON] \tdisplay the VIS data in dot or JSON
format\n");
- printf(" \taggregation|ag [0|1] \tdisplay or modify the packet aggregation
setting\n");
- printf(" \tbonding|b [0|1] \tdisplay or modify the bonding mode
setting\n");
+ printf(" \tvis_mode|vm [mode] \tdisplay or modify the status of the VIS
server\n");
+ printf(" \tvis_data|vd [dot|JSON] \tdisplay the VIS data in dot or JSON
format\n");
+ printf(" \taggregation|ag [0|1] \tdisplay or modify the packet aggregation
setting\n");
+ printf(" \tbonding|b [0|1] \tdisplay or modify the bonding mode
setting\n");
+ printf(" \tfragmentation|f [0|1] \tdisplay or modify the fragmentation mode
setting\n"); printf("\n");
- printf(" \tping|p <destination> \tping another batman adv host via layer 2\n");
- printf(" \ttraceroute|tr <destination> \ttraceroute another batman adv host via layer
2\n");
- printf(" \ttcpdump|td <interface> \ttcpdump layer 2 traffic on the given
interface\n");
- printf(" \tbisect <file1> .. <fileN>\tanalyze given log files for routing
stability\n");
+ printf(" \tping|p <destination> \tping another batman adv host via layer
2\n");
+ printf(" \ttraceroute|tr <destination> \ttraceroute another batman adv host via
layer 2\n");
+ printf(" \ttcpdump|td <interface> \ttcpdump layer 2 traffic on the given
interface\n");
+ printf(" \tbisect <file1> .. <fileN>\tanalyze given log files for routing
stability\n"); printf("options:\n");
printf(" \t-h print this help (or 'batctl <command> -h' for the command specific help)\n");
printf(" \t-v print version\n");
@@ -149,6 +150,10 @@ int main(int argc, char **argv)
ret = handle_sys_setting(argc - 1, argv + 1, SYS_BONDING, bonding_usage,
sysfs_param_enable);
+ } else if ((strcmp(argv[1], "fragmentation") == 0) || (strcmp(argv[1], "f") == 0)) {
+
+ ret = handle_sys_setting(argc - 1, argv + 1, SYS_FRAG, fragmentation_usage,
sysfs_param_enable); +
} else if ((strcmp(argv[1], "bisect") == 0)) {
ret = bisect(argc - 1, argv + 1);
diff --git a/batctl/sys.c b/batctl/sys.c
index 9137424..c928dd4 100644
--- a/batctl/sys.c
+++ b/batctl/sys.c
@@ -292,6 +292,13 @@ void orig_interval_usage(void)
printf(" \t -h print this help\n");
}
+void fragmentation_usage(void)
+{
+ printf("Usage: batctl [options] fragmentation [0|1]\n");
+ printf("options:\n");
+ printf(" \t -h print this help\n");
+}
+
int handle_sys_setting(int argc, char **argv,
char *file_path, void setting_usage(void),
const char *sysfs_param[])
diff --git a/batctl/sys.h b/batctl/sys.h
index 3bbe030..fc10851 100644
--- a/batctl/sys.h
+++ b/batctl/sys.h
@@ -32,12 +32,14 @@
#define SYS_IFACE_PATH "/sys/class/net"
#define SYS_MESH_IFACE_FMT SYS_IFACE_PATH"/%s/batman_adv/mesh_iface"
#define SYS_IFACE_STATUS_FMT SYS_IFACE_PATH"/%s/batman_adv/iface_status"
+#define SYS_FRAG "fragmentation"
extern const char *sysfs_param_enable[];
extern const char *sysfs_param_server[];
void aggregation_usage(void);
void bonding_usage(void);
+void fragmentation_usage(void);
void gw_mode_usage(void);
void vis_mode_usage(void);
void orig_interval_usage(void);
--
1.7.0.4
12 years, 7 months