The following commit has been merged in the merge/master branch: commit dfb7cb2f929af7f5f1b43fa906f258796796fa14 Merge: ecc9b7898e87231069fd892b496333dcd7ad46b6 8335c0dac22497c44a500df7f428bc7ac4c6d1ad Author: Marek Lindner lindner_marek@yahoo.de Date: Mon Jul 4 16:51:47 2011 +0200
Merge remote-tracking branch 'origin/standalone/next' into merge/master
diff --combined net/batman-adv/aggregation.c index c583e04,69467fe..69467fe --- a/net/batman-adv/aggregation.c +++ b/net/batman-adv/aggregation.c @@@ -28,6 -28,7 +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 +38,8 @@@ 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 +64,10 @@@ * 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 +77,10 @@@ /* 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 +93,16 @@@ * (= 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 +224,7 @@@ void add_bat_packet_to_list(struct bat_ 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, diff --combined net/batman-adv/packet.h index c5f081d,590e4a6..590e4a6 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@@ -78,10 -78,13 +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 --combined net/batman-adv/routing.c index 0ce090c,2cb98be..2cb98be --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@@ -1677,7 -1677,7 +1677,7 @@@ int recv_bcast_packet(struct sk_buff *s 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 --combined net/batman-adv/send.c index 7a2f082,4b8e11b..4b8e11b --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@@ -163,6 -163,7 +163,7 @@@ static void send_packet(struct forw_pac 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 +171,23 @@@ 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 +204,7 @@@ broadcast_addr); forw_packet->skb = NULL;
- return; + goto out; }
/* broadcast on every interface */ @@@ -211,6 -216,10 +216,10 @@@ 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, @@@ -455,7 -464,7 +464,7 @@@ static void _add_bcast_packet_to_list(s * 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 -501,7 +501,7 @@@ /* 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 --combined net/batman-adv/send.h index 633224a,1f2d1e8..1f2d1e8 --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h @@@ -31,7 -31,7 +31,7 @@@ void schedule_forward_packet(struct ori 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 --combined net/batman-adv/soft-interface.c index 2dcdbb7,3f20332..3f20332 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@@ -634,7 -634,7 +634,7 @@@ static int interface_tx(struct sk_buff 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. */ diff --combined net/batman-adv/translation-table.c index 5f1fcd5,06d361d..06d361d --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@@ -143,8 -143,8 +143,8 @@@ static void tt_global_entry_free_ref(st 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 +153,7 @@@ 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,21 -200,20 +200,20 @@@ void tt_local_add(struct net_device *so 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));
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; + + 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); @@@ -387,7 -383,9 +383,9 @@@ void tt_local_remove(struct bat_priv *b 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_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) @@@ -410,15 -408,15 +408,15 @@@ static void tt_local_purge(struct bat_p 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_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", @@@ -1335,7 -1333,7 +1333,7 @@@ static void _tt_update_changes(struct b 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 --combined net/batman-adv/translation-table.h index 1cd2d39,460e583..460e583 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h @@@ -30,8 -30,7 +30,7 @@@ void tt_local_add(struct net_device *so 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 --combined net/batman-adv/types.h index 85cf122,25bd1db..25bd1db --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@@ -224,7 -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 +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;