Hi,
I would like to propose following changes for net-next-2.6/3.1. Most patches are simple cleanup patches and only Daniele Furlan provided an enhancement which should fix some routing decisions when a mesh node is overloaded and OGMs get delayed.
Thanks, Sven
The following changes since commit bb899b89f46eb1fd6f62a4c360f6511b9714e479:
batman-adv: Ensure that we really have route changes in update_route (2011-05-30 07:39:37 +0200)
are available in the git repository at: git://git.open-mesh.org/ecsv/linux-merge.git batman-adv/next
Daniele Furlan (1): batman-adv: accept delayed rebroadcasts to avoid bogus routing under heavy load
Marek Lindner (1): batman-adv: use NO_FLAGS define instead of hard-coding 0
Sven Eckelmann (4): batman-adv: Don't return value in void function batman-adv: Fix signedness problem in parse_gw_bandwidth batman-adv: Rewrite debugfs kobj_to_* helpers as functions batman-adv: Use enums for related constants
net/batman-adv/aggregation.c | 2 +- net/batman-adv/bat_sysfs.c | 14 +++++++++-- net/batman-adv/gateway_client.c | 6 ++-- net/batman-adv/gateway_common.c | 4 +- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/hard-interface.h | 14 ++++++----- net/batman-adv/main.h | 19 ++++++++++----- net/batman-adv/packet.h | 47 ++++++++++++++++++++++++--------------- net/batman-adv/routing.c | 9 +++---- net/batman-adv/send.c | 2 +- 10 files changed, 72 insertions(+), 47 deletions(-)
From: Daniele Furlan daniele.furlan@gmail.com
When a link is saturated (re)broadcasts of OGMs are delayed. Under heavy load this delay may exceed the orig interval which leads to OGMs being dropped (the code would only accept an OGM rebroadcast if it arrived before the next OGM was broadcasted). With this patch batman-adv will also accept delayed OGMs in order to avoid a bogus influence on the routing metric.
Signed-off-by: Daniele Furlan daniele.furlan@gmail.com Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/routing.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 368ceeb..934f1f2 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -698,17 +698,16 @@ void receive_bat_packet(const struct ethhdr *ethhdr,
/* neighbor has to indicate direct link and it has to * come via the corresponding interface */ - /* if received seqno equals last send seqno save new - * seqno for bidirectional check */ + /* save packet seqno for bidirectional check */ if (has_directlink_flag && compare_eth(if_incoming->net_dev->dev_addr, - batman_packet->orig) && - (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { + batman_packet->orig)) { offset = if_incoming->if_num * NUM_WORDS;
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); word = &(orig_neigh_node->bcast_own[offset]); - bit_mark(word, 0); + bit_mark(word, + if_incoming_seqno - batman_packet->seqno - 2); orig_neigh_node->bcast_own_sum[if_incoming->if_num] = bit_packet_count(word); spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
gw_node_delete is defined with "void" as return type, but still tries to return a value. The called function gw_node_delete is also return as void and thus doesn't provide a value for us.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/gateway_client.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index ab597c4..cf7f95e 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -352,7 +352,7 @@ unlock:
void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node) { - return gw_node_update(bat_priv, orig_node, 0); + gw_node_update(bat_priv, orig_node, 0); }
void gw_node_purge(struct bat_priv *bat_priv)
strict_strtoul as used in parse_gw_bandwidth is defined for unsigned long and strict_strtol should be used instead for long.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/gateway_common.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index ed3bd36..e74307b 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -97,7 +97,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, *tmp_ptr = '\0'; }
- ret = strict_strtoul(buff, 10, &ldown); + ret = strict_strtol(buff, 10, &ldown); if (ret) { bat_err(net_dev, "Download speed of gateway mode invalid: %s\n", @@ -122,7 +122,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, *tmp_ptr = '\0'; }
- ret = strict_strtoul(slash_ptr + 1, 10, &lup); + ret = strict_strtol(slash_ptr + 1, 10, &lup); if (ret) { bat_err(net_dev, "Upload speed of gateway mode invalid: "
CodingStyle "Chapter 12: Macros, Enums and RTL" highly recommends to use functions instead of macros were possible. This ensures type safety and prevents shadowing of other variables.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/bat_sysfs.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index 6f70560..924d577 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@ -28,9 +28,17 @@ #include "gateway_client.h" #include "vis.h"
-#define to_dev(obj) container_of(obj, struct device, kobj) -#define kobj_to_netdev(obj) to_net_dev(to_dev(obj->parent)) -#define kobj_to_batpriv(obj) netdev_priv(kobj_to_netdev(obj)) +static struct net_device *kobj_to_netdev(struct kobject *obj) +{ + struct device *dev = container_of(obj->parent, struct device, kobj); + return to_net_dev(dev); +} + +static struct bat_priv *kobj_to_batpriv(struct kobject *obj) +{ + struct net_device *net_dev = kobj_to_netdev(obj); + return netdev_priv(net_dev); +}
/* Use this, if you have customized show and store functions */ #define BAT_ATTR(_name, _mode, _show, _store) \
CodingStyle "Chapter 12: Macros, Enums and RTL" recommends to use enums for several related constants. Internal states can be used without defining the actual value, but all values which are visible to the outside must be defined as before. Normal values are assigned as usual and flags are defined by shifts of a bit.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/hard-interface.h | 14 ++++++----- net/batman-adv/main.h | 17 ++++++++----- net/batman-adv/packet.h | 47 ++++++++++++++++++++++++--------------- 3 files changed, 47 insertions(+), 31 deletions(-)
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index 79e25cb..442eacb 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h @@ -22,12 +22,14 @@ #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ #define _NET_BATMAN_ADV_HARD_INTERFACE_H_
-#define IF_NOT_IN_USE 0 -#define IF_TO_BE_REMOVED 1 -#define IF_INACTIVE 2 -#define IF_ACTIVE 3 -#define IF_TO_BE_ACTIVATED 4 -#define IF_I_WANT_YOU 5 +enum hard_if_state { + IF_NOT_IN_USE, + IF_TO_BE_REMOVED, + IF_INACTIVE, + IF_ACTIVE, + IF_TO_BE_ACTIVATED, + IF_I_WANT_YOU +};
extern struct notifier_block hard_if_notifier;
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 610eaf0..27ad734 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -72,9 +72,11 @@ #define RESET_PROTECTION_MS 30000 #define EXPECTED_SEQNO_RANGE 65536
-#define MESH_INACTIVE 0 -#define MESH_ACTIVE 1 -#define MESH_DEACTIVATING 2 +enum mesh_state { + MESH_INACTIVE, + MESH_ACTIVE, + MESH_DEACTIVATING +};
#define BCAST_QUEUE_LEN 256 #define BATMAN_QUEUE_LEN 256 @@ -89,10 +91,11 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* all messages related to routing / flooding / broadcasting / etc */ -#define DBG_BATMAN 1 -/* route or tt entry added / changed / deleted */ -#define DBG_ROUTES 2 -#define DBG_ALL 3 +enum dbg_level { + DBG_BATMAN = 1 << 0, + DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ + DBG_ALL = 3 +};
/* diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index eda9965..9f77086 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -24,33 +24,44 @@
#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
-#define BAT_PACKET 0x01 -#define BAT_ICMP 0x02 -#define BAT_UNICAST 0x03 -#define BAT_BCAST 0x04 -#define BAT_VIS 0x05 -#define BAT_UNICAST_FRAG 0x06 +enum bat_packettype { + BAT_PACKET = 0x01, + BAT_ICMP = 0x02, + BAT_UNICAST = 0x03, + BAT_BCAST = 0x04, + BAT_VIS = 0x05, + BAT_UNICAST_FRAG = 0x06 +};
/* this file is included by batctl which needs these defines */ #define COMPAT_VERSION 12 -#define DIRECTLINK 0x40 -#define VIS_SERVER 0x20 -#define PRIMARIES_FIRST_HOP 0x10 + +enum batman_flags { + PRIMARIES_FIRST_HOP = 1 << 4, + VIS_SERVER = 1 << 5, + DIRECTLINK = 1 << 6 +};
/* ICMP message types */ -#define ECHO_REPLY 0 -#define DESTINATION_UNREACHABLE 3 -#define ECHO_REQUEST 8 -#define TTL_EXCEEDED 11 -#define PARAMETER_PROBLEM 12 +enum icmp_packettype { + ECHO_REPLY = 0, + DESTINATION_UNREACHABLE = 3, + ECHO_REQUEST = 8, + TTL_EXCEEDED = 11, + PARAMETER_PROBLEM = 12 +};
/* vis defines */ -#define VIS_TYPE_SERVER_SYNC 0 -#define VIS_TYPE_CLIENT_UPDATE 1 +enum vis_packettype { + VIS_TYPE_SERVER_SYNC = 0, + VIS_TYPE_CLIENT_UPDATE = 1 +};
/* fragmentation defines */ -#define UNI_FRAG_HEAD 0x01 -#define UNI_FRAG_LARGETAIL 0x02 +enum unicast_frag_flags { + UNI_FRAG_HEAD = 1 << 0, + UNI_FRAG_LARGETAIL = 1 << 1 +};
struct batman_packet { uint8_t packet_type;
From: Marek Lindner lindner_marek@yahoo.de
The definition NO_FLAGS was introduced to make the code more readable and shall be used to initialize flag fields.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/aggregation.c | 2 +- net/batman-adv/gateway_client.c | 4 ++-- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/main.h | 2 ++ net/batman-adv/send.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/batman-adv/aggregation.c b/net/batman-adv/aggregation.c index b41f25b..4080970 100644 --- a/net/batman-adv/aggregation.c +++ b/net/batman-adv/aggregation.c @@ -151,7 +151,7 @@ static void new_aggregated_packet(const unsigned char *packet_buff, forw_packet_aggr->own = own_packet; forw_packet_aggr->if_incoming = if_incoming; forw_packet_aggr->num_packets = 0; - forw_packet_aggr->direct_link_flags = 0; + forw_packet_aggr->direct_link_flags = NO_FLAGS; forw_packet_aggr->send_time = send_time;
/* save packet direct link flag status */ diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index cf7f95e..24aee56 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -322,7 +322,7 @@ void gw_node_update(struct bat_priv *bat_priv,
gw_node->deleted = 0;
- if (new_gwflags == 0) { + if (new_gwflags == NO_FLAGS) { gw_node->deleted = jiffies; bat_dbg(DBG_BATMAN, bat_priv, "Gateway %pM removed from gateway list\n", @@ -335,7 +335,7 @@ void gw_node_update(struct bat_priv *bat_priv, goto unlock; }
- if (new_gwflags == 0) + if (new_gwflags == NO_FLAGS) goto unlock;
gw_node_add(bat_priv, orig_node, new_gwflags); diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index a3fbfb5..b55e861 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -337,7 +337,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, batman_packet = (struct batman_packet *)(hard_iface->packet_buff); batman_packet->packet_type = BAT_PACKET; batman_packet->version = COMPAT_VERSION; - batman_packet->flags = 0; + batman_packet->flags = NO_FLAGS; batman_packet->ttl = 2; batman_packet->tq = TQ_MAX_VALUE; batman_packet->num_tt = 0; diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 27ad734..ed488cb 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -51,6 +51,8 @@ #define TQ_LOCAL_BIDRECT_RECV_MINIMUM 1 #define TQ_TOTAL_BIDRECT_LIMIT 1
+#define NO_FLAGS 0 + #define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index d0cfa95..a1b8c31 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -289,7 +289,7 @@ void schedule_own_packet(struct hard_iface *hard_iface) batman_packet->gw_flags = (uint8_t)atomic_read(&bat_priv->gw_bandwidth); else - batman_packet->gw_flags = 0; + batman_packet->gw_flags = NO_FLAGS;
atomic_inc(&hard_iface->seqno);
From: Sven Eckelmann sven@narfation.org Date: Thu, 9 Jun 2011 23:09:08 +0200
Hi,
I would like to propose following changes for net-next-2.6/3.1. Most patches are simple cleanup patches and only Daniele Furlan provided an enhancement which should fix some routing decisions when a mesh node is overloaded and OGMs get delayed.
Pulled, thanks Sven.
b.a.t.m.a.n@lists.open-mesh.org