[B.A.T.M.A.N.] switch routing algorithm at runtime
by Marek Lindner
Hi,
I massaged the RFC patches a little longer to integrate all the feedback
received so far. They are ready to be considered 'real' patches now.
The 'dynamically load routing kernel module' feature has not found its
way into my patchset. At this point I still see no benefit and only
complications. The mentioned reasons (kernel folks might not like it /
helps to better abstract) can be addressed in a different way (for
example asking David if he is going to accept it or not). The only
reason seems to be "because we can". That's not enough for me.
This does not mean we can't add this feature at a later point in time
when we have the feeling it actually brings some benefits.
Here the changelog:
* sysfs documentation added
* changed batman iv function prefix to bat_iv
* renamed struct bat_algo to struct bat_algo_ops
* all bat_algo_ops callbacks are mandatory for now
* added struct bat_algo_ops documentation
* introduced bat_algo.h for the routing algo init calls
* bat_algo_ops->name became a pointer
* removed all (unnecessary) locking from bat_algo_*
Cheers,
Marek
10 years, 7 months
Re: [B.A.T.M.A.N.] TT inconsistency problem (again)
by Sven Eckelmann
On Tuesday 06 December 2011 15:18:03 Marko Panger - AGB Lab wrote:
> Sven,
Please don't mail me in private without a good reason. At least Cc
b.a.t.m.a.n(a)lists.open-mesh.org for batman-adv related things.
> This is a very important info. Gigabyte is the provider of the HW and if
> this is related to the driver I have to report them. We had some
> problems already with this driver as it doesn't set the cell number
> correctly.
It sounds more like Ralink... but that is not important right now ;)
But maybe you can provide more information about the driver (which exact
driver did you use, ...) because some people on the mailing list may have used
the same driver and know a workaround/fix.
> Could you give me a hint how to provide such information to them ?
The same way you contacted us... with a lot of information. But try to use a
small tool to send unicast packets in one direction and look if you can create
the same situation without batman-adv involved. IP is not the best solution
because it has to send more packets and therefore create more problems when
you just want to test a simple scenario. I usually use a small program that
directly sends one small ethernet frame to another node over the selected
interface while the other side only waits for this packet on a specific
interface. So nothing really complicated.
The receiver side has to start the program like this:
$ ./rawsend ra0
and the sender has to start it with the MAC of the receiver
$ ./rawsend ra0 ca:fe:ba:de:ba:be
The receiver will exit the rawsend after it finished the receive.
So start the setup without batman-adv. Try to contact the nodes, restart the
one node you always restarted in your tests and try to communicat with it. You
can also use broadcast (just use the mac ff:ff:ff:ff:ff:ff as target) to test
if unicast is the only problem.
I hope this helps to document the problem. This should allow the driver author
to debug/reproduce the whole scenario. But please send us more information
when this is not the problem and really batman-adv's fault.
Kind regards,
Sven
10 years, 7 months
[B.A.T.M.A.N.] TT inconsistency problem (again)
by Marko Panger - AGB Lab
Hi,
I'm evaluating the possibility to use batman in our next product
(measurement equipment) and I'm facing problems in using batman.
I have five nodes installed around and I experience black-outs in
connection among nodes. The resoult is I can't ping a certain node anymore.
Here is the output from 'batctl o' and the subsequent ping to a node
which has good link quality (TQ):
[root@gtam00119 ~]# batctl o
[B.A.T.M.A.N. adv 2011.4.0, MainIF/MAC: ra0/48:5d:60:b8:a2:f6 (bat0)]
Originator last-seen (#/255) Nexthop [outgoingIF]:
Potential nexthops ...
48:5d:60:b8:a2:b7 0.974s (202) 48:5d:60:b8:a3:0e [ ra0]:
48:5d:60:b8:a2:d2 ( 0) 48:5d:60:b8:a3:0e (202)
48:5d:60:b8:a3:0e 0.439s (249) 48:5d:60:b8:a3:0e [ ra0]:
48:5d:60:b8:a2:d2 (231) 48:5d:60:b8:a3:0e (249)
48:5d:60:b8:a2:d2 0.749s (250) 48:5d:60:b8:a2:d2 [ ra0]:
48:5d:60:b8:a3:0e (235) 48:5d:60:b8:a2:d2 (250)
48:5d:60:b8:a2:ff 0.156s (209) 48:5d:60:b8:a3:0e [ ra0]:
48:5d:60:b8:a2:d2 ( 0) 48:5d:60:b8:a3:0e (209)
[root@gtam00119 ~]# batctl ping 48:5d:60:b8:a3:0e
PING 48:5d:60:b8:a3:0e (48:5d:60:b8:a3:0e) 20(48) bytes of data
Reply from host 48:5d:60:b8:a3:0e timed out
Reply from host 48:5d:60:b8:a3:0e timed out
Reply from host 48:5d:60:b8:a3:0e timed out
Reply from host 48:5d:60:b8:a3:0e timed out
And this is the output from 'batctl ll tt routes' from he node that is
being pinged (see above):
[ 63665] Sending TT_REQUEST to 48:5d:60:b8:a2:b7 via
48:5d:60:b8:a2:ff [.]
[ 63665] TT inconsistency for 48:5d:60:b8:a2:ff. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 19133 last_crc: 0
num_changes: 0)
[ 63666] TT inconsistency for 48:5d:60:b8:a2:b7. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 22851 last_crc: 0
num_changes: 0)
[ 63666] TT inconsistency for 48:5d:60:b8:a2:ff. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 19133 last_crc: 0
num_changes: 0)
[ 63666] Sending TT_REQUEST to 48:5d:60:b8:a2:ff via
48:5d:60:b8:a2:ff [.]
[ 63667] TT inconsistency for 48:5d:60:b8:a2:b7. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 22851 last_crc: 0
num_changes: 0)
[ 63667] TT inconsistency for 48:5d:60:b8:a2:ff. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 19133 last_crc: 0
num_changes: 0)
[ 63668] TT inconsistency for 48:5d:60:b8:a2:b7. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 22851 last_crc: 0
num_changes: 0)
[ 63668] TT inconsistency for 48:5d:60:b8:a2:ff. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 19133 last_crc: 0
num_changes: 0)
[ 63669] TT inconsistency for 48:5d:60:b8:a2:b7. Need to retrieve
the correct information (ttvn: 1 last_ttvn: 0 crc: 22851 last_crc: 0
num_changes: 0)
This situation was triggered by the following procedure:
1) from node (last two octets) 'a2:f6' the 'a3:0e' node was pinged
2) in the middle a ssh connection from the node 'a2:f6' was made to the
node 'a3:0e'.
3) so far so good
4) the node 'a3:0e' was rebooted by issuing the 'reboot' command in the
console
5) after this the connection is lost and the above logs were produced
I'm using the version 2011.4.0 on all nodes:
[root@gtam00119 ~]# batctl -v
batctl 2011.4.0 [batman-adv: 2011.4.0]
Any help is highly appreciated. I might be doing something wrong, but
seems a stability problem.
Marko
10 years, 7 months
[B.A.T.M.A.N.] about batman performance
by zb1981gm
I have used batman on my project for several months.It performs very well,stable especially!
But,actually,I am not satisfied with the performance of Batman.I found that the bandwidth would drop sharply with the wireless hop increase.
Now I provide my test result here:
routerA and routerB is composed of compex wp543ahv mainboard (AR7161 platform) and two AR9220 wireless card.Firmware is Openwrt backfire.
one card is working on 2.4G channel as AP mode,the other is working on 5G channel as mesh backbone
batman version:2.0
notebook1 and notebook2 is equiped with 802.11n usb wireless card which access to the AP mode card of routerA and routerB
channel 1 channel 36 channel 11
notebook1 --------------- routerA -------------- routerB -------------- notebook2
I use iperf to test bandwidth
notebook1 ----------- routerA 45Mbps
routerA ----------- routerB 46Mbps
routerB ----------- notebook2 45Mbps
But the bandwidth between notebook1 and notebook2 remains 8Mbps
bandwidth between notebook1 and routerB remain 18Mbps
So the conclution is that the bandwidth will be halfed with the 1 hop increase! right?
I also found that the interface alternating mode and bonding mode doesn't take effect
channel 1
routerA ------------------ routerB
channel 36
The test result is no difference whatever I configured alternating or bonding or just single radio
According to the batman official site, alternating or bonding mode would improve the performance compared with the single radio mode
looking forward somebody's help
highly appreciated!
10 years, 7 months
[B.A.T.M.A.N.] [PATCH] batman-adv: delete global entry in case of roaming
by Antonio Quartulli
When receiving a DEL change for a client due to a roaming event (change is
marked with TT_CLIENT_ROAM), each node has to check if the client roamed
to itself or somewhere else.
In the latter case the global entry is kept to avoid having no route at all
otherwise we can safely delete the global entry
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
translation-table.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index cf3e2c2..6e01079 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -663,6 +663,7 @@ void tt_global_del(struct bat_priv *bat_priv,
const char *message, bool roaming)
{
struct tt_global_entry *tt_global_entry = NULL;
+ struct tt_local_entry *tt_local_entry = NULL
tt_global_entry = tt_global_hash_find(bat_priv, addr);
if (!tt_global_entry)
@@ -670,15 +671,29 @@ void tt_global_del(struct bat_priv *bat_priv,
if (tt_global_entry->orig_node == orig_node) {
if (roaming) {
- tt_global_entry->common.flags |= TT_CLIENT_ROAM;
- tt_global_entry->roam_at = jiffies;
- goto out;
+ /* if we are deleting a global entry due to a roam
+ * event, there are two possibilities:
+ * 1) the client roamed from node A to node B => we mark
+ * it with TT_CLIENT_ROAM, we start a timer and we
+ * wait for node B to claim it. In case of timeout
+ * the entry is purged.
+ * 2) the client roamed to us => we can directly delete
+ * the global entry, since it is useless now. */
+ tt_local_entry = tt_local_hash_find(bat_priv,
+ tt_global_entry->addr);
+ if (!tt_local_entry) {
+ tt_global_entry->common.flags |= TT_CLIENT_ROAM;
+ tt_global_entry->roam_at = jiffies;
+ goto out;
+ }
}
_tt_global_del(bat_priv, tt_global_entry, message);
}
out:
if (tt_global_entry)
tt_global_entry_free_ref(tt_global_entry);
+ if (tt_local_entry)
+ tt_local_entry_free_ref(tt_local_entry);
}
void tt_global_del_orig(struct bat_priv *bat_priv,
--
1.7.3.4
10 years, 7 months
[B.A.T.M.A.N.] Fw: Rede Mesh BatmanADV no brazil
by Flavio Leonel "suporte tecnico"
> GOOD DAY
>
> MY NAME AND FLAVIO LEONEL
> I am Brazilian MORO near Sao Paulo 100 KM.
>
> MESH NETWORKS AND I'M STUDYING A FEW MONTHS AND THEY ALREADY KNOW A FEW
> YEARS.
> I am testing two U.S. "FOLLOW THE MAP NETWORK STRUCTURE"
>
>
> STRUCTURE OF RADIO NETWORK
>
> NODE BASE:
> UNIFI Ubiquiti AP WITH OpenWRT RC6 backfire, BATMAN-ADV AND DRIVER ATH9
> for
> Atheros
> INTERFECAE 1: MODE: 802.11s CONNECTED TO NODE 2
> 2 INTERFACE: VIRTUAL WLAN AP MODE = "WI-FI IN TO MY HOUSE AND POSSIBLE
> NEXT
> CUSTOMER"
> 3 BR-LAN INTERFACE WITH BATMAN-ADV ACTIVE
> LINK UP WITH LAN = MikroTik
>
> NODE 2:
> M2 HP Ubiquiti Bullet
> Backfire OpenWRT RC6, BATMAN-ADV AND DRIVER ATH9 for Atheros
> INTERFECAE 1: MODE: 802.11s CONNECTED WITH THE BASE NODE
> 2 INTERFACE: VIRTUAL WLAN AP MODE = "WIFI FOR CUSTOMERS"
> 3 BR-LAN INTERFACE WITH BATMAN-ADV ACTIVE
> LAN = WINDOWS PC LINK
>
> ROUTING STRUCTURE OF INTERNAL NODES:
> ALL INTERFACES IN BRIDGE
> BRIDGES WITH INTERFACE FOR MONITORING 10.1.137.0/24 IPS.
> FIREWALL OpenWRT "iptables"
> TCP + UDP FORWARD
>
> Default router by the firewall
> "images attached"
>
> SUPER RUN THIS WELL WITH BATMAN-ADV
> SO I'M HAVING A PROBLEM THAT STILL DO NOT UNDERSTAND IS WHERE THE ERROR
> NODE 2 MY CLIENT HAS a wired LAN CONNECTED IN THE RADIO As you can see the
> network map.
> THIS IS IT YOU OFF THE COMPUTER AND I RESTART THE RADIO WITH HIM HE
> DISCONNECTED BY ANY RULE NO MORE VOUT to connect eth0 DISABLE RADIO
> ELEA WAS DISABLED AS ME BUT NO PHYSICAL CONNECTION OR COMMUNICATION WITH
> OWN
> AP.
> DETAIL THIS CAN HELP ME I'M BREAKING THE HEAD
>
>
>
> And I like to better understand and make an alliance with any VCS HERE IN
> BRAZIL
> BECAUSE I am excited about the BATMAND ADV WE HAVE A POOR BUT STILL
> AVAILABLE DOCUMENTATION
>
> Another question HOW THE QUALITY OF BATMAN-LINK
>
> HUG
> I HOPE YOU UNDERSTAND MY PROBLEM AND WE CAN TALK MORE
>
10 years, 7 months
[B.A.T.M.A.N.] [PATCH] batman-adv: in case of roaming mark the client with TT_CLIENT_ROAM
by Antonio Quartulli
Whenever we add a local client for which we already have a global entry, the
latter has to be marked with the TT_CLIENT_ROAM flag (instead of
TT_CLIENT_PENDING)
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
translation-table.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/translation-table.c b/translation-table.c
index 7a7df4a..cf3e2c2 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -242,9 +242,11 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
if (tt_global_entry) {
/* This node is probably going to update its tt table */
tt_global_entry->orig_node->tt_poss_change = true;
- /* The global entry has to be marked as PENDING and has to be
+ /* The global entry has to be marked as ROAMING and has to be
* kept for consistency purpose */
- tt_global_entry->common.flags |= TT_CLIENT_PENDING;
+ tt_global_entry->common.flags |= TT_CLIENT_ROAM;
+ tt_global_entry->roam_at = jiffies;
+
send_roam_adv(bat_priv, tt_global_entry->common.addr,
tt_global_entry->orig_node);
}
--
1.7.3.4
10 years, 7 months
[B.A.T.M.A.N.] [PATCHv5] atomic: add *_dec_not_zero
by Sven Eckelmann
Introduce an *_dec_not_zero operation. Make this a special case of
*_add_unless because batman-adv uses atomic_dec_not_zero in different
places like re-broadcast queue or aggregation queue management. There
are other non-final patches which may also want to use this macro.
Suggested-by: David S. Miller <davem(a)davemloft.net>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Cc: Randy Dunlap <rdunlap(a)xenotime.net>
Cc: Richard Henderson <rth(a)twiddle.net>
Cc: Ivan Kokshaysky <ink(a)jurassic.park.msu.ru>
Cc: Matt Turner <mattst88(a)gmail.com>
Cc: Russell King <linux(a)arm.linux.org.uk>
Cc: Tony Luck <tony.luck(a)intel.com>
Cc: Fenghua Yu <fenghua.yu(a)intel.com>
Cc: Hirokazu Takata <takata(a)linux-m32r.org>
Cc: Ralf Baechle <ralf(a)linux-mips.org>
Cc: Kyle McMartin <kyle(a)mcmartin.ca>
Cc: Helge Deller <deller(a)gmx.de>
Cc: "James E.J. Bottomley" <jejb(a)parisc-linux.org>
Cc: Benjamin Herrenschmidt <benh(a)kernel.crashing.org>
Cc: Paul Mackerras <paulus(a)samba.org>
Cc: Martin Schwidefsky <schwidefsky(a)de.ibm.com>
Cc: Heiko Carstens <heiko.carstens(a)de.ibm.com>
Cc: linux390(a)de.ibm.com
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: Chris Metcalf <cmetcalf(a)tilera.com>
Cc: Jeff Dike <jdike(a)addtoit.com>
Cc: Richard Weinberger <richard(a)nod.at>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Ingo Molnar <mingo(a)redhat.com>
Cc: "H. Peter Anvin" <hpa(a)zytor.com>
Cc: x86(a)kernel.org
Cc: Arnd Bergmann <arnd(a)arndb.de>
Cc: linux-doc(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
Cc: linux-alpha(a)vger.kernel.org
Cc: linux-arm-kernel(a)lists.infradead.org
Cc: linux-ia64(a)vger.kernel.org
Cc: linux-m32r(a)ml.linux-m32r.org
Cc: linux-m32r-ja(a)ml.linux-m32r.org
Cc: linux-mips(a)linux-mips.org
Cc: linux-parisc(a)vger.kernel.org
Cc: linuxppc-dev(a)lists.ozlabs.org
Cc: linux-s390(a)vger.kernel.org
Cc: sparclinux(a)vger.kernel.org
Cc: user-mode-linux-devel(a)lists.sourceforge.net
Cc: linux-hexagon(a)vger.kernel.org
---
David S. Miller recommended this change in
https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2011-May/004560.html
Arnd Bergmann wanted to apply it in 201106172320.26476.arnd(a)arndb.de
... and then Arun Sharma created a big merge conflict with
https://lkml.org/lkml/2011/6/6/430
I don't think that it is a a good idea to assume that everyone still
agrees with the patch after I've rewritten it. I try Andrew Morton this
time because he applied the last changes to include/linux/atomic.h.
There are already two projects (batman-adv/fault_inject) which include
their private definition (not conflicting) and I have patches for 9
other modules that could use it.
Documentation/atomic_ops.txt | 1 +
arch/alpha/include/asm/atomic.h | 1 +
arch/alpha/include/asm/local.h | 1 +
arch/arm/include/asm/atomic.h | 1 +
arch/hexagon/include/asm/atomic.h | 1 +
arch/ia64/include/asm/atomic.h | 1 +
arch/m32r/include/asm/local.h | 1 +
arch/mips/include/asm/atomic.h | 1 +
arch/mips/include/asm/local.h | 1 +
arch/parisc/include/asm/atomic.h | 1 +
arch/powerpc/include/asm/atomic.h | 1 +
arch/powerpc/include/asm/local.h | 1 +
arch/s390/include/asm/atomic.h | 1 +
arch/sparc/include/asm/atomic_64.h | 1 +
arch/tile/include/asm/atomic_32.h | 1 +
arch/tile/include/asm/atomic_64.h | 1 +
arch/x86/include/asm/atomic64_32.h | 12 ++++++++++++
arch/x86/include/asm/atomic64_64.h | 1 +
arch/x86/include/asm/local.h | 1 +
arch/x86/lib/atomic64_32.c | 4 ++++
arch/x86/lib/atomic64_386_32.S | 21 +++++++++++++++++++++
arch/x86/lib/atomic64_cx8_32.S | 28 ++++++++++++++++++++++++++++
include/asm-generic/atomic-long.h | 2 ++
include/asm-generic/atomic64.h | 1 +
include/asm-generic/local.h | 1 +
include/asm-generic/local64.h | 2 ++
include/linux/atomic.h | 9 +++++++++
lib/atomic64_test.c | 19 +++++++++++++++++++
28 files changed, 117 insertions(+), 0 deletions(-)
diff --git a/Documentation/atomic_ops.txt b/Documentation/atomic_ops.txt
index 3bd585b..1eec221 100644
--- a/Documentation/atomic_ops.txt
+++ b/Documentation/atomic_ops.txt
@@ -190,6 +190,7 @@ atomic_add_unless requires explicit memory barriers around the operation
unless it fails (returns 0).
atomic_inc_not_zero, equivalent to atomic_add_unless(v, 1, 0)
+atomic_dec_not_zero, equivalent to atomic_add_unless(v, -1, 0)
If a caller requires memory barrier semantics around an atomic_t
diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
index 640f909..09d1571 100644
--- a/arch/alpha/include/asm/atomic.h
+++ b/arch/alpha/include/asm/atomic.h
@@ -225,6 +225,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
#define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
diff --git a/arch/alpha/include/asm/local.h b/arch/alpha/include/asm/local.h
index 9c94b84..51eb678 100644
--- a/arch/alpha/include/asm/local.h
+++ b/arch/alpha/include/asm/local.h
@@ -79,6 +79,7 @@ static __inline__ long local_sub_return(long i, local_t * l)
c != (u); \
})
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define local_dec_not_zero(l) local_add_unless((l), -1, 0)
#define local_add_negative(a, l) (local_add_return((a), (l)) < 0)
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 86976d0..80ed975 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -458,6 +458,7 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
#define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1LL, 0LL)
#endif /* !CONFIG_GENERIC_ATOMIC64 */
#endif
diff --git a/arch/hexagon/include/asm/atomic.h b/arch/hexagon/include/asm/atomic.h
index e220f90..3a1a33a 100644
--- a/arch/hexagon/include/asm/atomic.h
+++ b/arch/hexagon/include/asm/atomic.h
@@ -148,6 +148,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
}
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
#define atomic_inc(v) atomic_add(1, (v))
#define atomic_dec(v) atomic_sub(1, (v))
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
index 3fad89e..af6e9b2 100644
--- a/arch/ia64/include/asm/atomic.h
+++ b/arch/ia64/include/asm/atomic.h
@@ -122,6 +122,7 @@ static __inline__ long atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#define atomic_add_return(i,v) \
({ \
diff --git a/arch/m32r/include/asm/local.h b/arch/m32r/include/asm/local.h
index 734bca8..d536082 100644
--- a/arch/m32r/include/asm/local.h
+++ b/arch/m32r/include/asm/local.h
@@ -272,6 +272,7 @@ static inline int local_add_unless(local_t *l, long a, long u)
}
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define local_dec_not_zero(l) local_add_unless((l), -1, 0)
static inline void local_clear_mask(unsigned long mask, local_t *addr)
{
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index 1d93f81..babb043 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -697,6 +697,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#define atomic64_dec_return(v) atomic64_sub_return(1, (v))
#define atomic64_inc_return(v) atomic64_add_return(1, (v))
diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
index 94fde8d..0242256 100644
--- a/arch/mips/include/asm/local.h
+++ b/arch/mips/include/asm/local.h
@@ -137,6 +137,7 @@ static __inline__ long local_sub_return(long i, local_t * l)
c != (u); \
})
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define local_dec_not_zero(l) local_add_unless((l), -1, 0)
#define local_dec_return(l) local_sub_return(1, (l))
#define local_inc_return(l) local_add_return(1, (l))
diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
index 4054b31..57b7069 100644
--- a/arch/parisc/include/asm/atomic.h
+++ b/arch/parisc/include/asm/atomic.h
@@ -334,6 +334,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#endif /* !CONFIG_64BIT */
diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
index 02e41b5..0798420 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -468,6 +468,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#endif /* __powerpc64__ */
diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
index b8da913..d182e34 100644
--- a/arch/powerpc/include/asm/local.h
+++ b/arch/powerpc/include/asm/local.h
@@ -134,6 +134,7 @@ static __inline__ int local_add_unless(local_t *l, long a, long u)
}
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define local_dec_not_zero(l) local_add_unless((l), -1, 0)
#define local_sub_and_test(a, l) (local_sub_return((a), (l)) == 0)
#define local_dec_and_test(l) (local_dec_return((l)) == 0)
diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
index 8517d2a..92e7d5d 100644
--- a/arch/s390/include/asm/atomic.h
+++ b/arch/s390/include/asm/atomic.h
@@ -325,6 +325,7 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
#define atomic64_dec_return(_v) atomic64_sub_return(1, _v)
#define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
#define smp_mb__before_atomic_dec() smp_mb()
#define smp_mb__after_atomic_dec() smp_mb()
diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
index 9f421df..94cf160 100644
--- a/arch/sparc/include/asm/atomic_64.h
+++ b/arch/sparc/include/asm/atomic_64.h
@@ -106,6 +106,7 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
/* Atomic operations are already serializing */
#define smp_mb__before_atomic_dec() barrier()
diff --git a/arch/tile/include/asm/atomic_32.h b/arch/tile/include/asm/atomic_32.h
index c03349e..9cfafb3 100644
--- a/arch/tile/include/asm/atomic_32.h
+++ b/arch/tile/include/asm/atomic_32.h
@@ -233,6 +233,7 @@ static inline void atomic64_set(atomic64_t *v, u64 n)
#define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1LL, 0LL)
/*
* We need to barrier before modifying the word, since the _atomic_xxx()
diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
index 27fe667..9c22f50 100644
--- a/arch/tile/include/asm/atomic_64.h
+++ b/arch/tile/include/asm/atomic_64.h
@@ -141,6 +141,7 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
#define atomic64_add_negative(i, v) (atomic64_add_return((i), (v)) < 0)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
/* Atomic dec and inc don't implement barrier, so provide them if needed. */
#define smp_mb__before_atomic_dec() smp_mb()
diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
index 24098aa..3cd4431 100644
--- a/arch/x86/include/asm/atomic64_32.h
+++ b/arch/x86/include/asm/atomic64_32.h
@@ -287,6 +287,18 @@ static inline int atomic64_inc_not_zero(atomic64_t *v)
return r;
}
+
+static inline int atomic64_dec_not_zero(atomic64_t *v)
+{
+ int r;
+ asm volatile(ATOMIC64_ALTERNATIVE(dec_not_zero)
+ : "=a" (r)
+ : "S" (v)
+ : "ecx", "edx", "memory"
+ );
+ return r;
+}
+
static inline long long atomic64_dec_if_positive(atomic64_t *v)
{
long long r;
diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
index 0e1cbfc..539e41b 100644
--- a/arch/x86/include/asm/atomic64_64.h
+++ b/arch/x86/include/asm/atomic64_64.h
@@ -216,6 +216,7 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
}
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1, 0)
/*
* atomic64_dec_if_positive - decrement by 1 if old value positive
diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
index 9cdae5d..2c8c92d 100644
--- a/arch/x86/include/asm/local.h
+++ b/arch/x86/include/asm/local.h
@@ -185,6 +185,7 @@ static inline long local_sub_return(long i, local_t *l)
c != (u); \
})
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define local_dec_not_zero(l) local_add_unless((l), -1, 0)
/* On x86_32, these are no better than the atomic variants.
* On x86-64 these are better than the atomic variants on SMP kernels
diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c
index 042f682..7da05c3 100644
--- a/arch/x86/lib/atomic64_32.c
+++ b/arch/x86/lib/atomic64_32.c
@@ -24,6 +24,8 @@ long long atomic64_dec_if_positive_cx8(atomic64_t *v);
EXPORT_SYMBOL(atomic64_dec_if_positive_cx8);
int atomic64_inc_not_zero_cx8(atomic64_t *v);
EXPORT_SYMBOL(atomic64_inc_not_zero_cx8);
+int atomic64_dec_not_zero_cx8(atomic64_t *v);
+EXPORT_SYMBOL(atomic64_dec_not_zero_cx8);
int atomic64_add_unless_cx8(atomic64_t *v, long long a, long long u);
EXPORT_SYMBOL(atomic64_add_unless_cx8);
@@ -54,6 +56,8 @@ long long atomic64_dec_if_positive_386(atomic64_t *v);
EXPORT_SYMBOL(atomic64_dec_if_positive_386);
int atomic64_inc_not_zero_386(atomic64_t *v);
EXPORT_SYMBOL(atomic64_inc_not_zero_386);
+int atomic64_dec_not_zero_386(atomic64_t *v);
+EXPORT_SYMBOL(atomic64_dec_not_zero_386);
int atomic64_add_unless_386(atomic64_t *v, long long a, long long u);
EXPORT_SYMBOL(atomic64_add_unless_386);
#endif
diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
index e8e7e0d..c78337b 100644
--- a/arch/x86/lib/atomic64_386_32.S
+++ b/arch/x86/lib/atomic64_386_32.S
@@ -181,6 +181,27 @@ ENDP
#undef v
#define v %esi
+BEGIN(dec_not_zero)
+ movl (v), %eax
+ movl 4(v), %edx
+ testl %eax, %eax
+ je 3f
+1:
+ subl $1, %eax
+ sbbl $0, %edx
+ movl %eax, (v)
+ movl %edx, 4(v)
+ movl $1, %eax
+2:
+ RET
+3:
+ testl %edx, %edx
+ jne 1b
+ jmp 2b
+ENDP
+#undef v
+
+#define v %esi
BEGIN(dec_if_positive)
movl (v), %eax
movl 4(v), %edx
diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
index 391a083..989638c 100644
--- a/arch/x86/lib/atomic64_cx8_32.S
+++ b/arch/x86/lib/atomic64_cx8_32.S
@@ -220,3 +220,31 @@ ENTRY(atomic64_inc_not_zero_cx8)
jmp 3b
CFI_ENDPROC
ENDPROC(atomic64_inc_not_zero_cx8)
+
+ENTRY(atomic64_dec_not_zero_cx8)
+ CFI_STARTPROC
+ SAVE ebx
+
+ read64 %esi
+1:
+ testl %eax, %eax
+ je 4f
+2:
+ movl %eax, %ebx
+ movl %edx, %ecx
+ subl $1, %ebx
+ sbbl $0, %ecx
+ LOCK_PREFIX
+ cmpxchg8b (%esi)
+ jne 1b
+
+ movl $1, %eax
+3:
+ RESTORE ebx
+ ret
+4:
+ testl %edx, %edx
+ jne 2b
+ jmp 3b
+ CFI_ENDPROC
+ENDPROC(atomic64_dec_not_zero_cx8)
diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
index b7babf0..0fe75ab 100644
--- a/include/asm-generic/atomic-long.h
+++ b/include/asm-generic/atomic-long.h
@@ -130,6 +130,7 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
}
#define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l))
+#define atomic_long_dec_not_zero(l) atomic64_dec_not_zero((atomic64_t *)(l))
#define atomic_long_cmpxchg(l, old, new) \
(atomic64_cmpxchg((atomic64_t *)(l), (old), (new)))
@@ -247,6 +248,7 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
}
#define atomic_long_inc_not_zero(l) atomic_inc_not_zero((atomic_t *)(l))
+#define atomic_long_dec_not_zero(l) atomic_dec_not_zero((atomic_t *)(l))
#define atomic_long_cmpxchg(l, old, new) \
(atomic_cmpxchg((atomic_t *)(l), (old), (new)))
diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
index b18ce4f..90ff9b1 100644
--- a/include/asm-generic/atomic64.h
+++ b/include/asm-generic/atomic64.h
@@ -38,5 +38,6 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
#define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
+#define atomic64_dec_not_zero(v) atomic64_add_unless((v), -1LL, 0LL)
#endif /* _ASM_GENERIC_ATOMIC64_H */
diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
index 9ceb03b..fabf4f3 100644
--- a/include/asm-generic/local.h
+++ b/include/asm-generic/local.h
@@ -44,6 +44,7 @@ typedef struct
#define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
#define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
#define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
+#define local_dec_not_zero(l) atomic_long_dec_not_zero(&(l)->a)
/* Non-atomic variants, ie. preemption disabled and won't be touched
* in interrupt, etc. Some archs can optimize this case well. */
diff --git a/include/asm-generic/local64.h b/include/asm-generic/local64.h
index 5980002..76acbe2 100644
--- a/include/asm-generic/local64.h
+++ b/include/asm-generic/local64.h
@@ -45,6 +45,7 @@ typedef struct {
#define local64_xchg(l, n) local_xchg((&(l)->a), (n))
#define local64_add_unless(l, _a, u) local_add_unless((&(l)->a), (_a), (u))
#define local64_inc_not_zero(l) local_inc_not_zero(&(l)->a)
+#define local64_dec_not_zero(l) local_dec_not_zero(&(l)->a)
/* Non-atomic variants, ie. preemption disabled and won't be touched
* in interrupt, etc. Some archs can optimize this case well. */
@@ -83,6 +84,7 @@ typedef struct {
#define local64_xchg(l, n) atomic64_xchg((&(l)->a), (n))
#define local64_add_unless(l, _a, u) atomic64_add_unless((&(l)->a), (_a), (u))
#define local64_inc_not_zero(l) atomic64_inc_not_zero(&(l)->a)
+#define local64_dec_not_zero(l) atomic64_dec_not_zero(&(l)->a)
/* Non-atomic variants, ie. preemption disabled and won't be touched
* in interrupt, etc. Some archs can optimize this case well. */
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 42b77b5..ad2b750 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -27,6 +27,15 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
/**
+ * atomic_dec_not_zero - decrement unless the number is zero
+ * @v: pointer of type atomic_t
+ *
+ * Atomically decrements @v by 1, so long as @v is non-zero.
+ * Returns non-zero if @v was non-zero, and zero otherwise.
+ */
+#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
+
+/**
* atomic_inc_not_zero_hint - increment if not null
* @v: pointer of type atomic_t
* @hint: probable value of the atomic before the increment
diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c
index 0c33cde..b7468b7 100644
--- a/lib/atomic64_test.c
+++ b/lib/atomic64_test.c
@@ -145,6 +145,25 @@ static __init int test_atomic64(void)
r += one;
BUG_ON(v.counter != r);
+ INIT(onestwos);
+ BUG_ON(!atomic64_dec_not_zero(&v));
+ r -= one;
+ BUG_ON(v.counter != r);
+
+ INIT(0);
+ BUG_ON(atomic64_dec_not_zero(&v));
+ BUG_ON(v.counter != r);
+
+ INIT(one);
+ BUG_ON(!atomic64_dec_not_zero(&v));
+ r -= one;
+ BUG_ON(v.counter != r);
+
+ INIT(-one);
+ BUG_ON(!atomic64_dec_not_zero(&v));
+ r -= one;
+ BUG_ON(v.counter != r);
+
#ifdef CONFIG_X86
printk(KERN_INFO "atomic64 test passed for %s platform %s CX8 and %s SSE\n",
#ifdef CONFIG_X86_64
--
1.7.7.3
10 years, 7 months
[B.A.T.M.A.N.] pull request: batman-adv 2011-11-26
by Marek Lindner
Hi David,
the following 10 patches constitute the first batch I'd like to get the pulled
into net-next-2.6/3.3. They're mostly uncritical fixes around the recently
introduced tt code, some code refactoring, the kstrto update and the range
check fix reported by Thomas Jarosch.
Thanks,
Marek
The following changes since commit 1ea6b8f48918282bdca0b32a34095504ee65bab5:
Linux 3.2-rc1 (2011-11-07 16:16:02 -0800)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git for_david
Antonio Quartulli (5):
batman-adv: tt_global_del_orig() has to print the correct message
batman-adv: use orig_hash_find() instead of get_orig_node() in TT code
batman-adv: fixed hash functions type to uint32_t instead of int
batman-adv: linearise the tt_response skb only if needed
batman-adv: check for tt_reponse packet real length
Marek Lindner (1):
batman-adv: refactoring gateway handling code
Simon Wunderlich (2):
batman-adv: directly write tt entries without buffering
batman-adv: Fix range check for expected packets
Sven Eckelmann (2):
batman-adv: update internal version number
batman-adv: Replace obsolete strict_strto<foo> with kstrto<foo>
net/batman-adv/bat_sysfs.c | 4 +-
net/batman-adv/bitarray.c | 2 +-
net/batman-adv/gateway_client.c | 153 ++++++++++++++++++++++--------------
net/batman-adv/gateway_client.h | 5 +-
net/batman-adv/gateway_common.c | 4 +-
net/batman-adv/hash.c | 4 +-
net/batman-adv/hash.h | 13 ++--
net/batman-adv/main.h | 2 +-
net/batman-adv/originator.c | 13 ++-
net/batman-adv/originator.h | 2 +-
net/batman-adv/routing.c | 22 ++++--
net/batman-adv/soft-interface.c | 43 +++++++---
net/batman-adv/translation-table.c | 100 ++++++-----------------
net/batman-adv/vis.c | 17 +++--
14 files changed, 202 insertions(+), 182 deletions(-)
10 years, 7 months
[B.A.T.M.A.N.] [PATCH] batman-adv: format multi-line if in the correct way
by Antonio Quartulli
in an multi-line if statement leading edges should line up to the opening
parenthesis
Reported-by: David Miller <davem(a)davemloft.net>
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
routing.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/routing.c b/routing.c
index d5ddbd1..4363d19 100644
--- a/routing.c
+++ b/routing.c
@@ -627,8 +627,7 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
/* Ensure we have all the claimed data */
if (unlikely(skb_headlen(skb) <
- sizeof(struct tt_query_packet) +
- tt_len))
+ sizeof(struct tt_query_packet) + tt_len))
goto out;
handle_tt_response(bat_priv, tt_query);
--
1.7.3.4
10 years, 7 months