Author: simon
Date: 2010-06-05 19:58:38 +0200 (Sat, 05 Jun 2010)
New Revision: 1691
Modified:
trunk/batman/batman.c
Log:
batman: Correct gw_speed down bit mask
We want to get bits .OOOO... and not as the mask would suggest .OOOOO..
when we decode the encoded bits for the download part of the gateway
speed.
Reported-By: Bill Meier <wmeier(a)newsguy.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman/batman.c
===================================================================
--- trunk/batman/batman.c 2010-06-05 17:57:18 UTC (rev 1690)
+++ trunk/batman/batman.c 2010-06-05 17:58:38 UTC (rev 1691)
@@ -482,7 +482,7 @@
void get_gw_speeds(unsigned char gw_class, int *down, int *up)
{
char sbit = (gw_class & 0x80) >> 7;
- char dpart = (gw_class & 0x7C) >> 3;
+ char dpart = (gw_class & 0x78) >> 3;
char upart = (gw_class & 0x07);
*down = 32 * (sbit + 2) * (1 << dpart);
Author: simon
Date: 2010-06-05 19:57:18 +0200 (Sat, 05 Jun 2010)
New Revision: 1690
Modified:
trunk/batman-adv-kernelland/gateway_common.c
Log:
batman-adv: Correct gw_speed down bit mask
We want to get bits .OOOO... and not as the mask would suggest .OOOOO..
when we decode the encoded bits for the download part of the gateway
speed.
Reported-By: Bill Meier <wmeier(a)newsguy.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman-adv-kernelland/gateway_common.c
===================================================================
--- trunk/batman-adv-kernelland/gateway_common.c 2010-06-05 17:47:28 UTC (rev 1689)
+++ trunk/batman-adv-kernelland/gateway_common.c 2010-06-05 17:57:18 UTC (rev 1690)
@@ -63,7 +63,7 @@
void gw_srv_class_to_kbit(uint8_t gw_srv_class, int *down, int *up)
{
char sbit = (gw_srv_class & 0x80) >> 7;
- char dpart = (gw_srv_class & 0x7C) >> 3;
+ char dpart = (gw_srv_class & 0x78) >> 3;
char upart = (gw_srv_class & 0x07);
if (!gw_srv_class) {
Author: simon
Date: 2010-06-05 19:47:28 +0200 (Sat, 05 Jun 2010)
New Revision: 1689
Modified:
trunk/batman-adv-kernelland/icmp_socket.c
Log:
batman-adv: return -EFAULT on copy_to_user errors
copy_to_user() returns the number of bites remaining but we want to
return a negative error code here.
Signed-off-by: Dan Carpenter <error27(a)gmail.com>
[sven.eckelmann(a)gmx.de: Move change from device.c to icmp_socket.c]
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman-adv-kernelland/icmp_socket.c
===================================================================
--- trunk/batman-adv-kernelland/icmp_socket.c 2010-06-05 17:42:40 UTC (rev 1688)
+++ trunk/batman-adv-kernelland/icmp_socket.c 2010-06-05 17:47:28 UTC (rev 1689)
@@ -148,7 +148,7 @@
kfree(socket_packet);
if (error)
- return error;
+ return -EFAULT;
return packet_len;
}
Author: simon
Date: 2010-06-05 19:42:40 +0200 (Sat, 05 Jun 2010)
New Revision: 1688
Modified:
trunk/batman-adv-kernelland/bat_printk.c
trunk/batman-adv-kernelland/compat.h
trunk/batman-adv-kernelland/main.c
trunk/batman-adv-kernelland/translation-table.c
Log:
batman-adv: Convert MAC_FMT to %pM
Remove the last uses of MAC_FMT
Signed-off-by: Joe Perches <joe(a)perches.com>
[sven.eckelmann(a)gmx.de: Adapted for current batman-adv version]
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman-adv-kernelland/bat_printk.c
===================================================================
--- trunk/batman-adv-kernelland/bat_printk.c 2010-06-04 19:44:14 UTC (rev 1687)
+++ trunk/batman-adv-kernelland/bat_printk.c 2010-06-05 17:42:40 UTC (rev 1688)
@@ -859,3 +859,53 @@
return printk("%s", buf);
}
+
+/**
+ * sprintf - Format a string and place it in a buffer
+ * @buf: The buffer to place the result into
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
+ *
+ * The function returns the number of characters written
+ * into @buf. Use snprintf() or scnprintf() in order to avoid
+ * buffer overflows.
+ *
+ * See the vsnprintf() documentation for format string extensions over C99.
+ */
+int bat_sprintf(char *buf, const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = bat_vsnprintf(buf, INT_MAX, fmt, args);
+ va_end(args);
+
+ return i;
+}
+
+/**
+ * snprintf - Format a string and place it in a buffer
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
+ *
+ * The return value is the number of characters which would be
+ * generated for the given input, excluding the trailing null,
+ * as per ISO C99. If the return is greater than or equal to
+ * @size, the resulting string is truncated.
+ *
+ * See the vsnprintf() documentation for format string extensions over C99.
+ */
+int bat_snprintf(char *buf, size_t size, const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = bat_vsnprintf(buf, size, fmt, args);
+ va_end(args);
+
+ return i;
+}
Modified: trunk/batman-adv-kernelland/compat.h
===================================================================
--- trunk/batman-adv-kernelland/compat.h 2010-06-04 19:44:14 UTC (rev 1687)
+++ trunk/batman-adv-kernelland/compat.h 2010-06-05 17:42:40 UTC (rev 1688)
@@ -74,12 +74,6 @@
#endif /* < KERNEL_VERSION(2, 6, 23) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
-
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-
-#endif /* < KERNEL_VERSION(2, 6, 24) */
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
#define strict_strtoul(cp, base, res) \
@@ -235,6 +229,12 @@
asmlinkage int bat_printk(const char *fmt, ...);
#define printk bat_printk
+int bat_sprintf(char *buf, const char *fmt, ...);
+#define sprintf bat_sprintf
+
+int bat_snprintf(char *buf, size_t size, const char *fmt, ...);
+#define snprintf bat_snprintf
+
static inline struct net_device_stats *dev_get_stats(struct net_device *dev)
{
if (dev->get_stats)
Modified: trunk/batman-adv-kernelland/main.c
===================================================================
--- trunk/batman-adv-kernelland/main.c 2010-06-04 19:44:14 UTC (rev 1687)
+++ trunk/batman-adv-kernelland/main.c 2010-06-05 17:42:40 UTC (rev 1688)
@@ -227,8 +227,7 @@
int addr_to_string(char *buff, uint8_t *addr)
{
- return sprintf(buff, MAC_FMT,
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+ return sprintf(buff, "%pM", addr);
}
/* returns 1 if they are the same originator */
Modified: trunk/batman-adv-kernelland/translation-table.c
===================================================================
--- trunk/batman-adv-kernelland/translation-table.c 2010-06-04 19:44:14 UTC (rev 1687)
+++ trunk/batman-adv-kernelland/translation-table.c 2010-06-05 17:42:40 UTC (rev 1688)
@@ -200,13 +200,8 @@
while (hash_iterate(hna_local_hash, &hashit)) {
hna_local_entry = hashit.bucket->data;
- pos += snprintf(buff + pos, 22, " * " MAC_FMT "\n",
- hna_local_entry->addr[0],
- hna_local_entry->addr[1],
- hna_local_entry->addr[2],
- hna_local_entry->addr[3],
- hna_local_entry->addr[4],
- hna_local_entry->addr[5]);
+ pos += snprintf(buff + pos, 22, " * %pM\n",
+ hna_local_entry->addr);
}
spin_unlock_irqrestore(&hna_local_hash_lock, flags);
@@ -418,19 +413,8 @@
hna_global_entry = hashit.bucket->data;
pos += snprintf(buff + pos, 44,
- " * " MAC_FMT " via " MAC_FMT "\n",
- hna_global_entry->addr[0],
- hna_global_entry->addr[1],
- hna_global_entry->addr[2],
- hna_global_entry->addr[3],
- hna_global_entry->addr[4],
- hna_global_entry->addr[5],
- hna_global_entry->orig_node->orig[0],
- hna_global_entry->orig_node->orig[1],
- hna_global_entry->orig_node->orig[2],
- hna_global_entry->orig_node->orig[3],
- hna_global_entry->orig_node->orig[4],
- hna_global_entry->orig_node->orig[5]);
+ " * %pM via %pM\n", hna_global_entry->addr,
+ hna_global_entry->orig_node->orig);
}
spin_unlock_irqrestore(&hna_global_hash_lock, flags);
Author: simon
Date: 2010-06-04 15:50:59 +0200 (Fri, 04 Jun 2010)
New Revision: 1686
Modified:
trunk/batman-adv-kernelland/hard-interface.c
trunk/batman-adv-kernelland/routing.c
trunk/batman-adv-kernelland/routing.h
trunk/batman-adv-kernelland/soft-interface.c
Log:
batman-adv: bonding and interface alternating
This patch adds interface alternating to the new bonding feature. By
default, we now try to avoid forwarding packets on the receiving
interface, instead choosing alternative interfaces. This feature
works only on nodes which have multiple interfaces connected to the
mesh. This approach should reduce problems of the half-duplex nature
of WiFi Hardware and thus increase performance.
The patch also includes a bug fix for the interference detection.
Neighbors which are not (yet) candidates should not be considered for
the interference.
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Acked-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
Note that unlike the first bonding/alternating patch, the interface
alternating is now activated by default. We have concluded at the
WBMv3 that this is generally a good idea.
We also did tests on dual radio meshnodes, and the link appeared
much more stable (steady 25 Mbit/s, instead of switching between
15 and 25 Mbit/s).
Modified: trunk/batman-adv-kernelland/hard-interface.c
===================================================================
--- trunk/batman-adv-kernelland/hard-interface.c 2010-06-04 13:34:00 UTC (rev 1685)
+++ trunk/batman-adv-kernelland/hard-interface.c 2010-06-04 13:50:59 UTC (rev 1686)
@@ -514,7 +514,7 @@
/* unicast packet */
case BAT_UNICAST:
- ret = recv_unicast_packet(skb);
+ ret = recv_unicast_packet(skb, batman_if);
break;
/* broadcast packet */
Modified: trunk/batman-adv-kernelland/routing.c
===================================================================
--- trunk/batman-adv-kernelland/routing.c 2010-06-04 13:34:00 UTC (rev 1685)
+++ trunk/batman-adv-kernelland/routing.c 2010-06-04 13:50:59 UTC (rev 1686)
@@ -416,12 +416,6 @@
struct batman_packet *batman_packet)
{
- /* don't care if bonding is not enabled */
- if (!atomic_read(&bat_priv->bonding_enabled)) {
- orig_node->bond.candidates = 0;
- return;
- }
-
if (batman_packet->flags & PRIMARIES_FIRST_HOP)
memcpy(orig_neigh_node->primary_addr,
orig_node->orig, ETH_ALEN);
@@ -429,7 +423,7 @@
return;
}
-/* mark possible bonding candidates in the neighbor list */
+/* mark possible bond.candidates in the neighbor list */
void update_bonding_candidates(struct bat_priv *bat_priv,
struct orig_node *orig_node)
{
@@ -439,12 +433,6 @@
struct neigh_node *tmp_neigh_node, *tmp_neigh_node2;
struct neigh_node *first_candidate, *last_candidate;
- /* don't care if bonding is not enabled */
- if (!atomic_read(&bat_priv->bonding_enabled)) {
- orig_node->bond.candidates = 0;
- return;
- }
-
/* update the candidates for this originator */
if (!orig_node->router) {
orig_node->bond.candidates = 0;
@@ -453,7 +441,7 @@
best_tq = orig_node->router->tq_avg;
- /* update bonding candidates */
+ /* update bond.candidates */
candidates = 0;
@@ -490,6 +478,12 @@
if (tmp_neigh_node2 == tmp_neigh_node)
continue;
+ /* we only care if the other candidate is even
+ * considered as candidate. */
+ if (tmp_neigh_node2->next_bond_candidate == NULL)
+ continue;
+
+
if ((tmp_neigh_node->if_incoming ==
tmp_neigh_node2->if_incoming)
|| (memcmp(tmp_neigh_node->addr,
@@ -1007,14 +1001,16 @@
/* find a suitable router for this originator, and use
* bonding if possible. */
-struct neigh_node *find_router(struct orig_node *orig_node)
+struct neigh_node *find_router(struct orig_node *orig_node,
+ struct batman_if *recv_if)
{
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct orig_node *primary_orig_node;
struct orig_node *router_orig;
- struct neigh_node *router;
+ struct neigh_node *router, *first_candidate, *best_router;
static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
+ int bonding_enabled;
if (!orig_node)
return NULL;
@@ -1022,10 +1018,13 @@
if (!orig_node->router)
return NULL;
- /* don't care if bonding is not enabled */
- if (!atomic_read(&bat_priv->bonding_enabled))
- return orig_node->router;
+ /* without bonding, the first node should
+ * always choose the default router. */
+ bonding_enabled = atomic_read(&bat_priv->bonding_enabled);
+ if (!bonding_enabled && (recv_if == NULL))
+ return orig_node->router;
+
router_orig = orig_node->router->orig_node;
/* if we have something in the primary_addr, we can search
@@ -1052,19 +1051,48 @@
if (primary_orig_node->bond.candidates < 2)
return orig_node->router;
- router = primary_orig_node->bond.selected;
- /* sanity check - this should never happen. */
- if (!router)
- return orig_node->router;
+ /* all nodes between should choose a candidate which
+ * is is not on the interface where the packet came
+ * in. */
+ first_candidate = primary_orig_node->bond.selected;
+ router = first_candidate;
- /* select the next bonding partner ... */
- primary_orig_node->bond.selected = router->next_bond_candidate;
+ if (bonding_enabled) {
+ /* in the bonding case, send the packets in a round
+ * robin fashion over the remaining interfaces. */
+ do {
+ /* recv_if == NULL on the first node. */
+ if (router->if_incoming != recv_if)
+ break;
+ router = router->next_bond_candidate;
+ } while (router != first_candidate);
+
+ primary_orig_node->bond.selected = router->next_bond_candidate;
+
+ } else {
+ /* if bonding is disabled, use the best of the
+ * remaining candidates which are not using
+ * this interface. */
+ best_router = first_candidate;
+
+ do {
+ /* recv_if == NULL on the first node. */
+ if ((router->if_incoming != recv_if) &&
+ (router->tq_avg > best_router->tq_avg))
+ best_router = router;
+
+ router = router->next_bond_candidate;
+ } while (router != first_candidate);
+
+ router = best_router;
+ }
+
return router;
}
-int recv_unicast_packet(struct sk_buff *skb)
+int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
{
struct unicast_packet *unicast_packet;
struct orig_node *orig_node;
@@ -1116,7 +1144,7 @@
orig_node = ((struct orig_node *)
hash_find(orig_hash, unicast_packet->dest));
- router = find_router(orig_node);
+ router = find_router(orig_node, recv_if);
if (!router) {
spin_unlock_irqrestore(&orig_hash_lock, flags);
Modified: trunk/batman-adv-kernelland/routing.h
===================================================================
--- trunk/batman-adv-kernelland/routing.h 2010-06-04 13:34:00 UTC (rev 1685)
+++ trunk/batman-adv-kernelland/routing.h 2010-06-04 13:50:59 UTC (rev 1686)
@@ -32,11 +32,12 @@
struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len);
int recv_icmp_packet(struct sk_buff *skb);
-int recv_unicast_packet(struct sk_buff *skb);
+int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if);
int recv_bcast_packet(struct sk_buff *skb);
int recv_vis_packet(struct sk_buff *skb);
int recv_bat_packet(struct sk_buff *skb,
struct batman_if *batman_if);
-struct neigh_node *find_router(struct orig_node *orig_node);
+struct neigh_node *find_router(struct orig_node *orig_node,
+ struct batman_if *recv_if);
void update_bonding_candidates(struct bat_priv *bat_priv,
struct orig_node *orig_node);
Modified: trunk/batman-adv-kernelland/soft-interface.c
===================================================================
--- trunk/batman-adv-kernelland/soft-interface.c 2010-06-04 13:34:00 UTC (rev 1685)
+++ trunk/batman-adv-kernelland/soft-interface.c 2010-06-04 13:50:59 UTC (rev 1686)
@@ -250,7 +250,7 @@
if (!orig_node)
orig_node = transtable_search(ethhdr->h_dest);
- router = find_router(orig_node);
+ router = find_router(orig_node, NULL);
if (!router)
goto unlock;