From 5fbc1598c28555d2aa44bff0ac56ec3739401aff Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Fri, 17 Jun 2011 16:11:27 +0200 Subject: batman-adv: unify flags for tt_change/tt_local_entry/tt_global_entry The tt_local_entry structure now has a 'flags' field. This helps to unify the flags format to all the client related structures (tt_global_entry and tt_change). The 'never_purge' field is now encoded in the 'flags' one. To optimise the usage of this field, its length has been increased to 16bit in order to use the eight leading bits (from 0 to 7) to store flags that have to be sent on the wire, while the eight ending ones are used for local computation only. Moreover 'enum tt_change_flags' is now called 'enum tt_client_flags' and the defined values apply to the tt_local_entry, tt_global_entry and the tt_change 'flags' field. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/packet.h | 11 +++++++---- net/batman-adv/translation-table.c | 13 ++++++------- net/batman-adv/translation-table.h | 3 +-- net/batman-adv/types.h | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index c5f081dfc6d1..590e4a66089f 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -78,10 +78,13 @@ enum tt_query_flags { TT_FULL_TABLE = 1 << 2 }; -/* TT_CHANGE flags */ -enum tt_change_flags { - TT_CHANGE_DEL = 0x01, - TT_CLIENT_ROAM = 0x02 +/* TT_CLIENT flags. + * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to + * 1 << 15 are used for local computation only */ +enum tt_client_flags { + TT_CLIENT_DEL = 1 << 0, + TT_CLIENT_ROAM = 1 << 1, + TT_CLIENT_NOPURGE = 1 << 8 }; struct batman_packet { diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 5f1fcd573633..4208dc71257b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -211,13 +211,12 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) memcpy(tt_local_entry->addr, addr, ETH_ALEN); tt_local_entry->last_seen = jiffies; + tt_local_entry->flags = NO_FLAGS; atomic_set(&tt_local_entry->refcount, 2); /* the batman interface mac address should never be purged */ if (compare_eth(addr, soft_iface->dev_addr)) - tt_local_entry->never_purge = 1; - else - tt_local_entry->never_purge = 0; + tt_local_entry->flags |= TT_CLIENT_NOPURGE; hash_add(bat_priv->tt_local_hash, compare_ltt, choose_orig, tt_local_entry, &tt_local_entry->hash_entry); @@ -387,7 +386,7 @@ void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, if (!tt_local_entry) goto out; - tt_local_event(bat_priv, TT_CHANGE_DEL, tt_local_entry->addr, roaming); + tt_local_event(bat_priv, TT_CLIENT_DEL, tt_local_entry->addr, roaming); tt_local_del(bat_priv, tt_local_entry, message); out: if (tt_local_entry) @@ -410,14 +409,14 @@ static void tt_local_purge(struct bat_priv *bat_priv) spin_lock_bh(list_lock); hlist_for_each_entry_safe(tt_local_entry, node, node_tmp, head, hash_entry) { - if (tt_local_entry->never_purge) + if (tt_local_entry->flags & TT_CLIENT_NOPURGE) continue; if (!is_out_of_time(tt_local_entry->last_seen, TT_LOCAL_TIMEOUT * 1000)) continue; - tt_local_event(bat_priv, TT_CHANGE_DEL, + tt_local_event(bat_priv, TT_CLIENT_DEL, tt_local_entry->addr, false); atomic_dec(&bat_priv->num_local_tt); bat_dbg(DBG_TT, bat_priv, "Deleting local " @@ -1335,7 +1334,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, int i; for (i = 0; i < tt_num_changes; i++) { - if ((tt_change + i)->flags & TT_CHANGE_DEL) + if ((tt_change + i)->flags & TT_CLIENT_DEL) tt_global_del(bat_priv, orig_node, (tt_change + i)->addr, "tt removed by changes", diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index 1cd2d39529fe..460e5839cdd6 100644 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h @@ -30,8 +30,7 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr); void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, const char *message, bool roaming); int tt_local_seq_print_text(struct seq_file *seq, void *offset); -void tt_global_add_orig(struct bat_priv *bat_priv, - struct orig_node *orig_node, +void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, const unsigned char *tt_buff, int tt_buff_len); int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, const unsigned char *addr, diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 85cf1224881e..25bd1db35370 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -224,7 +224,7 @@ struct socket_packet { struct tt_local_entry { uint8_t addr[ETH_ALEN]; unsigned long last_seen; - char never_purge; + uint16_t flags; atomic_t refcount; struct rcu_head rcu; struct hlist_node hash_entry; @@ -234,7 +234,7 @@ struct tt_global_entry { uint8_t addr[ETH_ALEN]; struct orig_node *orig_node; uint8_t ttvn; - uint8_t flags; /* only TT_GLOBAL_ROAM is used */ + uint16_t flags; /* only TT_GLOBAL_ROAM is used */ unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ atomic_t refcount; struct rcu_head rcu; -- cgit v1.2.3-58-ga151 From 8698529d209c43f6434592caf38733b84ccab5f3 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Sat, 25 Jun 2011 19:09:12 +0200 Subject: batman-adv: add_bcast_packet_to_list() takes the sending delay as parameter In order to make possible to use the broadcast list for delayed sendings the "delay" parameter is now provided instead of using 1 as hardcoded value. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/routing.c | 2 +- net/batman-adv/send.c | 4 ++-- net/batman-adv/send.h | 2 +- net/batman-adv/soft-interface.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 0ce090c9fe86..2cb98bed1586 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -1677,7 +1677,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) spin_unlock_bh(&orig_node->bcast_seqno_lock); /* rebroadcast packet */ - add_bcast_packet_to_list(bat_priv, skb); + add_bcast_packet_to_list(bat_priv, skb, 1); /* broadcast for me */ interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size); diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 7a2f0823f1c2..2f62b2e4a47b 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -455,7 +455,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, * The skb is not consumed, so the caller should make sure that the * skb is freed. */ int add_bcast_packet_to_list(struct bat_priv *bat_priv, - const struct sk_buff *skb) + const struct sk_buff *skb, unsigned long delay) { struct hard_iface *primary_if = NULL; struct forw_packet *forw_packet; @@ -492,7 +492,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv, /* how often did we send the bcast packet ? */ forw_packet->num_packets = 0; - _add_bcast_packet_to_list(bat_priv, forw_packet, 1); + _add_bcast_packet_to_list(bat_priv, forw_packet, delay); return NETDEV_TX_OK; packet_free: diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h index 633224ab028a..1f2d1e877663 100644 --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h @@ -31,7 +31,7 @@ void schedule_forward_packet(struct orig_node *orig_node, int directlink, struct hard_iface *if_outgoing); int add_bcast_packet_to_list(struct bat_priv *bat_priv, - const struct sk_buff *skb); + const struct sk_buff *skb, unsigned long delay); void send_outstanding_bat_packet(struct work_struct *work); void purge_outstanding_packets(struct bat_priv *bat_priv, const struct hard_iface *hard_iface); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 2dcdbb7a236c..3f20332e1d38 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -634,7 +634,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) bcast_packet->seqno = htonl(atomic_inc_return(&bat_priv->bcast_seqno)); - add_bcast_packet_to_list(bat_priv, skb); + add_bcast_packet_to_list(bat_priv, skb, 1); /* a copy is stored in the bcast list, therefore removing * the original skb. */ -- cgit v1.2.3-58-ga151 From ff66c975d5e412817f8122012760e852b4571b5e Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Thu, 30 Jun 2011 01:14:00 +0200 Subject: batman-adv: pass a unique flag arg instead of a sequence of bool ones now tt_local_event() takes a flags argument instead of a sequence of boolean values which would grow up with the time. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 4208dc71257b..06d361d4ac4b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -143,8 +143,8 @@ static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) kfree_rcu(tt_global_entry, rcu); } -static void tt_local_event(struct bat_priv *bat_priv, uint8_t op, - const uint8_t *addr, bool roaming) +static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, + uint8_t flags) { struct tt_change_node *tt_change_node; @@ -153,10 +153,7 @@ static void tt_local_event(struct bat_priv *bat_priv, uint8_t op, if (!tt_change_node) return; - tt_change_node->change.flags = op; - if (roaming) - tt_change_node->change.flags |= TT_CLIENT_ROAM; - + tt_change_node->change.flags = flags; memcpy(tt_change_node->change.addr, addr, ETH_ALEN); spin_lock_bh(&bat_priv->tt_changes_list_lock); @@ -203,8 +200,6 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) if (!tt_local_entry) goto out; - tt_local_event(bat_priv, NO_FLAGS, addr, false); - bat_dbg(DBG_TT, bat_priv, "Creating new local tt entry: %pM (ttvn: %d)\n", addr, (uint8_t)atomic_read(&bat_priv->ttvn)); @@ -218,6 +213,8 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) if (compare_eth(addr, soft_iface->dev_addr)) tt_local_entry->flags |= TT_CLIENT_NOPURGE; + tt_local_event(bat_priv, addr, tt_local_entry->flags); + hash_add(bat_priv->tt_local_hash, compare_ltt, choose_orig, tt_local_entry, &tt_local_entry->hash_entry); @@ -386,7 +383,9 @@ void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, if (!tt_local_entry) goto out; - tt_local_event(bat_priv, TT_CLIENT_DEL, tt_local_entry->addr, roaming); + tt_local_event(bat_priv, tt_local_entry->addr, + tt_local_entry->flags | TT_CLIENT_DEL | + (roaming ? TT_CLIENT_ROAM : NO_FLAGS)); tt_local_del(bat_priv, tt_local_entry, message); out: if (tt_local_entry) @@ -416,8 +415,8 @@ static void tt_local_purge(struct bat_priv *bat_priv) TT_LOCAL_TIMEOUT * 1000)) continue; - tt_local_event(bat_priv, TT_CLIENT_DEL, - tt_local_entry->addr, false); + tt_local_event(bat_priv, tt_local_entry->addr, + tt_local_entry->flags | TT_CLIENT_DEL); atomic_dec(&bat_priv->num_local_tt); bat_dbg(DBG_TT, bat_priv, "Deleting local " "tt entry (%pM): timed out\n", -- cgit v1.2.3-58-ga151 From 6a020ab452d38b3878903de931c162429072a7d7 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Sun, 26 Jun 2011 15:26:18 +0200 Subject: batman-adv: broadcast primary OGM on all active hard-interfaces The primary interface OGM has to be broadcasted on all hard-interfaces even if the primary interface is not the first interface (if_num = 0). Therefore the code has to compare the originating interface with the primary interface instead of checking the if_num. Reported-by: Linus Luessing Signed-off-by: Marek Lindner --- net/batman-adv/send.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 2f62b2e4a47b..4b8e11bc14fa 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -163,6 +163,7 @@ static void send_packet(struct forw_packet *forw_packet) struct hard_iface *hard_iface; struct net_device *soft_iface; struct bat_priv *bat_priv; + struct hard_iface *primary_if = NULL; struct batman_packet *batman_packet = (struct batman_packet *)(forw_packet->skb->data); int directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); @@ -170,19 +171,23 @@ static void send_packet(struct forw_packet *forw_packet) if (!forw_packet->if_incoming) { pr_err("Error - can't forward packet: incoming iface not " "specified\n"); - return; + goto out; } soft_iface = forw_packet->if_incoming->soft_iface; bat_priv = netdev_priv(soft_iface); if (forw_packet->if_incoming->if_status != IF_ACTIVE) - return; + goto out; + + primary_if = primary_if_get_selected(bat_priv); + if (!primary_if) + goto out; /* multihomed peer assumed */ /* non-primary OGMs are only broadcasted on their interface */ if ((directlink && (batman_packet->ttl == 1)) || - (forw_packet->own && (forw_packet->if_incoming->if_num > 0))) { + (forw_packet->own && (forw_packet->if_incoming != primary_if))) { /* FIXME: what about aggregated packets ? */ bat_dbg(DBG_BATMAN, bat_priv, @@ -199,7 +204,7 @@ static void send_packet(struct forw_packet *forw_packet) broadcast_addr); forw_packet->skb = NULL; - return; + goto out; } /* broadcast on every interface */ @@ -211,6 +216,10 @@ static void send_packet(struct forw_packet *forw_packet) send_packet_to_if(forw_packet, hard_iface); } rcu_read_unlock(); + +out: + if (primary_if) + hardif_free_ref(primary_if); } static void realloc_packet_buffer(struct hard_iface *hard_iface, -- cgit v1.2.3-58-ga151 From b539e4cd3b08dddbaa2ba0f158eed3c7c2244eaf Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Sun, 26 Jun 2011 21:15:13 +0200 Subject: batman-adv: aggregation checks should use the primary_if pointer The packet aggregation needs to ensure that only compatible packets are aggregated. Some of the checks are based on the interface number while assuming that the first interface also is the primary interface which is not always the case. This patch addresses the issue by using the primary_if pointer. Reported-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/aggregation.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/aggregation.c b/net/batman-adv/aggregation.c index c583e049f421..69467fe71ff2 100644 --- a/net/batman-adv/aggregation.c +++ b/net/batman-adv/aggregation.c @@ -28,6 +28,7 @@ /* return true if new_packet can be aggregated with forw_packet */ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, + struct bat_priv *bat_priv, int packet_len, unsigned long send_time, bool directlink, @@ -37,6 +38,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, struct batman_packet *batman_packet = (struct batman_packet *)forw_packet->skb->data; int aggregated_bytes = forw_packet->packet_len + packet_len; + struct hard_iface *primary_if = NULL; + bool res = false; /** * we can aggregate the current packet to this aggregated packet @@ -61,6 +64,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * packet */ + primary_if = primary_if_get_selected(bat_priv); + if (!primary_if) + goto out; + /* packets without direct link flag and high TTL * are flooded through the net */ if ((!directlink) && @@ -70,8 +77,10 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, /* own packets originating non-primary * interfaces leave only that interface */ ((!forw_packet->own) || - (forw_packet->if_incoming->if_num == 0))) - return true; + (forw_packet->if_incoming == primary_if))) { + res = true; + goto out; + } /* if the incoming packet is sent via this one * interface only - we still can aggregate */ @@ -84,11 +93,16 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * (= secondary interface packets in general) */ (batman_packet->flags & DIRECTLINK || (forw_packet->own && - forw_packet->if_incoming->if_num != 0))) - return true; + forw_packet->if_incoming != primary_if))) { + res = true; + goto out; + } } - return false; +out: + if (primary_if) + hardif_free_ref(primary_if); + return res; } /* create a new aggregated packet and add this packet to it */ @@ -210,6 +224,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv, hlist_for_each_entry(forw_packet_pos, tmp_node, &bat_priv->forw_bat_list, list) { if (can_aggregate_with(batman_packet, + bat_priv, packet_len, send_time, direct_link, -- cgit v1.2.3-58-ga151 From 44c4349a2a117b22a5c4087f2ac9faf10c575e17 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 5 Jul 2011 10:42:51 +0200 Subject: batman-adv: Replace version info instead of appending them The version number of modules build outside of the tree can get revision numbers added. This is useful to give hints about the revision of a distribution package and the used patchset. The prepended source number or branch name doesn't add any additional information which would help to identify problems and can therefore be omitted. Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/gateway_client.c | 5 ++--- net/batman-adv/main.c | 9 ++------- net/batman-adv/main.h | 11 +++-------- net/batman-adv/originator.c | 5 ++--- 4 files changed, 9 insertions(+), 21 deletions(-) (limited to 'net/batman-adv') diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 8b25b52a4764..056180ef9e1a 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -487,10 +487,9 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) } seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... " - "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", + "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", "Gateway", "#", TQ_MAX_VALUE, "Nexthop", - "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR, - primary_if->net_dev->name, + "outgoingIF", SOURCE_VERSION, primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); rcu_read_lock(); diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e367e690a9f6..b0f9068ade57 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -58,9 +58,8 @@ static int __init batman_init(void) register_netdevice_notifier(&hard_if_notifier); - pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) " - "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR, - COMPAT_VERSION); + pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) " + "loaded\n", SOURCE_VERSION, COMPAT_VERSION); return 0; } @@ -184,8 +183,4 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); -#ifdef REVISION_VERSION -MODULE_VERSION(SOURCE_VERSION "-" REVISION_VERSION); -#else MODULE_VERSION(SOURCE_VERSION); -#endif diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 4f293b594475..a6df61a6933b 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -27,8 +27,9 @@ #define DRIVER_DESC "B.A.T.M.A.N. advanced" #define DRIVER_DEVICE "batman-adv" -#define SOURCE_VERSION "next" - +#ifndef SOURCE_VERSION +#define SOURCE_VERSION "2011.3.0" +#endif /* B.A.T.M.A.N. parameters */ @@ -144,12 +145,6 @@ enum dbg_level { #include #include "types.h" -#ifndef REVISION_VERSION -#define REVISION_VERSION_STR "" -#else -#define REVISION_VERSION_STR " "REVISION_VERSION -#endif - extern struct list_head hardif_list; extern unsigned char broadcast_addr[]; diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 338b3c597e4a..4cc94d4ba890 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -430,9 +430,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) goto out; } - seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", - SOURCE_VERSION, REVISION_VERSION_STR, - primary_if->net_dev->name, + seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", + SOURCE_VERSION, primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", -- cgit v1.2.3-58-ga151