aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-03-18 13:17:53 +0100
committerOle Trøan <otroan@employees.org>2019-08-20 09:57:10 +0000
commit053204ab039d34a990ff0e14c32ce3b294fcce0e (patch)
tree7261eaf0b905ea456ac536d8f728e89319b16a69
parentdf36f4963f1a590ce9a02f048507c3d4590580ae (diff)
api: Cleanup APIs interface.api
Use of consistent API types for interface.api Type: fix Change-Id: I88206d7d0907cffd564031f73c9a996df2e5e21a Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
-rw-r--r--extras/vom/vom/interface.cpp4
-rw-r--r--extras/vom/vom/interface_cmds.cpp10
-rw-r--r--extras/vom/vom/interface_factory.cpp12
-rw-r--r--extras/vom/vom/l3_binding_cmds.cpp8
-rw-r--r--src/vat/api_format.c78
-rw-r--r--src/vat/vat.h24
-rw-r--r--src/vlibapi/api_types.h2
-rw-r--r--src/vnet/ethernet/ethernet_types_api.h1
-rw-r--r--src/vnet/interface.api216
-rw-r--r--src/vnet/interface_api.c170
-rw-r--r--src/vnet/interface_types.api56
-rw-r--r--src/vnet/ip/ip_types_api.h1
-rw-r--r--src/vpp/api/custom_dump.c35
-rw-r--r--test/ext/vapi_c_test.c18
-rw-r--r--test/ext/vapi_cpp_test.cpp8
-rw-r--r--test/remote_test.py9
-rw-r--r--test/test_bond.py8
-rw-r--r--test/test_container.py8
-rw-r--r--test/test_interface_crud.py4
-rw-r--r--test/test_ip4.py19
-rw-r--r--test/test_memif.py6
-rw-r--r--test/test_nat.py35
-rw-r--r--test/test_span.py2
-rw-r--r--test/vpp_interface.py128
-rw-r--r--test/vpp_ip_route.py6
-rw-r--r--test/vpp_memif.py16
-rw-r--r--test/vpp_sub_interface.py8
27 files changed, 500 insertions, 392 deletions
diff --git a/extras/vom/vom/interface.cpp b/extras/vom/vom/interface.cpp
index 70035648d06..c80dc793604 100644
--- a/extras/vom/vom/interface.cpp
+++ b/extras/vom/vom/interface.cpp
@@ -647,8 +647,8 @@ interface::event_handler::handle_populate(const client_db::key_t& key)
for (auto& itf_record : *cmd) {
auto payload = itf_record.get_payload();
VOM_LOG(log_level_t::DEBUG) << "dump: [" << payload.sw_if_index
- << " name:" << (char*)payload.interface_name
- << " tag:" << (char*)payload.tag << "]";
+ << " name:" << (char*)payload.interface_name.buf
+ << " tag:" << (char*)payload.tag.buf << "]";
std::shared_ptr<interface> itf = interface_factory::new_interface(payload);
diff --git a/extras/vom/vom/interface_cmds.cpp b/extras/vom/vom/interface_cmds.cpp
index b72c2ad69e5..8c47b9f4c45 100644
--- a/extras/vom/vom/interface_cmds.cpp
+++ b/extras/vom/vom/interface_cmds.cpp
@@ -318,7 +318,7 @@ state_change_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.sw_if_index = m_hdl.data().value();
- payload.admin_up_down = m_hw_item.data().value();
+ payload.flags = (vapi_enum_if_status_flags)m_hw_item.data().value();
VAPI_CALL(req.execute());
@@ -516,8 +516,8 @@ events_cmd::notify()
std::shared_ptr<interface> sp = interface::find(handle);
if (sp) {
- interface::oper_state_t oper_state =
- interface::oper_state_t::from_int(payload.link_up_down);
+ interface::oper_state_t oper_state = interface::oper_state_t::from_int(
+ payload.flags & vapi_enum_if_status_flags::IF_STATUS_API_FLAG_LINK_UP);
VOM_LOG(log_level_t::DEBUG) << "Interface Event: " << sp->to_string()
<< " state: " << oper_state.to_string();
@@ -635,8 +635,8 @@ set_tag::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
payload.sw_if_index = m_hw_item.data().value();
- memset(payload.tag, 0, sizeof(payload.tag));
- memcpy(payload.tag, m_name.c_str(), m_name.length());
+ memset(payload.tag.buf, 0, payload.tag.length);
+ memcpy(payload.tag.buf, m_name.c_str(), m_name.length());
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/interface_factory.cpp b/extras/vom/vom/interface_factory.cpp
index abb26f84a6f..750df96b025 100644
--- a/extras/vom/vom/interface_factory.cpp
+++ b/extras/vom/vom/interface_factory.cpp
@@ -30,12 +30,12 @@ interface_factory::new_interface(const vapi_payload_sw_interface_details& vd)
/**
* Determine the interface type from the name and VLAN attributes
*/
- std::string name = reinterpret_cast<const char*>(vd.interface_name);
+ std::string name = reinterpret_cast<const char*>(vd.interface_name.buf);
interface::type_t type = interface::type_t::from_string(name);
- interface::admin_state_t state =
- interface::admin_state_t::from_int(vd.admin_up_down);
+ interface::admin_state_t state = interface::admin_state_t::from_int(
+ vd.flags & vapi_enum_if_status_flags::IF_STATUS_API_FLAG_ADMIN_UP);
handle_t hdl(vd.sw_if_index);
- l2_address_t l2_address(vd.l2_address, vd.l2_address_length);
+ l2_address_t l2_address(vd.l2_address, 6);
std::string tag = "";
if (interface::type_t::UNKNOWN == type) {
@@ -64,8 +64,8 @@ interface_factory::new_interface(const vapi_payload_sw_interface_details& vd)
* if the tag is set, then we wrote that to specify a name to make
* the interface type more specific
*/
- if (vd.tag[0] != 0) {
- tag = std::string(reinterpret_cast<const char*>(vd.tag));
+ if (vd.tag.buf[0] != 0) {
+ tag = std::string(reinterpret_cast<const char*>(vd.tag.buf));
}
if (!tag.empty() && interface::type_t::LOOPBACK == type) {
diff --git a/extras/vom/vom/l3_binding_cmds.cpp b/extras/vom/vom/l3_binding_cmds.cpp
index 4afe13e1076..15122bc9dd6 100644
--- a/extras/vom/vom/l3_binding_cmds.cpp
+++ b/extras/vom/vom/l3_binding_cmds.cpp
@@ -44,7 +44,9 @@ bind_cmd::issue(connection& con)
payload.is_add = 1;
payload.del_all = 0;
- m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
+ m_pfx.to_vpp((uint8_t*)&payload.prefix.address.af,
+ (uint8_t*)&payload.prefix.address,
+ (uint8_t*)&payload.prefix.len);
VAPI_CALL(req.execute());
@@ -86,7 +88,9 @@ unbind_cmd::issue(connection& con)
payload.is_add = 0;
payload.del_all = 0;
- m_pfx.to_vpp(&payload.is_ipv6, payload.address, &payload.address_length);
+ m_pfx.to_vpp((uint8_t*)&payload.prefix.address.af,
+ (uint8_t*)&payload.prefix.address,
+ (uint8_t*)&payload.prefix.len);
VAPI_CALL(req.execute());
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index ec21c045f5c..7aa46f4015f 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -974,7 +974,8 @@ static void vl_api_sw_interface_details_t_handler
(vl_api_sw_interface_details_t * mp)
{
vat_main_t *vam = &vat_main;
- u8 *s = format (0, "%s%c", mp->interface_name, 0);
+ u8 *s = format (0, "%s%c",
+ vl_api_from_api_string (&mp->interface_name), 0);
hash_set_mem (vam->sw_if_index_by_interface_name, s,
ntohl (mp->sw_if_index));
@@ -992,14 +993,11 @@ static void vl_api_sw_interface_details_t_handler
sub->sw_if_index = ntohl (mp->sw_if_index);
sub->sub_id = ntohl (mp->sub_id);
- sub->sub_dot1ad = mp->sub_dot1ad;
+ sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
+
sub->sub_number_of_tags = mp->sub_number_of_tags;
sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
- sub->sub_exact_match = mp->sub_exact_match;
- sub->sub_default = mp->sub_default;
- sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
- sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
/* vlan tag rewrite */
sub->vtr_op = ntohl (mp->vtr_op);
@@ -1026,37 +1024,28 @@ static void vl_api_sw_interface_details_t_handler_json
vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
vat_json_object_add_uint (node, "sup_sw_if_index",
ntohl (mp->sup_sw_if_index));
- vat_json_object_add_uint (node, "l2_address_length",
- ntohl (mp->l2_address_length));
vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
sizeof (mp->l2_address));
vat_json_object_add_string_copy (node, "interface_name",
- mp->interface_name);
- vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
- vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
+ mp->interface_name.buf);
+ vat_json_object_add_uint (node, "flags", mp->flags);
vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
vat_json_object_add_uint (node, "link_speed", mp->link_speed);
vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
- vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
vat_json_object_add_uint (node, "sub_number_of_tags",
mp->sub_number_of_tags);
vat_json_object_add_uint (node, "sub_outer_vlan_id",
ntohs (mp->sub_outer_vlan_id));
vat_json_object_add_uint (node, "sub_inner_vlan_id",
ntohs (mp->sub_inner_vlan_id));
- vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
- vat_json_object_add_uint (node, "sub_default", mp->sub_default);
- vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
- mp->sub_outer_vlan_id_any);
- vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
- mp->sub_inner_vlan_id_any);
+ vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
vat_json_object_add_uint (node, "vtr_push_dot1q",
ntohl (mp->vtr_push_dot1q));
vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
- if (mp->sub_dot1ah)
+ if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
{
vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
format (0, "%U",
@@ -1079,8 +1068,10 @@ static void vl_api_sw_interface_event_t_handler
if (vam->interface_event_display)
errmsg ("interface flags: sw_if_index %d %s %s",
ntohl (mp->sw_if_index),
- mp->admin_up_down ? "admin-up" : "admin-down",
- mp->link_up_down ? "link-up" : "link-down");
+ ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
+ "admin-up" : "admin-down",
+ ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
+ "link-up" : "link-down");
}
#endif
@@ -6016,7 +6007,7 @@ api_sw_interface_set_flags (vat_main_t * vam)
/* Construct the API message */
M (SW_INTERFACE_SET_FLAGS, mp);
mp->sw_if_index = ntohl (sw_if_index);
- mp->admin_up_down = admin_up;
+ mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
/* send it... */
S (mp);
@@ -6072,7 +6063,7 @@ api_sw_interface_set_rx_mode (vat_main_t * vam)
/* Construct the API message */
M (SW_INTERFACE_SET_RX_MODE, mp);
mp->sw_if_index = ntohl (sw_if_index);
- mp->mode = mode;
+ mp->mode = (vl_api_rx_mode_t) mode;
mp->queue_id_valid = queue_id_valid;
mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
@@ -6308,14 +6299,15 @@ api_sw_interface_add_del_address (vat_main_t * vam)
mp->del_all = del_all;
if (v6_address_set)
{
- mp->is_ipv6 = 1;
- clib_memcpy (mp->address, &v6address, sizeof (v6address));
+ mp->prefix.address.af = ADDRESS_IP6;
+ clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
}
else
{
- clib_memcpy (mp->address, &v4address, sizeof (v4address));
+ mp->prefix.address.af = ADDRESS_IP4;
+ clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
}
- mp->address_length = address_length;
+ mp->prefix.len = address_length;
/* send it... */
S (mp);
@@ -9221,6 +9213,16 @@ _(default_sub) \
_(outer_vlan_id_any) \
_(inner_vlan_id_any)
+#define foreach_create_subif_flag \
+_(0, "no_tags") \
+_(1, "one_tag") \
+_(2, "two_tags") \
+_(3, "dot1ad") \
+_(4, "exact_match") \
+_(5, "default_sub") \
+_(6, "outer_vlan_id_any") \
+_(7, "inner_vlan_id_any")
+
static int
api_create_subif (vat_main_t * vam)
{
@@ -9230,14 +9232,14 @@ api_create_subif (vat_main_t * vam)
u8 sw_if_index_set = 0;
u32 sub_id;
u8 sub_id_set = 0;
- u32 no_tags = 0;
- u32 one_tag = 0;
- u32 two_tags = 0;
- u32 dot1ad = 0;
- u32 exact_match = 0;
- u32 default_sub = 0;
- u32 outer_vlan_id_any = 0;
- u32 inner_vlan_id_any = 0;
+ u32 __attribute__ ((unused)) no_tags = 0;
+ u32 __attribute__ ((unused)) one_tag = 0;
+ u32 __attribute__ ((unused)) two_tags = 0;
+ u32 __attribute__ ((unused)) dot1ad = 0;
+ u32 __attribute__ ((unused)) exact_match = 0;
+ u32 __attribute__ ((unused)) default_sub = 0;
+ u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
+ u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
u32 tmp;
u16 outer_vlan_id = 0;
u16 inner_vlan_id = 0;
@@ -9283,8 +9285,8 @@ api_create_subif (vat_main_t * vam)
mp->sw_if_index = ntohl (sw_if_index);
mp->sub_id = ntohl (sub_id);
-#define _(a) mp->a = a;
- foreach_create_subif_bit;
+#define _(a,b) mp->sub_if_flags |= (1 << a);
+ foreach_create_subif_flag;
#undef _
mp->outer_vlan_id = ntohs (outer_vlan_id);
@@ -20435,7 +20437,7 @@ api_sw_interface_tag_add_del (vat_main_t * vam)
mp->sw_if_index = ntohl (sw_if_index);
mp->is_add = enable;
if (enable)
- strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
+ vl_api_to_api_string (strlen ((char *) tag), (char *) tag, &mp->tag);
vec_free (tag);
S (mp);
diff --git a/src/vat/vat.h b/src/vat/vat.h
index e21940c4cd4..bcaddfe0126 100644
--- a/src/vat/vat.h
+++ b/src/vat/vat.h
@@ -48,17 +48,27 @@ typedef struct
*/
u32 sub_id;
- /* 0 = dot1q, 1=dot1ad */
- u8 sub_dot1ad;
-
/* Number of tags 0-2 */
u8 sub_number_of_tags;
u16 sub_outer_vlan_id;
u16 sub_inner_vlan_id;
- u8 sub_exact_match;
- u8 sub_default;
- u8 sub_outer_vlan_id_any;
- u8 sub_inner_vlan_id_any;
+
+ union
+ {
+ u16 raw_flags;
+ struct
+ {
+ u16 no_tags:1;
+ u16 one_tag:1;
+ u16 two_tags:1;
+ /* 0 = dot1q, 1=dot1ad */
+ u16 sub_dot1ad:1;
+ u16 sub_exact_match:1;
+ u16 sub_default:1;
+ u16 sub_outer_vlan_id_any:1;
+ u16 sub_inner_vlan_id_any:1;
+ };
+ };
/* vlan tag rewrite */
u32 vtr_op;
diff --git a/src/vlibapi/api_types.h b/src/vlibapi/api_types.h
index b0efa6177bd..04f84a5f908 100644
--- a/src/vlibapi/api_types.h
+++ b/src/vlibapi/api_types.h
@@ -20,6 +20,8 @@
#ifndef included_api_types_h
#define included_api_types_h
+#include <stdbool.h>
+
#include <vppinfra/types.h>
#include <arpa/inet.h>
#include <string.h>
diff --git a/src/vnet/ethernet/ethernet_types_api.h b/src/vnet/ethernet/ethernet_types_api.h
index e2c638d1fec..8bd8b7e514e 100644
--- a/src/vnet/ethernet/ethernet_types_api.h
+++ b/src/vnet/ethernet/ethernet_types_api.h
@@ -21,6 +21,7 @@
*/
#include <vnet/ethernet/mac_address.h>
+#include <vlibapi/api_types.h>
extern void mac_address_decode (const u8 * in, mac_address_t * out);
extern void mac_address_encode (const mac_address_t * in, u8 * out);
diff --git a/src/vnet/interface.api b/src/vnet/interface.api
index d30f1c285ea..8a2d0797b5c 100644
--- a/src/vnet/interface.api
+++ b/src/vnet/interface.api
@@ -14,9 +14,11 @@
* limitations under the License.
*/
-option version = "2.3.1";
+option version = "3.0.0";
import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/ip/ip_types.api";
service {
rpc want_interface_events returns want_interface_events_reply
@@ -27,16 +29,15 @@ service {
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param sw_if_index - index of the interface to set flags on
- @param admin_up_down - set the admin state, 1 = up, 0 = down
- @param link_up_down - Oper state sent on change event, not used in config.
+ @param flags - interface_status flags
+ (only IF_STATUS_API_FLAG_ADMIN_UP used in config)
*/
autoreply define sw_interface_set_flags
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- /* 1 = up, 0 = down */
- u8 admin_up_down;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_if_status_flags_t flags;
};
/** \brief Set interface physical MTU
@@ -49,7 +50,7 @@ autoreply define hw_interface_set_mtu
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u16 mtu;
};
@@ -58,9 +59,8 @@ autoreply define sw_interface_set_mtu
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- /* $$$$ Replace with enum */
- u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
+ vl_api_interface_index_t sw_if_index;
+ u32 mtu[4]; /* vl_api_mtu_proto_t 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
};
/** \brief Set IP4 directed broadcast
@@ -73,26 +73,24 @@ autoreply define sw_interface_set_ip_directed_broadcast
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 enable;
+ vl_api_interface_index_t sw_if_index;
+ bool enable;
};
/** \brief Interface Event generated by want_interface_events
@param client_index - opaque cookie to identify the sender
@param pid - client pid registered to receive notification
@param sw_if_index - index of the interface of the event
- @param admin_up_down - The administrative state; 1 = up, 0 = down
- @param link_up_down - The operational state; 1 = up, 0 = down
+ @param flags - interface_status flags
@param deleted - interface was deleted
*/
define sw_interface_event
{
u32 client_index;
u32 pid;
- u32 sw_if_index;
- u8 admin_up_down;
- u8 link_up_down;
- u8 deleted;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_if_status_flags_t flags;
+ bool deleted;
};
/** \brief Register for interface events
@@ -109,25 +107,20 @@ autoreply define want_interface_events
u32 pid;
};
-/** \brief Interface details structure (fix this)
+/** \brief Interface details structure (fix this)
@param sw_if_index - index of the interface
@param sup_sw_if_index - index of parent interface if any, else same as sw_if_index
- @param l2_address_length - length of the interface's l2 address
@param l2_address - the interface's l2 address
- @param interface_name - name of the interface
+ @param flags - interface_status flags
+ @param type - interface type
@param link_duplex - 1 if half duplex, 2 if full duplex
@param link_speed - value in kbps
@param link_MTU - max. transmission unit
- @param sub_if_id - A number 0-N to uniquely identify this subif on super if
- @param sub_dot1ad - 0 = dot1q, 1 = dot1ad
- @param sub_dot1ah - 1 = dot1ah, 0 = otherwise
+ @param sub_id - A number 0-N to uniquely identify this subif on super if
@param sub_number_of_tags - Number of tags (0 - 2)
@param sub_outer_vlan_id
@param sub_inner_vlan_id
- @param sub_exact_match
- @param sub_default
- @param sub_outer_vlan_id_any
- @param sub_inner_vlan_id_any
+ @param sub_if_flags - sub interface flags
@param vtr_op - vlan tag rewrite operation
@param vtr_push_dot1q
@param vtr_tag1
@@ -137,29 +130,27 @@ autoreply define want_interface_events
@param pbb_b_smac[6] - B-tag local mac address
@param pbb_b_vlanid - B-tag vlanid
@param pbb_i_sid - I-tag service id
+ @param interface_name - name of the interface
+ @param tag - an ascii tag
*/
define sw_interface_details
{
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
/* index of sup interface (e.g. hw interface).
equal to sw_if_index for super hw interface. */
u32 sup_sw_if_index;
/* Layer 2 address, if applicable */
- u32 l2_address_length;
- u8 l2_address[8];
+ vl_api_mac_address_t l2_address;
- /* Interface name */
- u8 interface_name[64];
+ vl_api_if_status_flags_t flags;
- /* 1 = up, 0 = down */
- u8 admin_up_down;
- u8 link_up_down;
+ vl_api_if_type_t type;
/* 1 = half duplex, 2 = full duplex */
- u8 link_duplex;
+ vl_api_link_duplex_t link_duplex;
/* link speed in kbps */
u32 link_speed;
@@ -168,38 +159,34 @@ define sw_interface_details
u16 link_mtu;
/* Per protocol MTUs */
- u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
+ u32 mtu[4]; /* vl_api_mtu_proto_t 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */
/* Subinterface ID. A number 0-N to uniquely identify this subinterface under the super interface */
u32 sub_id;
- /* 0 = dot1q, 1=dot1ad */
- u8 sub_dot1ad;
- /* 1 = dot1h, 1=otherwise */
- u8 sub_dot1ah;
-
/* Number of tags 0-2 */
u8 sub_number_of_tags;
u16 sub_outer_vlan_id;
u16 sub_inner_vlan_id;
- u8 sub_exact_match;
- u8 sub_default;
- u8 sub_outer_vlan_id_any;
- u8 sub_inner_vlan_id_any;
+
+ vl_api_sub_if_flags_t sub_if_flags;
/* vlan tag rewrite state */
u32 vtr_op;
u32 vtr_push_dot1q; // ethertype of first pushed tag is dot1q/dot1ad
u32 vtr_tag1; // first pushed tag
u32 vtr_tag2; // second pushed tag
- u8 tag[64];
/* pbb tag rewrite info */
u16 outer_tag;
- u8 b_dmac[6];
- u8 b_smac[6];
+ vl_api_mac_address_t b_dmac;
+ vl_api_mac_address_t b_smac;
u16 b_vlanid;
u32 i_sid;
+
+ /* Interface name */
+ string interface_name;
+ string tag;
};
/** \brief Request all or filtered subset of sw_interface_details
@@ -216,30 +203,27 @@ define sw_interface_dump
u32 client_index;
u32 context;
vl_api_interface_index_t sw_if_index;
- u8 name_filter_valid;
- u8 name_filter[49];
+ bool name_filter_valid;
+ string name_filter;
};
/** \brief Set or delete one or all ip addresses on a specified interface
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param sw_if_index - index of the interface to add/del addresses
+ @param sw_if_index - index of the interface to add/del addresses
@param is_add - add address if non-zero, else delete
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
@param del_all - if non-zero delete all addresses on the interface
- @param address_length - address length in bytes, 4 for ip4, 16 for ip6
- @param address - array of address bytes
+ @param prefix - address + a prefix length for the implied connected route
*/
autoreply define sw_interface_add_del_address
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_add;
- u8 is_ipv6;
- u8 del_all;
- u8 address_length;
- u8 address[16];
+ vl_api_interface_index_t sw_if_index;
+ bool is_add;
+
+ bool del_all;
+ vl_api_prefix_t prefix;
};
/** \brief Associate the specified interface with a fib table
@@ -253,8 +237,8 @@ autoreply define sw_interface_set_table
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_ipv6;
+ vl_api_interface_index_t sw_if_index;
+ bool is_ipv6;
u32 vrf_id;
};
@@ -267,8 +251,8 @@ define sw_interface_get_table
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_ipv6;
+ vl_api_interface_index_t sw_if_index;
+ bool is_ipv6;
};
/** \brief Reply to get_sw_interface_vrf
@@ -293,9 +277,9 @@ autoreply define sw_interface_set_unnumbered
{
u32 client_index;
u32 context;
- u32 sw_if_index; /* use this intfc address */
- u32 unnumbered_sw_if_index; /* on this interface */
- u8 is_add;
+ vl_api_interface_index_t sw_if_index; /* use this intfc address */
+ vl_api_interface_index_t unnumbered_sw_if_index; /* on this interface */
+ bool is_add;
};
/** \brief Clear interface statistics
@@ -307,7 +291,7 @@ autoreply define sw_interface_clear_stats
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Set / clear software interface tag
@@ -317,13 +301,13 @@ autoreply define sw_interface_clear_stats
@param add_del - 1 = add, 0 = delete
@param tag - an ascii tag
*/
-autoreply define sw_interface_tag_add_del
+autoreply define sw_interface_tag_add_del
{
- u32 client_index;
- u32 context;
- u8 is_add;
- u32 sw_if_index;
- u8 tag[64];
+ u32 client_index;
+ u32 context;
+ bool is_add;
+ vl_api_interface_index_t sw_if_index;
+ string tag;
};
/** \brief Set an interface's MAC address
@@ -334,10 +318,10 @@ autoreply define sw_interface_tag_add_del
*/
autoreply define sw_interface_set_mac_address
{
- u32 client_index;
- u32 context;
- u32 sw_if_index;
- u8 mac_address[6];
+ u32 client_index;
+ u32 context;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_mac_address_t mac_address;
};
/** \brief Get interface's MAC address
@@ -347,9 +331,9 @@ autoreply define sw_interface_set_mac_address
*/
define sw_interface_get_mac_address
{
- u32 client_index;
- u32 context;
- u32 sw_if_index;
+ u32 client_index;
+ u32 context;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Reply for get interface's MAC address request
@@ -359,9 +343,9 @@ define sw_interface_get_mac_address
*/
define sw_interface_get_mac_address_reply
{
- u32 context;
- i32 retval;
- u8 mac_address[6];
+ u32 context;
+ i32 retval;
+ vl_api_mac_address_t mac_address;
};
/** \brief Set an interface's rx-mode
@@ -376,12 +360,12 @@ define sw_interface_get_mac_address_reply
*/
autoreply define sw_interface_set_rx_mode
{
- u32 client_index;
- u32 context;
- u32 sw_if_index;
- u8 queue_id_valid;
- u32 queue_id;
- u8 mode;
+ u32 client_index;
+ u32 context;
+ vl_api_interface_index_t sw_if_index;
+ bool queue_id_valid;
+ u32 queue_id;
+ vl_api_rx_mode_t mode;
};
/** \brief Set an interface's rx-placement
@@ -399,10 +383,10 @@ autoreply define sw_interface_set_rx_placement
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u32 queue_id;
u32 worker_id;
- u8 is_main;
+ bool is_main;
};
/** \brief dump the rx queue placement of interface(s)
@@ -415,7 +399,7 @@ define sw_interface_rx_placement_dump
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief show the interface's queue - thread placement
@@ -437,10 +421,10 @@ define sw_interface_rx_placement_details
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u32 queue_id;
u32 worker_id;
- u8 mode;
+ vl_api_rx_mode_t mode;
};
/* Gross kludge, DGMS */
@@ -448,7 +432,7 @@ autoreply define interface_name_renumber
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u32 new_show_dev_instance;
};
@@ -456,18 +440,10 @@ define create_subif
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u32 sub_id;
- /* These fields map directly onto the subif template */
- u8 no_tags;
- u8 one_tag;
- u8 two_tags;
- u8 dot1ad; // 0 = dot1q, 1=dot1ad
- u8 exact_match;
- u8 default_sub;
- u8 outer_vlan_id_any;
- u8 inner_vlan_id_any;
+ vl_api_sub_if_flags_t sub_if_flags;
u16 outer_vlan_id;
u16 inner_vlan_id;
};
@@ -476,7 +452,7 @@ define create_subif_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Create a new subinterface with the given vlan id
@@ -489,7 +465,7 @@ define create_vlan_subif
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
u32 vlan_id;
};
@@ -502,7 +478,7 @@ define create_vlan_subif_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Delete sub interface request
@@ -513,7 +489,7 @@ define create_vlan_subif_reply
autoreply define delete_subif {
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Create loopback interface request
@@ -525,7 +501,7 @@ define create_loopback
{
u32 client_index;
u32 context;
- u8 mac_address[6];
+ vl_api_mac_address_t mac_address;
};
/** \brief Create loopback interface response
@@ -537,7 +513,7 @@ define create_loopback_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Create loopback interface instance request
@@ -551,8 +527,8 @@ define create_loopback_instance
{
u32 client_index;
u32 context;
- u8 mac_address[6];
- u8 is_specified;
+ vl_api_mac_address_t mac_address;
+ bool is_specified;
u32 user_instance;
};
@@ -565,7 +541,7 @@ define create_loopback_instance_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Delete loopback interface request
@@ -577,7 +553,7 @@ autoreply define delete_loopback
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
/** \brief Enable or disable detailed interface stats
@@ -591,8 +567,8 @@ autoreply define collect_detailed_interface_stats
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 enable_disable;
+ vl_api_interface_index_t sw_if_index;
+ bool enable_disable;
};
/*
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index fb1982ae8b0..9a695ed5bdd 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -31,6 +31,11 @@
#include <vnet/fib/fib_api.h>
#include <vnet/mfib/mfib_table.h>
+#include <vlibapi/api_types.h>
+
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
@@ -87,7 +92,9 @@ vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp)
VALIDATE_SW_IF_INDEX (mp);
- flags = mp->admin_up_down ? VNET_SW_INTERFACE_FLAG_ADMIN_UP : 0;
+ flags =
+ ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
+ VNET_SW_INTERFACE_FLAG_ADMIN_UP : 0;
error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
if (error)
@@ -193,13 +200,40 @@ send_sw_interface_details (vpe_api_main_t * am,
vnet_hw_interface_t *hi =
vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index);
- vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
- clib_memset (mp, 0, sizeof (*mp));
+ uint32_t if_name_len = strlen ((char *) interface_name);
+ u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index);
+ uint32_t tag_len = 0;
+ if (tag != NULL)
+ tag_len = strlen ((char *) tag);
+ vl_api_sw_interface_details_t *mp =
+ vl_msg_api_alloc (sizeof (*mp) + if_name_len + tag_len);
+ clib_memset (mp, 0, sizeof (*mp) + if_name_len + tag_len);
mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
mp->sw_if_index = ntohl (swif->sw_if_index);
mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
- mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
- mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
+
+ mp->flags |= (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
+ IF_STATUS_API_FLAG_ADMIN_UP : 0;
+ mp->flags |= (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ?
+ IF_STATUS_API_FLAG_LINK_UP : 0;
+ mp->flags = ntohl (mp->flags);
+
+ switch (swif->type)
+ {
+ case VNET_SW_INTERFACE_TYPE_SUB:
+ mp->type = IF_API_TYPE_SUB;
+ break;
+ case VNET_SW_INTERFACE_TYPE_P2P:
+ mp->type = IF_API_TYPE_P2P;
+ break;
+ case VNET_SW_INTERFACE_TYPE_PIPE:
+ mp->type = IF_API_TYPE_PIPE;
+ break;
+ default:
+ mp->type = IF_API_TYPE_HARDWARE;
+ }
+ mp->type = ntohl (mp->type);
+
mp->link_duplex = ((hi->flags & VNET_HW_INTERFACE_FLAG_DUPLEX_MASK) >>
VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT);
mp->link_speed = ntohl (hi->link_speed);
@@ -211,9 +245,6 @@ send_sw_interface_details (vpe_api_main_t * am,
mp->context = context;
- strncpy ((char *) mp->interface_name,
- (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
-
/* Send the L2 address for ethernet physical intfcs */
if (swif->sup_sw_if_index == swif->sw_if_index
&& hi->hw_class_index == ethernet_hw_interface_class.index)
@@ -223,42 +254,38 @@ send_sw_interface_details (vpe_api_main_t * am,
ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
- clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
- mp->l2_address_length = ntohl (sizeof (ei->address));
+ mac_address_encode ((mac_address_t *) ei->address, mp->l2_address);
}
else if (swif->sup_sw_if_index != swif->sw_if_index)
{
vnet_sub_interface_t *sub = &swif->sub;
mp->sub_id = ntohl (sub->id);
- mp->sub_dot1ad = sub->eth.flags.dot1ad;
mp->sub_number_of_tags =
sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
- mp->sub_exact_match = sub->eth.flags.exact_match;
- mp->sub_default = sub->eth.flags.default_sub;
- mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
- mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
- }
+ mp->sub_if_flags =
+ ntohl (sub->eth.raw_flags & SUB_IF_API_FLAG_MASK_VNET);
- /* vlan tag rewrite data */
- u32 vtr_op = L2_VTR_DISABLED;
- u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
+ /* vlan tag rewrite data */
+ u32 vtr_op = L2_VTR_DISABLED;
+ u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
- if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
- &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
- {
- // error - default to disabled
- mp->vtr_op = ntohl (L2_VTR_DISABLED);
- clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
- swif->sw_if_index);
- }
- else
- {
- mp->vtr_op = ntohl (vtr_op);
- mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
- mp->vtr_tag1 = ntohl (vtr_tag1);
- mp->vtr_tag2 = ntohl (vtr_tag2);
+ if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
+ &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
+ {
+ // error - default to disabled
+ mp->vtr_op = ntohl (L2_VTR_DISABLED);
+ clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
+ swif->sw_if_index);
+ }
+ else
+ {
+ mp->vtr_op = ntohl (vtr_op);
+ mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
+ mp->vtr_tag1 = ntohl (vtr_tag1);
+ mp->vtr_tag2 = ntohl (vtr_tag2);
+ }
}
/* pbb tag rewrite data */
@@ -272,18 +299,19 @@ send_sw_interface_details (vpe_api_main_t * am,
if (!l2pbb_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
&pbb_vtr_op, &outer_tag, &eth_hdr, &b_vlanid, &i_sid))
{
- mp->sub_dot1ah = 1;
- clib_memcpy (mp->b_dmac, eth_hdr.dst_address,
- sizeof (eth_hdr.dst_address));
- clib_memcpy (mp->b_smac, eth_hdr.src_address,
- sizeof (eth_hdr.src_address));
+ mp->sub_if_flags |= ntohl (SUB_IF_API_FLAG_DOT1AH);
+ mac_address_encode ((mac_address_t *) eth_hdr.dst_address, mp->b_dmac);
+ mac_address_encode ((mac_address_t *) eth_hdr.src_address, mp->b_smac);
mp->b_vlanid = b_vlanid;
mp->i_sid = i_sid;
}
- u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index);
- if (tag)
- strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
+ char *p = (char *) &mp->interface_name;
+ p +=
+ vl_api_to_api_string (if_name_len, (char *) interface_name,
+ (vl_api_string_t *) p);
+ if (tag != NULL)
+ vl_api_to_api_string (tag_len, (char *) tag, (vl_api_string_t *) p);
vl_api_send_msg (rp, (u8 *) mp);
}
@@ -327,8 +355,8 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp)
if (mp->name_filter_valid)
{
- mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
- filter = format (0, "%s%c", mp->name_filter, 0);
+ filter =
+ format (0, "%s%c", vl_api_from_api_string (&mp->name_filter), 0);
}
char *strcasestr (char *, char *); /* lnx hdr file botch */
@@ -362,6 +390,7 @@ static void
int rv = 0;
u32 is_del;
clib_error_t *error = 0;
+ ip46_address_t address;
VALIDATE_SW_IF_INDEX (mp);
@@ -370,14 +399,14 @@ static void
if (mp->del_all)
ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index));
- else if (mp->is_ipv6)
+ else if (ip_address_decode (&mp->prefix.address, &address) == IP46_TYPE_IP6)
error = ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
- (void *) mp->address,
- mp->address_length, is_del);
+ (void *) &address.ip6,
+ mp->prefix.len, is_del);
else
error = ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
- (void *) mp->address,
- mp->address_length, is_del);
+ (void *) &address.ip4,
+ mp->prefix.len, is_del);
if (error)
{
@@ -707,9 +736,13 @@ send_sw_interface_event (vpe_api_main_t * am,
mp->sw_if_index = ntohl (sw_if_index);
mp->client_index = reg->client_index;
mp->pid = reg->client_pid;
- mp->admin_up_down = events & API_ADMIN_UP_EVENT ? 1 : 0;
- mp->link_up_down = events & API_LINK_STATE_UP_EVENT ? 1 : 0;
- mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? 1 : 0;
+ mp->flags = 0;
+ mp->flags |= (events & API_ADMIN_UP_EVENT) ?
+ IF_STATUS_API_FLAG_ADMIN_UP : 0;
+ mp->flags |= (events & API_LINK_STATE_UP_EVENT) ?
+ IF_STATUS_API_FLAG_LINK_UP : 0;
+ mp->flags = ntohl (mp->flags);
+ mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? true : false;
vl_api_send_msg (vl_reg, (u8 *) mp);
}
@@ -851,14 +884,13 @@ static void vl_api_sw_interface_tag_add_del_t_handler
if (mp->is_add)
{
- if (mp->tag[0] == 0)
+ if (vl_api_from_api_string (&mp->tag)[0] == 0)
{
rv = VNET_API_ERROR_INVALID_VALUE;
goto out;
}
- mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
- tag = format (0, "%s%c", mp->tag, 0);
+ tag = format (0, "%s%c", vl_api_from_api_string (&mp->tag), 0);
vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
}
else
@@ -878,12 +910,14 @@ static void vl_api_sw_interface_set_mac_address_t_handler
vnet_sw_interface_t *si;
clib_error_t *error;
int rv = 0;
+ mac_address_t mac;
VALIDATE_SW_IF_INDEX (mp);
si = vnet_get_sw_interface (vnm, sw_if_index);
- error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index,
- mp->mac_address);
+ mac_address_decode (mp->mac_address, &mac);
+ error =
+ vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, (u8 *) & mac);
if (error)
{
rv = VNET_API_ERROR_UNIMPLEMENTED;
@@ -923,7 +957,7 @@ static void vl_api_sw_interface_get_mac_address_t_handler
rmp->context = mp->context;
rmp->retval = htonl (rv);
if (!rv && eth_if)
- memcpy (rmp->mac_address, eth_if->address, 6);
+ mac_address_encode ((mac_address_t *) eth_if->address, rmp->mac_address);
vl_api_send_msg (reg, (u8 *) rmp);
}
@@ -948,7 +982,10 @@ static void vl_api_sw_interface_set_rx_mode_t_handler
error = set_hw_interface_change_rx_mode (vnm, si->hw_if_index,
mp->queue_id_valid,
- ntohl (mp->queue_id), mp->mode);
+ ntohl (mp->queue_id),
+ (vnet_hw_interface_rx_mode)
+ mp->mode);
+
if (error)
{
rv = VNET_API_ERROR_UNIMPLEMENTED;
@@ -1215,14 +1252,7 @@ vl_api_create_subif_t_handler (vl_api_create_subif_t * mp)
template.flood_class = VNET_FLOOD_CLASS_NORMAL;
template.sup_sw_if_index = sw_if_index;
template.sub.id = sub_id;
- template.sub.eth.flags.no_tags = mp->no_tags;
- template.sub.eth.flags.one_tag = mp->one_tag;
- template.sub.eth.flags.two_tags = mp->two_tags;
- template.sub.eth.flags.dot1ad = mp->dot1ad;
- template.sub.eth.flags.exact_match = mp->exact_match;
- template.sub.eth.flags.default_sub = mp->default_sub;
- template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
- template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
+ template.sub.eth.raw_flags = ntohl (mp->sub_if_flags);
template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
@@ -1286,8 +1316,10 @@ vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
vl_api_create_loopback_reply_t *rmp;
u32 sw_if_index;
int rv;
+ mac_address_t mac;
- rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0);
+ mac_address_decode (mp->mac_address, &mac);
+ rv = vnet_create_loopback_interface (&sw_if_index, (u8 *) & mac, 0, 0);
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
@@ -1305,8 +1337,10 @@ static void vl_api_create_loopback_instance_t_handler
u8 is_specified = mp->is_specified;
u32 user_instance = ntohl (mp->user_instance);
int rv;
+ mac_address_t mac;
- rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address,
+ mac_address_decode (mp->mac_address, &mac);
+ rv = vnet_create_loopback_interface (&sw_if_index, (u8 *) & mac,
is_specified, user_instance);
/* *INDENT-OFF* */
diff --git a/src/vnet/interface_types.api b/src/vnet/interface_types.api
index f6fb4219ef8..a6178396e79 100644
--- a/src/vnet/interface_types.api
+++ b/src/vnet/interface_types.api
@@ -16,3 +16,59 @@
typedef u32 interface_index;
+enum if_status_flags
+{
+ IF_STATUS_API_FLAG_ADMIN_UP = 1,
+ IF_STATUS_API_FLAG_LINK_UP = 2,
+};
+
+/* Per protocol MTU */
+enum mtu_proto
+{
+ MTU_PROTO_API_L3, /* Default payload MTU (without L2 headers) */
+ MTU_PROTO_API_IP4, /* Per-protocol MTUs overriding default */
+ MTU_PROTO_API_IP6,
+ MTU_PROTO_API_MPLS,
+ MTU_PROTO_API_N,
+};
+
+enum link_duplex
+{
+ LINK_DUPLEX_API_UNKNOWN = 0,
+ LINK_DUPLEX_API_HALF = 1,
+ LINK_DUPLEX_API_FULL = 2,
+};
+
+enum sub_if_flags
+{
+ SUB_IF_API_FLAG_NO_TAGS = 1,
+ SUB_IF_API_FLAG_ONE_TAG = 2,
+ SUB_IF_API_FLAG_TWO_TAGS = 4,
+ SUB_IF_API_FLAG_DOT1AD = 8,
+ SUB_IF_API_FLAG_EXACT_MATCH = 16,
+ SUB_IF_API_FLAG_DEFAULT = 32,
+ SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY = 64,
+ SUB_IF_API_FLAG_INNER_VLAN_ID_ANY = 128,
+ SUB_IF_API_FLAG_MASK_VNET = 254, /* use with vnet_sub_interface_t raw_flags */
+ SUB_IF_API_FLAG_DOT1AH = 256,
+};
+
+enum rx_mode
+{
+ RX_MODE_API_UNKNOWN = 0,
+ RX_MODE_API_POLLING,
+ RX_MODE_API_INTERRUPT,
+ RX_MODE_API_ADAPTIVE,
+ RX_MODE_API_DEFAULT,
+};
+
+enum if_type
+{
+ /* A hw interface. */
+ IF_API_TYPE_HARDWARE,
+
+ /* A sub-interface. */
+ IF_API_TYPE_SUB,
+ IF_API_TYPE_P2P,
+ IF_API_TYPE_PIPE,
+};
diff --git a/src/vnet/ip/ip_types_api.h b/src/vnet/ip/ip_types_api.h
index fc7a416a06d..09ca0e6e1a0 100644
--- a/src/vnet/ip/ip_types_api.h
+++ b/src/vnet/ip/ip_types_api.h
@@ -23,6 +23,7 @@
#include <vnet/ip/ip.h>
#include <vnet/fib/fib_types.h>
#include <vnet/mfib/mfib_types.h>
+#include <vlibapi/api_types.h>
/**
* Forward declarations so we need not #include the API definitions here
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index c75837209d5..428e2883af2 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -112,7 +112,7 @@ static void *vl_api_sw_interface_set_flags_t_print
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
- if (mp->admin_up_down)
+ if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
s = format (s, "admin-up ");
else
s = format (s, "admin-down ");
@@ -160,12 +160,12 @@ static void *vl_api_sw_interface_event_t_print
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
- if (mp->admin_up_down)
+ if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
s = format (s, "admin-up ");
else
s = format (s, "admin-down ");
- if (mp->link_up_down)
+ if (ntohl (mp->flags) & IF_STATUS_API_FLAG_LINK_UP)
s = format (s, "link-up");
else
s = format (s, "link-down");
@@ -180,17 +180,18 @@ static void *vl_api_sw_interface_add_del_address_t_print
(vl_api_sw_interface_add_del_address_t * mp, void *handle)
{
u8 *s;
+ ip46_address_t address;
s = format (0, "SCRIPT: sw_interface_add_del_address ");
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
- if (mp->is_ipv6)
+ if (ip_address_decode (&mp->prefix.address, &address) == IP46_TYPE_IP6)
s = format (s, "%U/%d ", format_ip6_address,
- (ip6_address_t *) mp->address, mp->address_length);
+ (ip6_address_t *) & address.ip6, mp->prefix.len);
else
s = format (s, "%U/%d ", format_ip4_address,
- (ip4_address_t *) mp->address, mp->address_length);
+ (ip4_address_t *) & address.ip4, mp->prefix.len);
if (mp->is_add == 0)
s = format (s, "del ");
@@ -970,15 +971,15 @@ static void *vl_api_create_vlan_subif_t_print
FINISH;
}
-#define foreach_create_subif_bit \
-_(no_tags) \
-_(one_tag) \
-_(two_tags) \
-_(dot1ad) \
-_(exact_match) \
-_(default_sub) \
-_(outer_vlan_id_any) \
-_(inner_vlan_id_any)
+#define foreach_create_subif_flag \
+_(0, "no_tags") \
+_(1, "one_tag") \
+_(2, "two_tags") \
+_(3, "dot1ad") \
+_(4, "exact_match") \
+_(5, "default_sub") \
+_(6, "outer_vlan_id_any") \
+_(7, "inner_vlan_id_any")
static void *vl_api_create_subif_t_print
(vl_api_create_subif_t * mp, void *handle)
@@ -997,8 +998,8 @@ static void *vl_api_create_subif_t_print
if (mp->inner_vlan_id)
s = format (s, "inner_vlan_id %d ", ntohs (mp->inner_vlan_id));
-#define _(a) if (mp->a) s = format (s, "%s ", #a);
- foreach_create_subif_bit;
+#define _(a,b) if (mp->sub_if_flags & (1 << a)) s = format (s, "%s ", b);
+ foreach_create_subif_flag;
#undef _
FINISH;
diff --git a/test/ext/vapi_c_test.c b/test/ext/vapi_c_test.c
index 0b22fff1706..725f5c30407 100644
--- a/test/ext/vapi_c_test.c
+++ b/test/ext/vapi_c_test.c
@@ -514,7 +514,7 @@ sw_interface_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
{
ck_assert (NULL != reply);
printf ("Interface dump entry: [%u]: %s\n", reply->sw_if_index,
- reply->interface_name);
+ reply->interface_name.buf);
size_t i = 0;
for (i = 0; i < dctx->num_ifs; ++i)
{
@@ -577,8 +577,8 @@ START_TEST (test_loopbacks_1)
clib_memset (&seen, 0, sizeof (seen));
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb,
@@ -609,8 +609,8 @@ START_TEST (test_loopbacks_1)
clib_memset (&seen, 0, sizeof (seen));
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
@@ -734,8 +734,8 @@ START_TEST (test_loopbacks_2)
sw_interface_dump_ctx dctx = { false, num_ifs, sw_if_indexes, seen, 0 };
vapi_msg_sw_interface_dump *dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
@@ -775,8 +775,8 @@ START_TEST (test_loopbacks_2)
dctx.last_called = false;
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
diff --git a/test/ext/vapi_cpp_test.cpp b/test/ext/vapi_cpp_test.cpp
index 68366af2ac8..46a2c0ec2f1 100644
--- a/test/ext/vapi_cpp_test.cpp
+++ b/test/ext/vapi_cpp_test.cpp
@@ -151,7 +151,7 @@ START_TEST (test_loopbacks_1)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -193,7 +193,7 @@ START_TEST (test_loopbacks_1)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -311,7 +311,7 @@ START_TEST (test_loopbacks_2)
Sw_interface_dump d (con, std::ref (swdcb));
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -340,7 +340,7 @@ START_TEST (test_loopbacks_2)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
diff --git a/test/remote_test.py b/test/remote_test.py
index cd2e46fe219..9c825ccf755 100644
--- a/test/remote_test.py
+++ b/test/remote_test.py
@@ -3,14 +3,13 @@
import inspect
import os
import unittest
+from framework import VppTestCase
from multiprocessing import Process, Pipe
from pickle import dumps
-
import six
from six import moves
-
-from framework import VppTestCase
-from aenum import Enum
+import sys
+from aenum import IntEnum, IntFlag
class SerializableClassCopy(object):
@@ -270,7 +269,7 @@ class RemoteClass(Process):
if type(obj) is tuple:
rv = tuple(rv)
return rv
- elif (isinstance(obj, Enum)):
+ elif (isinstance(obj, IntEnum) or isinstance(obj, IntFlag)):
return obj.value
else:
return self._make_obj_serializable(obj)
diff --git a/test/test_bond.py b/test/test_bond.py
index d1ae77ad3f5..60ee33c0356 100644
--- a/test/test_bond.py
+++ b/test/test_bond.py
@@ -9,6 +9,7 @@ from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
from vpp_bond_interface import VppBondInterface
from vpp_papi import MACAddress
+from vpp_ip import VppIpPrefix
class TestBondInterface(VppTestCase):
@@ -70,10 +71,9 @@ class TestBondInterface(VppTestCase):
mac_address=mac)
bond0.add_vpp_config()
bond0.admin_up()
- bond0_addr = socket.inet_pton(socket.AF_INET, "10.10.10.1")
- self.vapi.sw_interface_add_del_address(sw_if_index=bond0.sw_if_index,
- address=bond0_addr,
- address_length=24)
+ self.vapi.sw_interface_add_del_address(
+ sw_if_index=bond0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.1", 24).encode())
self.pg2.config_ip4()
self.pg2.resolve_arp()
diff --git a/test/test_container.py b/test/test_container.py
index 139dfcfbcaf..1e3ec40a2f7 100644
--- a/test/test_container.py
+++ b/test/test_container.py
@@ -82,11 +82,11 @@ class ContainerIntegrationTestCase(VppTestCase):
for i in range(2):
intf = self.lo_interfaces[i]
intf.admin_up()
- intf._local_ip4 = self.pg_interfaces[i].remote_ip4
- intf._local_ip4_prefix_len = 32
+ intf.local_ip4 = self.pg_interfaces[i].remote_ip4
+ intf.local_ip4_prefix_len = 32
intf.config_ip4()
- intf._local_ip6 = self.pg_interfaces[i].remote_ip6
- intf._local_ip6_prefix_len = 128
+ intf.local_ip6 = self.pg_interfaces[i].remote_ip6
+ intf.local_ip6_prefix_len = 128
intf.config_ip6()
def test_0110_basic_conn_test(self):
diff --git a/test/test_interface_crud.py b/test/test_interface_crud.py
index ae30a6d47ea..4711c2f7931 100644
--- a/test/test_interface_crud.py
+++ b/test/test_interface_crud.py
@@ -85,7 +85,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# create
loopbacks = self.create_loopback_interfaces(20)
for i in loopbacks:
- i.local_ip4_prefix_len = 32
+ i.local_ip4_prefix.len = 32
i.config_ip4()
i.admin_up()
@@ -127,7 +127,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# create
loopbacks = self.create_loopback_interfaces(20)
for i in loopbacks:
- i.local_ip4_prefix_len = 32
+ i.local_ip4_prefix.len = 32
i.config_ip4()
i.admin_up()
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 0923771200e..60bc023a280 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -13,6 +13,7 @@ from six import moves
from framework import VppTestCase, VppTestRunner
from util import ppp
+from vpp_ip import VppIpPrefix
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
VppMplsTable, VppIpTable, FibPathType, find_route, \
@@ -920,8 +921,8 @@ class TestIPSubNets(VppTestCase):
ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=16)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 16).encode())
pn = (Ether(src=self.pg1.remote_mac,
dst=self.pg1.local_mac) /
@@ -939,8 +940,9 @@ class TestIPSubNets(VppTestCase):
# remove the sub-net and we are forwarding via the cover again
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=16, is_add=0)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 16).encode(), is_add=0)
+
self.pg1.add_stream(pn)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -957,8 +959,8 @@ class TestIPSubNets(VppTestCase):
ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=31)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 31).encode())
pn = (Ether(src=self.pg1.remote_mac,
dst=self.pg1.local_mac) /
@@ -974,8 +976,9 @@ class TestIPSubNets(VppTestCase):
# remove the sub-net and we are forwarding via the cover again
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=31, is_add=0)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 31).encode(), is_add=0)
+
self.pg1.add_stream(pn)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
diff --git a/test/test_memif.py b/test/test_memif.py
index aae5b3c1efb..6413cfdbf20 100644
--- a/test/test_memif.py
+++ b/test/test_memif.py
@@ -209,14 +209,14 @@ class TestMemif(VppTestCase):
pkts = []
for i in range(num):
pkt = (Ether(dst=pg.local_mac, src=pg.remote_mac) /
- IP(src=pg.remote_ip4, dst=memif.ip4_addr) /
+ IP(src=pg.remote_ip4, dst=memif.ip_prefix.address) /
ICMP(id=memif.if_id, type='echo-request', seq=i))
pkts.append(pkt)
return pkts
def _verify_icmp(self, pg, memif, rx, seq):
ip = rx[IP]
- self.assertEqual(ip.src, memif.ip4_addr)
+ self.assertEqual(ip.src, memif.ip_prefix.address)
self.assertEqual(ip.dst, pg.remote_ip4)
self.assertEqual(ip.proto, 1)
icmp = rx[ICMP]
@@ -250,7 +250,7 @@ class TestMemif(VppTestCase):
# add routing to remote vpp
route = VppIpRoute(self.remote_test, self.pg0._local_ip4_subnet, 24,
- [VppRoutePath(memif.ip4_addr, 0xffffffff)],
+ [VppRoutePath(memif.ip_prefix.address, 0xffffffff)],
register=False)
route.add_vpp_config()
diff --git a/test/test_nat.py b/test/test_nat.py
index 773eb51d4ee..a64b5709c72 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -27,6 +27,7 @@ from io import BytesIO
from vpp_papi import VppEnum
from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathType
from vpp_neighbor import VppNeighbor
+from vpp_ip import VppIpAddress, VppIpPrefix
from scapy.all import bind_layers, Packet, ByteEnumField, ShortField, \
IPField, IntField, LongField, XByteField, FlagsField, FieldLenField, \
PacketListField
@@ -1504,16 +1505,16 @@ class TestNAT44(MethodHolder):
cls.vapi.ip_table_add_del(is_add=1, table_id=10)
cls.vapi.ip_table_add_del(is_add=1, table_id=20)
- cls.pg4._local_ip4 = "172.16.255.1"
- cls.pg4._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg4._local_ip4 = VppIpPrefix("172.16.255.1",
+ cls.pg4.local_ip4_prefix.len)
cls.pg4._remote_hosts[0]._ip4 = "172.16.255.2"
cls.pg4.set_table_ip4(10)
- cls.pg5._local_ip4 = "172.17.255.3"
- cls.pg5._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg5._local_ip4 = VppIpPrefix("172.17.255.3",
+ cls.pg5.local_ip4_prefix.len)
cls.pg5._remote_hosts[0]._ip4 = "172.17.255.4"
cls.pg5.set_table_ip4(10)
- cls.pg6._local_ip4 = "172.16.255.1"
- cls.pg6._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg6._local_ip4 = VppIpPrefix("172.16.255.1",
+ cls.pg6.local_ip4_prefix.len)
cls.pg6._remote_hosts[0]._ip4 = "172.16.255.2"
cls.pg6.set_table_ip4(20)
for i in cls.overlapping_interfaces:
@@ -1526,10 +1527,10 @@ class TestNAT44(MethodHolder):
cls.pg9.generate_remote_hosts(2)
cls.pg9.config_ip4()
- ip_addr_n = socket.inet_pton(socket.AF_INET, "10.0.0.1")
cls.vapi.sw_interface_add_del_address(
- sw_if_index=cls.pg9.sw_if_index, address=ip_addr_n,
- address_length=24)
+ sw_if_index=cls.pg9.sw_if_index,
+ prefix=VppIpPrefix("10.0.0.1", 24).encode())
+
cls.pg9.admin_up()
cls.pg9.resolve_arp()
cls.pg9._remote_hosts[1]._ip4 = cls.pg9._remote_hosts[0]._ip4
@@ -4428,10 +4429,10 @@ class TestNAT44EndpointDependent(MethodHolder):
cls.pg4.generate_remote_hosts(2)
cls.pg4.config_ip4()
- ip_addr_n = socket.inet_pton(socket.AF_INET, "10.0.0.1")
cls.vapi.sw_interface_add_del_address(
- sw_if_index=cls.pg4.sw_if_index, address=ip_addr_n,
- address_length=24)
+ sw_if_index=cls.pg4.sw_if_index,
+ prefix=VppIpPrefix("10.0.0.1", 24).encode())
+
cls.pg4.admin_up()
cls.pg4.resolve_arp()
cls.pg4._remote_hosts[1]._ip4 = cls.pg4._remote_hosts[0]._ip4
@@ -4440,9 +4441,8 @@ class TestNAT44EndpointDependent(MethodHolder):
zero_ip4n = socket.inet_pton(socket.AF_INET, "0.0.0.0")
cls.vapi.ip_table_add_del(is_add=1, table_id=1)
- cls.pg5._local_ip4 = "10.1.1.1"
- cls.pg5._local_ip4n = socket.inet_pton(socket.AF_INET,
- cls.pg5.local_ip4)
+ cls.pg5._local_ip4 = VppIpPrefix("10.1.1.1",
+ cls.pg5.local_ip4_prefix.len)
cls.pg5._remote_hosts[0]._ip4 = "10.1.1.2"
cls.pg5._remote_hosts[0]._ip4n = socket.inet_pton(
socket.AF_INET, cls.pg5.remote_ip4)
@@ -4456,9 +4456,8 @@ class TestNAT44EndpointDependent(MethodHolder):
register=False)
r1.add_vpp_config()
- cls.pg6._local_ip4 = "10.1.2.1"
- cls.pg6._local_ip4n = socket.inet_pton(socket.AF_INET,
- cls.pg6.local_ip4)
+ cls.pg6._local_ip4 = VppIpPrefix("10.1.2.1",
+ cls.pg6.local_ip4_prefix.len)
cls.pg6._remote_hosts[0]._ip4 = "10.1.2.2"
cls.pg6._remote_hosts[0]._ip4n = socket.inet_pton(
socket.AF_INET, cls.pg6.remote_ip4)
diff --git a/test/test_span.py b/test/test_span.py
index e4b0d0ad2b4..c67bc7b8587 100644
--- a/test/test_span.py
+++ b/test/test_span.py
@@ -235,7 +235,7 @@ class TestSpan(VppTestCase):
self.sub_if.admin_up()
self.vapi.sw_interface_set_flags(self.vxlan.sw_if_index,
- admin_up_down=1)
+ flags=1)
self.bridge(self.vxlan.sw_if_index, is_add=1)
# Create bi-directional cross-connects between pg0 subif and pg1
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index e8100d362ec..1e047f5f700 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -6,7 +6,8 @@ import six
from six import moves
from util import Host, mk_ll_addr
-from vpp_papi import mac_ntop
+from vpp_papi import mac_ntop, VppEnum
+from vpp_ip import VppIpAddress, VppIpPrefix
from ipaddress import IPv4Network
try:
@@ -43,22 +44,33 @@ class VppInterface(object):
return self._remote_addr
@property
- def local_addr_n(self):
- return self._local_addr_n
+ def local_ip4(self):
+ """Local IPv4 address on VPP interface (string)."""
+ return self._local_ip4.address
+
+ @local_ip4.setter
+ def local_ip4(self, value):
+ self._local_ip4.address = value
@property
- def remote_addr_n(self):
- return self._remote_addr_n
+ def local_ip4_prefix_len(self):
+ """Local IPv4 prefix length """
+ return self._local_ip4.len
+
+ @local_ip4_prefix_len.setter
+ def local_ip4_prefix_len(self, value):
+ self._local_ip4.len = value
@property
- def local_ip4(self):
- """Local IPv4 address on VPP interface (string)."""
+ def local_ip4_prefix(self):
+ """Local IPv4 prefix """
return self._local_ip4
@property
def local_ip4n(self):
+ """DEPRECATED """
"""Local IPv4 address - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET, self._local_ip4)
+ return socket.inet_pton(socket.AF_INET, self._local_ip4.address)
@property
def remote_ip4(self):
@@ -67,18 +79,38 @@ class VppInterface(object):
@property
def remote_ip4n(self):
- """IPv4 address of remote peer - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET, self.remote_ip4)
+ """DEPRECATED """
+ """Local IPv6 address - raw, suitable as API parameter."""
+ return socket.inet_pton(socket.AF_INET, self._remote_hosts[0].ip4)
@property
def local_ip6(self):
"""Local IPv6 address on VPP interface (string)."""
+ return self._local_ip6.address
+
+ @local_ip6.setter
+ def local_ip6(self, value):
+ self._local_ip6.address = value
+
+ @property
+ def local_ip6_prefix_len(self):
+ """Local IPv6 prefix length """
+ return self._local_ip6.len
+
+ @local_ip6_prefix_len.setter
+ def local_ip6_prefix_len(self, value):
+ self._local_ip6.len = value
+
+ @property
+ def local_ip6_prefix(self):
+ """Local IPv6 prefix """
return self._local_ip6
@property
def local_ip6n(self):
+ """DEPRECATED """
"""Local IPv6 address - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET6, self.local_ip6)
+ return socket.inet_pton(socket.AF_INET6, self._local_ip6.address)
@property
def remote_ip6(self):
@@ -87,18 +119,20 @@ class VppInterface(object):
@property
def remote_ip6n(self):
- """IPv6 address of remote peer - raw, suitable as API parameter"""
- return socket.inet_pton(socket.AF_INET6, self.remote_ip6)
+ """DEPRECATED """
+ """Local IPv6 address - raw, suitable as API parameter."""
+ return socket.inet_pton(socket.AF_INET6, self._remote_hosts[0].ip6)
@property
def local_ip6_ll(self):
"""Local IPv6 link-local address on VPP interface (string)."""
- return self._local_ip6_ll
+ return self._local_ip6_ll.address
@property
def local_ip6n_ll(self):
- """Local IPv6 link-local address - raw, suitable as API parameter."""
- return self._local_ip6n_ll
+ """DEPRECATED """
+ """Local IPv6 link-local address on VPP interface (string)."""
+ return socket.inet_pton(socket.AF_INET6, self._local_ip6_ll.address)
@property
def remote_ip6_ll(self):
@@ -108,9 +142,9 @@ class VppInterface(object):
@property
def remote_ip6n_ll(self):
- """Link-local IPv6 address of remote peer
- - raw, suitable as API parameter"""
- return self._remote_ip6n_ll
+ """DEPRECATED """
+ """Local IPv6 link-local address on VPP interface (string)."""
+ return socket.inet_pton(socket.AF_INET6, self._remote_ip6_ll)
@property
def name(self):
@@ -199,7 +233,7 @@ class VppInterface(object):
def set_mac(self, mac):
self._local_mac = str(mac)
- self._local_ip6_ll = mk_ll_addr(self._local_mac)
+ self._local_ip6_ll = VppIpAddress(mk_ll_addr(self._local_mac))
self.test.vapi.sw_interface_set_mac_address(
self.sw_if_index, mac.packed)
@@ -208,39 +242,27 @@ class VppInterface(object):
self.generate_remote_hosts()
- self._local_ip4 = "172.16.%u.1" % self.sw_if_index
- self._local_ip4n = socket.inet_pton(socket.AF_INET, self.local_ip4)
+ self._local_ip4 = VppIpPrefix("172.16.%u.1" % self.sw_if_index, 24)
self._local_ip4_subnet = "172.16.%u.0" % self.sw_if_index
- self._local_ip4n_subnet = socket.inet_pton(socket.AF_INET,
- self._local_ip4_subnet)
self._local_ip4_bcast = "172.16.%u.255" % self.sw_if_index
- self._local_ip4n_bcast = socket.inet_pton(socket.AF_INET,
- self._local_ip4_bcast)
- self.local_ip4_prefix_len = 24
self.has_ip4_config = False
self.ip4_table_id = 0
- self._local_ip6 = "fd01:%x::1" % self.sw_if_index
- self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6)
- self.local_ip6_prefix_len = 64
+ self._local_ip6 = VppIpPrefix("fd01:%x::1" % self.sw_if_index, 64)
self.has_ip6_config = False
self.ip6_table_id = 0
self._local_addr = {socket.AF_INET: self.local_ip4,
socket.AF_INET6: self.local_ip6}
- self._local_addr_n = {socket.AF_INET: self.local_ip4n,
- socket.AF_INET6: self.local_ip6n}
self._remote_addr = {socket.AF_INET: self.remote_ip4,
socket.AF_INET6: self.remote_ip6}
- self._remote_addr_n = {socket.AF_INET: self.remote_ip4n,
- socket.AF_INET6: self.remote_ip6n}
r = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index)
for intf in r:
if intf.sw_if_index == self.sw_if_index:
self._name = intf.interface_name.split(b'\0',
1)[0].decode('utf8')
- self._local_mac = mac_ntop(intf.l2_address)
+ self._local_mac = bytes(intf.l2_address)
self._dump = intf
break
else:
@@ -248,18 +270,13 @@ class VppInterface(object):
"Could not find interface with sw_if_index %d "
"in interface dump %s" %
(self.sw_if_index, moves.reprlib.repr(r)))
- self._local_ip6_ll = mk_ll_addr(self.local_mac)
- self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6,
- self.local_ip6_ll)
+ self._local_ip6_ll = VppIpAddress(mk_ll_addr(self.local_mac))
self._remote_ip6_ll = mk_ll_addr(self.remote_mac)
- self._remote_ip6n_ll = socket.inet_pton(socket.AF_INET6,
- self.remote_ip6_ll)
def config_ip4(self):
"""Configure IPv4 address on the VPP interface."""
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip4n,
- address_length=self.local_ip4_prefix_len)
+ sw_if_index=self.sw_if_index, prefix=self._local_ip4.encode())
self.has_ip4_config = True
def unconfig_ip4(self):
@@ -267,8 +284,8 @@ class VppInterface(object):
try:
if self.has_ip4_config:
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip4n,
- address_length=self.local_ip4_prefix_len, is_add=0)
+ sw_if_index=self.sw_if_index,
+ prefix=self._local_ip4.encode(), is_add=0)
except AttributeError:
self.has_ip4_config = False
self.has_ip4_config = False
@@ -286,8 +303,7 @@ class VppInterface(object):
def config_ip6(self):
"""Configure IPv6 address on the VPP interface."""
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self._local_ip6n,
- address_length=self.local_ip6_prefix_len, is_ipv6=1)
+ sw_if_index=self.sw_if_index, prefix=self._local_ip6.encode())
self.has_ip6_config = True
def unconfig_ip6(self):
@@ -295,9 +311,8 @@ class VppInterface(object):
try:
if self.has_ip6_config:
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip6n,
- address_length=self.local_ip6_prefix_len, is_ipv6=1,
- is_add=0)
+ sw_if_index=self.sw_if_index,
+ prefix=self._local_ip6.encode(), is_add=0)
except AttributeError:
self.has_ip6_config = False
self.has_ip6_config = False
@@ -365,13 +380,14 @@ class VppInterface(object):
def admin_up(self):
"""Put interface ADMIN-UP."""
- self.test.vapi.sw_interface_set_flags(self.sw_if_index,
- admin_up_down=1)
+ self.test.vapi.sw_interface_set_flags(
+ self.sw_if_index,
+ flags=VppEnum.vl_api_if_status_flags_t.IF_STATUS_API_FLAG_ADMIN_UP)
def admin_down(self):
"""Put interface ADMIN-down."""
self.test.vapi.sw_interface_set_flags(self.sw_if_index,
- admin_up_down=0)
+ flags=0)
def link_up(self):
"""Put interface link-state-UP."""
@@ -459,15 +475,15 @@ class VppInterface(object):
name='sw_interface_event')
self.test.assert_equal(event.sw_if_index, self.sw_if_index,
"sw_if_index")
- self.test.assert_equal(event.admin_up_down, admin_up_down,
+ self.test.assert_equal((event.flags & 1), admin_up_down,
"admin state")
- self.test.assert_equal(event.link_up_down, link_up_down,
+ self.test.assert_equal((event.flags & 2), link_up_down,
"link state")
dump = self.test.vapi.sw_interface_dump()
if_state = self.get_interface_config_from_dump(dump)
- self.test.assert_equal(if_state.admin_up_down, admin_up_down,
+ self.test.assert_equal((if_state.flags & 1), admin_up_down,
"admin state")
- self.test.assert_equal(if_state.link_up_down, link_up_down,
+ self.test.assert_equal((if_state.flags & 2), link_up_down,
"link state")
def __str__(self):
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py
index a70180b3de5..7742936a8a0 100644
--- a/test/vpp_ip_route.py
+++ b/test/vpp_ip_route.py
@@ -202,15 +202,13 @@ class VppIpInterfaceAddress(VppObject):
def add_vpp_config(self):
self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.intf.sw_if_index, address=self.prefix.bytes,
- address_length=self.prefix.length, is_ipv6=self.prefix.is_ip6,
+ sw_if_index=self.intf.sw_if_index, prefix=self.prefix.encode(),
is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.intf.sw_if_index, address=self.prefix.bytes,
- address_length=self.prefix.length, is_ipv6=self.prefix.is_ip6,
+ sw_if_index=self.intf.sw_if_index, prefix=self.prefix.encode(),
is_add=0)
def query_vpp_config(self):
diff --git a/test/vpp_memif.py b/test/vpp_memif.py
index 7fa45092740..befcc2840c5 100644
--- a/test/vpp_memif.py
+++ b/test/vpp_memif.py
@@ -3,6 +3,8 @@ import socket
import six
from vpp_object import VppObject
+from vpp_ip import VppIpPrefix
+from vpp_papi import VppEnum
class MEMIF_ROLE:
@@ -84,8 +86,8 @@ class VppMemif(VppObject):
self.buffer_size = buffer_size
self.hw_addr = hw_addr
self.sw_if_index = None
- self.ip4_addr = "192.168.%d.%d" % (self.if_id + 1, self.role + 1)
- self.ip4_addr_len = 24
+ self.ip_prefix = VppIpPrefix("192.168.%d.%d" %
+ (self.if_id + 1, self.role + 1), 24)
def add_vpp_config(self):
rv = self._test.vapi.memif_create(
@@ -112,11 +114,13 @@ class VppMemif(VppObject):
def admin_up(self):
if self.sw_if_index:
- return self._test.vapi.sw_interface_set_flags(self.sw_if_index, 1)
+ return self._test.vapi.sw_interface_set_flags(
+ sw_if_index=self.sw_if_index, flags=1)
def admin_down(self):
if self.sw_if_index:
- return self._test.vapi.sw_interface_set_flags(self.sw_if_index, 0)
+ return self._test.vapi.sw_interface_set_flags(
+ sw_if_index=self.sw_if_index, flags=0)
def wait_for_link_up(self, timeout, step=1):
if not self.sw_if_index:
@@ -132,9 +136,7 @@ class VppMemif(VppObject):
def config_ip4(self):
return self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=socket.inet_pton(
- socket.AF_INET, self.ip4_addr),
- address_length=self.ip4_addr_len)
+ sw_if_index=self.sw_if_index, prefix=self.ip_prefix.encode())
def remove_vpp_config(self):
self._test.vapi.memif_delete(self.sw_if_index)
diff --git a/test/vpp_sub_interface.py b/test/vpp_sub_interface.py
index 4961ba5ff69..8f422d8a050 100644
--- a/test/vpp_sub_interface.py
+++ b/test/vpp_sub_interface.py
@@ -3,6 +3,7 @@ import abc
import six
from vpp_pg_interface import VppPGInterface
from vpp_interface import VppInterface
+from vpp_papi import VppEnum
class L2_VTR_OP:
@@ -182,10 +183,13 @@ class VppDot1ADSubint(VppSubInterface):
def __init__(self, test, parent, sub_id, outer_vlan, inner_vlan):
super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
+ flags = (VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_DOT1AD |
+ VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_TWO_TAGS |
+ VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_EXACT_MATCH)
r = test.vapi.create_subif(sw_if_index=parent.sw_if_index,
sub_id=sub_id, outer_vlan_id=outer_vlan,
- inner_vlan_id=inner_vlan, two_tags=1,
- dot1ad=1, exact_match=1)
+ inner_vlan_id=inner_vlan,
+ sub_if_flags=flags)
self.set_sw_if_index(r.sw_if_index)
self._outer_vlan = outer_vlan
self._inner_vlan = inner_vlan