aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c12
-rw-r--r--src/vnet/l2tp/l2tp.api41
-rw-r--r--src/vnet/l2tp/l2tp_api.c22
-rw-r--r--src/vpp/api/custom_dump.c5
-rw-r--r--test/test_l2tp.py5
5 files changed, 50 insertions, 35 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 3ad4ec6e2cd..482575a66bf 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -11575,17 +11575,17 @@ api_l2tpv3_create_tunnel (vat_main_t * vam)
M (L2TPV3_CREATE_TUNNEL, mp);
- clib_memcpy (mp->client_address, client_address.as_u8,
- sizeof (mp->client_address));
+ clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
+ sizeof (ip6_address_t));
- clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
+ clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
+ sizeof (ip6_address_t));
mp->local_session_id = ntohl (local_session_id);
mp->remote_session_id = ntohl (remote_session_id);
mp->local_cookie = clib_host_to_net_u64 (local_cookie);
mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
mp->l2_sublayer_present = l2_sublayer_present;
- mp->is_ipv6 = 1;
S (mp);
W (ret);
@@ -11750,9 +11750,9 @@ static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
vat_json_init_object (node);
- clib_memcpy (&addr, mp->our_address, sizeof (addr));
+ clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
vat_json_object_add_ip6 (node, "our_address", addr);
- clib_memcpy (&addr, mp->client_address, sizeof (addr));
+ clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
vat_json_object_add_ip6 (node, "client_address", addr);
vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
diff --git a/src/vnet/l2tp/l2tp.api b/src/vnet/l2tp/l2tp.api
index f679b751789..618c4122fd6 100644
--- a/src/vnet/l2tp/l2tp.api
+++ b/src/vnet/l2tp/l2tp.api
@@ -13,7 +13,11 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/ip/ip_types.api";
/** \brief l2tpv3 tunnel interface create request
@param client_index - opaque cookie to identify the sender
@@ -31,14 +35,13 @@ define l2tpv3_create_tunnel
{
u32 client_index;
u32 context;
- u8 client_address[16];
- u8 our_address[16];
- u8 is_ipv6;
+ vl_api_address_t client_address;
+ vl_api_address_t our_address;
u32 local_session_id;
u32 remote_session_id;
u64 local_cookie;
u64 remote_cookie;
- u8 l2_sublayer_present;
+ bool l2_sublayer_present;
u32 encap_vrf_id;
};
@@ -51,14 +54,14 @@ define l2tpv3_create_tunnel_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
autoreply define l2tpv3_set_tunnel_cookies
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u64 new_local_cookie;
u64 new_remote_cookie;
};
@@ -66,15 +69,15 @@ autoreply define l2tpv3_set_tunnel_cookies
define sw_if_l2tpv3_tunnel_details
{
u32 context;
- u32 sw_if_index;
- u8 interface_name[64];
- u8 client_address[16];
- u8 our_address[16];
+ vl_api_interface_index_t sw_if_index;
+ string interface_name[64];
+ vl_api_address_t client_address;
+ vl_api_address_t our_address;
u32 local_session_id;
u32 remote_session_id;
u64 local_cookie[2];
u64 remote_cookie;
- u8 l2_sublayer_present;
+ bool l2_sublayer_present;
};
define sw_if_l2tpv3_tunnel_dump
@@ -87,16 +90,22 @@ autoreply define l2tpv3_interface_enable_disable
{
u32 client_index;
u32 context;
- u8 enable_disable;
- u32 sw_if_index;
+ bool enable_disable;
+ vl_api_interface_index_t sw_if_index;
+};
+
+enum l2t_lookup_key : u8
+{
+ L2T_LOOKUP_KEY_API_SRC_ADDR = 0,
+ L2T_LOOKUP_KEY_API_DST_ADDR = 1,
+ L2T_LOOKUP_KEY_API_SESSION_ID = 2,
};
autoreply define l2tpv3_set_lookup_key
{
u32 client_index;
u32 context;
- /* 0 = ip6 src_address, 1 = ip6 dst_address, 2 = session_id */
- u8 key;
+ vl_api_l2t_lookup_key_t key;
};
/*
diff --git a/src/vnet/l2tp/l2tp_api.c b/src/vnet/l2tp/l2tp_api.c
index 6b48c140c71..ba1f7c61cc6 100644
--- a/src/vnet/l2tp/l2tp_api.c
+++ b/src/vnet/l2tp/l2tp_api.c
@@ -23,6 +23,7 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/l2tp/l2tp.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -75,9 +76,10 @@ send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
mp->local_cookie[0] = s->local_cookie[0];
mp->local_cookie[1] = s->local_cookie[1];
mp->remote_cookie = s->remote_cookie;
- clib_memcpy (mp->client_address, &s->client_address,
- sizeof (s->client_address));
- clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
+ ip_address_encode ((ip46_address_t *) & s->client_address, IP46_TYPE_IP6,
+ &mp->client_address);
+ ip_address_encode ((ip46_address_t *) & s->our_address, IP46_TYPE_IP6,
+ &mp->our_address);
mp->l2_sublayer_present = s->l2_sublayer_present;
mp->context = context;
@@ -113,8 +115,9 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
l2t_main_t *lm = &l2t_main;
u32 sw_if_index = (u32) ~ 0;
int rv;
+ ip46_address_t client, our;
- if (mp->is_ipv6 != 1)
+ if (mp->our_address.af == ADDRESS_IP4)
{
rv = VNET_API_ERROR_UNIMPLEMENTED;
goto out;
@@ -140,9 +143,12 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
encap_fib_index = ~0;
}
+ ip_address_decode (&mp->client_address, &client);
+ ip_address_decode (&mp->our_address, &our);
+
rv = create_l2tpv3_ipv6_tunnel (lm,
- (ip6_address_t *) mp->client_address,
- (ip6_address_t *) mp->our_address,
+ &client.ip6,
+ &our.ip6,
ntohl (mp->local_session_id),
ntohl (mp->remote_session_id),
clib_net_to_host_u64 (mp->local_cookie),
@@ -202,13 +208,13 @@ static void vl_api_l2tpv3_set_lookup_key_t_handler
l2t_main_t *lm = &l2t_main;
vl_api_l2tpv3_set_lookup_key_reply_t *rmp;
- if (mp->key > L2T_LOOKUP_SESSION_ID)
+ if (mp->key > L2T_LOOKUP_KEY_API_SESSION_ID)
{
rv = VNET_API_ERROR_INVALID_VALUE;
goto out;
}
- lm->lookup_type = mp->key;
+ lm->lookup_type = (ip6_to_l2_lookup_t) mp->key;
out:
REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 7b37862fd40..e96f4ee320c 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1509,8 +1509,9 @@ static void *vl_api_l2tpv3_create_tunnel_t_print
s = format (0, "SCRIPT: l2tpv3_create_tunnel ");
s = format (s, "client_address %U our_address %U ",
- format_ip6_address, (ip6_address_t *) (mp->client_address),
- format_ip6_address, (ip6_address_t *) (mp->our_address));
+ format_ip6_address,
+ (ip6_address_t *) (mp->client_address.un.ip6),
+ format_ip6_address, (ip6_address_t *) (mp->our_address.un.ip6));
s = format (s, "local_session_id %d ", (mp->local_session_id));
s = format (s, "remote_session_id %d ", (mp->remote_session_id));
s = format (s, "local_cookie %lld ",
diff --git a/test/test_l2tp.py b/test/test_l2tp.py
index 1d229e6e356..6ce7de75d40 100644
--- a/test/test_l2tp.py
+++ b/test/test_l2tp.py
@@ -34,9 +34,8 @@ class TestL2tp(VppTestCase):
self.assertEqual(err, 0)
err_count = err
- self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6n,
- our_address=self.pg0.remote_ip6n,
- is_ipv6=1)
+ self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6,
+ our_address=self.pg0.remote_ip6)
self.pg0.add_stream(pkt)
self.pg_start()