Lines Matching full:claim
61 * batadv_choose_claim() - choose the right bucket for a claim.
65 * Return: the hash index of the claim
69 const struct batadv_bla_claim *claim = data;
72 hash = jhash(&claim->addr, sizeof(claim->addr), hash);
73 hash = jhash(&claim->vid, sizeof(claim->vid), hash);
126 * Return: true if the claim have the same data, 0 otherwise
174 * batadv_claim_release() - release claim from lists and queue for free after
176 * @ref: kref pointer of the claim
180 struct batadv_bla_claim *claim;
183 claim = container_of(ref, struct batadv_bla_claim, refcount);
185 spin_lock_bh(&claim->backbone_lock);
186 old_backbone_gw = claim->backbone_gw;
187 claim->backbone_gw = NULL;
188 spin_unlock_bh(&claim->backbone_lock);
191 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
196 kfree_rcu(claim, rcu);
200 * batadv_claim_put() - decrement the claim refcounter and possibly release it
201 * @claim: claim to be free'd
203 static void batadv_claim_put(struct batadv_bla_claim *claim)
205 if (!claim)
208 kref_put(&claim->refcount, batadv_claim_release);
212 * batadv_claim_hash_find() - looks for a claim in the claim hash
216 * Return: claim if found or NULL otherwise.
224 struct batadv_bla_claim *claim;
235 hlist_for_each_entry_rcu(claim, head, hash_entry) {
236 if (!batadv_compare_claim(&claim->hash_entry, data))
239 if (!kref_get_unless_zero(&claim->refcount))
242 claim_tmp = claim;
304 struct batadv_bla_claim *claim;
317 hlist_for_each_entry_safe(claim, node_tmp,
319 if (claim->backbone_gw != backbone_gw)
322 batadv_claim_put(claim);
323 hlist_del_rcu(&claim->hash_entry);
335 * batadv_bla_send_claim() - sends a claim frame according to the provided info
337 * @mac: the mac address to be announced within the claim
339 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
373 * with XX = claim type
387 /* normal claim frame
392 "%s(): CLAIM %pM on vid %d\n", __func__, mac,
597 struct batadv_bla_claim *claim;
602 "%s(): received a claim request, send all of our own claims again\n",
616 hlist_for_each_entry_rcu(claim, head, hash_entry) {
618 if (claim->backbone_gw != backbone_gw)
621 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
638 * send an announcement claim with which we can check again.
681 * batadv_bla_add_claim() - Adds a claim in the claim hash
683 * @mac: the mac address of the claim
692 struct batadv_bla_claim *claim;
699 claim = batadv_claim_hash_find(bat_priv, &search_claim);
701 /* create a new claim entry if it does not exist yet. */
702 if (!claim) {
703 claim = kzalloc(sizeof(*claim), GFP_ATOMIC);
704 if (!claim)
707 ether_addr_copy(claim->addr, mac);
708 spin_lock_init(&claim->backbone_lock);
709 claim->vid = vid;
710 claim->lasttime = jiffies;
712 claim->backbone_gw = backbone_gw;
713 kref_init(&claim->refcount);
719 kref_get(&claim->refcount);
722 batadv_choose_claim, claim,
723 &claim->hash_entry);
727 kfree(claim);
731 claim->lasttime = jiffies;
732 if (claim->backbone_gw == backbone_gw)
745 spin_lock_bh(&claim->backbone_lock);
746 old_backbone_gw = claim->backbone_gw;
748 claim->backbone_gw = backbone_gw;
749 spin_unlock_bh(&claim->backbone_lock);
752 /* remove claim address from old backbone_gw */
754 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
760 /* add claim address to new backbone_gw */
762 backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
767 batadv_claim_put(claim);
772 * claim
773 * @claim: claim whose backbone_gw should be returned
775 * Return: valid reference to claim::backbone_gw
778 batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
782 spin_lock_bh(&claim->backbone_lock);
783 backbone_gw = claim->backbone_gw;
785 spin_unlock_bh(&claim->backbone_lock);
791 * batadv_bla_del_claim() - delete a claim from the claim hash
793 * @mac: mac address of the claim to be removed
794 * @vid: VLAN id for the claim to be removed
799 struct batadv_bla_claim search_claim, *claim;
805 claim = batadv_claim_hash_find(bat_priv, &search_claim);
806 if (!claim)
814 batadv_choose_claim, claim);
825 batadv_claim_put(claim);
958 * batadv_handle_claim() - check for CLAIM frame
974 /* register the gateway if not yet available, and add the claim. */
982 /* this must be a CLAIM frame */
995 * batadv_check_claim_group() - check for claim group membership
1000 * @ethhdr: pointer to the Ethernet header of the claim frame
1002 * checks if it is a claim packet and if it's on the same group.
1007 * 2 - if it is a claim packet and on the same group
1008 * 1 - if is a claim packet from another group
1009 * 0 - if it is not a claim packet
1039 /* don't accept claim frames from ourselves */
1059 "taking other backbones claim group: %#.4x\n",
1070 * batadv_bla_process_claim() - Check if this is a claim frame, and process it
1075 * Return: true if it was a claim frame, otherwise return false to
1104 * The depth of the VLAN headers is recorded to drop BLA claim
1120 return false; /* not a claim frame */
1122 /* this must be a ARP frame. check if it is a claim. */
1148 /* check if it is a claim frame in general */
1153 /* check if there is a claim frame encapsulated deeper in (QinQ) and
1164 /* check if it is a claim frame. */
1169 "%s(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1179 /* check for the different types of claim frames ... */
1205 "%s(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1278 struct batadv_bla_claim *claim;
1291 hlist_for_each_entry_rcu(claim, head, hash_entry) {
1292 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
1300 if (!batadv_has_timed_out(claim->lasttime,
1310 claim->addr, claim->vid);
1314 claim->addr, claim->vid);
1514 /* The hash for claim and backbone hash receive the same key because they
1540 /* setting claim destination address */
1920 * * we have to race for a claim
1933 struct batadv_bla_claim search_claim, *claim = NULL;
1980 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1982 if (!claim) {
1985 /* possible optimization: race for a claim */
1986 /* No claim exists yet, claim it for us!
1990 "%s(): Unclaimed MAC %pM found. Claim it. Local: %s\n",
1998 /* if it is our own claim ... */
1999 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
2006 claim->lasttime = jiffies;
2022 * send a claim and update the claim table
2041 batadv_claim_put(claim);
2052 * * a claim was received which has to be processed
2066 struct batadv_bla_claim search_claim, *claim = NULL;
2092 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2094 /* if no claim exists, allow it. */
2095 if (!claim)
2099 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
2108 if (batadv_has_timed_out(claim->lasttime, 100)) {
2109 /* only unclaim if the last claim entry is
2120 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n",
2146 batadv_claim_put(claim);
2151 * batadv_bla_claim_dump_entry() - dump one entry of the claim table
2157 * @claim: entry to dump
2165 struct batadv_bla_claim *claim)
2183 is_own = batadv_compare_eth(claim->backbone_gw->orig,
2186 spin_lock_bh(&claim->backbone_gw->crc_lock);
2187 backbone_crc = claim->backbone_gw->crc;
2188 spin_unlock_bh(&claim->backbone_gw->crc_lock);
2196 if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->addr) ||
2197 nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->vid) ||
2199 claim->backbone_gw->orig) ||
2214 * batadv_bla_claim_dump_bucket() - dump one bucket of the claim table
2233 struct batadv_bla_claim *claim;
2240 hlist_for_each_entry(claim, &hash->table[bucket], hash_entry) {
2245 primary_if, claim);
2259 * batadv_bla_claim_dump() - dump claim table to a netlink socket
2475 * @addr: mac address of which the claim status is checked
2487 struct batadv_bla_claim *claim = NULL;
2502 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2504 /* If there is a claim and we are not owner of the claim,
2507 if (claim) {
2508 if (!batadv_compare_eth(claim->backbone_gw->orig,
2511 batadv_claim_put(claim);