The following commit has been merged in the master branch: commit 292753056eede01fb925415ff32e987c5570546e Merge: 5a1f1a52a2af40669b17db05cd18bb0b65b4afd0 dc96f5b62bfbac7ea0a5f53ed9795ad262daad91 Author: Marek Lindner lindner_marek@yahoo.de Date: Tue Dec 6 15:58:26 2011 +0800
Merge branch 'next'
diff --combined routing.c index d5ddbd1,773e606..4363d19 --- a/routing.c +++ b/routing.c @@@ -320,7 -320,7 +320,7 @@@ static int recv_my_icmp_packet(struct b memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = ECHO_REPLY; - icmp_packet->ttl = TTL; + icmp_packet->header.ttl = TTL;
send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; @@@ -376,7 -376,7 +376,7 @@@ static int recv_icmp_ttl_exceeded(struc memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = TTL_EXCEEDED; - icmp_packet->ttl = TTL; + icmp_packet->header.ttl = TTL;
send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; @@@ -441,7 -441,7 +441,7 @@@ int recv_icmp_packet(struct sk_buff *sk return recv_my_icmp_packet(bat_priv, skb, hdr_size);
/* TTL exceeded */ - if (icmp_packet->ttl < 2) + if (icmp_packet->header.ttl < 2) return recv_icmp_ttl_exceeded(bat_priv, skb);
/* get routing information */ @@@ -460,7 -460,7 +460,7 @@@ icmp_packet = (struct icmp_packet_rr *)skb->data;
/* decrement ttl */ - icmp_packet->ttl--; + icmp_packet->header.ttl--;
/* route it */ send_skb_packet(skb, router->if_incoming, router->addr); @@@ -627,8 -627,7 +627,7 @@@ int recv_tt_query(struct sk_buff *skb,
/* 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); @@@ -816,7 -815,7 +815,7 @@@ int route_unicast_packet(struct sk_buf unicast_packet = (struct unicast_packet *)skb->data;
/* TTL exceeded */ - if (unicast_packet->ttl < 2) { + if (unicast_packet->header.ttl < 2) { pr_debug("Warning - can't forward unicast packet from %pM to " "%pM: ttl exceeded\n", ethhdr->h_source, unicast_packet->dest); @@@ -841,7 -840,7 +840,7 @@@
unicast_packet = (struct unicast_packet *)skb->data;
- if (unicast_packet->packet_type == BAT_UNICAST && + if (unicast_packet->header.packet_type == BAT_UNICAST && atomic_read(&bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { ret = frag_send_skb(skb, bat_priv, @@@ -849,7 -848,7 +848,7 @@@ goto out; }
- if (unicast_packet->packet_type == BAT_UNICAST_FRAG && + if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) {
ret = frag_reassemble_skb(skb, bat_priv, &new_skb); @@@ -868,7 -867,7 +867,7 @@@ }
/* decrement ttl */ - unicast_packet->ttl--; + unicast_packet->header.ttl--;
/* route it */ send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); @@@ -1042,7 -1041,7 +1041,7 @@@ int recv_bcast_packet(struct sk_buff *s if (is_my_mac(bcast_packet->orig)) goto out;
- if (bcast_packet->ttl < 2) + if (bcast_packet->header.ttl < 2) goto out;
orig_node = orig_hash_find(bat_priv, bcast_packet->orig); diff --combined translation-table.c index 7a7df4a,58361ed..20d6628 --- a/translation-table.c +++ b/translation-table.c @@@ -242,9 -242,10 +242,10 @@@ void tt_local_add(struct net_device *so 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); } @@@ -661,6 -662,7 +662,7 @@@ void tt_global_del(struct bat_priv *bat 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) @@@ -668,15 -670,29 +670,29 @@@
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->common.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, @@@ -717,7 -733,6 +733,7 @@@ spin_unlock_bh(list_lock); } atomic_set(&orig_node->tt_size, 0); + orig_node->tt_initialised = false; }
static void tt_global_roam_purge(struct bat_priv *bat_priv) @@@ -1119,11 -1134,11 +1135,11 @@@ static int send_tt_request(struct bat_p tt_request = (struct tt_query_packet *)skb_put(skb, sizeof(struct tt_query_packet));
- tt_request->packet_type = BAT_TT_QUERY; - tt_request->version = COMPAT_VERSION; + tt_request->header.packet_type = BAT_TT_QUERY; + tt_request->header.version = COMPAT_VERSION; memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); - tt_request->ttl = TTL; + tt_request->header.ttl = TTL; tt_request->ttvn = ttvn; tt_request->tt_data = tt_crc; tt_request->flags = TT_REQUEST; @@@ -1249,9 -1264,9 +1265,9 @@@ static bool send_other_tt_response(stru tt_response = (struct tt_query_packet *)skb->data; }
- tt_response->packet_type = BAT_TT_QUERY; - tt_response->version = COMPAT_VERSION; - tt_response->ttl = TTL; + tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.version = COMPAT_VERSION; + tt_response->header.ttl = TTL; memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@@ -1366,9 -1381,9 +1382,9 @@@ static bool send_my_tt_response(struct tt_response = (struct tt_query_packet *)skb->data; }
- tt_response->packet_type = BAT_TT_QUERY; - tt_response->version = COMPAT_VERSION; - tt_response->ttl = TTL; + tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.version = COMPAT_VERSION; + tt_response->header.ttl = TTL; memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@@ -1477,7 -1492,6 +1493,7 @@@ static void tt_update_changes(struct ba tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change, tt_num_changes); atomic_set(&orig_node->last_ttvn, ttvn); + orig_node->tt_initialised = true; }
bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) @@@ -1655,9 -1669,9 +1671,9 @@@ void send_roam_adv(struct bat_priv *bat roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, sizeof(struct roam_adv_packet));
- roam_adv_packet->packet_type = BAT_ROAM_ADV; - roam_adv_packet->version = COMPAT_VERSION; - roam_adv_packet->ttl = TTL; + roam_adv_packet->header.packet_type = BAT_ROAM_ADV; + roam_adv_packet->header.version = COMPAT_VERSION; + roam_adv_packet->header.ttl = TTL; primary_if = primary_if_get_selected(bat_priv); if (!primary_if) goto out; @@@ -1840,10 -1854,8 +1856,10 @@@ void tt_update_orig(struct bat_priv *ba uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); bool full_table = true;
- /* the ttvn increased by one -> we can apply the attached changes */ - if (ttvn - orig_ttvn == 1) { + /* orig table not initialised AND first diff is in the OGM OR the ttvn + * increased by one -> we can apply the attached changes */ + if ((!orig_node->tt_initialised && ttvn == 1) || + ttvn - orig_ttvn == 1) { /* the OGM could not contain the changes due to their size or * because they have already been sent TT_OGM_APPEND_MAX times. * In this case send a tt request */ @@@ -1877,8 -1889,7 +1893,8 @@@ } else { /* if we missed more than one change or our tables are not * in sync anymore -> request fresh tt data */ - if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { + if (!orig_node->tt_initialised || ttvn != orig_ttvn || + orig_node->tt_crc != tt_crc) { request_table: bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " "Need to retrieve the correct information "