diff options
author | eyal bari <royalbee@gmail.com> | 2018-04-26 13:14:55 +0300 |
---|---|---|
committer | John Lo <loj@cisco.com> | 2018-05-02 04:28:05 +0000 |
commit | 82e21d77be726636065278d014539d5c5ee97b88 (patch) | |
tree | cbfb9949338efc3e9f35186a6b04385a68e5fbb8 /src/vnet/vxlan/vxlan.c | |
parent | c1a448b3ad16f4ae78527220420fe5c1e41a4ab9 (diff) |
vxlan:encap - use vnet rewrite
moving the rewrite into the tunnel struct
Change-Id: Iec74b48e13456d32957e826cffb5ea35a8ebd1a0
Signed-off-by: Eyal Bari <ebari@cisco.com>
Diffstat (limited to 'src/vnet/vxlan/vxlan.c')
-rw-r--r-- | src/vnet/vxlan/vxlan.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c index 3d9a3edd7dc..ed5406c8fc0 100644 --- a/src/vnet/vxlan/vxlan.c +++ b/src/vnet/vxlan/vxlan.c @@ -18,6 +18,7 @@ #include <vnet/fib/fib_table.h> #include <vnet/mfib/mfib_table.h> #include <vnet/adj/adj_mcast.h> +#include <vnet/adj/rewrite.h> #include <vnet/interface.h> #include <vlib/vlib.h> @@ -218,21 +219,18 @@ static void vxlan_rewrite (vxlan_tunnel_t * t, bool is_ip6) { union { - ip4_vxlan_header_t * h4; - ip6_vxlan_header_t * h6; - u8 *rw; - } r = { .rw = 0 }; - int len = is_ip6 ? sizeof *r.h6 : sizeof *r.h4; - - vec_validate_aligned (r.rw, len-1, CLIB_CACHE_LINE_BYTES); + ip4_vxlan_header_t h4; + ip6_vxlan_header_t h6; + } h = {0}; + int len = is_ip6 ? sizeof h.h6 : sizeof h.h4; udp_header_t * udp; vxlan_header_t * vxlan; /* Fixed portion of the (outer) ip header */ if (!is_ip6) { - ip4_header_t * ip = &r.h4->ip4; - udp = &r.h4->udp, vxlan = &r.h4->vxlan; + ip4_header_t * ip = &h.h4.ip4; + udp = &h.h4.udp, vxlan = &h.h4.vxlan; ip->ip_version_and_header_length = 0x45; ip->ttl = 254; ip->protocol = IP_PROTOCOL_UDP; @@ -245,8 +243,8 @@ vxlan_rewrite (vxlan_tunnel_t * t, bool is_ip6) } else { - ip6_header_t * ip = &r.h6->ip6; - udp = &r.h6->udp, vxlan = &r.h6->vxlan; + ip6_header_t * ip = &h.h6.ip6; + udp = &h.h6.udp, vxlan = &h.h6.vxlan; ip->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32(6 << 28); ip->hop_limit = 255; ip->protocol = IP_PROTOCOL_UDP; @@ -261,8 +259,7 @@ vxlan_rewrite (vxlan_tunnel_t * t, bool is_ip6) /* VXLAN header */ vnet_set_vni_and_flags(vxlan, t->vni); - - t->rewrite = r.rw; + vnet_rewrite_set_data (*t, &h, len); } static bool @@ -573,7 +570,6 @@ int vnet_vxlan_add_del_tunnel hash_unset (vxm->instance_used, t->user_instance); fib_node_deinit(&t->node); - vec_free (t->rewrite); pool_put (vxm->tunnels, t); } |