/* Description: Add a new address entry to the list pointed to by @head. On success zero is returned, otherwise a negative value is returned. The caller is responsible for calling the necessary locking functions.  */
int netlbl_af4list_add(struct netlbl_af4list *entry, struct list_head *head)
/* Description: Add a new address entry to the list pointed to by @head. On success zero is returned, otherwise a negative value is returned. The caller is responsible for calling the necessary locking functions.  */
int netlbl_af4list_add(struct netlbl_af4list *entry, struct list_head *head)
{
	struct netlbl_af4list *iter;
	iter = netlbl_af4list_search(entry->addr, head);
	if (iter != NULL &&
	    iter->addr == entry->addr && iter->mask == entry->mask)
		return -EEXIST;
	list_for_each_entry_rcu(iter, head, list)
		if (iter->valid &&
		    ntohl(entry->mask) > ntohl(iter->mask)) {
			__list_add_rcu(&entry->list,
				       iter->list.prev,
				       &iter->list);
			return 0;
		}
	list_add_tail_rcu(&entry->list, head);
	return 0;
}