summaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2018-06-07 19:36:07 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-06-20 15:36:56 +0000
commitee52d877d41a6349c1090f62fb2948f90e6301ce (patch)
tree2d9c201e4134c693a6ed88b94bc5385085d043fd /src/vnet/ipsec
parent22f9fb1286d2469819cfcef68ffdc258f4d52c24 (diff)
ipsec: VPP-1308 fix sorting of SPD entries
Change-Id: I761aced55b7cef51a9b47048283b2cb9430bcde2 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet/ipsec')
-rw-r--r--src/vnet/ipsec/ipsec.c18
-rw-r--r--src/vnet/ipsec/ipsec.h3
2 files changed, 11 insertions, 10 deletions
diff --git a/src/vnet/ipsec/ipsec.c b/src/vnet/ipsec/ipsec.c
index 928cafd5e25..73b51012880 100644
--- a/src/vnet/ipsec/ipsec.c
+++ b/src/vnet/ipsec/ipsec.c
@@ -135,20 +135,15 @@ ipsec_add_del_spd (vlib_main_t * vm, u32 spd_id, int is_add)
static int
ipsec_spd_entry_sort (void *a1, void *a2)
{
- ipsec_main_t *im = &ipsec_main;
u32 *id1 = a1;
u32 *id2 = a2;
- ipsec_spd_t *spd;
+ ipsec_spd_t *spd = ipsec_main.spd_to_sort;
ipsec_policy_t *p1, *p2;
- /* *INDENT-OFF* */
- pool_foreach (spd, im->spds, ({
- p1 = pool_elt_at_index(spd->policies, *id1);
- p2 = pool_elt_at_index(spd->policies, *id2);
- if (p1 && p2)
- return p2->priority - p1->priority;
- }));
- /* *INDENT-ON* */
+ p1 = pool_elt_at_index (spd->policies, *id1);
+ p2 = pool_elt_at_index (spd->policies, *id2);
+ if (p1 && p2)
+ return p2->priority - p1->priority;
return 0;
}
@@ -191,6 +186,8 @@ ipsec_add_del_policy (vlib_main_t * vm, ipsec_policy_t * policy, int is_add)
clib_memcpy (vp, policy, sizeof (*vp));
policy_index = vp - spd->policies;
+ ipsec_main.spd_to_sort = spd;
+
if (policy->is_outbound)
{
if (policy->is_ipv6)
@@ -256,6 +253,7 @@ ipsec_add_del_policy (vlib_main_t * vm, ipsec_policy_t * policy, int is_add)
}
}
+ ipsec_main.spd_to_sort = NULL;
}
else
{
diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h
index 5b548322d28..404756a418f 100644
--- a/src/vnet/ipsec/ipsec.h
+++ b/src/vnet/ipsec/ipsec.h
@@ -299,6 +299,9 @@ typedef struct
/* callbacks */
ipsec_main_callbacks_t cb;
+
+ /* helper for sort function */
+ ipsec_spd_t *spd_to_sort;
} ipsec_main_t;
extern ipsec_main_t ipsec_main;
font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
packet-generator new {
  name x0
  limit 1
  node ip4-input
  size 64-64
  no-recycle
  data {
    ICMP: 1.0.0.2 -> 2.0.0.2
    ICMP echo_request
    incrementing 100
  }
}
packet-generator new {
  name x1
  limit 1
  node ip4-input
  size 64-64
  no-recycle
  data {
    ICMP: 1.0.0.2 -> 2.0.1.2
    ICMP echo_request
    incrementing 100
  }
}
packet-generator new {
  name x2
  limit 1
  node ip4-input
  size 64-64
  no-recycle
  data {
    ICMP: 1.0.0.2 -> 2.0.2.2
    ICMP echo_request
    incrementing 100
  }
}
packet-generator new {
  name x3
  limit 1
  node ip4-input
  size 64-64
  no-recycle
  data {
    ICMP: 1.0.0.2 -> 2.0.3.2
    ICMP echo_request
    incrementing 100
  }
}



trace add pg-input 100

loop create
set int state loop0 up

set int ip address loop0 10.0.0.1/24
set ip arp loop0 10.0.0.2 00:00:11:aa:bb:cc

mpls tunnel add via 10.0.0.2 loop0 out-label 33 out-label 34 out-label 35 out-label 36
set int state mpls-tunnel0 up
set int ip addr  mpls-tunnel0 192.168.0.1/32
ip route add 2.0.0.2/32 via 192.168.0.2 mpls-tunnel0


mpls tunnel add via 10.0.0.2 out-label 33
set int state mpls-tunnel1 up
set int ip addr  mpls-tunnel1 192.168.1.1/32
ip route add 2.0.1.2/32 via 192.168.1.2 mpls-tunnel1 out-label 99

mpls tunnel add via 10.0.0.2 loop0 out-label 3
set int state mpls-tunnel2 up
set int ip addr  mpls-tunnel2 192.168.2.1/32
ip route add 2.0.2.2/32 via 192.168.2.2 mpls-tunnel2


mpls tunnel add l2-only via 10.0.0.2 loop0 out-label 234 out-label 0
set int state mpls-tunnel3 up
set int l2 bridge mpls-tunnel3 1

loop create
set int ip addr loop1 6.0.1.44/24
set int l2 bridge loop1 1 bvi
set int l2 learn loop1 disable
set int state loop1 up

ip route add 2.0.3.2/32 via 6.0.1.45 loop1