aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYulong Pei <yulong.pei@intel.com>2020-01-09 01:12:43 +0800
committerOle Trøan <otroan@employees.org>2020-01-17 14:21:03 +0000
commitdb43bb6af78c33e47d29889b047cced4b11fe4d7 (patch)
tree125108d5ae646765cce8cbaff9240058eb3f05ad
parent720435d03531da68e18c2a0dc867aa99d2daced6 (diff)
lb: fix that lb_add_del_vip and lb_add_del_as api doesn't work correctly
Currently if user want to set ip4 address to the api, it must convert to ip6 format, e.g. user want to ip4 "90.1.2.1" but must convert to "::5A01:0201", it is not acceptable, this fix solved the issue. Ticket: FDIO-753 Type: fix Change-Id: I2ffa5a3d38400ee176cf601421074f71fc395f03 Signed-off-by: Yulong Pei <yulong.pei@intel.com>
-rw-r--r--src/plugins/lb/CMakeLists.txt1
-rw-r--r--src/plugins/lb/api.c13
-rw-r--r--src/plugins/lb/lb_test.c7
-rw-r--r--src/vnet/CMakeLists.txt9
4 files changed, 18 insertions, 12 deletions
diff --git a/src/plugins/lb/CMakeLists.txt b/src/plugins/lb/CMakeLists.txt
index 69ca948a001..6fab329abfd 100644
--- a/src/plugins/lb/CMakeLists.txt
+++ b/src/plugins/lb/CMakeLists.txt
@@ -32,3 +32,4 @@ add_vpp_plugin(lb
lb_test.c
)
+target_link_libraries(lb_test_plugin vatclient)
diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c
index bef6969ed84..0fed63f19f8 100644
--- a/src/plugins/lb/api.c
+++ b/src/plugins/lb/api.c
@@ -93,7 +93,7 @@ vl_api_lb_add_del_vip_t_handler
mp->protocol = ~0;
}
- memcpy (&(args.prefix.ip6), &mp->pfx.address.un.ip6, sizeof(args.prefix.ip6));
+ ip_address_decode (&mp->pfx.address, &(args.prefix));
if (mp->is_del) {
u32 vip_index;
@@ -183,20 +183,15 @@ vl_api_lb_add_del_as_t_handler
int rv = 0;
u32 vip_index;
ip46_address_t vip_ip_prefix;
+ ip46_address_t as_address;
/* if port == 0, it means all-port VIP */
if (mp->port == 0)
{
mp->protocol = ~0;
}
-
- memcpy(&vip_ip_prefix.ip6, &mp->pfx.address.un.ip6,
- sizeof(vip_ip_prefix.ip6));
-
- ip46_address_t as_address;
-
- memcpy(&as_address.ip6, &mp->as_address.un.ip6,
- sizeof(as_address.ip6));
+ ip_address_decode (&mp->pfx.address, &vip_ip_prefix);
+ ip_address_decode (&mp->as_address, &as_address);
if ((rv = lb_vip_find_index(&vip_ip_prefix, mp->pfx.len,
mp->protocol, ntohs(mp->port), &vip_index)))
diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c
index 007303f82c8..80fc38e2746 100644
--- a/src/plugins/lb/lb_test.c
+++ b/src/plugins/lb/lb_test.c
@@ -16,6 +16,7 @@
#include <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
+#include <vnet/ip/ip_types_api.h>
#include <vppinfra/error.h>
#include <lb/lb.h>
@@ -189,7 +190,7 @@ static int api_lb_add_del_vip (vat_main_t * vam)
}
M(LB_ADD_DEL_VIP, mp);
- clib_memcpy (mp->pfx.address.un.ip6, &ip_prefix.ip6, sizeof (ip_prefix.ip6));
+ ip_address_encode(&ip_prefix, IP46_TYPE_ANY, &mp->pfx.address);
mp->pfx.len = prefix_length;
mp->protocol = (u8)protocol;
mp->port = htons((u16)port);
@@ -264,11 +265,11 @@ static int api_lb_add_del_as (vat_main_t * vam)
}
M(LB_ADD_DEL_AS, mp);
- clib_memcpy (mp->pfx.address.un.ip6, &vip_prefix.ip6, sizeof (vip_prefix.ip6));
+ ip_address_encode(&vip_prefix, IP46_TYPE_ANY, &mp->pfx.address);
mp->pfx.len = vip_plen;
mp->protocol = (u8)protocol;
mp->port = htons((u16)port);
- clib_memcpy (&mp->as_address.un.ip6, &as_addr.ip6, sizeof (as_addr.ip6));
+ ip_address_encode(&as_addr, IP46_TYPE_ANY, &mp->as_address);
mp->is_del = is_del;
mp->is_flush = is_flush;
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index c2a0dd54401..04a8b1d4e09 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -1587,3 +1587,12 @@ add_vpp_library(vnet
)
##############################################################################
+# vpp api test client library
+##############################################################################
+
+add_vpp_library (vatclient
+ SOURCES ip/ip_types_api.c
+ DEPENDS api_headers
+)
+
+##############################################################################