Lines Matching refs:claim
60 * batadv_choose_claim() - choose the right bucket for a claim.
64 * Return: the hash index of the claim
68 const struct batadv_bla_claim *claim = data;
71 hash = jhash(&claim->addr, sizeof(claim->addr), hash);
72 hash = jhash(&claim->vid, sizeof(claim->vid), hash);
125 * Return: true if the claim have the same data, 0 otherwise
173 * batadv_claim_release() - release claim from lists and queue for free after
175 * @ref: kref pointer of the claim
179 struct batadv_bla_claim *claim;
182 claim = container_of(ref, struct batadv_bla_claim, refcount);
184 spin_lock_bh(&claim->backbone_lock);
185 old_backbone_gw = claim->backbone_gw;
186 claim->backbone_gw = NULL;
187 spin_unlock_bh(&claim->backbone_lock);
190 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
195 kfree_rcu(claim, rcu);
199 * batadv_claim_put() - decrement the claim refcounter and possibly release it
200 * @claim: claim to be free'd
202 static void batadv_claim_put(struct batadv_bla_claim *claim)
204 if (!claim)
207 kref_put(&claim->refcount, batadv_claim_release);
211 * batadv_claim_hash_find() - looks for a claim in the claim hash
215 * Return: claim if found or NULL otherwise.
223 struct batadv_bla_claim *claim;
234 hlist_for_each_entry_rcu(claim, head, hash_entry) {
235 if (!batadv_compare_claim(&claim->hash_entry, data))
238 if (!kref_get_unless_zero(&claim->refcount))
241 claim_tmp = claim;
303 struct batadv_bla_claim *claim;
316 hlist_for_each_entry_safe(claim, node_tmp,
318 if (claim->backbone_gw != backbone_gw)
321 batadv_claim_put(claim);
322 hlist_del_rcu(&claim->hash_entry);
334 * batadv_bla_send_claim() - sends a claim frame according to the provided info
336 * @mac: the mac address to be announced within the claim
338 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
372 * with XX = claim type
386 /* normal claim frame
596 struct batadv_bla_claim *claim;
601 "%s(): received a claim request, send all of our own claims again\n",
615 hlist_for_each_entry_rcu(claim, head, hash_entry) {
617 if (claim->backbone_gw != backbone_gw)
620 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
637 * send an announcement claim with which we can check again.
680 * batadv_bla_add_claim() - Adds a claim in the claim hash
682 * @mac: the mac address of the claim
691 struct batadv_bla_claim *claim;
698 claim = batadv_claim_hash_find(bat_priv, &search_claim);
700 /* create a new claim entry if it does not exist yet. */
701 if (!claim) {
702 claim = kzalloc(sizeof(*claim), GFP_ATOMIC);
703 if (!claim)
706 ether_addr_copy(claim->addr, mac);
707 spin_lock_init(&claim->backbone_lock);
708 claim->vid = vid;
709 claim->lasttime = jiffies;
711 claim->backbone_gw = backbone_gw;
712 kref_init(&claim->refcount);
718 kref_get(&claim->refcount);
721 batadv_choose_claim, claim,
722 &claim->hash_entry);
726 kfree(claim);
730 claim->lasttime = jiffies;
731 if (claim->backbone_gw == backbone_gw)
744 spin_lock_bh(&claim->backbone_lock);
745 old_backbone_gw = claim->backbone_gw;
747 claim->backbone_gw = backbone_gw;
748 spin_unlock_bh(&claim->backbone_lock);
751 /* remove claim address from old backbone_gw */
753 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
759 /* add claim address to new backbone_gw */
761 backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
766 batadv_claim_put(claim);
771 * claim
772 * @claim: claim whose backbone_gw should be returned
774 * Return: valid reference to claim::backbone_gw
777 batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
781 spin_lock_bh(&claim->backbone_lock);
782 backbone_gw = claim->backbone_gw;
784 spin_unlock_bh(&claim->backbone_lock);
790 * batadv_bla_del_claim() - delete a claim from the claim hash
792 * @mac: mac address of the claim to be removed
793 * @vid: VLAN id for the claim to be removed
798 struct batadv_bla_claim search_claim, *claim;
804 claim = batadv_claim_hash_find(bat_priv, &search_claim);
805 if (!claim)
813 batadv_choose_claim, claim);
824 batadv_claim_put(claim);
973 /* register the gateway if not yet available, and add the claim. */
994 * batadv_check_claim_group() - check for claim group membership
999 * @ethhdr: pointer to the Ethernet header of the claim frame
1001 * checks if it is a claim packet and if it's on the same group.
1006 * 2 - if it is a claim packet and on the same group
1007 * 1 - if is a claim packet from another group
1008 * 0 - if it is not a claim packet
1038 /* don't accept claim frames from ourselves */
1058 "taking other backbones claim group: %#.4x\n",
1069 * batadv_bla_process_claim() - Check if this is a claim frame, and process it
1074 * Return: true if it was a claim frame, otherwise return false to
1103 * The depth of the VLAN headers is recorded to drop BLA claim
1119 return false; /* not a claim frame */
1121 /* this must be a ARP frame. check if it is a claim. */
1147 /* check if it is a claim frame in general */
1152 /* check if there is a claim frame encapsulated deeper in (QinQ) and
1163 /* check if it is a claim frame. */
1168 "%s(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1178 /* check for the different types of claim frames ... */
1204 "%s(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
1277 struct batadv_bla_claim *claim;
1290 hlist_for_each_entry_rcu(claim, head, hash_entry) {
1291 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
1299 if (!batadv_has_timed_out(claim->lasttime,
1309 claim->addr, claim->vid);
1313 claim->addr, claim->vid);
1513 /* The hash for claim and backbone hash receive the same key because they
1539 /* setting claim destination address */
1886 * * we have to race for a claim
1899 struct batadv_bla_claim search_claim, *claim = NULL;
1946 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1948 if (!claim) {
1949 /* possible optimization: race for a claim */
1950 /* No claim exists yet, claim it for us!
1965 /* if it is our own claim ... */
1966 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
1973 claim->lasttime = jiffies;
1989 * send a claim and update the claim table
2008 batadv_claim_put(claim);
2019 * * a claim was received which has to be processed
2033 struct batadv_bla_claim search_claim, *claim = NULL;
2059 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2061 /* if no claim exists, allow it. */
2062 if (!claim)
2066 backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
2075 if (batadv_has_timed_out(claim->lasttime, 100)) {
2076 /* only unclaim if the last claim entry is
2087 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n",
2113 batadv_claim_put(claim);
2118 * batadv_bla_claim_dump_entry() - dump one entry of the claim table
2124 * @claim: entry to dump
2132 struct batadv_bla_claim *claim)
2150 is_own = batadv_compare_eth(claim->backbone_gw->orig,
2153 spin_lock_bh(&claim->backbone_gw->crc_lock);
2154 backbone_crc = claim->backbone_gw->crc;
2155 spin_unlock_bh(&claim->backbone_gw->crc_lock);
2163 if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->addr) ||
2164 nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->vid) ||
2166 claim->backbone_gw->orig) ||
2181 * batadv_bla_claim_dump_bucket() - dump one bucket of the claim table
2200 struct batadv_bla_claim *claim;
2207 hlist_for_each_entry(claim, &hash->table[bucket], hash_entry) {
2212 primary_if, claim);
2226 * batadv_bla_claim_dump() - dump claim table to a netlink socket
2460 * @addr: mac address of which the claim status is checked
2472 struct batadv_bla_claim *claim = NULL;
2487 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2489 /* If there is a claim and we are not owner of the claim,
2492 if (claim) {
2493 if (!batadv_compare_eth(claim->backbone_gw->orig,
2496 batadv_claim_put(claim);