Lines Matching +full:entry +full:- +full:address
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * NetLabel Network Address Lists
5 * This file contains network address list functions used to manage ordered
10 * Author: Paul Moore <paul@paul-moore.com>
14 * (c) Copyright Hewlett-Packard Development Company, L.P., 2008
32 * Address List Functions
36 * netlbl_af4list_search - Search for a matching IPv4 address entry
37 * @addr: IPv4 address
41 * Searches the IPv4 address list given by @head. If a matching address entry
52 if (iter->valid && (addr & iter->mask) == iter->addr) in netlbl_af4list_search()
59 * netlbl_af4list_search_exact - Search for an exact IPv4 address entry
60 * @addr: IPv4 address
61 * @mask: IPv4 address mask
65 * Searches the IPv4 address list given by @head. If an exact match if found
77 if (iter->valid && iter->addr == addr && iter->mask == mask) in netlbl_af4list_search_exact()
86 * netlbl_af6list_search - Search for a matching IPv6 address entry
87 * @addr: IPv6 address
91 * Searches the IPv6 address list given by @head. If a matching address entry
102 if (iter->valid && in netlbl_af6list_search()
103 ipv6_masked_addr_cmp(&iter->addr, &iter->mask, addr) == 0) in netlbl_af6list_search()
110 * netlbl_af6list_search_exact - Search for an exact IPv6 address entry
111 * @addr: IPv6 address
112 * @mask: IPv6 address mask
116 * Searches the IPv6 address list given by @head. If an exact match if found
128 if (iter->valid && in netlbl_af6list_search_exact()
129 ipv6_addr_equal(&iter->addr, addr) && in netlbl_af6list_search_exact()
130 ipv6_addr_equal(&iter->mask, mask)) in netlbl_af6list_search_exact()
138 * netlbl_af4list_add - Add a new IPv4 address entry to a list
139 * @entry: address entry
143 * Add a new address entry to the list pointed to by @head. On success zero is
148 int netlbl_af4list_add(struct netlbl_af4list *entry, struct list_head *head) in netlbl_af4list_add() argument
152 iter = netlbl_af4list_search(entry->addr, head); in netlbl_af4list_add()
154 iter->addr == entry->addr && iter->mask == entry->mask) in netlbl_af4list_add()
155 return -EEXIST; in netlbl_af4list_add()
157 /* in order to speed up address searches through the list (the common in netlbl_af4list_add()
159 * address mask such that the entry with the widest mask (smallest in netlbl_af4list_add()
162 if (iter->valid && in netlbl_af4list_add()
163 ntohl(entry->mask) > ntohl(iter->mask)) { in netlbl_af4list_add()
164 __list_add_rcu(&entry->list, in netlbl_af4list_add()
165 iter->list.prev, in netlbl_af4list_add()
166 &iter->list); in netlbl_af4list_add()
169 list_add_tail_rcu(&entry->list, head); in netlbl_af4list_add()
175 * netlbl_af6list_add - Add a new IPv6 address entry to a list
176 * @entry: address entry
180 * Add a new address entry to the list pointed to by @head. On success zero is
185 int netlbl_af6list_add(struct netlbl_af6list *entry, struct list_head *head) in netlbl_af6list_add() argument
189 iter = netlbl_af6list_search(&entry->addr, head); in netlbl_af6list_add()
191 ipv6_addr_equal(&iter->addr, &entry->addr) && in netlbl_af6list_add()
192 ipv6_addr_equal(&iter->mask, &entry->mask)) in netlbl_af6list_add()
193 return -EEXIST; in netlbl_af6list_add()
195 /* in order to speed up address searches through the list (the common in netlbl_af6list_add()
197 * address mask such that the entry with the widest mask (smallest in netlbl_af6list_add()
200 if (iter->valid && in netlbl_af6list_add()
201 ipv6_addr_cmp(&entry->mask, &iter->mask) > 0) { in netlbl_af6list_add()
202 __list_add_rcu(&entry->list, in netlbl_af6list_add()
203 iter->list.prev, in netlbl_af6list_add()
204 &iter->list); in netlbl_af6list_add()
207 list_add_tail_rcu(&entry->list, head); in netlbl_af6list_add()
213 * netlbl_af4list_remove_entry - Remove an IPv4 address entry
214 * @entry: address entry
217 * Remove the specified IP address entry. The caller is responsible for
221 void netlbl_af4list_remove_entry(struct netlbl_af4list *entry) in netlbl_af4list_remove_entry() argument
223 entry->valid = 0; in netlbl_af4list_remove_entry()
224 list_del_rcu(&entry->list); in netlbl_af4list_remove_entry()
228 * netlbl_af4list_remove - Remove an IPv4 address entry
229 * @addr: IP address
230 * @mask: IP address mask
234 * Remove an IP address entry from the list pointed to by @head. Returns the
235 * entry on success, NULL on failure. The caller is responsible for calling
242 struct netlbl_af4list *entry; in netlbl_af4list_remove() local
244 entry = netlbl_af4list_search_exact(addr, mask, head); in netlbl_af4list_remove()
245 if (entry == NULL) in netlbl_af4list_remove()
247 netlbl_af4list_remove_entry(entry); in netlbl_af4list_remove()
248 return entry; in netlbl_af4list_remove()
253 * netlbl_af6list_remove_entry - Remove an IPv6 address entry
254 * @entry: address entry
257 * Remove the specified IP address entry. The caller is responsible for
261 void netlbl_af6list_remove_entry(struct netlbl_af6list *entry) in netlbl_af6list_remove_entry() argument
263 entry->valid = 0; in netlbl_af6list_remove_entry()
264 list_del_rcu(&entry->list); in netlbl_af6list_remove_entry()
268 * netlbl_af6list_remove - Remove an IPv6 address entry
269 * @addr: IP address
270 * @mask: IP address mask
274 * Remove an IP address entry from the list pointed to by @head. Returns the
275 * entry on success, NULL on failure. The caller is responsible for calling
283 struct netlbl_af6list *entry; in netlbl_af6list_remove() local
285 entry = netlbl_af6list_search_exact(addr, mask, head); in netlbl_af6list_remove()
286 if (entry == NULL) in netlbl_af6list_remove()
288 netlbl_af6list_remove_entry(entry); in netlbl_af6list_remove()
289 return entry; in netlbl_af6list_remove()
299 * netlbl_af4list_audit_addr - Audit an IPv4 address
301 * @src: true if source address, false if destination
303 * @addr: IP address
304 * @mask: IP address mask
307 * Write the IPv4 address and address mask, if necessary, to @audit_buf.
332 * netlbl_af6list_audit_addr - Audit an IPv6 address
334 * @src: true if source address, false if destination
336 * @addr: IP address
337 * @mask: IP address mask
340 * Write the IPv6 address and address mask, if necessary, to @audit_buf.
354 if (ntohl(mask->s6_addr32[3]) != 0xffffffff) { in netlbl_af6list_audit_addr()
357 int iter = -1; in netlbl_af6list_audit_addr()
358 while (ntohl(mask->s6_addr32[++iter]) == 0xffffffff) in netlbl_af6list_audit_addr()
360 mask_val = ntohl(mask->s6_addr32[iter]); in netlbl_af6list_audit_addr()