Lines Matching full: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; in batadv_choose_claim() local
71 hash = jhash(&claim->addr, sizeof(claim->addr), hash); in batadv_choose_claim()
72 hash = jhash(&claim->vid, sizeof(claim->vid), hash); in batadv_choose_claim()
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; in batadv_claim_release() local
182 claim = container_of(ref, struct batadv_bla_claim, refcount); in batadv_claim_release()
184 spin_lock_bh(&claim->backbone_lock); in batadv_claim_release()
185 old_backbone_gw = claim->backbone_gw; in batadv_claim_release()
186 claim->backbone_gw = NULL; in batadv_claim_release()
187 spin_unlock_bh(&claim->backbone_lock); in batadv_claim_release()
190 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); in batadv_claim_release()
195 kfree_rcu(claim, rcu); in batadv_claim_release()
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) in batadv_claim_put() argument
204 if (!claim) in batadv_claim_put()
207 kref_put(&claim->refcount, batadv_claim_release); in batadv_claim_put()
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; in batadv_claim_hash_find() local
234 hlist_for_each_entry_rcu(claim, head, hash_entry) { in batadv_claim_hash_find()
235 if (!batadv_compare_claim(&claim->hash_entry, data)) in batadv_claim_hash_find()
238 if (!kref_get_unless_zero(&claim->refcount)) in batadv_claim_hash_find()
241 claim_tmp = claim; in batadv_claim_hash_find()
303 struct batadv_bla_claim *claim; in batadv_bla_del_backbone_claims() local
316 hlist_for_each_entry_safe(claim, node_tmp, in batadv_bla_del_backbone_claims()
318 if (claim->backbone_gw != backbone_gw) in batadv_bla_del_backbone_claims()
321 batadv_claim_put(claim); in batadv_bla_del_backbone_claims()
322 hlist_del_rcu(&claim->hash_entry); in batadv_bla_del_backbone_claims()
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 in batadv_bla_send_claim()
386 /* normal claim frame in batadv_bla_send_claim()
391 "%s(): CLAIM %pM on vid %d\n", __func__, mac, in batadv_bla_send_claim()
596 struct batadv_bla_claim *claim; in batadv_bla_answer_request() local
601 "%s(): received a claim request, send all of our own claims again\n", in batadv_bla_answer_request()
615 hlist_for_each_entry_rcu(claim, head, hash_entry) { in batadv_bla_answer_request()
617 if (claim->backbone_gw != backbone_gw) in batadv_bla_answer_request()
620 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid, in batadv_bla_answer_request()
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; in batadv_bla_add_claim() local
698 claim = batadv_claim_hash_find(bat_priv, &search_claim); in batadv_bla_add_claim()
700 /* create a new claim entry if it does not exist yet. */ in batadv_bla_add_claim()
701 if (!claim) { in batadv_bla_add_claim()
702 claim = kzalloc(sizeof(*claim), GFP_ATOMIC); in batadv_bla_add_claim()
703 if (!claim) in batadv_bla_add_claim()
706 ether_addr_copy(claim->addr, mac); in batadv_bla_add_claim()
707 spin_lock_init(&claim->backbone_lock); in batadv_bla_add_claim()
708 claim->vid = vid; in batadv_bla_add_claim()
709 claim->lasttime = jiffies; in batadv_bla_add_claim()
711 claim->backbone_gw = backbone_gw; in batadv_bla_add_claim()
712 kref_init(&claim->refcount); in batadv_bla_add_claim()
718 kref_get(&claim->refcount); in batadv_bla_add_claim()
721 batadv_choose_claim, claim, in batadv_bla_add_claim()
722 &claim->hash_entry); in batadv_bla_add_claim()
726 kfree(claim); in batadv_bla_add_claim()
730 claim->lasttime = jiffies; in batadv_bla_add_claim()
731 if (claim->backbone_gw == backbone_gw) in batadv_bla_add_claim()
744 spin_lock_bh(&claim->backbone_lock); in batadv_bla_add_claim()
745 old_backbone_gw = claim->backbone_gw; in batadv_bla_add_claim()
747 claim->backbone_gw = backbone_gw; in batadv_bla_add_claim()
748 spin_unlock_bh(&claim->backbone_lock); in batadv_bla_add_claim()
751 /* remove claim address from old backbone_gw */ in batadv_bla_add_claim()
753 old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); in batadv_bla_add_claim()
759 /* add claim address to new backbone_gw */ in batadv_bla_add_claim()
761 backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); in batadv_bla_add_claim()
766 batadv_claim_put(claim); in batadv_bla_add_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) in batadv_bla_claim_get_backbone_gw() argument
781 spin_lock_bh(&claim->backbone_lock); in batadv_bla_claim_get_backbone_gw()
782 backbone_gw = claim->backbone_gw; in batadv_bla_claim_get_backbone_gw()
784 spin_unlock_bh(&claim->backbone_lock); in batadv_bla_claim_get_backbone_gw()
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; in batadv_bla_del_claim() local
804 claim = batadv_claim_hash_find(bat_priv, &search_claim); in batadv_bla_del_claim()
805 if (!claim) in batadv_bla_del_claim()
813 batadv_choose_claim, claim); in batadv_bla_del_claim()
824 batadv_claim_put(claim); in batadv_bla_del_claim()
957 * batadv_handle_claim() - check for CLAIM frame
973 /* register the gateway if not yet available, and add the claim. */ in batadv_handle_claim()
981 /* this must be a CLAIM frame */ in batadv_handle_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 */ in batadv_check_claim_group()
1058 "taking other backbones claim group: %#.4x\n", in batadv_check_claim_group()
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 in batadv_bla_process_claim()
1119 return false; /* not a claim frame */ in batadv_bla_process_claim()
1121 /* this must be a ARP frame. check if it is a claim. */ in batadv_bla_process_claim()
1147 /* check if it is a claim frame in general */ in batadv_bla_process_claim()
1152 /* check if there is a claim frame encapsulated deeper in (QinQ) and in batadv_bla_process_claim()
1163 /* check if it is a claim frame. */ in batadv_bla_process_claim()
1168 …"%s(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\… in batadv_bla_process_claim()
1178 /* check for the different types of claim frames ... */ in batadv_bla_process_claim()
1204 …"%s(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM… in batadv_bla_process_claim()
1277 struct batadv_bla_claim *claim; in batadv_bla_purge_claims() local
1290 hlist_for_each_entry_rcu(claim, head, hash_entry) { in batadv_bla_purge_claims()
1291 backbone_gw = batadv_bla_claim_get_backbone_gw(claim); in batadv_bla_purge_claims()
1299 if (!batadv_has_timed_out(claim->lasttime, in batadv_bla_purge_claims()
1309 claim->addr, claim->vid); in batadv_bla_purge_claims()
1313 claim->addr, claim->vid); in batadv_bla_purge_claims()
1513 /* The hash for claim and backbone hash receive the same key because they
1539 /* setting claim destination address */ in batadv_bla_init()
1886 * * we have to race for a claim
1899 struct batadv_bla_claim search_claim, *claim = NULL; in batadv_bla_rx() local
1946 claim = batadv_claim_hash_find(bat_priv, &search_claim); in batadv_bla_rx()
1948 if (!claim) { in batadv_bla_rx()
1949 /* possible optimization: race for a claim */ in batadv_bla_rx()
1950 /* No claim exists yet, claim it for us! in batadv_bla_rx()
1954 "%s(): Unclaimed MAC %pM found. Claim it. Local: %s\n", in batadv_bla_rx()
1965 /* if it is our own claim ... */ in batadv_bla_rx()
1966 backbone_gw = batadv_bla_claim_get_backbone_gw(claim); in batadv_bla_rx()
1973 claim->lasttime = jiffies; in batadv_bla_rx()
1989 * send a claim and update the claim table in batadv_bla_rx()
2008 batadv_claim_put(claim); in batadv_bla_rx()
2019 * * a claim was received which has to be processed
2033 struct batadv_bla_claim search_claim, *claim = NULL; in batadv_bla_tx() local
2059 claim = batadv_claim_hash_find(bat_priv, &search_claim); in batadv_bla_tx()
2061 /* if no claim exists, allow it. */ in batadv_bla_tx()
2062 if (!claim) in batadv_bla_tx()
2066 backbone_gw = batadv_bla_claim_get_backbone_gw(claim); in batadv_bla_tx()
2075 if (batadv_has_timed_out(claim->lasttime, 100)) { in batadv_bla_tx()
2076 /* only unclaim if the last claim entry is in batadv_bla_tx()
2087 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n", in batadv_bla_tx()
2113 batadv_claim_put(claim); in batadv_bla_tx()
2118 * batadv_bla_claim_dump_entry() - dump one entry of the claim table
2124 * @claim: entry to dump
2132 struct batadv_bla_claim *claim) in batadv_bla_claim_dump_entry() argument
2150 is_own = batadv_compare_eth(claim->backbone_gw->orig, in batadv_bla_claim_dump_entry()
2153 spin_lock_bh(&claim->backbone_gw->crc_lock); in batadv_bla_claim_dump_entry()
2154 backbone_crc = claim->backbone_gw->crc; in batadv_bla_claim_dump_entry()
2155 spin_unlock_bh(&claim->backbone_gw->crc_lock); in batadv_bla_claim_dump_entry()
2163 if (nla_put(msg, BATADV_ATTR_BLA_ADDRESS, ETH_ALEN, claim->addr) || in batadv_bla_claim_dump_entry()
2164 nla_put_u16(msg, BATADV_ATTR_BLA_VID, claim->vid) || in batadv_bla_claim_dump_entry()
2166 claim->backbone_gw->orig) || in batadv_bla_claim_dump_entry()
2181 * batadv_bla_claim_dump_bucket() - dump one bucket of the claim table
2200 struct batadv_bla_claim *claim; in batadv_bla_claim_dump_bucket() local
2207 hlist_for_each_entry(claim, &hash->table[bucket], hash_entry) { in batadv_bla_claim_dump_bucket()
2212 primary_if, claim); in batadv_bla_claim_dump_bucket()
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; in batadv_bla_check_claim() local
2487 claim = batadv_claim_hash_find(bat_priv, &search_claim); in batadv_bla_check_claim()
2489 /* If there is a claim and we are not owner of the claim, in batadv_bla_check_claim()
2492 if (claim) { in batadv_bla_check_claim()
2493 if (!batadv_compare_eth(claim->backbone_gw->orig, in batadv_bla_check_claim()
2496 batadv_claim_put(claim); in batadv_bla_check_claim()