Lines Matching refs:claim
61 * batadv_choose_claim() - choose the right bucket for a claim.
65 * Return: the hash index of the claim
69 struct batadv_bla_claim *claim = (struct batadv_bla_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
601 struct batadv_bla_claim *claim;
606 "%s(): received a claim request, send all of our own claims again\n",
620 hlist_for_each_entry_rcu(claim, head, hash_entry) {
622 if (claim->backbone_gw != backbone_gw)
625 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
642 * send an announcement claim with which we can check again.
685 * batadv_bla_add_claim() - Adds a claim in the claim hash
687 * @mac: the mac address of the claim
696 struct batadv_bla_claim *claim;
703 claim = batadv_claim_hash_find(bat_priv, &search_claim);
705 /* create a new claim entry if it does not exist yet. */
706 if (!claim) {
707 claim = kzalloc(sizeof(*claim), GFP_ATOMIC);
708 if (!claim)
711 ether_addr_copy(claim->addr, mac);
712 spin_lock_init(&claim->backbone_lock);
713 claim->vid = vid;
714 claim->lasttime = jiffies;
716 claim->backbone_gw = backbone_gw;
717 kref_init(&claim->refcount);
723 kref_get(&claim->refcount);
726 batadv_choose_claim, claim,
727 &claim->hash_entry);
731 kfree(claim);
735 claim->lasttime = jiffies;
736 if (claim->backbone_gw == backbone_gw)
749 spin_lock_bh(&claim->backbone_lock);
750 old_backbone_gw = claim->backbone_gw;
752 claim->backbone_gw = backbone_gw;
753 spin_unlock_bh(&claim->backbone_lock);
756 /* remove claim address from old backbone_gw */
758 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
764 /* add claim address to new backbone_gw */
766 backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
771 batadv_claim_put(claim);
776 * claim
777 * @claim: claim whose backbone_gw should be returned
779 * Return: valid reference to claim::backbone_gw
782 batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
786 spin_lock_bh(&claim->backbone_lock);
787 backbone_gw = claim->backbone_gw;
789 spin_unlock_bh(&claim->backbone_lock);
795 * batadv_bla_del_claim() - delete a claim from the claim hash
797 * @mac: mac address of the claim to be removed
798 * @vid: VLAN id for the claim to be removed
803 struct batadv_bla_claim search_claim, *claim;
809 claim = batadv_claim_hash_find(bat_priv, &search_claim);
810 if (!claim)
818 batadv_choose_claim, claim);
829 batadv_claim_put(claim);
978 /* register the gateway if not yet available, and add the claim. */
999 * batadv_check_claim_group() - check for claim group membership
1004 * @ethhdr: pointer to the Ethernet header of the claim frame
1006 * checks if it is a claim packet and if it's on the same group.
1011 * 2 - if it is a claim packet and on the same group
1012 * 1 - if is a claim packet from another group
1013 * 0 - if it is not a claim packet
1043 /* don't accept claim frames from ourselves */
1063 "taking other backbones claim group: %#.4x\n",
1074 * batadv_bla_process_claim() - Check if this is a claim frame, and process it
1079 * Return: true if it was a claim frame, otherwise return false to
1108 * The depth of the VLAN headers is recorded to drop BLA claim
1124 return false; /* not a claim frame */
1126 /* this must be a ARP frame. check if it is a claim. */
1152 /* check if it is a claim frame in general */
1157 /* check if there is a claim frame encapsulated deeper in (QinQ) and
1168 /* check if it is a claim frame. */
1173 "%s(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1183 /* check for the different types of claim frames ... */
1209 "%s(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1282 struct batadv_bla_claim *claim;
1295 hlist_for_each_entry_rcu(claim, head, hash_entry) {
1296 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
1304 if (!batadv_has_timed_out(claim->lasttime,
1314 claim->addr, claim->vid);
1318 claim->addr, claim->vid);
1519 /* The hash for claim and backbone hash receive the same key because they
1545 /* setting claim destination address */
1893 * * we have to race for a claim
1906 struct batadv_bla_claim search_claim, *claim = NULL;
1953 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1955 if (!claim) {
1956 /* possible optimization: race for a claim */
1957 /* No claim exists yet, claim it for us!
1972 /* if it is our own claim ... */
1973 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
1980 claim->lasttime = jiffies;
1996 * send a claim and update the claim table
2016 if (claim)
2017 batadv_claim_put(claim);
2028 * * a claim was received which has to be processed
2042 struct batadv_bla_claim search_claim, *claim = NULL;
2068 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2070 /* if no claim exists, allow it. */
2071 if (!claim)
2075 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
2084 if (batadv_has_timed_out(claim->lasttime, 100)) {
2085 /* only unclaim if the last claim entry is
2096 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n",
2123 if (claim)
2124 batadv_claim_put(claim);
2130 * batadv_bla_claim_table_seq_print_text() - print the claim table in a seq file
2142 struct batadv_bla_claim *claim;
2165 hlist_for_each_entry_rcu(claim, head, hash_entry) {
2166 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
2175 claim->addr, batadv_print_vid(claim->vid),
2192 * batadv_bla_claim_dump_entry() - dump one entry of the claim table
2198 * @claim: entry to dump
2206 struct batadv_bla_claim *claim)
2224 is_own = batadv_compare_eth(claim->backbone_gw->orig,
2227 spin_lock_bh(&claim->backbone_gw->crc_lock);
2228 backbone_crc = claim->backbone_gw->crc;
2229 spin_unlock_bh(&claim->backbone_gw->crc_lock);
2237 if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->addr) ||
2238 nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->vid) ||
2240 claim->backbone_gw->orig) ||
2255 * batadv_bla_claim_dump_bucket() - dump one bucket of the claim table
2274 struct batadv_bla_claim *claim;
2281 hlist_for_each_entry(claim, &hash->table[bucket], hash_entry) {
2286 primary_if, claim);
2300 * batadv_bla_claim_dump() - dump claim table to a netlink socket
2604 * @addr: mac address of which the claim status is checked
2616 struct batadv_bla_claim *claim = NULL;
2631 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2633 /* If there is a claim and we are not owner of the claim,
2636 if (claim) {
2637 if (!batadv_compare_eth(claim->backbone_gw->orig,
2640 batadv_claim_put(claim);