Skip to contentSkip to conversation

reorganized kernel interface patches (version 3)

B.A.T.M.A.N. New Marek Lindner 2 participants 9 messages Mar 24, 2010 – Apr 5, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

since my last patches did not trigger too many complaints I went ahead and submitted them. This opens the way for the last series of patches which conclude the matter. All remaining /proc files have been eliminated and moved over to /sys. While doing so, I reworked the interface handling to satisfy an old feature request: interfaces can be added & removed on the fly.

On startup batman-adv will scan the system for available interfaces to create a "batman_adv" subfolder in their respective /sys/class/net folder, e.g.
eth0: /sys/class/net/eth0/batman_adv
This subfolder will contain the settings which are relevant for this interface. You can tell batman-adv to use an interface by writing "bat0" into the mesh_iface file:
echo bat0 > /sys/class/net/eth0/batman_adv/mesh_iface
or write "none" to deactivate it:
echo none > /sys/class/net/eth0/batman_adv/mesh_iface
Although only "bat0" is accepted at this point, the syntax already gears towards multiple virtual mesh support. Later you will be able to create/name your virtual meshes by writing into this file. Retrieve the interface status by simply reading its status file:
cat /sys/class/net/eth0/batman_adv/iface_status

Note: batman-adv will continuously observe the system's interfaces. Whenever new interfaces appear or disappear batman will update the /sys/class/net folders automatically. Also, batman-adv will make sure that incompatible interfaces (e.g. loopback, non-ethernet, etc) won't have the subfolder, hence can't be activated.

The batctl interface syntax had to be modified in order to cope with these changes. You can run:
batctl interface
to get the list of active interfaces and their status. To add or delete interfaces you can run:
batctl interface add|del eth0 eth1 ..

Since removing an active interface is a tricky thing where many operations can go wrong I expect some crashes/race conditions in the code. I tested it a while on multiple machines with multiple interfaces and it works for me but I'm sure there are more bugs to find.

Regards,
Marek

#1 lore raw

PATCH 1/5 batman-adv: move originator interval setting from /proc to /sys

---
 batman-adv-kernelland/bat_sysfs.c |   47 +++++++++++++++++++++++
 batman-adv-kernelland/main.c      |    2 -
 batman-adv-kernelland/main.h      |    1 -
 batman-adv-kernelland/proc.c      |   75 -------------------------------------
 batman-adv-kernelland/proc.h      |    1 -
 batman-adv-kernelland/send.c      |    6 +-
 batman-adv-kernelland/types.h     |    1 +
 7 files changed, 51 insertions(+), 82 deletions(-)
batman-adv-kernelland/bat_sysfs.c +47 -0
index e4685a7..58bf44e 100644
@@ -251,17 +251,63 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr,
 	return gw_mode_set(bat_priv, buff, count);
 }
 
+static ssize_t show_orig_interval(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));
+
+	return sprintf(buff, "status: %i\n",
+		       atomic_read(&bat_priv->orig_interval));
+}
+
+static ssize_t store_orig_interval(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);
+	unsigned long orig_interval_tmp;
+	int ret;
+
+	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);
+		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);
+		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);
+
+	atomic_set(&bat_priv->orig_interval, orig_interval_tmp);
+	return count;
+}
+
 static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR,
 		show_aggr_ogm, store_aggr_ogm);
 static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond);
 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,
+		show_orig_interval, store_orig_interval);
 
 static struct bat_attribute *mesh_attrs[] = {
 	&bat_attr_aggregate_ogm,
 	&bat_attr_bonding,
 	&bat_attr_vis_mode,
 	&bat_attr_gw_mode,
+	&bat_attr_orig_interval,
 	NULL,
 };
 
@@ -345,6 +391,7 @@ int sysfs_add_meshif(struct net_device *dev)
 	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);
+	atomic_set(&bat_priv->orig_interval, 1000);
 
 	bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
 						    batif_kobject);
batman-adv-kernelland/main.c +0 -2
index cd53ced..b276e86 100644
@@ -44,7 +44,6 @@ DEFINE_SPINLOCK(orig_hash_lock);
 DEFINE_SPINLOCK(forw_bat_list_lock);
 DEFINE_SPINLOCK(forw_bcast_list_lock);
 
-atomic_t originator_interval;
 atomic_t vis_interval;
 int16_t num_hna;
 int16_t num_ifs;
@@ -82,7 +81,6 @@ int init_module(void)
 
 	atomic_set(&module_state, MODULE_INACTIVE);
 
-	atomic_set(&originator_interval, 1000);
 	atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
 					 * for debugging now. */
 
batman-adv-kernelland/main.h +0 -1
index d72f2c2..ddb0d6c 100644
@@ -131,7 +131,6 @@ extern spinlock_t orig_hash_lock;
 extern spinlock_t forw_bat_list_lock;
 extern spinlock_t forw_bcast_list_lock;
 
-extern atomic_t originator_interval;
 extern atomic_t vis_interval;
 extern int16_t num_hna;
 extern int16_t num_ifs;
batman-adv-kernelland/proc.c +0 -75

100 lines not on this page · raw message

batman-adv-kernelland/proc.h +0 -1
index 6a972a6..6f4f5b3 100644
@@ -24,7 +24,6 @@
 
 #define PROC_ROOT_DIR "batman-adv"
 #define PROC_FILE_INTERFACES "interfaces"
-#define PROC_FILE_ORIG_INTERVAL "orig_interval"
 
 void cleanup_procfs(void);
 int setup_procfs(void);
batman-adv-kernelland/send.c +3 -3
index 51011d4..b5a96f5 100644
@@ -39,10 +39,10 @@ static uint8_t hop_penalty(const uint8_t tq)
 }
 
 /* when do we schedule our own packet to be sent */
-static unsigned long own_send_time(void)
+static unsigned long own_send_time(struct bat_priv *bat_priv)
 {
 	return jiffies +
-		(((atomic_read(&originator_interval) - JITTER +
+		(((atomic_read(&bat_priv->orig_interval) - JITTER +
 		   (random32() % 2*JITTER)) * HZ) / 1000);
 }
 
@@ -285,7 +285,7 @@ void schedule_own_packet(struct batman_if *batman_if)
 	atomic_inc(&batman_if->seqno);
 
 	slide_own_bcast_window(batman_if);
-	send_time = own_send_time();
+	send_time = own_send_time(bat_priv);
 	add_bat_packet_to_list(bat_priv,
 			       batman_if->packet_buff,
 			       batman_if->packet_len,
batman-adv-kernelland/types.h +1 -0
index 98968b4..0794dfc 100644
@@ -99,6 +99,7 @@ struct bat_priv {
 	atomic_t vis_mode;
 	atomic_t gw_mode;
 	atomic_t gw_class;
+	atomic_t orig_interval;
 	struct kobject *mesh_obj;
 };
 
Signature · 1 line
1.7.0
#2 lore raw

PATCH 2/5 batctl: follow the orig_interval move to /sys

In reply to Marek Lindner
---
 batctl/main.c |    4 ++--
 batctl/proc.c |    7 -------
 batctl/proc.h |    2 --
 batctl/sys.c  |    7 +++++++
 batctl/sys.h  |    2 ++
 5 files changed, 11 insertions(+), 11 deletions(-)
batctl/main.c +2 -2
index a07e75b..da7fb4a 100644
@@ -43,7 +43,7 @@ void print_usage(void) {
 	printf("commands:\n");
 	printf(" \tinterface|if   [none|interface]  \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(" \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");
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
 
 	} else if ((strcmp(argv[1], "interval") == 0) || (strcmp(argv[1], "it") == 0)) {
 
-		ret = handle_proc_setting(argc - 1, argv + 1, PROC_ORIG_INTERVAL, orig_interval_usage);
+		ret = handle_sys_setting(argc - 1, argv + 1, SYS_ORIG_INTERVAL, orig_interval_usage);
 
 	} else if ((strcmp(argv[1], "vis_mode") == 0) || (strcmp(argv[1], "vm") == 0)) {
 
batctl/proc.c +0 -7
index 9f5c24f..192d4fb 100644
@@ -68,13 +68,6 @@ int interface(int argc, char **argv)
 	return EXIT_SUCCESS;
 }
 
-void orig_interval_usage(void)
-{
-	printf("Usage: batctl [options] interval \n");
-	printf("options:\n");
-	printf(" \t -h print this help\n");
-}
-
 int handle_table(int argc, char **argv, char *file_path, void table_usage(void))
 {
 	int optchar, read_opt = USE_BAT_HOSTS;
batctl/proc.h +0 -2
index 0b5a6f2..61d6058 100644
@@ -21,10 +21,8 @@
 
 #define PROC_ROOT_PATH "/proc/net/batman-adv/"
 #define PROC_INTERFACES "interfaces"
-#define PROC_ORIG_INTERVAL "orig_interval"
 
 int interface(int argc, char **argv);
 
-void orig_interval_usage(void);
 int handle_table(int argc, char **argv, char *file_path, void table_usage(void));
 int handle_proc_setting(int argc, char **argv, char *file_path, void setting_usage(void));
batctl/sys.c +7 -0
index 7d035d6..cd8979a 100644
@@ -207,6 +207,13 @@ void vis_mode_usage(void)
 	printf(" \t -h print this help\n");
 }
 
+void orig_interval_usage(void)
+{
+	printf("Usage: batctl [options] interval \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))
 {
 	int optchar, res;
batctl/sys.h +2 -0
index 4f10cee..19d19f5 100644
@@ -33,6 +33,7 @@
 #define SYS_GATEWAYS "gateways"
 #define SYS_VIS_MODE "vis_mode"
 #define SYS_VIS_DATA "vis_data"
+#define SYS_ORIG_INTERVAL "orig_interval"
 
 void originators_usage(void);
 void trans_local_usage(void);
@@ -42,6 +43,7 @@ void bonding_usage(void);
 void gw_mode_usage(void);
 void gateways_usage(void);
 void vis_mode_usage(void);
+void orig_interval_usage(void);
 int log_print(int argc, char **argv);
 int handle_loglevel(int argc, char **argv);
 int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void));
Signature · 1 line
1.7.0
#3 lore raw

PATCH 3/5 batman-adv: remove redundant pointer to originator interface

In reply to Marek Lindner
---
 batman-adv-kernelland/device.c     |    2 +-
 batman-adv-kernelland/originator.c |    1 -
 batman-adv-kernelland/routing.c    |   14 +++-----------
 batman-adv-kernelland/types.h      |    1 -
 batman-adv-kernelland/vis.c        |   15 +++++++--------
 5 files changed, 11 insertions(+), 22 deletions(-)
batman-adv-kernelland/device.c +1 -1
index 484b2a1..a3e066a 100644
@@ -260,7 +260,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	if (!orig_node->router)
 		goto unlock;
 
-	batman_if = orig_node->batman_if;
+	batman_if = orig_node->router->if_incoming;
 	memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 
 	spin_unlock_irqrestore(&orig_hash_lock, flags);
batman-adv-kernelland/originator.c +0 -1
index 1f607f4..dbc7cbf 100644
@@ -139,7 +139,6 @@ struct orig_node *get_orig_node(uint8_t *addr)
 
 	memcpy(orig_node->orig, addr, ETH_ALEN);
 	orig_node->router = NULL;
-	orig_node->batman_if = NULL;
 	orig_node->hna_buff = NULL;
 
 	size = num_ifs * sizeof(TYPE_OF_WORD) * NUM_WORDS;
batman-adv-kernelland/routing.c +3 -11
index 2e357bf..3168215 100644
@@ -99,11 +99,6 @@ static void update_route(struct orig_node *orig_node,
 		bat_dbg(DBG_ROUTES, "Changing route towards: %pM (now via %pM - was via %pM)\n", orig_node->orig, neigh_node->addr, orig_node->router->addr);
 	}
 
-	if (neigh_node != NULL)
-		orig_node->batman_if = neigh_node->if_incoming;
-	else
-		orig_node->batman_if = NULL;
-
 	orig_node->router = neigh_node;
 }
 
@@ -747,12 +742,11 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 	ret = NET_RX_DROP;
 
 	if ((orig_node != NULL) &&
-	    (orig_node->batman_if != NULL) &&
 	    (orig_node->router != NULL)) {
 
 		/* don't lock while sending the packets ... we therefore
 		 * copy the required data before sending */
-		batman_if = orig_node->batman_if;
+		batman_if = orig_node->router->if_incoming;
 		memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 		spin_unlock_irqrestore(&orig_hash_lock, flags);
 
@@ -809,12 +803,11 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
 	ret = NET_RX_DROP;
 
 	if ((orig_node != NULL) &&
-	    (orig_node->batman_if != NULL) &&
 	    (orig_node->router != NULL)) {
 
 		/* don't lock while sending the packets ... we therefore
 		 * copy the required data before sending */
-		batman_if = orig_node->batman_if;
+		batman_if = orig_node->router->if_incoming;
 		memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 		spin_unlock_irqrestore(&orig_hash_lock, flags);
 
@@ -905,12 +898,11 @@ int recv_icmp_packet(struct sk_buff *skb)
 		     hash_find(orig_hash, icmp_packet->dst));
 
 	if ((orig_node != NULL) &&
-	    (orig_node->batman_if != NULL) &&
 	    (orig_node->router != NULL)) {
 
 		/* don't lock while sending the packets ... we therefore
 		 * copy the required data before sending */
-		batman_if = orig_node->batman_if;
+		batman_if = orig_node->router->if_incoming;
 		memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 		spin_unlock_irqrestore(&orig_hash_lock, flags);
 
batman-adv-kernelland/types.h +0 -1
index 0794dfc..de13c99 100644
@@ -49,7 +49,6 @@ struct orig_node {               /* structure for orig_list maintaining nodes of
 	uint8_t orig[ETH_ALEN];
 	uint8_t primary_addr[ETH_ALEN];	/* hosts primary interface address */
 	struct neigh_node *router;
-	struct batman_if *batman_if;
 	TYPE_OF_WORD *bcast_own;
 	uint8_t *bcast_own_sum;
 	uint8_t tq_own;
batman-adv-kernelland/vis.c +7 -8
index 91849f4..a774de7 100644
@@ -499,14 +499,14 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
 		if (orig_node->router != NULL
 			&& compare_orig(orig_node->router->addr,
 					orig_node->orig)
-			&& orig_node->batman_if
-			&& (orig_node->batman_if->if_active == IF_ACTIVE)
+			&& (orig_node->router->if_incoming->if_status ==
+								IF_ACTIVE)
 		    && orig_node->router->tq_avg > 0) {
 
 			/* fill one entry into buffer. */
 			entry = &entry_array[info->packet.entries];
 			memcpy(entry->src,
-			       orig_node->batman_if->net_dev->dev_addr,
+			     orig_node->router->if_incoming->net_dev->dev_addr,
 			       ETH_ALEN);
 			memcpy(entry->dest, orig_node->orig, ETH_ALEN);
 			entry->quality = orig_node->router->tq_avg;
@@ -574,8 +574,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length)
 		orig_node = hashit.bucket->data;
 
 		/* if it's a vis server and reachable, send it. */
-		if ((!orig_node) || (!orig_node->batman_if) ||
-		    (!orig_node->router))
+		if ((!orig_node) || (!orig_node->router))
 			continue;
 		if (!(orig_node->flags & VIS_SERVER))
 			continue;
@@ -585,7 +584,7 @@ static void broadcast_vis_packet(struct vis_info *info, int packet_length)
 			continue;
 
 		memcpy(info->packet.target_orig, orig_node->orig, ETH_ALEN);
-		batman_if = orig_node->batman_if;
+		batman_if = orig_node->router->if_incoming;
 		memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 		spin_unlock_irqrestore(&orig_hash_lock, flags);
 
@@ -610,12 +609,12 @@ static void unicast_vis_packet(struct vis_info *info, int packet_length)
 	orig_node = ((struct orig_node *)
 		     hash_find(orig_hash, info->packet.target_orig));
 
-	if ((!orig_node) || (!orig_node->batman_if) || (!orig_node->router))
+	if ((!orig_node) || (!orig_node->router))
 		goto out;
 
 	/* don't lock while sending the packets ... we therefore
 	 * copy the required data before sending */
-	batman_if = orig_node->batman_if;
+	batman_if = orig_node->router->if_incoming;
 	memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
 	spin_unlock_irqrestore(&orig_hash_lock, flags);
 
Signature · 1 line
1.7.0
#4 lore raw

PATCH 4/5 batman-adv: move /proc interface handling to /sys

In reply to Marek Lindner

Instead of having a single /proc file "interfaces" in which you have to echo the wanted interface batman-adv will create a subfolder in each suitable /sys/class/net folder. This subfolder contains files for the interface specific settings. For example, mesh_iface to add/remove an interface from a virtual mesh network (at the moment only bat0 is supported).

Example:
echo bat0 > /sys/class/net/eth0/batman-adv/mesh_iface

to deactivate:
echo none > /sys/class/net/eth0/batman-adv/mesh_iface

Interfaces which are not compatible with batman-adv won't contain the batman-adv folder, therefore can't be activated. Not supported are:
loopback, non-ethernet, non-ARP and virtual mesh network interfaces

---
 batman-adv-kernelland/Makefile.kbuild     |    2 +-
 batman-adv-kernelland/bat_sysfs.c         |  144 ++++++++
 batman-adv-kernelland/bat_sysfs.h         |    3 +
 batman-adv-kernelland/device.c            |    2 +-
 batman-adv-kernelland/gateway_client.c    |    9 +-
 batman-adv-kernelland/hard-interface.c    |  515 +++++++++++++++--------------
 batman-adv-kernelland/hard-interface.h    |   18 +-
 batman-adv-kernelland/main.c              |   21 +-
 batman-adv-kernelland/main.h              |    3 +-
 batman-adv-kernelland/originator.c        |  195 ++++++++++-
 batman-adv-kernelland/originator.h        |    2 +
 batman-adv-kernelland/proc.c              |  173 ----------
 batman-adv-kernelland/proc.h              |   30 --
 batman-adv-kernelland/routing.c           |    4 +-
 batman-adv-kernelland/send.c              |   51 +++-
 batman-adv-kernelland/send.h              |    2 +-
 batman-adv-kernelland/soft-interface.c    |    4 +-
 batman-adv-kernelland/translation-table.c |   14 +-
 batman-adv-kernelland/types.h             |    5 +-
 batman-adv-kernelland/vis.c               |    7 +-
 20 files changed, 668 insertions(+), 536 deletions(-)
 delete mode 100644 batman-adv-kernelland/proc.c
 delete mode 100644 batman-adv-kernelland/proc.h
batman-adv-kernelland/Makefile.kbuild +1 -1
index c1f181a..e9b58b9 100644
@@ -32,4 +32,4 @@ EXTRA_CFLAGS += -DREVISION_VERSION=\"r$(REVISION)\"
 endif
 
 obj-m += batman-adv.o
-batman-adv-objs := main.o proc.o bat_sysfs.o send.o routing.o soft-interface.o device.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_sysfs.o send.o routing.o soft-interface.o device.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-kernelland/bat_sysfs.c +144 -0

165 lines not on this page · raw message

batman-adv-kernelland/bat_sysfs.h +3 -0
index 671ebd1..e189341 100644
@@ -21,6 +21,9 @@
 
 
 #define SYSFS_IF_MESH_SUBDIR "mesh"
+#define SYSFS_IF_BAT_SUBDIR "batman_adv"
 
 int sysfs_add_meshif(struct net_device *dev);
 void sysfs_del_meshif(struct net_device *dev);
+int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
+void sysfs_del_hardif(struct kobject **hardif_obj);
batman-adv-kernelland/device.c +1 -1
index a3e066a..f011430 100644
@@ -268,7 +268,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	if (!batman_if)
 		goto dst_unreach;
 
-	if (batman_if->if_active != IF_ACTIVE)
+	if (batman_if->if_status != IF_ACTIVE)
 		goto dst_unreach;
 
 	memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN);
batman-adv-kernelland/gateway_client.c +5 -4
index 29a4783..0e619dd 100644
@@ -337,12 +337,13 @@ static int _write_buffer_text(unsigned char *buff, int bytes_written,
 int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 			       size_t count, loff_t off)
 {
+	struct bat_priv *bat_priv = netdev_priv(net_dev);
 	struct gw_node *gw_node;
 	size_t hdr_len, tmp_len;
 	int bytes_written = 0, gw_count = 0;
 
 	rcu_read_lock();
-	if (list_empty(&if_list)) {
+	if (!bat_priv->primary_if) {
 		rcu_read_unlock();
 
 		if (off == 0)
@@ -353,7 +354,7 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 		return 0;
 	}
 
-	if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
+	if (bat_priv->primary_if->if_status != IF_ACTIVE) {
 		rcu_read_unlock();
 
 		if (off == 0)
@@ -368,8 +369,8 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 			  "      %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
 			  "Gateway", "#", TQ_MAX_VALUE, "Nexthop",
 			  "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR,
-			  ((struct batman_if *)if_list.next)->dev,
-			  ((struct batman_if *)if_list.next)->addr_str,
+			  bat_priv->primary_if->dev,
+			  bat_priv->primary_if->addr_str,
 			  net_dev->name);
 	rcu_read_unlock();
 
batman-adv-kernelland/hard-interface.c +262 -253

656 lines not on this page · raw message

batman-adv-kernelland/hard-interface.h +9 -9
index 4100a27..1e5fc3e 100644
@@ -19,19 +19,19 @@
  *
  */
 
-#define IF_INACTIVE 0
-#define IF_ACTIVE 1
-/* #define IF_TO_BE_DEACTIVATED 2 - not needed anymore */
-#define IF_TO_BE_ACTIVATED 3
+#define IF_NOT_IN_USE 0
+#define IF_TO_BE_REMOVED 1
+#define IF_INACTIVE 2
+#define IF_ACTIVE 3
+#define IF_TO_BE_ACTIVATED 4
+#define IF_I_WANT_YOU 5
 
 extern struct notifier_block hard_if_notifier;
 
+struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev);
+int hardif_enable_interface(struct batman_if *batman_if);
+void hardif_disable_interface(struct batman_if *batman_if);
 void hardif_remove_interfaces(void);
-int hardif_add_interface(char *dev, int if_num);
-void hardif_deactivate_interface(struct batman_if *batman_if);
-char hardif_get_active_if_num(void);
-void hardif_check_interfaces_status(void);
-void hardif_check_interfaces_status_wq(struct work_struct *work);
 int batman_skb_recv(struct sk_buff *skb,
 				struct net_device *dev,
 				struct packet_type *ptype,
batman-adv-kernelland/main.c +7 -14
index b276e86..b98fd83 100644
@@ -20,7 +20,6 @@
  */
 
 #include "main.h"
-#include "proc.h"
 #include "bat_sysfs.h"
 #include "routing.h"
 #include "send.h"
@@ -46,7 +45,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);
 
 atomic_t vis_interval;
 int16_t num_hna;
-int16_t num_ifs;
 
 struct net_device *soft_device;
 
@@ -91,10 +89,6 @@ int init_module(void)
 	if (!bat_event_workqueue)
 		return -ENOMEM;
 
-	retval = setup_procfs();
-	if (retval < 0)
-		return retval;
-
 	bat_device_init();
 
 	/* initialize layer 2 interface */
@@ -137,7 +131,10 @@ end:
 
 void cleanup_module(void)
 {
-	shutdown_module();
+	deactivate_module();
+
+	unregister_netdevice_notifier(&hard_if_notifier);
+	hardif_remove_interfaces();
 
 	if (soft_device) {
 		sysfs_del_meshif(soft_device);
@@ -147,9 +144,6 @@ void cleanup_module(void)
 
 	dev_remove_pack(&batman_adv_packet_type);
 
-	unregister_netdevice_notifier(&hard_if_notifier);
-	cleanup_procfs();
-
 	destroy_workqueue(bat_event_workqueue);
 	bat_event_workqueue = NULL;
 }
@@ -180,17 +174,17 @@ void activate_module(void)
 
 err:
 	printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
-	shutdown_module();
+	deactivate_module();
 end:
 	return;
 }
 
 /* shuts down the whole module.*/
-void shutdown_module(void)
+void deactivate_module(void)
 {
 	atomic_set(&module_state, MODULE_DEACTIVATING);
 
-	purge_outstanding_packets();
+	purge_outstanding_packets(NULL);
 	flush_workqueue(bat_event_workqueue);
 
 	vis_quit();
@@ -206,7 +200,6 @@ void shutdown_module(void)
 	synchronize_net();
 	bat_device_destroy();
 
-	hardif_remove_interfaces();
 	synchronize_rcu();
 	atomic_set(&module_state, MODULE_INACTIVE);
 }
batman-adv-kernelland/main.h +1 -2
index ddb0d6c..5dcbf03 100644
@@ -133,7 +133,6 @@ extern spinlock_t forw_bcast_list_lock;
 
 extern atomic_t vis_interval;
 extern int16_t num_hna;
-extern int16_t num_ifs;
 
 extern struct net_device *soft_device;
 
@@ -142,7 +141,7 @@ extern atomic_t module_state;
 extern struct workqueue_struct *bat_event_workqueue;
 
 void activate_module(void);
-void shutdown_module(void);
+void deactivate_module(void);
 void inc_module_count(void);
 void dec_module_count(void);
 int addr_to_string(char *buff, uint8_t *addr);
batman-adv-kernelland/originator.c +178 -17

260 lines not on this page · raw message

batman-adv-kernelland/originator.h +2 -0
index 745b4b0..afbc7c0 100644
@@ -30,3 +30,5 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
 		uint8_t *neigh, struct batman_if *if_incoming);
 ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 			      size_t count, loff_t off);
+int orig_hash_add_if(struct batman_if *batman_if, int max_if_num);
+int orig_hash_del_if(struct batman_if *batman_if, int max_if_num);
batman-adv-kernelland/proc.c deleted +0 -173

173 lines not on this page · raw message

batman-adv-kernelland/proc.h deleted +0 -30
deleted file mode 100644
index 6f4f5b3..0000000
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * 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 <linux/proc_fs.h>
-#include <linux/seq_file.h>
-
-#define PROC_ROOT_DIR "batman-adv"
-#define PROC_FILE_INTERFACES "interfaces"
-
-void cleanup_procfs(void);
-int setup_procfs(void);
-
batman-adv-kernelland/routing.c +2 -2
index 3168215..dbe27ad 100644
@@ -207,7 +207,7 @@ static int isBidirectionalNeigh(struct orig_node *orig_node,
 	batman_packet->tq = ((batman_packet->tq *
 			      orig_neigh_node->tq_own *
 			      orig_neigh_node->tq_asym_penalty) /
-			     (TQ_MAX_VALUE *	 TQ_MAX_VALUE));
+			     (TQ_MAX_VALUE * TQ_MAX_VALUE));
 
 	bat_dbg(DBG_BATMAN, "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,
@@ -514,7 +514,7 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 		batman_packet->version, has_directlink_flag);
 
 	list_for_each_entry_rcu(batman_if, &if_list, list) {
-		if (batman_if->if_active != IF_ACTIVE)
+		if (batman_if->if_status != IF_ACTIVE)
 			continue;
 
 		if (compare_orig(ethhdr->h_source,
batman-adv-kernelland/send.c +41 -10

118 lines not on this page · raw message

batman-adv-kernelland/send.h +1 -1
index b2ddf63..b84a470 100644
@@ -36,4 +36,4 @@ void schedule_forward_packet(struct orig_node *orig_node,
 void add_bcast_packet_to_list(struct sk_buff *skb);
 void send_outstanding_bcast_packet(struct work_struct *work);
 void send_outstanding_bat_packet(struct work_struct *work);
-void purge_outstanding_packets(void);
+void purge_outstanding_packets(struct batman_if *batman_if);
batman-adv-kernelland/soft-interface.c +1 -3
index d2c7864..a36d3de 100644
@@ -176,8 +176,6 @@ int interface_change_mtu(struct net_device *dev, int new_mtu)
 	return 0;
 }
 
-
-
 int interface_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	struct unicast_packet *unicast_packet;
@@ -263,7 +261,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
 
 		spin_unlock_irqrestore(&orig_hash_lock, flags);
 
-		if (batman_if->if_active != IF_ACTIVE)
+		if (batman_if->if_status != IF_ACTIVE)
 			goto dropped;
 
 		if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
batman-adv-kernelland/translation-table.c +4 -10
index bab6d7e..d63f0b8 100644
@@ -160,16 +160,14 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len)
 int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 			       size_t count, loff_t off)
 {
+	struct bat_priv *bat_priv = netdev_priv(net_dev);
 	struct hna_local_entry *hna_local_entry;
 	HASHIT(hashit);
 	int bytes_written = 0;
 	unsigned long flags;
 	size_t hdr_len;
 
-	rcu_read_lock();
-	if (list_empty(&if_list)) {
-		rcu_read_unlock();
-
+	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
 				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -177,7 +175,6 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		return 0;
 	}
-	rcu_read_unlock();
 
 	hdr_len = sprintf(buff,
 			  "Locally retrieved addresses (from %s) announced via HNA:\n",
@@ -377,16 +374,14 @@ void hna_global_add_orig(struct orig_node *orig_node,
 int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 				size_t count, loff_t off)
 {
+	struct bat_priv *bat_priv = netdev_priv(net_dev);
 	struct hna_global_entry *hna_global_entry;
 	HASHIT(hashit);
 	int bytes_written = 0;
 	unsigned long flags;
 	size_t hdr_len;
 
-	rcu_read_lock();
-	if (list_empty(&if_list)) {
-		rcu_read_unlock();
-
+	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
 				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
@@ -394,7 +389,6 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		return 0;
 	}
-	rcu_read_unlock();
 
 	hdr_len = sprintf(buff,
 			  "Globally announced HNAs received via the mesh %s (translation table):\n",
batman-adv-kernelland/types.h +4 -1
index de13c99..737db7c 100644
@@ -36,12 +36,13 @@ struct batman_if {
 	struct list_head list;
 	int16_t if_num;
 	char *dev;
-	char if_active;
+	char if_status;
 	char addr_str[ETH_STR_LEN];
 	struct net_device *net_dev;
 	atomic_t seqno;
 	unsigned char *packet_buff;
 	int packet_len;
+	struct kobject *hardif_obj;
 	struct rcu_head rcu;
 };
 
@@ -99,6 +100,8 @@ struct bat_priv {
 	atomic_t gw_mode;
 	atomic_t gw_class;
 	atomic_t orig_interval;
+	char num_ifaces;
+	struct batman_if *primary_if;
 	struct kobject *mesh_obj;
 };
 
batman-adv-kernelland/vis.c +2 -5
index a774de7..3144439 100644
@@ -174,13 +174,10 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff,
 	unsigned long flags;
 	int vis_server = atomic_read(&bat_priv->vis_mode);
 
-	rcu_read_lock();
-	if (list_empty(&if_list) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) {
-		rcu_read_unlock();
+	if ((!bat_priv->primary_if) ||
+	    (vis_server == VIS_TYPE_CLIENT_UPDATE))
 		return 0;
-	}
 
-	rcu_read_unlock();
 	hdr_len = 0;
 
 	spin_lock_irqsave(&vis_hash_lock, flags);
Signature · 1 line
1.7.0
#5 lore raw

PATCH 5/5 batctl: adapt batctl to new sysfs interface handling

In reply to Marek Lindner
---
 batctl/Makefile     |    4 +-
 batctl/functions.c  |    3 +-
 batctl/functions.h  |    1 +
 batctl/main.c       |    3 +-
 batctl/man/batctl.8 |    6 +--
 batctl/proc.c       |  114 -------------------------------------------------
 batctl/proc.h       |   28 ------------
 batctl/sys.c        |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++
 batctl/sys.h        |    4 ++
 9 files changed, 130 insertions(+), 151 deletions(-)
 delete mode 100644 batctl/proc.c
 delete mode 100644 batctl/proc.h
batctl/Makefile +2 -2
index 595b996..db375f7 100644
@@ -39,8 +39,8 @@ SRC_FILES = "\(\.c\)\|\(\.h\)\|\(Makefile\)\|\(INSTALL\)\|\(LIESMICH\)\|\(README
 EXTRA_MODULES_C := bisect.c
 EXTRA_MODULES_H := bisect.h
 
-SRC_C = main.c bat-hosts.c functions.c proc.c sys.c ping.c traceroute.c tcpdump.c list-batman.c hash.c vis.c $(EXTRA_MODULES_C)
-SRC_H = main.h bat-hosts.h functions.h proc.h sys.h ping.h traceroute.h tcpdump.h list-batman.h hash.h allocate.h vis.h $(EXTRA_MODULES_H)
+SRC_C = main.c bat-hosts.c functions.c sys.c ping.c traceroute.c tcpdump.c list-batman.c hash.c vis.c $(EXTRA_MODULES_C)
+SRC_H = main.h bat-hosts.h functions.h sys.h ping.h traceroute.h tcpdump.h list-batman.h hash.h allocate.h vis.h $(EXTRA_MODULES_H)
 SRC_O = $(SRC_C:.c=.o)
 
 PACKAGE_NAME = batctl
batctl/functions.c +2 -1
index a7f4b77..7d8be51 100644
@@ -164,7 +164,8 @@ open:
 	fp = fopen(full_path, "r");
 
 	if (!fp) {
-		printf("Error - can't open file '%s': %s\n", full_path, strerror(errno));
+		if (!(read_opt & SILENCE_ERRORS))
+			printf("Error - can't open file '%s': %s\n", full_path, strerror(errno));
 		goto out;
 	}
 
batctl/functions.h +1 -0
index 3756392..63740d2 100644
@@ -48,4 +48,5 @@ enum {
 	LOG_MODE = 0x08,
 	USE_READ_BUFF = 0x10,
 	SEARCH_ARGS = 0x20,
+	SILENCE_ERRORS = 0x40,
 };
batctl/main.c +1 -2
index da7fb4a..1cabcdd 100644
@@ -29,7 +29,6 @@
 #include <string.h>
 
 #include "main.h"
-#include "proc.h"
 #include "sys.h"
 #include "ping.h"
 #include "traceroute.h"
@@ -41,7 +40,7 @@
 void print_usage(void) {
 	printf("Usage: batctl [options] commands \n");
 	printf("commands:\n");
-	printf(" \tinterface|if   [none|interface]  \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");
batctl/man/batctl.8 +2 -4
index 43af853..ad165bf 100644
@@ -53,10 +53,8 @@ protocol.
 .br
 .TP
 .I \fBcommands:
-.IP "\fBinterface\fP|\fBif\fP     [\fBnone\fP|\fBinterface\fP]"
-If no parameter is given the current interface settings are displayed
-otherwise the parameter(s) are added as new interfaces. Use the "none"
-keyword to deactivate all interfaces.
+.IP "\fBinterface\fP|\fBif\fP     [\fBadd\fP|\fBdel iface(s)\fP]"
+If no parameter is given or the first parameter is neither "add" nor "del" the current interface settings are displayed. In order to add or delete interfaces specify "add" or "del" as first argument and append the interface names you wish to add or delete.
 .br
 .IP "\fBoriginators\fP|\fBo\fP    [\fB\-b\fP][\fB\-n\fP]"
 Once started batctl will display the list of announced gateways in the network. Use the "\-w" option to let batctl refresh the list every second. If "\-n" is given batctl will not replace the MAC addresses with bat\-host names in the output.
batctl/proc.c deleted +0 -114

114 lines not on this page · raw message

batctl/proc.h deleted +0 -28
deleted file mode 100644
index 61d6058..0000000
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2009 B.A.T.M.A.N. contributors:
- *
- * Marek Lindner <[email protected]>
- *
- * 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 PROC_ROOT_PATH "/proc/net/batman-adv/"
-#define PROC_INTERFACES "interfaces"
-
-int interface(int argc, char **argv);
-
-int handle_table(int argc, char **argv, char *file_path, void table_usage(void));
-int handle_proc_setting(int argc, char **argv, char *file_path, void setting_usage(void));
batctl/sys.c +118 -0

129 lines not on this page · raw message

batctl/sys.h +4 -0
index 19d19f5..6d78622 100644
@@ -34,6 +34,9 @@
 #define SYS_VIS_MODE "vis_mode"
 #define SYS_VIS_DATA "vis_data"
 #define SYS_ORIG_INTERVAL "orig_interval"
+#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"
 
 void originators_usage(void);
 void trans_local_usage(void);
@@ -45,6 +48,7 @@ void gateways_usage(void);
 void vis_mode_usage(void);
 void orig_interval_usage(void);
 int log_print(int argc, char **argv);
+int interface(int argc, char **argv);
 int handle_loglevel(int argc, char **argv);
 int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void));
 int handle_sys_setting(int argc, char **argv, char *file_path, void setting_usage(void));
Signature · 1 line
1.7.0
#6 lore raw
In reply to Marek Lindner

Hi Marek,

had a look at your patches and found a bug which causes a kernel panic (see attachement). I can reproduce this with the following veeery complicated routine :):
---
ifconfig bat0 down && ifconfig bat0 up
---

The adding and deleting of mesh-port interfaces seems to work fine, the new, more dynamic interface is awesome :). And I just was wondering if you forgot about adding something like "batctl if del all" or did you schedule this for another patch?

Also some additional abbrevations for add/del would be nice (just "a" and "d" for instance).

Cheers, Linus

└─(18:09:%)─> picocom /dev/ttyUSB0 <─(Thu,Apr01)─┘
picocom v1.4

port is : /dev/ttyUSB0
flowcontrol : none
baudrate is : 9600
parity is : none
databits are : 8
escape is : C-a
noinit is : no
noreset is : no
nolock is : no
send_cmd is : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Terminal ready
+Warning: IP address 192.168.1.1 in use
Ethernet eth0: MAC address 00:22:b0:98:87:de
IP: 192.168.1.1/255.255.255.0, Gateway: 0.0.0.0
Default server: 192.168.1.2

RedBoot(tm) bootstrap and debug environment [ROMRAM] production release, version "2.1.3" - built 18:43:19, Sep 20 2007

Platform: ap61 (Atheros WiSOC)
Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. Copyright (C) 2007, NewMedia-NET GmbH.

Board: DLINK DIR-300
RAM: 0x80000000-0x81000000, [0x80040580-0x80fe1000] available
FLASH: 0xbfc00000 - 0xbfff0000, 64 blocks of 0x00010000 bytes each.
== Executing boot script in 5.000 seconds - enter ^C to abort
DD-WRT> fis load -l vmlinux.bin.l7
�����������Image loaded from 0x80041000-0x802c2200
DD-WRT> exec
Now booting linux kernel:
Base address 0x80030000 Entry 0x80041000
Cmdline :
Linux version 2.6.30.10 (linus@Linus-Debian) (gcc version 4.3.3 (GCC) ) #25 Thu Apr 1 14:30:45 CEST 2010 CPU revision is: 00019064 (MIPS 4KEc)
Determined physical RAM map:
memory: 01000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Zone PFN ranges:
Normal 0x00000000 -> 0x00001000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges

    0: 0x00000000 -> 0x00001000

Built 1 zonelists in Zone order, mobility grouping off. Total pages: 4064
Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2
Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.
Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 16 bytes
NR_IRQS:128
PID hash table entries: 64 (order: 6, 256 bytes)
console [ttyS0] enabled
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 13324k/16384k available (1985k kernel code, 3060k reserved, 452k data, 128k init, 0k highmem) Calibrating delay loop... 183.50 BogoMIPS (lpj=917504)
Mount-cache hash table entries: 512
net_namespace: 732 bytes
NET: Registered protocol family 16
bio: create slab <bio-0> at 0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 512 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 512 bind 512)
TCP reno registered
NET: Registered protocol family 1
Radio config found at offset 0xf8(0x1f8)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
Registering mini_fo version $Id$
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 26
io scheduler noop registered
io scheduler deadline registered (default)
gpiodev: gpio device registered with major 254
gpiodev: gpio platform device registered with access mask FFFFFFFF
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0xb1100003 (irq = 37) is a 16550A
eth0: Atheros AR231x: 00:22:b0:98:87:de, irq 4
ar231x_eth_mii: probed
eth0: attached PHY driver [IC+ IP175C] (mii_bus:phy_addr=0:00)
cmdlinepart partition parsing not available
Searching for RedBoot partition table in spiflash at offset 0x3d0000
Searching for RedBoot partition table in spiflash at offset 0x3e0000
6 RedBoot partitions found on MTD device spiflash
Creating 6 MTD partitions on "spiflash":
0x000000000000-0x000000030000 : "RedBoot"
0x000000030000-0x0000002f0000 : "rootfs"
mtd: partition "rootfs" set to be root filesystem
mtd: partition "rootfs_data" created automatically, ofs=230000, len=C0000 0x000000230000-0x0000002f0000 : "rootfs_data"
0x0000002f0000-0x0000003d0000 : "vmlinux.bin.l7"
0x0000003e0000-0x0000003ef000 : "FIS directory"
0x0000003ef000-0x0000003f0000 : "RedBoot config"
0x0000003f0000-0x000000400000 : "boardconfig"
TCP westwood registered
NET: Registered protocol family 17
Bridge firewalling registered
802.1Q VLAN Support v1.8 Ben Greear <[email protected]>
All bugs added by David S. Miller <[email protected]>
VFS: Mounted root (squashfs filesystem) readonly on device 31:1.
Freeing unused kernel memory: 128k freed
Please be patient, while OpenWrt loads ...
- preinit -
Press Press f<ENTER> to enter failsafe mode
- regular preinit -
jffs2 not ready yet; using ramdisk
mini_fo: using base directory: /
mini_fo: using storage directory: /tmp/root
- init -

Please press Enter to activate this console. NET: Registered protocol family 10
lo: Disabled Privacy Extensions
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
device eth0.1 entered promiscuous mode
device eth0 entered promiscuous mode
br-mesh: port 1(eth0.1) entering forwarding state
ip_tables: (C) 2000-2006 Netfilter Core Team
Ebtables v2.0 registered
ip6_tables: (C) 2000-2006 Netfilter Core Team
batman-adv:B.A.T.M.A.N. advanced 0.3.0-alpha r1611 (compatibility version 9) loaded
ath_hal: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
ath_hal: 2009-05-08 (AR5212, AR5312, RF5111, RF5112, RF2316, RF2317, REGOPS_FUNC, TX_DESC_SWAP, XR) device eth0.4 entered promiscuous mode
br-wan_vpn: port 1(eth0.4) entering forwarding state
br-wan_vpn: starting userspace STP failed, starting kernel STP
ath_ahb: trunk
wlan: trunk
wlan: mac acl policy registered
ath_rate_minstrel: Minstrel automatic rate control algorithm 1.2 (trunk)
ath_rate_minstrel: look around rate set to 10%
ath_rate_minstrel: EWMA rolloff level set to 75%
ath_rate_minstrel: max segment size in the mrr set to 6000 us
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies
wifi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
wifi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
wifi0: turboG rates: 6Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
wifi0: H/W encryption support: WEP AES AES_CCM TKIP
ath_ahb: wifi0: Atheros 2317 WiSoC REV1: mem=0xb0000000, irq=3
IRQ 3/wifi0: IRQF_DISABLED is not guaranteed on shared IRQs
device bat0 entered promiscuous mode
br-mesh: port 2(bat0) entering forwarding state
device ath0 entered promiscuous mode
br-mesh: port 3(ath0) entering forwarding state
device ath0 left promiscuous mode
br-mesh: port 3(ath0) entering disabled state
device ath0 entered promiscuous mode
br-mesh: port 3(ath0) entering forwarding state
device ath1 entered promiscuous mode
br-wan_vpn: topology change detected, propagating
br-wan_vpn: port 2(ath1) entering forwarding state
device ath1 left promiscuous mode
br-wan_vpn: port 2(ath1) entering disabled state
device ath1 entered promiscuous mode
br-wan_vpn: topology change detected, propagating
br-wan_vpn: port 2(ath1) entering forwarding state
br-wan_vpn: port 2(ath1) entering disabled state
br-wan_vpn: port 1(eth0.4) entering disabled state
br-wan_vpn: topology change detected, propagating
br-wan_vpn: port 2(ath1) entering forwarding state
br-wan_vpn: topology change detected, propagating
br-wan_vpn: port 1(eth0.4) entering forwarding state
br-mesh: port 3(ath0) entering disabled state
br-mesh: port 2(bat0) entering disabled state
br-mesh: port 1(eth0.1) entering disabled state
br-mesh: port 3(ath0) entering forwarding state
br-mesh: port 2(bat0) entering forwarding state
br-mesh: port 1(eth0.1) entering forwarding state
batman-adv:Adding interface: ath2
batman-adv:Interface activated: ath2
CPU 0 Unable to handle kernel paging request at virtual address 00000011, epc == 80bd1524, ra == 80bd3ec4 Oops[#1]:
Cpu 0

$ 0   : 00000000 10009c00 00000001 80c2a4a0
$ 4   : 80e9b300 00000001 00000000 80e21020
$ 8   : 00000000 00000000 00000000 00000000
$12   : 00000000 00000000 802d0000 00000000
$16   : 80e21008 809fe2c0 80f33e20 809fe000
$20   : 8096dd80 0000006e ffffffff 80290000
$24   : 00000000 80bd3ddc
$28   : 8057a000 8057bcb0 80279490 80bd3ec4
Hi    : 00000064
Lo    : 00af485a
epc   : 80bd1524 purge_outstanding_packets+0x21c/0x300 [batman_adv]
    Tainted: P
ra    : 80bd3ec4 interface_tx+0xe8/0x294 [batman_adv]
Status: 10009c03    KERNEL EXL IE
Cause : 10800008
BadVA : 00000011
PrId  : 00019064 (MIPS 4KEc)
Modules linked in: ath_ahb ath_hal(P) batman_adv ip6t_REJECT ip6t_LOG ip6t_rt ip6t_hbh ip6t_mh ip6t_ipv6header ip6t_frag ip6t_eui64 ip6t_ah ip6table_raw ip6_queue ip6table_mangle ip6table_filter ip6_tables ebt_redirect ebt_mark ebt_vlan ebt_stp ebt_pkttype ebt_mark_m ebt_limit ebt_among ebt_802_3 ebtable_nat ebtable_filter ebtable_broute ebtables xt_quota xt_pkttype xt_physdev ipt_REJECT xt_TCPMSS ipt_LOG xt_multiport xt_mac xt_limit iptable_mangle iptable_filter ip_tables xt_tcpudp x_tables tun ipv6
Process dropbearkey (pid: 1090, threadinfo=8057a000, task=80343988, tls=00000000)
Stack : 80f33e20 8057bcf4 80e21012 809fe2c0 80f33e20 80e21008 809fe2c0 80bd3ec4
        0000000a 80a82e98 809fe000 00000005 80bc9800 801d2c40 80bc9800 80bc9800
        00000001 80f33e20 809fe000 8096dd80 ffffa89e ffffffff 80290000 801c6310
        80f33e20 80f33e20 80bcb800 802d4ac0 8096dd80 00000000 80f33e20 809fe000
        802d4ac0 80e21050 00000003 00000004 80bcb800 801b3e08 00000000 00000060
        ...
Call Trace:
[<80bd1524>] purge_outstanding_packets+0x21c/0x300 [batman_adv]
[<80bd3ec4>] interface_tx+0xe8/0x294 [batman_adv]
[<801c6310>] __qdisc_run+0x118/0x2cc
[<801b3e08>] dev_queue_xmit+0x298/0x3dc
[<80a8615c>] ip6_output+0xcd4/0x103c [ipv6]
[<80aa2934>] ipv6_chk_mcast_addr+0xe18/0x1620 [ipv6]
Code: 8c82004c  ac800000  ac800004 <80430010> 24020001  00808021  10620030  00a08821  40056000
Kernel panic - not syncing: Fatal exception in interrupt
#7 lore raw

Hey,

thanks a lot for testing and your feedback!

Quoted 6 lines

had a look at your patches and found a bug which causes a kernel panic (see attachement). I can reproduce this with the following veeery complicated routine :):
---
ifconfig bat0 down && ifconfig bat0 up
---

I tried that but it does not crash at my end. Maybe you did more than you think to provoke this crash ? In my test setup I have 2 nodes with 3 interfaces each. I ran your command several times without seeing any odd behaviour.

Quoted 4 lines

The adding and deleting of mesh-port interfaces seems to work fine, the new, more dynamic interface is awesome :). And I just was wondering if you forgot about adding something like "batctl if del all" or did you schedule this for another patch?

Actually, a "delete all" was not on my agenda.

Quoted 2 lines

Also some additional abbrevations for add/del would be nice (just "a" and "d" for instance).

Should be no problem - I'll add it before submitting the patches.

Regards,
Marek

#8 lore raw
Quoted 4 lines · On Saturday 03 April 2010 17:44:28 Marek Lindner wrote:

I tried that but it does not crash at my end. Maybe you did more than you think to provoke this crash ? In my test setup I have 2 nodes with 3 interfaces each. I ran your command several times without seeing any odd behaviour.

Ok, we found the bug and fixed it.
The sysfs changes are complete now and can be found in the trunk.

Regards,
Marek