aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c6
-rw-r--r--src/vnet/ip/ip6_packet.h14
-rw-r--r--src/vnet/vxlan/vxlan_api.c40
-rw-r--r--src/vpp/api/custom_dump.c6
4 files changed, 29 insertions, 37 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index e6e4acd9ea6..391fe9cf7c4 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -10671,10 +10671,8 @@ static void vl_api_vxlan_tunnel_details_t_handler
(vl_api_vxlan_tunnel_details_t * mp)
{
vat_main_t *vam = &vat_main;
- ip46_address_t src, dst;
-
- ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
- ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
+ ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
+ ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
ntohl (mp->sw_if_index),
diff --git a/src/vnet/ip/ip6_packet.h b/src/vnet/ip/ip6_packet.h
index bb7d703926b..cdd7eed5a82 100644
--- a/src/vnet/ip/ip6_packet.h
+++ b/src/vnet/ip/ip6_packet.h
@@ -82,21 +82,23 @@ typedef CLIB_PACKED (union {
#define ip46_address_is_equal(a1, a2) (((a1)->as_u64[0] == (a2)->as_u64[0]) \
&& ((a1)->as_u64[1] == (a2)->as_u64[1]))
-always_inline void
-ip46_from_addr_buf (u32 is_ipv6, u8 * buf, ip46_address_t * ip)
+always_inline ip46_address_t
+to_ip46 (u32 is_ipv6, u8 * buf)
{
+ ip46_address_t ip;
if (is_ipv6)
- ip->ip6 = *((ip6_address_t *) buf);
+ ip.ip6 = *((ip6_address_t *) buf);
else
- ip46_address_set_ip4 (ip, (ip4_address_t *) buf);
+ ip46_address_set_ip4 (&ip, (ip4_address_t *) buf);
+ return ip;
}
+
always_inline void
ip6_addr_fib_init (ip6_address_fib_t * addr_fib, ip6_address_t * address,
u32 fib_index)
{
- addr_fib->ip6_addr.as_u64[0] = address->as_u64[0];
- addr_fib->ip6_addr.as_u64[1] = address->as_u64[1];
+ addr_fib->ip6_addr = *address;
addr_fib->fib_index = fib_index;
}
diff --git a/src/vnet/vxlan/vxlan_api.c b/src/vnet/vxlan/vxlan_api.c
index c726c7c5b6a..a2d412322fb 100644
--- a/src/vnet/vxlan/vxlan_api.c
+++ b/src/vnet/vxlan/vxlan_api.c
@@ -70,47 +70,41 @@ static void vl_api_vxlan_add_del_tunnel_t_handler
{
vl_api_vxlan_add_del_tunnel_reply_t *rmp;
int rv = 0;
- vnet_vxlan_add_del_tunnel_args_t _a, *a = &_a;
- u32 encap_fib_index;
- uword *p;
ip4_main_t *im = &ip4_main;
- vnet_main_t *vnm = vnet_get_main ();
- u32 sw_if_index = ~0;
- p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
+ uword *p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
if (!p)
{
rv = VNET_API_ERROR_NO_SUCH_FIB;
goto out;
}
- encap_fib_index = p[0];
- memset (a, 0, sizeof (*a));
-
- a->is_add = mp->is_add;
- a->is_ip6 = mp->is_ipv6;
- /* ip addresses sent in network byte order */
- ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &a->dst);
- ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &a->src);
+ vnet_vxlan_add_del_tunnel_args_t a = {
+ .is_add = mp->is_add,
+ .is_ip6 = mp->is_ipv6,
+ .mcast_sw_if_index = ntohl (mp->mcast_sw_if_index),
+ .encap_fib_index = p[0],
+ .decap_next_index = ntohl (mp->decap_next_index),
+ .vni = ntohl (mp->vni),
+ .dst = to_ip46 (mp->is_ipv6, mp->dst_address),
+ .src = to_ip46 (mp->is_ipv6, mp->src_address),
+ };
/* Check src & dst are different */
- if (ip46_address_cmp (&a->dst, &a->src) == 0)
+ if (ip46_address_cmp (&a.dst, &a.src) == 0)
{
rv = VNET_API_ERROR_SAME_SRC_DST;
goto out;
}
- a->mcast_sw_if_index = ntohl (mp->mcast_sw_if_index);
- if (ip46_address_is_multicast (&a->dst) &&
- pool_is_free_index (vnm->interface_main.sw_interfaces,
- a->mcast_sw_if_index))
+ if (ip46_address_is_multicast (&a.dst) &&
+ !vnet_sw_if_index_is_api_valid (a.mcast_sw_if_index))
{
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
goto out;
}
- a->encap_fib_index = encap_fib_index;
- a->decap_next_index = ntohl (mp->decap_next_index);
- a->vni = ntohl (mp->vni);
- rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
+
+ u32 sw_if_index = ~0;
+ rv = vnet_vxlan_add_del_tunnel (&a, &sw_if_index);
out:
/* *INDENT-OFF* */
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 648ac5f3937..a76840a240c 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1384,10 +1384,8 @@ static void *vl_api_vxlan_add_del_tunnel_t_print
u8 *s;
s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
- ip46_address_t src, dst;
-
- ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
- ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
+ ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
+ ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
u8 is_grp = ip46_address_is_multicast (&dst);
char *dst_name = is_grp ? "group" : "dst";