calipso.c (a5e34490c3160e09814403d040765b0ae0003121) calipso.c (e1ce69df7e6e8cbdca78ae831ecf435b12b4c168)
1/*
2 * CALIPSO - Common Architecture Label IPv6 Security Option
3 *
4 * This is an implementation of the CALIPSO protocol as specified in
5 * RFC 5570.
6 *
7 * Authors: Paul Moore <paul.moore@hp.com>
8 * Huw Davies <huw@codeweavers.com>

--- 196 unchanged lines hidden (view full) ---

205 return;
206 spin_lock(&calipso_doi_list_lock);
207 list_del_rcu(&doi_def->list);
208 spin_unlock(&calipso_doi_list_lock);
209
210 call_rcu(&doi_def->rcu, calipso_doi_free_rcu);
211}
212
1/*
2 * CALIPSO - Common Architecture Label IPv6 Security Option
3 *
4 * This is an implementation of the CALIPSO protocol as specified in
5 * RFC 5570.
6 *
7 * Authors: Paul Moore <paul.moore@hp.com>
8 * Huw Davies <huw@codeweavers.com>

--- 196 unchanged lines hidden (view full) ---

205 return;
206 spin_lock(&calipso_doi_list_lock);
207 list_del_rcu(&doi_def->list);
208 spin_unlock(&calipso_doi_list_lock);
209
210 call_rcu(&doi_def->rcu, calipso_doi_free_rcu);
211}
212
213/**
214 * calipso_doi_walk - Iterate through the DOI definitions
215 * @skip_cnt: skip past this number of DOI definitions, updated
216 * @callback: callback for each DOI definition
217 * @cb_arg: argument for the callback function
218 *
219 * Description:
220 * Iterate over the DOI definition list, skipping the first @skip_cnt entries.
221 * For each entry call @callback, if @callback returns a negative value stop
222 * 'walking' through the list and return. Updates the value in @skip_cnt upon
223 * return. Returns zero on success, negative values on failure.
224 *
225 */
226static int calipso_doi_walk(u32 *skip_cnt,
227 int (*callback)(struct calipso_doi *doi_def,
228 void *arg),
229 void *cb_arg)
230{
231 int ret_val = -ENOENT;
232 u32 doi_cnt = 0;
233 struct calipso_doi *iter_doi;
234
235 rcu_read_lock();
236 list_for_each_entry_rcu(iter_doi, &calipso_doi_list, list)
237 if (atomic_read(&iter_doi->refcount) > 0) {
238 if (doi_cnt++ < *skip_cnt)
239 continue;
240 ret_val = callback(iter_doi, cb_arg);
241 if (ret_val < 0) {
242 doi_cnt--;
243 goto doi_walk_return;
244 }
245 }
246
247doi_walk_return:
248 rcu_read_unlock();
249 *skip_cnt = doi_cnt;
250 return ret_val;
251}
252
213static const struct netlbl_calipso_ops ops = {
214 .doi_add = calipso_doi_add,
215 .doi_free = calipso_doi_free,
216 .doi_getdef = calipso_doi_getdef,
217 .doi_putdef = calipso_doi_putdef,
253static const struct netlbl_calipso_ops ops = {
254 .doi_add = calipso_doi_add,
255 .doi_free = calipso_doi_free,
256 .doi_getdef = calipso_doi_getdef,
257 .doi_putdef = calipso_doi_putdef,
258 .doi_walk = calipso_doi_walk,
218};
219
220/**
221 * calipso_init - Initialize the CALIPSO module
222 *
223 * Description:
224 * Initialize the CALIPSO module and prepare it for use. Returns zero on
225 * success and negative values on failure.

--- 12 unchanged lines hidden ---
259};
260
261/**
262 * calipso_init - Initialize the CALIPSO module
263 *
264 * Description:
265 * Initialize the CALIPSO module and prepare it for use. Returns zero on
266 * success and negative values on failure.

--- 12 unchanged lines hidden ---