All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event
@ 2010-08-14 21:07 Sven Eckelmann
  2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Revert "Adding netfilter-bridge hooks" Sven Eckelmann
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:07 UTC (permalink / raw)
  To: b.a.t.m.a.n

We try to get all events for all net_devices to be able to add special
sysfs folders for the batman-adv configuration. This also includes such
events like NETDEV_POST_INIT which has no valid kobject according to
v2.6.32-rc3-13-g7ffbe3f. This would create an oops in that situation.

It is enough to create the batman_if only on NETDEV_REGISTER events
because we will also receive those events for devices which already
existed when we registered the notifier call.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Cc: stable <stable@kernel.org>
---
 batman-adv/hard-interface.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index 1a829be..f481cbb 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -457,15 +457,13 @@ static int hard_if_event(struct notifier_block *this,
 	struct batman_if *batman_if = get_batman_if_by_netdev(net_dev);
 	struct bat_priv *bat_priv;
 
-	if (!batman_if)
-		batman_if = hardif_add_interface(net_dev);
+	if (!batman_if && event == NETDEV_REGISTER)
+			batman_if = hardif_add_interface(net_dev);
 
 	if (!batman_if)
 		goto out;
 
 	switch (event) {
-	case NETDEV_REGISTER:
-		break;
 	case NETDEV_UP:
 		hardif_activate_interface(batman_if);
 		break;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Revert "Adding netfilter-bridge hooks"
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
@ 2010-08-14 21:07 ` Sven Eckelmann
  2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: Provide skb_cow_head on kernels prior 2.6.23 Sven Eckelmann
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:07 UTC (permalink / raw)
  To: b.a.t.m.a.n

The netfilter hook seems to be misused and may leak skbs in situations
when NF_HOOK returns NF_STOLEN. It doesn't filter in the right chain and
may not filter everything as expected.

It was only added for testing purposes and can be removed again.

Reported-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/hard-interface.c |   13 -------------
 batman-adv/send.c           |    8 ++------
 2 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index f481cbb..d53138c 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -30,7 +30,6 @@
 #include "hash.h"
 
 #include <linux/if_arp.h>
-#include <linux/netfilter_bridge.h>
 
 #include "compat.h"
 
@@ -495,11 +494,6 @@ out:
 	return NOTIFY_DONE;
 }
 
-static int batman_skb_recv_finish(struct sk_buff *skb)
-{
-	return NF_ACCEPT;
-}
-
 /* receive a packet with the batman ethertype coming on a hard
  * interface */
 int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
@@ -517,13 +511,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	if (!skb)
 		goto err_out;
 
-	/* if netfilter/ebtables wants to block incoming batman
-	 * packets then give them a chance to do so here */
-	ret = NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, dev, NULL,
-		      batman_skb_recv_finish);
-	if (ret != 1)
-		goto err_out;
-
 	/* packet should hold at least type and version */
 	if (unlikely(!pskb_may_pull(skb, 2)))
 		goto err_free;
diff --git a/batman-adv/send.c b/batman-adv/send.c
index 47bde44..97c3142 100644
--- a/batman-adv/send.c
+++ b/batman-adv/send.c
@@ -29,7 +29,6 @@
 #include "vis.h"
 #include "aggregation.h"
 #include "gateway_common.h"
-#include <linux/netfilter_bridge.h>
 
 #include "compat.h"
 
@@ -94,12 +93,9 @@ int send_skb_packet(struct sk_buff *skb,
 
 	/* dev_queue_xmit() returns a negative result on error.	 However on
 	 * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
-	 * (which is > 0). This will not be treated as an error.
-	 * Also, if netfilter/ebtables wants to block outgoing batman
-	 * packets then giving them a chance to do so here */
+	 * (which is > 0). This will not be treated as an error. */
 
-	return NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
-		       dev_queue_xmit);
+	return dev_queue_xmit(skb);
 send_skb_err:
 	kfree_skb(skb);
 	return NET_XMIT_DROP;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: Provide skb_cow_head on kernels prior 2.6.23
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
  2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Revert "Adding netfilter-bridge hooks" Sven Eckelmann
@ 2010-08-14 21:07 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: Provide old dev_get_by_name for kernel prior 2.6.24 Sven Eckelmann
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:07 UTC (permalink / raw)
  To: b.a.t.m.a.n

skb_cow_head was first introduced in v2.6.23-rc6-155-gd9cc204 and we
must use skb_cow on those kernel which will also copy the skb when it
shares data with other skbs and not only when the header is only shared.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/compat.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/batman-adv/compat.h b/batman-adv/compat.h
index f0f0b16..5bf1532 100644
--- a/batman-adv/compat.h
+++ b/batman-adv/compat.h
@@ -70,6 +70,11 @@ static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len)
 	return 0;
 }
 
+static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
+{
+	return skb_cow(skb, headroom);
+}
+
 #define cancel_delayed_work_sync(wq) cancel_delayed_work(wq)
 
 #endif /* < KERNEL_VERSION(2, 6, 23) */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: Provide old dev_get_by_name for kernel prior 2.6.24
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
  2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Revert "Adding netfilter-bridge hooks" Sven Eckelmann
  2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: Provide skb_cow_head on kernels prior 2.6.23 Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Remove duplicate of attached device name Sven Eckelmann
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

Since v2.6.23-173-g881d966 we must provide the net namespace to use for
dev_get_by_name. Older kernels didn't provide that functionality and we
must ignore that argument.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/compat.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/batman-adv/compat.h b/batman-adv/compat.h
index 5bf1532..617d23c 100644
--- a/batman-adv/compat.h
+++ b/batman-adv/compat.h
@@ -90,6 +90,8 @@ static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
 #define pr_warning(fmt, ...) \
        printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
 
+#define dev_get_by_name(x, y) dev_get_by_name(y)
+
 #endif /* < KERNEL_VERSION(2, 6, 24) */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Remove duplicate of attached device name
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (2 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: Provide old dev_get_by_name for kernel prior 2.6.24 Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 6/9] batman-adv: Don't inform about dropped packets in nodebug Sven Eckelmann
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

batman_if has the name of the net_dev as extra string in its own
structure, but also holds a reference to the actual net_device structure
which always has the current name of the device. This makes it
unneccessary and also more complex because we must update the name in
situations when we receive a NETDEV_CHANGENAME event.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/gateway_client.c |    6 +++---
 batman-adv/hard-interface.c |   29 ++++++++++-------------------
 batman-adv/originator.c     |    8 ++++----
 batman-adv/routing.c        |    9 +++++----
 batman-adv/send.c           |    9 +++++----
 batman-adv/types.h          |    1 -
 6 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/batman-adv/gateway_client.c b/batman-adv/gateway_client.c
index ec3aeb0..6721398 100644
--- a/batman-adv/gateway_client.c
+++ b/batman-adv/gateway_client.c
@@ -321,7 +321,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv,
 		       gw_str,
 		       gw_node->orig_node->router->tq_avg,
 		       router_str,
-		       gw_node->orig_node->router->if_incoming->dev,
+		       gw_node->orig_node->router->if_incoming->net_dev->name,
 		       gw_node->orig_node->gw_flags,
 		       (down > 2048 ? down / 1024 : down),
 		       (down > 2048 ? "MBit" : "KBit"),
@@ -358,8 +358,8 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset)
 		   "[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,
-		   bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
-		   net_dev->name);
+		   bat_priv->primary_if->net_dev->name,
+		   bat_priv->primary_if->addr_str, net_dev->name);
 	rcu_read_unlock();
 
 	rcu_read_lock();
diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index d53138c..a141ffb 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -160,7 +160,7 @@ static void check_known_mac_addr(uint8_t *addr)
 			continue;
 
 		pr_warning("The newly added mac address (%pM) already exists "
-			   "on: %s\n", addr, batman_if->dev);
+			   "on: %s\n", addr, batman_if->net_dev->name);
 		pr_warning("It is strongly recommended to keep mac addresses "
 			   "unique to avoid problems!\n");
 	}
@@ -226,7 +226,7 @@ static void hardif_activate_interface(struct batman_if *batman_if)
 		set_primary_if(bat_priv, batman_if);
 
 	bat_info(batman_if->soft_iface, "Interface activated: %s\n",
-		 batman_if->dev);
+		 batman_if->net_dev->name);
 
 	update_min_mtu(batman_if->soft_iface);
 	return;
@@ -243,7 +243,7 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
 	batman_if->if_status = IF_INACTIVE;
 
 	bat_info(batman_if->soft_iface, "Interface deactivated: %s\n",
-		 batman_if->dev);
+		 batman_if->net_dev->name);
 
 	update_min_mtu(batman_if->soft_iface);
 }
@@ -274,7 +274,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
 
 	if (!batman_if->packet_buff) {
 		bat_err(batman_if->soft_iface, "Can't add interface packet "
-			"(%s): out of memory\n", batman_if->dev);
+			"(%s): out of memory\n", batman_if->net_dev->name);
 		goto err;
 	}
 
@@ -299,7 +299,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
 	atomic_set(&batman_if->seqno, 1);
 	atomic_set(&batman_if->frag_seqno, 1);
 	bat_info(batman_if->soft_iface, "Adding interface: %s\n",
-		 batman_if->dev);
+		 batman_if->net_dev->name);
 
 	if (atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu <
 		ETH_DATA_LEN + BAT_HEADER_LEN)
@@ -309,7 +309,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
 			"over this interface will be fragmented on layer2 "
 			"which could impact the performance. Setting the MTU "
 			"to %zi would solve the problem.\n",
-			batman_if->dev, batman_if->net_dev->mtu,
+			batman_if->net_dev->name, batman_if->net_dev->mtu,
 			ETH_DATA_LEN + BAT_HEADER_LEN);
 
 	if (!atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu <
@@ -319,7 +319,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
 			"the transport of batman-adv packets. If you experience"
 			" problems getting traffic through try increasing the "
 			"MTU to %zi.\n",
-			batman_if->dev, batman_if->net_dev->mtu,
+			batman_if->net_dev->name, batman_if->net_dev->mtu,
 			ETH_DATA_LEN + BAT_HEADER_LEN);
 
 	if (hardif_is_iface_up(batman_if))
@@ -327,7 +327,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
 	else
 		bat_err(batman_if->soft_iface, "Not using interface %s "
 			"(retrying later): interface not active\n",
-			batman_if->dev);
+			batman_if->net_dev->name);
 
 	/* begin scheduling originator messages on that interface */
 	schedule_own_packet(batman_if);
@@ -350,7 +350,7 @@ void hardif_disable_interface(struct batman_if *batman_if)
 		return;
 
 	bat_info(batman_if->soft_iface, "Removing interface: %s\n",
-		 batman_if->dev);
+		 batman_if->net_dev->name);
 	dev_remove_pack(&batman_if->batman_adv_ptype);
 
 	bat_priv->num_ifaces--;
@@ -392,13 +392,9 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 		goto out;
 	}
 
-	batman_if->dev = kstrdup(net_dev->name, GFP_ATOMIC);
-	if (!batman_if->dev)
-		goto free_if;
-
 	ret = sysfs_add_hardif(&batman_if->hardif_obj, net_dev);
 	if (ret)
-		goto free_dev;
+		goto free_if;
 
 	batman_if->if_num = -1;
 	batman_if->net_dev = net_dev;
@@ -410,8 +406,6 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 	list_add_tail_rcu(&batman_if->list, &if_list);
 	return batman_if;
 
-free_dev:
-	kfree(batman_if->dev);
 free_if:
 	kfree(batman_if);
 out:
@@ -422,7 +416,6 @@ static void hardif_free_interface(struct rcu_head *rcu)
 {
 	struct batman_if *batman_if = container_of(rcu, struct batman_if, rcu);
 
-	kfree(batman_if->dev);
 	kfree(batman_if);
 }
 
@@ -473,8 +466,6 @@ static int hard_if_event(struct notifier_block *this,
 	case NETDEV_UNREGISTER:
 		hardif_remove_interface(batman_if);
 		break;
-	case NETDEV_CHANGENAME:
-		break;
 	case NETDEV_CHANGEADDR:
 		if (batman_if->if_status == IF_NOT_IN_USE)
 			goto out;
diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index eb8081d..2250266 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -216,7 +216,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv,
 					"neighbor purge: originator %pM, "
 					"neighbor: %pM, iface: %s\n",
 					orig_node->orig, neigh_node->addr,
-					neigh_node->if_incoming->dev);
+					neigh_node->if_incoming->net_dev->name);
 			else
 				bat_dbg(DBG_BATMAN, bat_priv,
 					"neighbor timeout: originator %pM, "
@@ -338,8 +338,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
 	rcu_read_lock();
 	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);
+		   bat_priv->primary_if->net_dev->name,
+		   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");
@@ -367,7 +367,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
 		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);
+			   orig_node->router->if_incoming->net_dev->name);
 
 		list_for_each_entry(neigh_node, &orig_node->neigh_list, list) {
 			addr_to_string(orig_str, neigh_node->addr);
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index 522e702..454a84c 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -569,10 +569,11 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 		"Received BATMAN packet via NB: %pM, IF: %s [%s] "
 		"(from OG: %pM, via prev OG: %pM, seqno %d, tq %d, "
 		"TTL %d, V %d, IDF %d)\n",
-		ethhdr->h_source, if_incoming->dev, if_incoming->addr_str,
-		batman_packet->orig, batman_packet->prev_sender,
-		batman_packet->seqno, batman_packet->tq, batman_packet->ttl,
-		batman_packet->version, has_directlink_flag);
+		ethhdr->h_source, if_incoming->net_dev->name,
+		if_incoming->addr_str, batman_packet->orig,
+		batman_packet->prev_sender, batman_packet->seqno,
+		batman_packet->tq, batman_packet->ttl, batman_packet->version,
+		has_directlink_flag);
 
 	list_for_each_entry_rcu(batman_if, &if_list, list) {
 		if (batman_if->if_status != IF_ACTIVE)
diff --git a/batman-adv/send.c b/batman-adv/send.c
index 97c3142..92eb421 100644
--- a/batman-adv/send.c
+++ b/batman-adv/send.c
@@ -70,7 +70,7 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		pr_warning("Interface %s is not up - can't send packet via "
-			   "that interface!\n", batman_if->dev);
+			   "that interface!\n", batman_if->net_dev->name);
 		goto send_skb_err;
 	}
 
@@ -143,7 +143,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 			batman_packet->tq, batman_packet->ttl,
 			(batman_packet->flags & DIRECTLINK ?
 			 "on" : "off"),
-			batman_if->dev, batman_if->addr_str);
+			batman_if->net_dev->name, batman_if->addr_str);
 
 		buff_pos += sizeof(struct batman_packet) +
 			(batman_packet->num_hna * ETH_ALEN);
@@ -188,7 +188,8 @@ static void send_packet(struct forw_packet *forw_packet)
 			"on interface %s [%s]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_packet->orig, ntohl(batman_packet->seqno),
-			batman_packet->ttl, forw_packet->if_incoming->dev,
+			batman_packet->ttl,
+			forw_packet->if_incoming->net_dev->name,
 			forw_packet->if_incoming->addr_str);
 
 		/* skb is only used once and than forw_packet is free'd */
@@ -530,7 +531,7 @@ void purge_outstanding_packets(struct bat_priv *bat_priv,
 	if (batman_if)
 		bat_dbg(DBG_BATMAN, bat_priv,
 			"purge_outstanding_packets(): %s\n",
-			batman_if->dev);
+			batman_if->net_dev->name);
 	else
 		bat_dbg(DBG_BATMAN, bat_priv,
 			"purge_outstanding_packets()\n");
diff --git a/batman-adv/types.h b/batman-adv/types.h
index d260fd2..1e736fb 100644
--- a/batman-adv/types.h
+++ b/batman-adv/types.h
@@ -36,7 +36,6 @@
 struct batman_if {
 	struct list_head list;
 	int16_t if_num;
-	char *dev;
 	char if_status;
 	char addr_str[ETH_STR_LEN];
 	struct net_device *net_dev;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 6/9] batman-adv: Don't inform about dropped packets in nodebug
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (3 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Remove duplicate of attached device name Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 7/9] batman-adv: Don't use net_dev after dev_put Sven Eckelmann
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

Information about dropped packets are usually only interesting for
debugging purposes and otherwise open the possibility to flood the logs
of the target machine with useless information.

pr_debug will not output those information on a nodebug kernel.

Reported-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/compat.h  |    8 ++++++++
 batman-adv/routing.c |   15 +++++++--------
 batman-adv/vis.c     |    2 +-
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/batman-adv/compat.h b/batman-adv/compat.h
index 617d23c..d59d709 100644
--- a/batman-adv/compat.h
+++ b/batman-adv/compat.h
@@ -90,6 +90,14 @@ static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
 #define pr_warning(fmt, ...) \
        printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
 
+#if defined(DEBUG)
+#define pr_debug(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_debug(fmt, ...) \
+	({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
 #define dev_get_by_name(x, y) dev_get_by_name(y)
 
 #endif /* < KERNEL_VERSION(2, 6, 24) */
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index 454a84c..a2c64a4 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -871,9 +871,9 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
 
 	/* send TTL exceeded if packet is an echo request (traceroute) */
 	if (icmp_packet->msg_type != ECHO_REQUEST) {
-		pr_warning("Warning - can't forward icmp packet from %pM to "
-			   "%pM: ttl exceeded\n", icmp_packet->orig,
-			   icmp_packet->dst);
+		pr_debug("Warning - can't forward icmp packet from %pM to "
+			 "%pM: ttl exceeded\n", icmp_packet->orig,
+			 icmp_packet->dst);
 		return NET_RX_DROP;
 	}
 
@@ -1153,9 +1153,9 @@ static int route_unicast_packet(struct sk_buff *skb,
 
 	/* TTL exceeded */
 	if (unicast_packet->ttl < 2) {
-		pr_warning("Warning - can't forward unicast packet from %pM to "
-			   "%pM: ttl exceeded\n", ethhdr->h_source,
-			   unicast_packet->dest);
+		pr_debug("Warning - can't forward unicast packet from %pM to "
+			 "%pM: ttl exceeded\n", ethhdr->h_source,
+			 unicast_packet->dest);
 		return NET_RX_DROP;
 	}
 
@@ -1236,8 +1236,7 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)
 			hash_find(bat_priv->orig_hash, unicast_packet->orig));
 
 		if (!orig_node) {
-			pr_warning("couldn't find orig node for "
-				"fragmentation\n");
+			pr_debug("couldn't find orig node for fragmentation\n");
 			spin_unlock_irqrestore(&bat_priv->orig_hash_lock,
 					       flags);
 			return NET_RX_DROP;
diff --git a/batman-adv/vis.c b/batman-adv/vis.c
index ac3779b..6de5c76 100644
--- a/batman-adv/vis.c
+++ b/batman-adv/vis.c
@@ -746,7 +746,7 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
 
 	packet = (struct vis_packet *)info->skb_packet->data;
 	if (packet->ttl < 2) {
-		pr_warning("Error - can't send vis packet: ttl exceeded\n");
+		pr_debug("Error - can't send vis packet: ttl exceeded\n");
 		return;
 	}
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 7/9] batman-adv: Don't use net_dev after dev_put
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (4 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 6/9] batman-adv: Don't inform about dropped packets in nodebug Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 8/9] batman-adv: Update mtu of bat device by changing mtu of slave device Sven Eckelmann
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

dev_put allows a device to be freed when all its references are dropped.
After that we are not allowed to access that information anymore. Access
to the data structure of a net_device must be surrounded a dev_hold
and ended using dev_put.

batman-adv adds a device to its own management structure in
hardif_add_interface and will release it in hardif_remove_interface.
Thus it must hold a reference all the time between those functions to
prevent any access to the already released net_device structure.

Reported-by: Tim Glaremin <Tim.Glaremin@web.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/hard-interface.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index a141ffb..2025ba1 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -213,7 +213,6 @@ static void hardif_activate_interface(struct batman_if *batman_if)
 		return;
 
 	bat_priv = netdev_priv(batman_if->soft_iface);
-	dev_hold(batman_if->net_dev);
 
 	update_mac_addresses(batman_if);
 	batman_if->if_status = IF_TO_BE_ACTIVATED;
@@ -238,8 +237,6 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
 	   (batman_if->if_status != IF_TO_BE_ACTIVATED))
 		return;
 
-	dev_put(batman_if->net_dev);
-
 	batman_if->if_status = IF_INACTIVE;
 
 	bat_info(batman_if->soft_iface, "Interface deactivated: %s\n",
@@ -385,11 +382,13 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 	if (ret != 1)
 		goto out;
 
+	dev_hold(net_dev);
+
 	batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
 	if (!batman_if) {
 		pr_err("Can't add interface (%s): out of memory\n",
 		       net_dev->name);
-		goto out;
+		goto release_dev;
 	}
 
 	ret = sysfs_add_hardif(&batman_if->hardif_obj, net_dev);
@@ -408,6 +407,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 
 free_if:
 	kfree(batman_if);
+release_dev:
+	dev_put(net_dev);
 out:
 	return NULL;
 }
@@ -431,6 +432,7 @@ static void hardif_remove_interface(struct batman_if *batman_if)
 	batman_if->if_status = IF_TO_BE_REMOVED;
 	list_del_rcu(&batman_if->list);
 	sysfs_del_hardif(&batman_if->hardif_obj);
+	dev_put(batman_if->net_dev);
 	call_rcu(&batman_if->rcu, hardif_free_interface);
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 8/9] batman-adv: Update mtu of bat device by changing mtu of slave device
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (5 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 7/9] batman-adv: Don't use net_dev after dev_put Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically Sven Eckelmann
  2010-08-20 19:23 ` [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Marek Lindner
  8 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

We must reduce our own mtu when we reduce the mtu of any device we use
to transfer our packets. Otherwise we may accept to large packets which
gets dropped by the actual device.

Reported-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/hard-interface.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index 2025ba1..ee02050 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -468,6 +468,10 @@ static int hard_if_event(struct notifier_block *this,
 	case NETDEV_UNREGISTER:
 		hardif_remove_interface(batman_if);
 		break;
+	case NETDEV_CHANGEMTU:
+		if (batman_if->soft_iface)
+			update_min_mtu(batman_if->soft_iface);
+		break;
 	case NETDEV_CHANGEADDR:
 		if (batman_if->if_status == IF_NOT_IN_USE)
 			goto out;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (6 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 8/9] batman-adv: Update mtu of bat device by changing mtu of slave device Sven Eckelmann
@ 2010-08-14 21:08 ` Sven Eckelmann
  2010-08-14 21:32   ` Marek Lindner
  2010-08-20 19:23 ` [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Marek Lindner
  8 siblings, 1 reply; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-14 21:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

The user usually sets a mtu by hand and don't want to have software to
change it automatically. This is only needed when we must reduce the mtu
due to a low mtu of an active slave device, but we should not increase
it when any other action is made on the system related to the used
interfaces.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/hard-interface.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index ee02050..eb26026 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -201,7 +201,7 @@ void update_min_mtu(struct net_device *soft_iface)
 	int min_mtu;
 
 	min_mtu = hardif_min_mtu(soft_iface);
-	if (soft_iface->mtu != min_mtu)
+	if (soft_iface->mtu > min_mtu)
 		soft_iface->mtu = min_mtu;
 }
 
@@ -241,8 +241,6 @@ static void hardif_deactivate_interface(struct batman_if *batman_if)
 
 	bat_info(batman_if->soft_iface, "Interface deactivated: %s\n",
 		 batman_if->net_dev->name);
-
-	update_min_mtu(batman_if->soft_iface);
 }
 
 int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically Sven Eckelmann
@ 2010-08-14 21:32   ` Marek Lindner
  2010-08-15  8:23     ` Sven Eckelmann
  0 siblings, 1 reply; 12+ messages in thread
From: Marek Lindner @ 2010-08-14 21:32 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Saturday 14 August 2010 23:08:05 Sven Eckelmann wrote:
> The user usually sets a mtu by hand and don't want to have software to
> change it automatically. This is only needed when we must reduce the mtu
> due to a low mtu of an active slave device, but we should not increase
> it when any other action is made on the system related to the used
> interfaces.

I fear that this might lead to a strange user experience. If the mtu on batX 
wasn't set explicitely but the mtu of an interface used by batman is increased 
while batman uses it the user has to know that he/she now needs to manually 
modify the batX mtu before it becomes effective.

What about a flag which remembers whether the mtu on batX was modified by the 
user. If so, batman-adv does not increase the mtu otherwise we keep the 
current behaviour ?

Regards,
Marek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically
  2010-08-14 21:32   ` Marek Lindner
@ 2010-08-15  8:23     ` Sven Eckelmann
  0 siblings, 0 replies; 12+ messages in thread
From: Sven Eckelmann @ 2010-08-15  8:23 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

[-- Attachment #1: Type: Text/Plain, Size: 1026 bytes --]

Marek Lindner wrote:
> On Saturday 14 August 2010 23:08:05 Sven Eckelmann wrote:
> > The user usually sets a mtu by hand and don't want to have software to
> > change it automatically. This is only needed when we must reduce the mtu
> > due to a low mtu of an active slave device, but we should not increase
> > it when any other action is made on the system related to the used
> > interfaces.
> 
> I fear that this might lead to a strange user experience. If the mtu on
> batX wasn't set explicitely but the mtu of an interface used by batman is
> increased while batman uses it the user has to know that he/she now needs
> to manually modify the batX mtu before it becomes effective.
> 
> What about a flag which remembers whether the mtu on batX was modified by
> the user. If so, batman-adv does not increase the mtu otherwise we keep
> the current behaviour ?

Ok, then drop that patch. The user seems to be familiar with that behavior 
because bridge handles it the same way.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event
  2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
                   ` (7 preceding siblings ...)
  2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically Sven Eckelmann
@ 2010-08-20 19:23 ` Marek Lindner
  8 siblings, 0 replies; 12+ messages in thread
From: Marek Lindner @ 2010-08-20 19:23 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Saturday 14 August 2010 23:07:57 Sven Eckelmann wrote:
> We try to get all events for all net_devices to be able to add special
> sysfs folders for the batman-adv configuration. This also includes such
> events like NETDEV_POST_INIT which has no valid kobject according to
> v2.6.32-rc3-13-g7ffbe3f. This would create an oops in that situation.

I applied all patches (revision 1769 - 1775)  except for patch 2 & 9. Linus is 
working on a fix for the netfilter stuff, so I'd rather wait for his 
patch/opinion. We might come back to your patch at a later point.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-08-20 19:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-14 21:07 [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Sven Eckelmann
2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Revert "Adding netfilter-bridge hooks" Sven Eckelmann
2010-08-14 21:07 ` [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: Provide skb_cow_head on kernels prior 2.6.23 Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: Provide old dev_get_by_name for kernel prior 2.6.24 Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Remove duplicate of attached device name Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 6/9] batman-adv: Don't inform about dropped packets in nodebug Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 7/9] batman-adv: Don't use net_dev after dev_put Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 8/9] batman-adv: Update mtu of bat device by changing mtu of slave device Sven Eckelmann
2010-08-14 21:08 ` [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: Don't increase mtu of interface automatically Sven Eckelmann
2010-08-14 21:32   ` Marek Lindner
2010-08-15  8:23     ` Sven Eckelmann
2010-08-20 19:23 ` [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Create batman_if only on register event Marek Lindner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.