The following commit has been merged in the next branch: commit 3153350ecd4ac0cbce59cdfe24bb80e6b4ad1367 Merge: 2c9aa3b4c37bd55148f5f25212c89e7bf5f28497 9b3b58e7bf51cc7e42b4851f6c5c79dc8d81a2fd Author: Marek Lindner lindner_marek@yahoo.de Date: Fri Apr 13 22:35:53 2012 +0200
Merge branch 'next'
diff --combined bridge_loop_avoidance.c index 96a943e,8bf9751..d864e1c --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@@ -123,13 -123,13 +123,13 @@@ static void claim_free_ref(struct clai call_rcu(&claim->rcu, claim_free_rcu); }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @data: search data (may be local/static data) * * looks for a claim in the hash, and returns it if found * or NULL otherwise. */ - static struct claim *claim_hash_find(struct bat_priv *bat_priv, struct claim *data) { @@@ -162,14 -162,14 +162,14 @@@ return claim_tmp; }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @addr: the address of the originator * @vid: the VLAN ID * * looks for a claim in the hash, and returns it if found * or NULL otherwise. */ - static struct backbone_gw *backbone_hash_find(struct bat_priv *bat_priv, uint8_t *addr, short vid) { @@@ -241,14 -241,14 +241,14 @@@ static void bla_del_backbone_claims(str backbone_gw->crc = BLA_CRC_INIT; }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @orig: the mac address to be announced within the claim * @vid: the VLAN ID * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...) * * sends a claim frame according to the provided info. */ - static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, short vid, int claimtype) { @@@ -282,7 -282,8 +282,8 @@@ primary_if->net_dev->dev_addr, /* HW DST: FF:43:05:XX:00:00 * with XX = claim type - * and YY:YY = group id */ + * and YY:YY = group id + */ (uint8_t *)&local_claim_dest);
if (!skb) @@@ -294,8 -295,7 +295,7 @@@ /* now we pretend that the client would have sent this ... */ switch (claimtype) { case CLAIM_TYPE_ADD: - /* - * normal claim frame + /* normal claim frame * set Ethernet SRC to the clients mac */ memcpy(ethhdr->h_source, mac, ETH_ALEN); @@@ -303,8 -303,7 +303,7 @@@ "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); break; case CLAIM_TYPE_DEL: - /* - * unclaim frame + /* unclaim frame * set HW SRC to the clients mac */ memcpy(hw_src, mac, ETH_ALEN); @@@ -312,8 -311,7 +311,7 @@@ "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, vid); break; case CLAIM_TYPE_ANNOUNCE: - /* - * announcement frame + /* announcement frame * set HW SRC to the special mac containg the crc */ memcpy(hw_src, mac, ETH_ALEN); @@@ -322,8 -320,7 +320,7 @@@ ethhdr->h_source, vid); break; case CLAIM_TYPE_REQUEST: - /* - * request frame + /* request frame * set HW SRC to the special mac containg the crc */ memcpy(hw_src, mac, ETH_ALEN); @@@ -350,14 -347,14 +347,14 @@@ out hardif_free_ref(primary_if); }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @orig: the mac address of the originator * @vid: the VLAN ID * * searches for the backbone gw or creates a new one if it could not * be found. */ - static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, uint8_t *orig, short vid) { @@@ -425,13 -422,13 +422,13 @@@ static void bla_update_own_backbone_gw( backbone_gw_free_ref(backbone_gw); }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @vid: the vid where the request came on * * Repeat all of our own claims, and finally send an ANNOUNCE frame * to allow the requester another check if the CRC is correct now. */ - static void bla_answer_request(struct bat_priv *bat_priv, struct hard_iface *primary_if, short vid) { @@@ -471,13 -468,13 +468,13 @@@ backbone_gw_free_ref(backbone_gw); }
- /* @backbone_gw: the backbone gateway from whom we are out of sync + /** + * @backbone_gw: the backbone gateway from whom we are out of sync * * When the crc is wrong, ask the backbone gateway for a full table update. * After the request, it will repeat all of his own claims and finally * send an announcement claim with which we can check again. */ - static void bla_send_request(struct backbone_gw *backbone_gw) { /* first, remove all old entries */ @@@ -498,7 -495,8 +495,8 @@@ } }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @backbone_gw: our backbone gateway which should be announced * * This function sends an announcement. It is called from multiple @@@ -518,14 -516,14 +516,14 @@@ static void bla_send_announce(struct ba
}
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @mac: the mac address of the claim * @vid: the VLAN ID of the frame * @backbone_gw: the backbone gateway which claims it * * Adds a claim in the claim hash. */ - static void bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, const short vid, struct backbone_gw *backbone_gw) { @@@ -644,7 -642,8 +642,8 @@@ static int handle_announce(struct bat_p bla_send_request(backbone_gw); } else { /* if we have sent a request and the crc was OK, - * we can allow traffic again. */ + * we can allow traffic again. + */ if (atomic_read(&backbone_gw->request_sent)) { atomic_dec(&backbone_gw->bat_priv->bla_num_requests); atomic_set(&backbone_gw->request_sent, 0); @@@ -666,7 -665,8 +665,8 @@@ static int handle_request(struct bat_pr return 0;
/* sanity check, this should not happen on a normal switch, - * we ignore it in this case. */ + * we ignore it in this case. + */ if (!compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) return 1;
@@@ -732,7 -732,6 +732,6 @@@ static int handle_claim(struct bat_pri }
/** - * * @bat_priv: the bat priv with all the soft interface information * @hw_src: the Hardware source in the ARP Header * @hw_dst: the Hardware destination in the ARP Header @@@ -765,7 -764,8 +764,8 @@@ static int check_claim_group(struct bat return 0;
/* if announcement packet, use the source, - * otherwise assume it is in the hw_src */ + * otherwise assume it is in the hw_src + */ switch (bla_dst->type) { case CLAIM_TYPE_ADD: backbone_addr = hw_src; @@@ -791,7 -791,8 +791,8 @@@ orig_node = orig_hash_find(bat_priv, backbone_addr);
/* dont accept claims from gateways which are not in - * the same mesh or group. */ + * the same mesh or group. + */ if (!orig_node) return 1;
@@@ -809,7 -810,8 +810,8 @@@ }
- /* @bat_priv: the bat priv with all the soft interface information + /** + * @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * * Check if this is a claim frame, and process it accordingly. @@@ -817,7 -819,6 +819,6 @@@ * returns 1 if it was a claim frame, otherwise return 0 to * tell the callee that it can use the frame on its own. */ - static int bla_process_claim(struct bat_priv *bat_priv, struct hard_iface *primary_if, struct sk_buff *skb) @@@ -857,7 -858,8 +858,8 @@@ arphdr = (struct arphdr *)((uint8_t *)ethhdr + headlen);
/* Check whether the ARP frame carries a valid - * IP information */ + * IP information + */
if (arphdr->ar_hrd != htons(ARPHRD_ETHER)) return 0; @@@ -1054,7 -1056,8 +1056,8 @@@ void bla_update_orig_address(struct bat memcpy(backbone_gw->orig, primary_if->net_dev->dev_addr, ETH_ALEN); /* send an announce frame so others will ask for our - * claims and update their tables. */ + * claims and update their tables. + */ bla_send_announce(bat_priv, backbone_gw); } rcu_read_unlock(); @@@ -1075,7 -1078,6 +1078,6 @@@ static void bla_start_timer(struct bat_ * * purge structures when they are too old * * send announcements */ - static void bla_periodic_work(struct work_struct *work) { struct delayed_work *delayed_work = @@@ -1125,14 -1127,6 +1127,14 @@@ out bla_start_timer(bat_priv); }
+/* The hash for claim and backbone hash receive the same key because they + * are getting initialized by hash_new with the same key. Reinitializing + * them with to different keys to allow nested locking without generating + * lockdep warnings + */ +static struct lock_class_key claim_hash_lock_class_key; +static struct lock_class_key backbone_hash_lock_class_key; + /* initialize all bla structures */ int bla_init(struct bat_priv *bat_priv) { @@@ -1167,10 -1161,6 +1169,10 @@@ bat_priv->claim_hash = hash_new(128); bat_priv->backbone_hash = hash_new(32);
+ hash_set_lock_class(bat_priv->claim_hash, &claim_hash_lock_class_key); + hash_set_lock_class(bat_priv->backbone_hash, + &backbone_hash_lock_class_key); + if (!bat_priv->claim_hash || !bat_priv->backbone_hash) return -1;
@@@ -1217,7 -1207,8 +1219,8 @@@ int bla_check_bcast_duplist(struct bat_ entry = &bat_priv->bcast_duplist[curr];
/* we can stop searching if the entry is too old ; - * later entries will be even older */ + * later entries will be even older + */ if (has_timed_out(entry->entrytime, DUPLIST_TIMEOUT)) break;
@@@ -1228,7 -1219,8 +1231,8 @@@ continue;
/* this entry seems to match: same crc, not too old, - * and from another gw. therefore return 1 to forbid it. */ + * and from another gw. therefore return 1 to forbid it. + */ return 1; } /* not found, add a new entry (overwrite the oldest entry) */ @@@ -1253,7 -1245,7 +1257,7 @@@ * * returns 1 if it is found, 0 otherwise * - **/ + */
int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig) { @@@ -1295,8 -1287,7 +1299,7 @@@ * if the orig_node is also a gateway on the soft interface, otherwise it * returns 0. * - **/ - + */ int bla_is_backbone_gw(struct sk_buff *skb, struct orig_node *orig_node, int hdr_size) { @@@ -1369,8 -1360,7 +1372,7 @@@ void bla_free(struct bat_priv *bat_priv * returns 1, otherwise it returns 0 and the caller shall further * process the skb. * - **/ - + */ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) { struct ethhdr *ethhdr; @@@ -1399,7 -1389,8 +1401,8 @@@
if (!claim) { /* possible optimization: race for a claim */ - /* No claim exists yet, claim it for us! */ + /* No claim exists yet, claim it for us! + */ handle_claim(bat_priv, primary_if, primary_if->net_dev->dev_addr, ethhdr->h_source, vid); @@@ -1421,7 -1412,8 +1424,8 @@@ } else { /* seems the client considers us as its best gateway. * send a claim and update the claim table - * immediately. */ + * immediately. + */ handle_claim(bat_priv, primary_if, primary_if->net_dev->dev_addr, ethhdr->h_source, vid); @@@ -1457,8 -1449,7 +1461,7 @@@ out * returns 1, otherwise it returns 0 and the caller shall further * process the skb. * - **/ - + */ int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) { struct ethhdr *ethhdr; @@@ -1499,7 -1490,8 +1502,8 @@@ if (compare_eth(claim->backbone_gw->orig, primary_if->net_dev->dev_addr)) { /* if yes, the client has roamed and we have - * to unclaim it. */ + * to unclaim it. + */ handle_unclaim(bat_priv, primary_if, primary_if->net_dev->dev_addr, ethhdr->h_source, vid); @@@ -1509,11 -1501,13 +1513,13 @@@ /* check if it is a multicast/broadcast frame */ if (is_multicast_ether_addr(ethhdr->h_dest)) { /* drop it. the responsible gateway has forwarded it into - * the backbone network. */ + * the backbone network. + */ goto handled; } else { /* we must allow it. at least if we are - * responsible for the DESTINATION. */ + * responsible for the DESTINATION. + */ goto allow; } allow: