2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vnet/ipsec/ipsec.h>
20 * Policy packet & bytes counters
22 vlib_combined_counter_main_t ipsec_spd_policy_counters = {
24 .stat_segment_name = "/net/ipsec/policy",
28 ipsec_spd_entry_sort (void *a1, void *a2)
30 ipsec_main_t *im = &ipsec_main;
33 ipsec_policy_t *p1, *p2;
35 p1 = pool_elt_at_index (im->policies, *id1);
36 p2 = pool_elt_at_index (im->policies, *id2);
38 return p2->priority - p1->priority;
44 ipsec_policy_mk_type (bool is_outbound,
46 ipsec_policy_action_t action,
47 ipsec_spd_policy_type_t * type)
52 IPSEC_SPD_POLICY_IP6_OUTBOUND : IPSEC_SPD_POLICY_IP4_OUTBOUND);
59 case IPSEC_POLICY_ACTION_PROTECT:
61 IPSEC_SPD_POLICY_IP6_INBOUND_PROTECT :
62 IPSEC_SPD_POLICY_IP4_INBOUND_PROTECT);
64 case IPSEC_POLICY_ACTION_BYPASS:
66 IPSEC_SPD_POLICY_IP6_INBOUND_BYPASS :
67 IPSEC_SPD_POLICY_IP4_INBOUND_BYPASS);
69 case IPSEC_POLICY_ACTION_DISCARD:
71 IPSEC_SPD_POLICY_IP6_INBOUND_DISCARD :
72 IPSEC_SPD_POLICY_IP4_INBOUND_DISCARD);
74 case IPSEC_POLICY_ACTION_RESOLVE:
79 /* Unsupported type */
84 ipsec_add_del_policy (vlib_main_t * vm,
85 ipsec_policy_t * policy, int is_add, u32 * stat_index)
87 ipsec_main_t *im = &ipsec_main;
93 p = hash_get (im->spd_index_by_spd_id, policy->id);
96 return VNET_API_ERROR_SYSCALL_ERROR_1;
99 spd = pool_elt_at_index (im->spds, spd_index);
101 return VNET_API_ERROR_SYSCALL_ERROR_1;
103 if (im->output_flow_cache_flag && !policy->is_ipv6 &&
104 policy->type == IPSEC_SPD_POLICY_IP4_OUTBOUND)
107 * Flow cache entry is valid only when epoch_count value in control
108 * plane and data plane match. Otherwise, flow cache entry is considered
109 * stale. To avoid the race condition of using old epoch_count value
110 * in data plane after the roll over of epoch_count in control plane,
111 * entire flow cache is reset.
113 if (im->epoch_count == 0xFFFFFFFF)
115 /* Reset all the entries in flow cache */
116 clib_memset_u8 (im->ipsec4_out_spd_hash_tbl, 0,
117 im->ipsec4_out_spd_hash_num_buckets *
118 (sizeof (*(im->ipsec4_out_spd_hash_tbl))));
120 /* Increment epoch counter by 1 */
121 clib_atomic_fetch_add_relax (&im->epoch_count, 1);
122 /* Reset spd flow cache counter since all old entries are stale */
123 clib_atomic_store_relax_n (&im->ipsec4_out_spd_flow_cache_entries, 0);
126 if ((policy->type == IPSEC_SPD_POLICY_IP4_INBOUND_PROTECT ||
127 policy->type == IPSEC_SPD_POLICY_IP4_INBOUND_BYPASS ||
128 policy->type == IPSEC_SPD_POLICY_IP4_INBOUND_DISCARD) &&
129 im->input_flow_cache_flag && !policy->is_ipv6)
132 * Flow cache entry is valid only when input_epoch_count value in control
133 * plane and data plane match. Otherwise, flow cache entry is considered
134 * stale. To avoid the race condition of using old input_epoch_count
135 * value in data plane after the roll over of input_epoch_count in
136 * control plane, entire flow cache is reset.
138 if (im->input_epoch_count == 0xFFFFFFFF)
140 /* Reset all the entries in flow cache */
141 clib_memset_u8 (im->ipsec4_in_spd_hash_tbl, 0,
142 im->ipsec4_in_spd_hash_num_buckets *
143 (sizeof (*(im->ipsec4_in_spd_hash_tbl))));
145 /* Increment epoch counter by 1 */
146 clib_atomic_fetch_add_relax (&im->input_epoch_count, 1);
147 /* Reset spd flow cache counter since all old entries are stale */
148 im->ipsec4_in_spd_flow_cache_entries = 0;
155 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
157 index_t sa_index = ipsec_sa_find_and_lock (policy->sa_id);
159 if (INDEX_INVALID == sa_index)
160 return VNET_API_ERROR_SYSCALL_ERROR_1;
161 policy->sa_index = sa_index;
164 policy->sa_index = INDEX_INVALID;
167 * Try adding the policy into fast path SPD first. Only adding to
168 * traditional SPD when failed.
170 if (im->fp_spd_is_enabled &&
171 (policy->type == IPSEC_SPD_POLICY_IP4_OUTBOUND))
172 return ipsec_fp_add_del_policy ((void *) &spd->fp_spd, policy, 1,
175 pool_get (im->policies, vp);
176 clib_memcpy (vp, policy, sizeof (*vp));
177 policy_index = vp - im->policies;
179 vlib_validate_combined_counter (&ipsec_spd_policy_counters,
181 vlib_zero_combined_counter (&ipsec_spd_policy_counters, policy_index);
182 vec_add1 (spd->policies[policy->type], policy_index);
183 vec_sort_with_function (spd->policies[policy->type],
184 ipsec_spd_entry_sort);
185 *stat_index = policy_index;
192 * Try to delete the policy from the fast path SPD first. Delete from
193 * traditional SPD when fp delete fails.
196 * TODO: add ipv6 fast path support for outbound and
197 * ipv4/v6 inbound support for fast path
199 if (im->fp_spd_is_enabled &&
200 (policy->type == IPSEC_SPD_POLICY_IP4_OUTBOUND))
201 return ipsec_fp_add_del_policy ((void *) &spd->fp_spd, policy, 0,
204 vec_foreach_index (ii, (spd->policies[policy->type]))
206 vp = pool_elt_at_index (im->policies,
207 spd->policies[policy->type][ii]);
208 if (ipsec_policy_is_equal (vp, policy))
210 vec_delete (spd->policies[policy->type], 1, ii);
211 ipsec_sa_unlock (vp->sa_index);
212 pool_put (im->policies, vp);
221 static_always_inline void
222 release_mask_type_index (ipsec_main_t *im, u32 mask_type_index)
224 ipsec_fp_mask_type_entry_t *mte =
225 pool_elt_at_index (im->fp_mask_types, mask_type_index);
227 if (mte->refcount == 0)
229 /* this entry is not in use anymore */
230 ASSERT (clib_memset (mte, 0xae, sizeof (*mte)) == EOK);
231 pool_put (im->fp_mask_types, mte);
235 static_always_inline u32
236 find_mask_type_index (ipsec_main_t *im, ipsec_fp_5tuple_t *mask)
238 ipsec_fp_mask_type_entry_t *mte;
240 pool_foreach (mte, im->fp_mask_types)
242 if (memcmp (&mte->mask, mask, sizeof (*mask)) == 0)
243 return (mte - im->fp_mask_types);
249 static_always_inline void
250 fill_ip6_hash_policy_kv (ipsec_main_t *im, ipsec_fp_5tuple_t *match,
251 ipsec_fp_5tuple_t *mask, clib_bihash_kv_40_8_t *kv)
253 ipsec_fp_lookup_value_t *kv_val = (ipsec_fp_lookup_value_t *) &kv->value;
254 u64 *pmatch = (u64 *) &match;
255 u64 *pmask = (u64 *) &mask;
256 u64 *pkey = (u64 *) &kv->key;
258 *pkey++ = *pmatch++ & *pmask++;
259 *pkey++ = *pmatch++ & *pmask++;
260 *pkey++ = *pmatch++ & *pmask++;
261 *pkey++ = *pmatch++ & *pmask++;
262 *pkey++ = *pmatch++ & *pmask++;
263 *pkey++ = *pmatch++ & *pmask++;
268 static_always_inline void
269 fill_ip4_hash_policy_kv (ipsec_main_t *im, ipsec_fp_5tuple_t *match,
270 ipsec_fp_5tuple_t *mask, clib_bihash_kv_16_8_t *kv)
272 ipsec_fp_lookup_value_t *kv_val = (ipsec_fp_lookup_value_t *) &kv->value;
273 u64 *pmatch = (u64 *) &match->laddr;
274 u64 *pmask = (u64 *) &mask->laddr;
275 u64 *pkey = (u64 *) kv->key;
277 *pkey++ = *pmatch++ & *pmask++;
278 *pkey++ = *pmatch++ & *pmask++;
283 static_always_inline u16
284 get_highest_set_bit_u16 (u16 x)
293 static_always_inline u32
294 get_highest_set_bit_u32 (u32 x)
304 static_always_inline void
305 ipsec_fp_ip4_get_policy_mask (ipsec_policy_t *policy, ipsec_fp_5tuple_t *mask)
307 u32 *pladdr_start = (u32 *) &policy->laddr.start.ip4;
308 u32 *pladdr_stop = (u32 *) &policy->laddr.stop.ip4;
309 u32 *plmask = (u32 *) &mask->laddr;
310 u32 *praddr_start = (u32 *) &policy->raddr.start.ip4;
311 u32 *praddr_stop = (u32 *) &policy->raddr.stop.ip4;
312 u32 *prmask = (u32 *) &mask->raddr;
314 memset (mask, 0, sizeof (mask->l3_zero_pad));
315 memset (plmask, 1, sizeof (*mask) - sizeof (mask->l3_zero_pad));
316 /* find bits where start != stop */
317 *plmask = *pladdr_start ^ *pladdr_stop;
318 *prmask = *praddr_start ^ *praddr_stop;
319 /* Find most significant bit set (that is the first position
320 * start differs from stop). Mask out everything after that bit and
321 * the bit itself. Remember that policy stores start and stop in the net
324 *plmask = get_highest_set_bit_u32 (clib_net_to_host_u32 (*plmask));
325 *plmask = clib_host_to_net_u32 (~(*plmask - 1) & (~*plmask));
327 *prmask = get_highest_set_bit_u32 (clib_net_to_host_u32 (*prmask));
328 *prmask = clib_host_to_net_u32 (~(*prmask - 1) & (~*prmask));
330 if (PREDICT_TRUE ((policy->protocol == IP_PROTOCOL_TCP) ||
331 (policy->protocol == IP_PROTOCOL_UDP) ||
332 (policy->protocol == IP_PROTOCOL_SCTP)))
334 mask->lport = policy->lport.start ^ policy->lport.stop;
335 mask->rport = policy->rport.start ^ policy->rport.stop;
337 mask->lport = get_highest_set_bit_u16 (mask->lport);
338 mask->lport = ~(mask->lport - 1) & (~mask->lport);
340 mask->rport = get_highest_set_bit_u16 (mask->rport);
341 mask->rport = ~(mask->rport - 1) & (~mask->rport);
349 mask->protocol = (policy->protocol == IPSEC_POLICY_PROTOCOL_ANY) ? 0 : ~0;
352 static_always_inline int
353 ipsec_fp_ip6_get_policy_mask (ipsec_policy_t *policy, ipsec_fp_5tuple_t *mask)
355 u64 *pladdr_start = (u64 *) &policy->laddr.start;
356 u64 *pladdr_stop = (u64 *) &policy->laddr.stop;
357 u64 *plmask = (u64 *) &mask->laddr;
358 u64 *praddr_start = (u64 *) &policy->raddr.start;
359 u64 *praddr_stop = (u64 *) &policy->raddr.stop;
360 u64 *prmask = (u64 *) &mask->ip6_raddr;
361 u16 *plport_start = (u16 *) &policy->lport.start;
362 u16 *plport_stop = (u16 *) &policy->lport.stop;
363 u16 *prport_start = (u16 *) &policy->rport.start;
364 u16 *prport_stop = (u16 *) &policy->rport.stop;
366 /* test if x is not power of 2. The test form is !((x & (x - 1)) == 0) */
367 if (((*pladdr_stop - *pladdr_start + 1) & (*pladdr_stop - *pladdr_start)) &&
368 (((*(pladdr_stop + 1) - *(pladdr_start + 1)) + 1) &
369 (*(pladdr_stop + 1) - *(pladdr_start + 1))))
372 if (((*praddr_stop - *praddr_start + 1) & (*praddr_stop - *praddr_start)) &&
373 (((*(praddr_stop + 1) - *(praddr_start + 1)) + 1) &
374 (*(praddr_stop + 1) - *(praddr_start + 1))))
377 if (((*plport_stop - *plport_start + 1) & (*plport_stop - *plport_start)))
380 if (((*prport_stop - *prport_start + 1) & (*prport_stop - *prport_start)))
383 memset (mask, 1, sizeof (ipsec_fp_5tuple_t));
385 *plmask++ = ~(*pladdr_start++ ^ *pladdr_stop++);
386 *plmask++ = ~(*pladdr_start++ ^ *pladdr_stop++);
388 *prmask++ = ~(*praddr_start++ ^ *praddr_stop++);
389 *prmask++ = ~(*praddr_start++ ^ *praddr_stop++);
391 mask->lport = ~(policy->lport.start ^ policy->lport.stop);
392 mask->rport = ~(policy->rport.start ^ policy->rport.stop);
397 static_always_inline void
398 ipsec_fp_get_policy_5tuple (ipsec_policy_t *policy, ipsec_fp_5tuple_t *tuple)
400 memset (tuple, 0, sizeof (*tuple));
401 tuple->is_ipv6 = policy->is_ipv6;
404 tuple->ip6_laddr = policy->laddr.start.ip6;
405 tuple->ip6_raddr = policy->raddr.start.ip6;
409 tuple->laddr = policy->laddr.start.ip4;
410 tuple->raddr = policy->raddr.start.ip4;
413 tuple->protocol = policy->protocol;
415 tuple->lport = policy->lport.start;
416 tuple->rport = policy->rport.start;
420 ipsec_fp_ip4_add_policy (ipsec_main_t *im, ipsec_spd_fp_t *fp_spd,
421 ipsec_policy_t *policy, u32 *stat_index)
425 ipsec_fp_mask_type_entry_t *mte;
427 clib_bihash_kv_16_8_t kv;
428 clib_bihash_kv_16_8_t result;
429 ipsec_fp_lookup_value_t *result_val =
430 (ipsec_fp_lookup_value_t *) &result.value;
431 ipsec_fp_lookup_value_t *key_val = (ipsec_fp_lookup_value_t *) &kv.value;
433 ipsec_fp_5tuple_t mask, policy_5tuple;
436 ipsec_fp_ip4_get_policy_mask (policy, &mask);
437 pool_get (im->policies, vp);
438 policy_index = vp - im->policies;
439 vlib_validate_combined_counter (&ipsec_spd_policy_counters, policy_index);
440 vlib_zero_combined_counter (&ipsec_spd_policy_counters, policy_index);
441 *stat_index = policy_index;
442 mask_index = find_mask_type_index (im, &mask);
444 if (mask_index == ~0)
446 /* mask type not found, we need to create a new entry */
447 pool_get (im->fp_mask_types, mte);
448 mask_index = mte - im->fp_mask_types;
452 mte = im->fp_mask_types + mask_index;
454 policy->fp_mask_type_id = mask_index;
455 ipsec_fp_get_policy_5tuple (policy, &policy_5tuple);
457 fill_ip4_hash_policy_kv (im, &policy_5tuple, &mask, &kv);
459 res = clib_bihash_search_inline_2_16_8 (&fp_spd->fp_ip4_lookup_hash, &kv,
463 /* key was not found crate a new entry */
464 vec_add1 (key_val->fp_policies_ids, policy_index);
465 res = clib_bihash_add_del_16_8 (&fp_spd->fp_ip4_lookup_hash, &kv, 1);
472 if (vec_max_len (result_val->fp_policies_ids) !=
473 vec_len (result_val->fp_policies_ids))
475 /* no need to resize */
476 vec_add1 (result_val->fp_policies_ids, policy_index);
480 vec_add1 (result_val->fp_policies_ids, policy_index);
483 clib_bihash_add_del_16_8 (&fp_spd->fp_ip4_lookup_hash, &result, 1);
490 if (mte->refcount == 0)
492 clib_memcpy (&mte->mask, &mask, sizeof (mask));
494 vec_add1 (fp_spd->fp_mask_types[policy->type], mask_index);
498 vec_add1 (fp_spd->fp_policies[policy->type], policy_index);
499 clib_memcpy (vp, policy, sizeof (*vp));
504 pool_put (im->policies, vp);
505 release_mask_type_index (im, mask_index);
510 ipsec_fp_ip6_add_policy (ipsec_main_t *im, ipsec_spd_fp_t *fp_spd,
511 ipsec_policy_t *policy, u32 *stat_index)
516 ipsec_fp_mask_type_entry_t *mte;
518 clib_bihash_kv_40_8_t kv;
519 clib_bihash_kv_40_8_t result;
520 ipsec_fp_lookup_value_t *result_val =
521 (ipsec_fp_lookup_value_t *) &result.value;
522 ipsec_fp_lookup_value_t *key_val = (ipsec_fp_lookup_value_t *) &kv.value;
524 ipsec_fp_5tuple_t mask, policy_5tuple;
528 if (PREDICT_FALSE (!fp_spd->fp_ip6_lookup_hash_initialized))
530 clib_bihash_init_40_8 (
531 &fp_spd->fp_ip6_lookup_hash, "SPD_FP ip6 rules lookup bihash",
532 im->fp_lookup_hash_buckets,
533 im->fp_lookup_hash_buckets * IPSEC_FP_IP6_HASH_MEM_PER_BUCKET);
534 fp_spd->fp_ip6_lookup_hash_initialized = 1;
537 if (ipsec_fp_ip6_get_policy_mask (policy, &mask) != 0)
540 pool_get (im->policies, vp);
541 policy_index = vp - im->policies;
542 vlib_validate_combined_counter (&ipsec_spd_policy_counters, policy_index);
543 vlib_zero_combined_counter (&ipsec_spd_policy_counters, policy_index);
544 *stat_index = policy_index;
545 mask_index = find_mask_type_index (im, &mask);
547 if (mask_index == ~0)
549 /* mask type not found, we need to create a new entry */
550 pool_get (im->fp_mask_types, mte);
551 mask_index = mte - im->fp_mask_types;
555 mte = im->fp_mask_types + mask_index;
557 policy->fp_mask_type_id = mask_index;
558 ipsec_fp_ip6_get_policy_mask (policy, &mask);
559 ipsec_fp_get_policy_5tuple (policy, &policy_5tuple);
561 fill_ip6_hash_policy_kv (im, &policy_5tuple, &mask, &kv);
563 res = clib_bihash_search_inline_2_40_8 (&fp_spd->fp_ip6_lookup_hash, &kv,
567 /* key was not found crate a new entry */
568 vec_add1 (key_val->fp_policies_ids, policy_index);
569 res = clib_bihash_add_del_40_8 (&fp_spd->fp_ip6_lookup_hash, &kv, 1);
576 if (vec_max_len (result_val->fp_policies_ids) !=
577 vec_len (result_val->fp_policies_ids))
579 /* no need to resize */
580 vec_add1 (result_val->fp_policies_ids, policy_index);
584 vec_add1 (result_val->fp_policies_ids, policy_index);
587 clib_bihash_add_del_40_8 (&fp_spd->fp_ip6_lookup_hash, &result, 1);
594 if (mte->refcount == 0)
596 clib_memcpy (&mte->mask, &mask, sizeof (mask));
598 vec_add1 (fp_spd->fp_mask_types[policy->type], mask_index);
602 vec_add1 (fp_spd->fp_policies[policy->type], policy_index);
603 clib_memcpy (vp, policy, sizeof (*vp));
608 pool_put (im->policies, vp);
609 release_mask_type_index (im, mask_index);
614 ipsec_fp_ip6_del_policy (ipsec_main_t *im, ipsec_spd_fp_t *fp_spd,
615 ipsec_policy_t *policy)
618 ipsec_fp_5tuple_t mask = { 0 }, policy_5tuple;
619 clib_bihash_kv_40_8_t kv;
620 clib_bihash_kv_40_8_t result;
621 ipsec_fp_lookup_value_t *result_val =
622 (ipsec_fp_lookup_value_t *) &result.value;
627 ipsec_fp_ip6_get_policy_mask (policy, &mask);
628 ipsec_fp_get_policy_5tuple (policy, &policy_5tuple);
629 fill_ip6_hash_policy_kv (im, &policy_5tuple, &mask, &kv);
630 res = clib_bihash_search_inline_2_40_8 (&fp_spd->fp_ip6_lookup_hash, &kv,
636 vec_foreach_index (ii, result_val->fp_policies_ids)
639 pool_elt_at_index (im->policies, *(result_val->fp_policies_ids + ii));
640 if (ipsec_policy_is_equal (vp, policy))
642 vec_foreach_index (iii, fp_spd->fp_policies[policy->type])
644 if (*(fp_spd->fp_policies[policy->type] + iii) ==
645 *(result_val->fp_policies_ids + ii))
647 if (vec_len (result_val->fp_policies_ids) == 1)
649 vec_free (result_val->fp_policies_ids);
650 clib_bihash_add_del_40_8 (&fp_spd->fp_ip6_lookup_hash,
655 vec_del1 (result_val->fp_policies_ids, ii);
657 vec_del1 (fp_spd->fp_policies[policy->type], iii);
659 vec_foreach_index (imt, fp_spd->fp_mask_types[policy->type])
661 if (*(fp_spd->fp_mask_types[policy->type] + imt) ==
664 ipsec_fp_mask_type_entry_t *mte = pool_elt_at_index (
665 im->fp_mask_types, vp->fp_mask_type_id);
667 if (mte->refcount == 1)
668 vec_del1 (fp_spd->fp_mask_types[policy->type],
683 release_mask_type_index (im, vp->fp_mask_type_id);
684 ipsec_sa_unlock (vp->sa_index);
685 pool_put (im->policies, vp);
694 ipsec_fp_ip4_del_policy (ipsec_main_t *im, ipsec_spd_fp_t *fp_spd,
695 ipsec_policy_t *policy)
698 ipsec_fp_5tuple_t mask = { 0 }, policy_5tuple;
699 clib_bihash_kv_16_8_t kv;
700 clib_bihash_kv_16_8_t result;
701 ipsec_fp_lookup_value_t *result_val =
702 (ipsec_fp_lookup_value_t *) &result.value;
707 ipsec_fp_ip4_get_policy_mask (policy, &mask);
708 ipsec_fp_get_policy_5tuple (policy, &policy_5tuple);
709 fill_ip4_hash_policy_kv (im, &policy_5tuple, &mask, &kv);
710 res = clib_bihash_search_inline_2_16_8 (&fp_spd->fp_ip4_lookup_hash, &kv,
716 vec_foreach_index (ii, result_val->fp_policies_ids)
719 pool_elt_at_index (im->policies, *(result_val->fp_policies_ids + ii));
720 if (ipsec_policy_is_equal (vp, policy))
722 vec_foreach_index (iii, fp_spd->fp_policies[policy->type])
724 if (*(fp_spd->fp_policies[policy->type] + iii) ==
725 *(result_val->fp_policies_ids + ii))
727 if (vec_len (result_val->fp_policies_ids) == 1)
729 vec_free (result_val->fp_policies_ids);
730 clib_bihash_add_del_16_8 (&fp_spd->fp_ip4_lookup_hash,
735 vec_del1 (result_val->fp_policies_ids, ii);
737 vec_del1 (fp_spd->fp_policies[policy->type], iii);
739 vec_foreach_index (imt, fp_spd->fp_mask_types[policy->type])
741 if (*(fp_spd->fp_mask_types[policy->type] + imt) ==
744 ipsec_fp_mask_type_entry_t *mte = pool_elt_at_index (
745 im->fp_mask_types, vp->fp_mask_type_id);
747 if (mte->refcount == 1)
748 vec_del1 (fp_spd->fp_mask_types[policy->type],
763 release_mask_type_index (im, vp->fp_mask_type_id);
764 ipsec_sa_unlock (vp->sa_index);
765 pool_put (im->policies, vp);
774 ipsec_fp_add_del_policy (void *fp_spd, ipsec_policy_t *policy, int is_add,
777 ipsec_main_t *im = &ipsec_main;
781 return ipsec_fp_ip6_add_policy (im, (ipsec_spd_fp_t *) fp_spd, policy,
784 return ipsec_fp_ip4_add_policy (im, (ipsec_spd_fp_t *) fp_spd, policy,
787 else if (policy->is_ipv6)
789 return ipsec_fp_ip6_del_policy (im, (ipsec_spd_fp_t *) fp_spd, policy);
791 return ipsec_fp_ip4_del_policy (im, (ipsec_spd_fp_t *) fp_spd, policy);
795 * fd.io coding-style-patch-verification: ON
798 * eval: (c-set-style "gnu")