b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] (no subject)
@ 2017-04-25  0:02 Linus Lüssing
  2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 1/5] batman-adv: Introduce packet type independent TVLV handler API Linus Lüssing
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Linus Lüssing @ 2017-04-25  0:02 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hi,

This patchset introduces aggregation support for BATMAN V -
as well as any other packet type with a broadcast destination.

Branch:
* https://git.open-mesh.org/batman-adv.git/shortlog/refs/heads/linus/aggregation

Regards, Linus

---

Changelog:

v3:
* moved "Introduce packet type independent TVLV ..." from
  linus/neighhash to this patchset
  (this patchset is more important, therefore swapping their order)
* removed the two already applied patches
* rebased to master

v2:
* reset skb->cb on the soft-iface reception path, too [PATCH 5/6]
  (thanks Sven!)

RFC->v1:
* removed tvlv (un)pack ctx wrappers
* fixed a crash when deaggregating ARP packets
* now compile tested down to 3.2, too (no issues found)
* now stress tested with multicast traffic of a larger, public mesh setup


^ permalink raw reply	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2018-09-28  6:17 udit kalra
  0 siblings, 0 replies; 25+ messages in thread
From: udit kalra @ 2018-09-28  6:17 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hi,

i want to install BATMAN-adv  open mesh network in Linux PC
can u please provide me the complete installation guide from the initial level.

Thanks & Regards,
Udit kalra

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2013-10-19 22:21 Antonio Quartulli
  2013-10-20  0:15 ` David Miller
  0 siblings, 1 reply; 25+ messages in thread
From: Antonio Quartulli @ 2013-10-19 22:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n

Hello David,

this is another batch intended for net-next/linux-3.13.

This pull request is a bit bigger than usual, but 6 patches are very small
(three of them are about email updates)..

Patch 1 is fixing a previous merge conflict resolution that went wrong
(I realised that only now while checking other patches..).
Patches from 2 to 4 that are updating our emails in all the proper files
(Documentation/, headers and MAINTAINERS).

Patches 5, 6 and 7 are bringing a big improvement to the TranslationTable
component: it is now able to group non-mesh clients based on the VLAN they
belong to. In this way a lot a new enhancements are now possible thanks to the
fact that each batman-adv behaviour can be applied on a per VLAN basis.

And, of course, in patches from 8 to 12 you have some of the enhancements I was
talking about:
- make the batman-Gateway selection VLAN dependent
- make DAT (Distributed ARP Table) group ARP entries on a VLAN basis (this
  allows DAT to work even when the admin decided to use the same IP subnet on
  different VLANs)
- make the AP-Isolation behaviour switchable on each VLAN independently
- export VLAN specific attributes via sysfs. Switches like the AP-Isolation are
  now exported once per VLAN (backward compatibility of the sysfs interface has
  been preserved)

Patches 13 and 14 are small code cleanups.
Patch 15 is a minor improvement in the TT locking mechanism.

Patches 16 and 17 are other enhancements to the TT component. Those allow a
node to parse a "non-mesh client announcement message" and accept only those
TT entries belonging to certain VLANs.

Patch 18 exploits this parse&accept mechanism to make the Bridge Loop Avoidance
component reject only TT entries connected to the VLAN where it is operating.
Previous to this change, BLA was rejecting all the entries coming from any other
Backbone node, regardless of the VLAN (for more details about how the Bridge
Loop Avoidance works please check [1]).


Please pull or let me know of any problem.

Thanks a lot,
	Antonio


[1] http://www.open-mesh.org/projects/batman-adv/wiki/Bridge-loop-avoidance-II

The following changes since commit b1eda2ac3fa6bf23b27c7c70eda6885124c79ed3:

  em_ipset: use dev_net() accessor (2013-10-18 16:23:06 -0400)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem

for you to fetch changes up to cfd4f75701b6b13b1ec74e6f65ad0d1969c19247:

  batman-adv: make the backbone gw check VLAN specific (2013-10-19 23:25:38 +0200)

----------------------------------------------------------------
Included changed:
- email addresses update in documentation, source files and MAINTAINERS
- make the TT component distinguish non-mesh clients based on the VLAN they
  belong to
- improve all the internal components to properly work on a per-VLAN basis
  (enabled by the new TT-VLAN feature)
- enhance the sysfs interface in order to provide behaviour switches on a
  per-VLAN basis (enabled by the new TT-VLAN feature)
- improve TT lock mechanism
- improve unicast transmission APIs

----------------------------------------------------------------
Antonio Quartulli (15):
      batman-adv: check skb preparation return value
      batman-adv: update email address for Antonio Quartulli
      batman-adv: add the VLAN ID attribute to the TT entry
      batman-adv: use vid when computing local and global TT CRC
      batman-adv: print the VID together with the TT entries
      batman-adv: make the GW module correctly talk to the new VLAN-TT
      batman-adv: make the Distributed ARP Table vlan aware
      batman-adv: add per VLAN interface attribute framework
      batman-adv: add sysfs framework for VLAN
      batman-adv: make the AP isolation attribute VLAN specific
      batman-adv: remove bogus comment
      batman-adv: lock around TT operations to avoid sending inconsistent data
      batman-adv: make the TT CRC logic VLAN specific
      batman-adv: make the TT global purge routine VLAN specific
      batman-adv: make the backbone gw check VLAN specific

Linus Lüssing (1):
      batman-adv: refine API calls for unicast transmissions of SKBs

Marek Lindner (1):
      batman-adv: update email address for Marek Lindner

Simon Wunderlich (1):
      batman-adv: update email address for Simon Wunderlich

 .../ABI/testing/sysfs-class-net-batman-adv         |    4 +-
 Documentation/ABI/testing/sysfs-class-net-mesh     |   23 +-
 Documentation/networking/batman-adv.txt            |    4 +-
 MAINTAINERS                                        |    2 +-
 net/batman-adv/bridge_loop_avoidance.c             |   58 +-
 net/batman-adv/bridge_loop_avoidance.h             |   10 +-
 net/batman-adv/distributed-arp-table.c             |  160 ++-
 net/batman-adv/gateway_client.c                    |   25 +-
 net/batman-adv/hard-interface.c                    |    2 +
 net/batman-adv/main.c                              |   33 +-
 net/batman-adv/main.h                              |   15 +-
 net/batman-adv/originator.c                        |  104 +-
 net/batman-adv/originator.h                        |    7 +
 net/batman-adv/packet.h                            |   32 +-
 net/batman-adv/routing.c                           |   28 +-
 net/batman-adv/send.c                              |   98 +-
 net/batman-adv/send.h                              |   51 +-
 net/batman-adv/soft-interface.c                    |  227 +++-
 net/batman-adv/soft-interface.h                    |    4 +
 net/batman-adv/sysfs.c                             |  178 ++-
 net/batman-adv/sysfs.h                             |   10 +
 net/batman-adv/translation-table.c                 | 1157 +++++++++++++++-----
 net/batman-adv/translation-table.h                 |   23 +-
 net/batman-adv/types.h                             |   83 +-
 24 files changed, 1851 insertions(+), 487 deletions(-)

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2013-08-02 12:44 Linus Lüssing
  0 siblings, 0 replies; 25+ messages in thread
From: Linus Lüssing @ 2013-08-02 12:44 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hi,

This second version adds a few more cases I could spot which look like trouble.

Secondly, instead of copying the destination mac on the stack it simply uses
eth_hdr().


Why do we need no skb_reset_mac_header() or skb_set_mac_header()? Because
batadv_skb_head_push() calls skb_headers_offset_update() after the reallocation
(via skb_cow_head()->__skb_cow()->pskb_expand_head()->
skb_headers_offset_update().

I also checked that the ether header in the newly allocated buffer is not going
to end up being fragmented. But looks like pskb_expand_head() actually reserves
enough space for both the old ethernet header plus the newly requested head
space.

So if the mac header was set correctly before, then eth_hdr() will point us
to the right one already.


This patch is maybe not so straight forward, you need to read quite skb
code. At least not as straight forward as the previous version of this patch.
So I leave it up to you to decide whether this is suitable for next or whether
you think there's a potential for unseen pitfalls, therefore making it
suitable for master only :).


This patch fixed the kernel panic I was reproduceably getting just as well. 
(Which was while sending multicast packets through the unicast functions
while having a bridge on top of bat0)


Cheers, Linus


^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <pull request for net: batman-adv 2013-05-21>]
* [B.A.T.M.A.N.] [PATCHv4 1/2] batman-adv: Remove unnecessary hardif_list_lock
@ 2011-05-02 19:19 Sven Eckelmann
  2011-05-03  9:51 ` [B.A.T.M.A.N.] (no subject) Linus Lüssing
  0 siblings, 1 reply; 25+ messages in thread
From: Sven Eckelmann @ 2011-05-02 19:19 UTC (permalink / raw)
  To: b.a.t.m.a.n

hardif_list_lock is unneccessary because we already ensure that no
multiple admin operations can take place through rtnl_lock.
hardif_list_lock only adds additional overhead and complexity.

Critical functions now check whether they are called with rtnl_lock
using ASSERT_RTNL.

It indirectly fixes the problem that orig_hash_del_if() expects that
only one interface is deleted from hardif_list at a time, but
hardif_remove_interfaces() removes all at once and then calls
orig_hash_del_if().

Reported-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Addressed Linus' comments:
 * Merged patch 1/3 and 2/3 again
 * Ensure that primary_if_select is only called with rtnl_lock through
   hardif_enable_interface (was fixed in patch 3/3... but now in a
   patch earlier)
 * Add a comment above hardif_list to inform about needed locking

 bat_sysfs.c      |    2 ++
 hard-interface.c |   30 +++++++-----------------------
 main.c           |    3 +++
 3 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/bat_sysfs.c b/bat_sysfs.c
index e449bf6..85ba20d 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -502,7 +502,9 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
 		rtnl_unlock();
 	}
 
+	rtnl_lock();
 	ret = hardif_enable_interface(hard_iface, buff);
+	rtnl_unlock();
 
 out:
 	hardif_free_ref(hard_iface);
diff --git a/hard-interface.c b/hard-interface.c
index 3e888f1..7e2f772 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -31,9 +31,6 @@
 
 #include <linux/if_arp.h>
 
-/* protect update critical side of hardif_list - but not the content */
-static DEFINE_SPINLOCK(hardif_list_lock);
-
 
 static int batman_skb_recv(struct sk_buff *skb,
 			   struct net_device *dev,
@@ -136,7 +133,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
 	struct hard_iface *curr_hard_iface;
 	struct batman_packet *batman_packet;
 
-	spin_lock_bh(&hardif_list_lock);
+	ASSERT_RTNL();
 
 	if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
 		new_hard_iface = NULL;
@@ -148,7 +145,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
 		hardif_free_ref(curr_hard_iface);
 
 	if (!new_hard_iface)
-		goto out;
+		return;
 
 	batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
 	batman_packet->flags = PRIMARIES_FIRST_HOP;
@@ -161,9 +158,6 @@ static void primary_if_select(struct bat_priv *bat_priv,
 	 * our new primary interface
 	 */
 	atomic_set(&bat_priv->hna_local_changed, 1);
-
-out:
-	spin_unlock_bh(&hardif_list_lock);
 }
 
 static bool hardif_is_iface_up(struct hard_iface *hard_iface)
@@ -456,6 +450,8 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
 	struct hard_iface *hard_iface;
 	int ret;
 
+	ASSERT_RTNL();
+
 	ret = is_valid_iface(net_dev);
 	if (ret != 1)
 		goto out;
@@ -482,10 +478,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
 	atomic_set(&hard_iface->refcount, 2);
 
 	check_known_mac_addr(hard_iface->net_dev);
-
-	spin_lock(&hardif_list_lock);
 	list_add_tail_rcu(&hard_iface->list, &hardif_list);
-	spin_unlock(&hardif_list_lock);
 
 	return hard_iface;
 
@@ -499,6 +492,8 @@ out:
 
 static void hardif_remove_interface(struct hard_iface *hard_iface)
 {
+	ASSERT_RTNL();
+
 	/* first deactivate interface */
 	if (hard_iface->if_status != IF_NOT_IN_USE)
 		hardif_disable_interface(hard_iface);
@@ -514,20 +509,11 @@ static void hardif_remove_interface(struct hard_iface *hard_iface)
 void hardif_remove_interfaces(void)
 {
 	struct hard_iface *hard_iface, *hard_iface_tmp;
-	struct list_head if_queue;
 
-	INIT_LIST_HEAD(&if_queue);
-
-	spin_lock(&hardif_list_lock);
+	rtnl_lock();
 	list_for_each_entry_safe(hard_iface, hard_iface_tmp,
 				 &hardif_list, list) {
 		list_del_rcu(&hard_iface->list);
-		list_add_tail(&hard_iface->list, &if_queue);
-	}
-	spin_unlock(&hardif_list_lock);
-
-	rtnl_lock();
-	list_for_each_entry_safe(hard_iface, hard_iface_tmp, &if_queue, list) {
 		hardif_remove_interface(hard_iface);
 	}
 	rtnl_unlock();
@@ -556,9 +542,7 @@ static int hard_if_event(struct notifier_block *this,
 		hardif_deactivate_interface(hard_iface);
 		break;
 	case NETDEV_UNREGISTER:
-		spin_lock(&hardif_list_lock);
 		list_del_rcu(&hard_iface->list);
-		spin_unlock(&hardif_list_lock);
 
 		hardif_remove_interface(hard_iface);
 		break;
diff --git a/main.c b/main.c
index 709b33b..39feb5a 100644
--- a/main.c
+++ b/main.c
@@ -33,6 +33,9 @@
 #include "vis.h"
 #include "hash.h"
 
+
+/* List manipulations on hardif_list have to be rtnl_lock()'ed,
+ * list traversals just rcu-locked */
 struct list_head hardif_list;
 
 unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: Use local tq values determined by NDP on OGMs
@ 2010-12-07 14:39 Linus Lüssing
  2010-12-07 20:19 ` [B.A.T.M.A.N.] (no subject) Linus Lüssing
  0 siblings, 1 reply; 25+ messages in thread
From: Linus Lüssing @ 2010-12-07 14:39 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Linus Lüssing

With this commit not the local transmit quality values determined
by the OGMs themselves are applied on received OGMs, but the local
transmit quality detemined by NDP instead. Usually the link quality
measurements of NDP are more up-to-date than the one of the OGMs, as NDP
is using a more frequent interval because NDP's packets are not being
flooded through the whole mesh.
---
 routing.c |   53 ++++++++++++++++++++++-------------------------------
 1 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/routing.c b/routing.c
index 1972bb8..8830129 100644
--- a/routing.c
+++ b/routing.c
@@ -136,7 +136,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 {
 	struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
 	struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
-	unsigned char total_count;
+	uint8_t local_tq = 0;
 
 	if (orig_node == orig_neigh_node) {
 		list_for_each_entry(tmp_neigh_node,
@@ -180,25 +180,19 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 			return 0;
 	}
 
-	orig_node->last_valid = jiffies;
+	spin_lock_bh(&if_incoming->neigh_list_lock);
+	list_for_each_entry(neigh_node, &if_incoming->neigh_list, list) {
+		if (!compare_orig(neigh_node->addr, orig_neigh_node->orig))
+			continue;
 
-	/* pay attention to not get a value bigger than 100 % */
-	total_count = (orig_neigh_node->bcast_own_sum[if_incoming->if_num] >
-		       neigh_node->real_packet_count ?
-		       neigh_node->real_packet_count :
-		       orig_neigh_node->bcast_own_sum[if_incoming->if_num]);
+		orig_node->last_valid = jiffies;
+		local_tq = neigh_node->tq_avg;
+		break;
+	}
+	spin_unlock_bh(&if_incoming->neigh_list_lock);
 
-	/* if we have too few packets (too less data) we set tq_own to zero */
-	/* if we receive too few packets it is not considered bidirectional */
-	if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) ||
-	    (neigh_node->real_packet_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM))
-		orig_neigh_node->tq_own = 0;
-	else
-		/* neigh_node->real_packet_count is never zero as we
-		 * only purge old information when getting new
-		 * information */
-		orig_neigh_node->tq_own = (TQ_MAX_VALUE * total_count) /
-			neigh_node->real_packet_count;
+	if (local_tq == 0)
+		return 0;
 
 	/*
 	 * 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
@@ -209,25 +203,22 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 	orig_neigh_node->tq_asym_penalty =
 		TQ_MAX_VALUE -
 		(TQ_MAX_VALUE *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count) *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count) *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count)) /
-		(TQ_LOCAL_WINDOW_SIZE *
-		 TQ_LOCAL_WINDOW_SIZE *
-		 TQ_LOCAL_WINDOW_SIZE);
+		 (TQ_MAX_VALUE - local_tq) *
+		 (TQ_MAX_VALUE - local_tq) *
+		 (TQ_MAX_VALUE - local_tq)) /
+		(TQ_MAX_VALUE *
+		 TQ_MAX_VALUE *
+		 TQ_MAX_VALUE);
 
 	batman_packet_ogm->tq = ((batman_packet_ogm->tq *
-			      orig_neigh_node->tq_own *
 			      orig_neigh_node->tq_asym_penalty) /
-			     (TQ_MAX_VALUE * TQ_MAX_VALUE));
+			      TQ_MAX_VALUE);
 
 	bat_dbg(DBG_BATMAN, bat_priv,
 		"bidirectional: "
-		"orig = %-15pM neigh = %-15pM => own_bcast = %2i, "
-		"real recv = %2i, local tq: %3i, asym_penalty: %3i, "
-		"total tq: %3i\n",
-		orig_node->orig, orig_neigh_node->orig, total_count,
-		neigh_node->real_packet_count, orig_neigh_node->tq_own,
+		"orig = %-15pM neigh = %-15pM => real recv = %2i, "
+	        "local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
+		orig_node->orig, orig_neigh_node->orig, local_tq,
 		orig_neigh_node->tq_asym_penalty, batman_packet_ogm->tq);
 
 	/* if link has the minimum required transmission quality
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2010-09-30 12:08 Marek Lindner
  2010-10-09 11:44 ` Marek Lindner
  0 siblings, 1 reply; 25+ messages in thread
From: Marek Lindner @ 2010-09-30 12:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hi,

since the vis code and the bridge loop avoidance code already use
the kref library functions, I converted the remaining refcounting
code to use kref as well.

Regards,
Marek

Marek Lindner (4):
      batman-adv: convert gw_node custom refcounting to kref functions
      batman-adv: use rcu callbacks when freeing gw_nodes
      batman-adv: convert batman_if custom refcounting to kref functions
      batman-adv: use rcu callbacks when freeing batman_if

 batman-adv/bat_sysfs.c      |   12 ++++++------
 batman-adv/gateway_client.c |   30 ++++++++++++++++--------------
 batman-adv/hard-interface.c |   41 +++++++++++++++++++++++------------------
 batman-adv/hard-interface.h |   13 ++++---------
 batman-adv/types.h          |    6 ++++--
 5 files changed, 53 insertions(+), 49 deletions(-)

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2010-08-22 20:53 Linus Lüssing
  0 siblings, 0 replies; 25+ messages in thread
From: Linus Lüssing @ 2010-08-22 20:53 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Vasiliy Kulikov


-------------
Hi Linus,

On Wed, Aug 18, 2010 at 00:10 +0200, Linus Lüssing wrote:
> Hi Vasiliy,
>
> Also first of all thanks for your little reviewing of the batman code from
> me too. I've been the person submitting the patch to enable ebtables
> filtering of batman-adv's packets.Sorry, I'm not a kernel coding veteran, so
> I might possibly have missed something ;). However, I don't fully understand
> when the skb should be leaked, so hope you don't mind some more asking from
> my side :).
>
> Okay, I had a little closer look again.NF_HOOK returns -1 in case of a drop
> due to nf_hook_slow() and 1 in case of a success due to nf_hook_slow() + the
> ok function returning 1 too. And hey, yes, nf_hook_slow() can also return 0,
> passing it all up to the NF_HOOK which would lead to the goto err_out in
> batman-adv - and both the kernel module and netfilter won't free the skb!
> However, I think I'm not quite getting when nf_hook_slow() might return 0...

The thing is that code using NF_HOOK should be written in functional
paradigm: the recv() should be divided into 2 functions, before the NF_HOOK
and after. All after-nf work should be delegated to second part, not to code in
first part that is run after NF_HOOK return. It solves the problem of asyncronous
processing in hooks. It is perferctly seen in ipv4 ip_rcv() & rp_rcv_finish().

>
> What confuses me even more is, that of course if nf_hook_slow() could return
> a value other than 1 and without freeing the skb, the batman-adv kernel
> module would have to free the skb itself in send.c, too. In send.c the
> return value of NF_HOOK is being returned there immediately without a check
> at the moment, hoping that either netfilter or dev_queue_xmit() would free
> the skb. But then net/ipv4/arp.c's arp_xmit() would have the same problem,
> too, wouldn't it? It also does not check whether the
> NF_HOOK(/nf_hook_slow()) there might return 0 either, meaning that the skb
> has not yet been consumed/freed? So is there the same bug / possible memleak
> or what is the difference between ipv4's arp.c and batman-adv's
> send.c/hard_interface.c in the usage of the NF_HOOK?

No, there isn't ;) In fact, for the caller of NF_HOOK() three cases may
happed:


1) All hooks return NF_ACCEPT or similar (NF_STOP or through
 NF_QUEUE/NF_REPEAT with the same result). In this case ok_fn() is called
 and code after return from NF_HOOK() is run.

 In case of arp dev_queue_xmit() processes the skb and free it.

 In your case ok_fn() does nothing and code after return from NF_HOOK()
 finishes the processing of skb.


2) Some hook returns NF_DROP or similar (like (1), with the same
 effect for the caller). In this case nf_hook_slow() frees skb and NF_HOOK()
 returns -1. ok_fn() is not called at all.

 Arp and batman don't leak anything as skb is freed.


3) Some hook returns NF_STOLEN signaling that now it is responsible for
 skb delivery and freeing. It can be stolen until some long
 calculations end or even some network communication is finished (e.g.
 hook wants to know whether skb dest ip is google.com)

 a) After some time the hook frees skb and doesn't call ok_fn().

   arp and you don't leak anything and work exactly like NF_HOOK() retuned
   NF_DROPPED.

 b) After some time the hook finishes calcs and passes the skb to
 ok_fn(). From this time ok_fn() is responsible for the skb.

   In arp case it is dev_queue_xmit() that frees skb.

   In batman case it does NOTHING and skb is leaked.


Also see the comment from linux/netfilter.h:

/* Activate hook; either okfn or kfree_skb called, unless a hook
  returns NF_STOLEN (in which case, it's up to the hook to deal with
  the consequences).

  Returns -ERRNO if packet dropped.  Zero means queued, stolen or
  accepted.
*/

/* RR:
  > I don't want nf_hook to return anything because people might forget
  > about async and trust the return value to mean "packet was ok".

  AK:
  Just document it clearly, then you can expect some sense from kernel
  coders :)
*/


Thanks,
Vasiliy.

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [B.A.T.M.A.N.] (no subject)
@ 2007-12-11  1:37 giuseppe de marco
  2007-12-11  2:03 ` Alexander Morlang
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: giuseppe de marco @ 2007-12-11  1:37 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

Anybody know a good embedded harware to use for test batman?
G

-- 
Giuseppe De Marco, PhD
Toyota Technological Institute
468-8511 Aichi 2-12-1 Hisakata, Tenpaku-ku, 
Nagoya, Japan
Email: demarco at toyota-ti dot ac dot jp
Tel (int): +81 (052)-809-1802
Skype-Id: giuseppe_dem2


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

end of thread, other threads:[~2018-09-28  6:17 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  0:02 [B.A.T.M.A.N.] (no subject) Linus Lüssing
2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 1/5] batman-adv: Introduce packet type independent TVLV handler API Linus Lüssing
2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 2/5] batman-adv: Allow TVLVs greater than 128 bytes Linus Lüssing
2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 3/5] batman-adv: aggregation packet reception Linus Lüssing
2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 4/5] batman-adv: aggregation packet queueing and transmission Linus Lüssing
2017-04-25  0:02 ` [B.A.T.M.A.N.] [PATCH v3 5/5] batman-adv: do not aggregate rebroadcasts in the same packet Linus Lüssing
2017-04-25  0:56 ` [B.A.T.M.A.N.] [PATCH v3 0/5] batman-adv: broadcast packet aggregation Linus Lüssing
  -- strict thread matches above, loose matches on Subject: below --
2018-09-28  6:17 [B.A.T.M.A.N.] (no subject) udit kalra
2013-10-19 22:21 Antonio Quartulli
2013-10-20  0:15 ` David Miller
2013-08-02 12:44 Linus Lüssing
     [not found] <pull request for net: batman-adv 2013-05-21>
2013-05-21 19:53 ` Antonio Quartulli
2013-05-21 19:56   ` Antonio Quartulli
2013-05-23  7:08     ` David Miller
2011-05-02 19:19 [B.A.T.M.A.N.] [PATCHv4 1/2] batman-adv: Remove unnecessary hardif_list_lock Sven Eckelmann
2011-05-03  9:51 ` [B.A.T.M.A.N.] (no subject) Linus Lüssing
2011-05-03 12:40   ` Sven Eckelmann
2010-12-07 14:39 [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: Use local tq values determined by NDP on OGMs Linus Lüssing
2010-12-07 20:19 ` [B.A.T.M.A.N.] (no subject) Linus Lüssing
2010-09-30 12:08 Marek Lindner
2010-10-09 11:44 ` Marek Lindner
2010-08-22 20:53 Linus Lüssing
2007-12-11  1:37 giuseppe de marco
2007-12-11  2:03 ` Alexander Morlang
2007-12-11  5:18 ` a.anselmi
2007-12-11 17:23 ` elektra
2007-12-11 18:43 ` Steven Leeman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).