aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-03-15 18:26:35 +0100
committerHongjun Ni <hongjun.ni@intel.com>2019-03-18 01:11:49 +0000
commit4157d85b570d5da6af042758813712ae04573c8f (patch)
tree74e07e950468d578e24088a3545f90755c99e976
parentd7680154981c54989bcbcab81173791dc1805512 (diff)
Integrate interface.api changes to 3.0.0 to sweetcomb
Change-Id: If7cd04e4e699e27e9fd278a1ac1897d5f53a4345 Signed-off-by: YohanPipereau <ypiperea@cisco.com>
-rw-r--r--src/plugins/openconfig/openconfig_interfaces.c54
-rw-r--r--src/plugins/openconfig/openconfig_local_routing.c4
-rw-r--r--src/scvpp/src/sc_vpp_interface.c36
-rw-r--r--src/scvpp/src/sc_vpp_ip.c13
-rw-r--r--src/scvpp/tests/scvpp_test.c4
5 files changed, 74 insertions, 37 deletions
diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c
index c72ad7f..5809429 100644
--- a/src/plugins/openconfig/openconfig_interfaces.c
+++ b/src/plugins/openconfig/openconfig_interfaces.c
@@ -222,7 +222,7 @@ static int sw_interface_dump_cb_inner(
return rc;
}
- const char* interface_name = (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name;
+ const char* interface_name = (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf;
sr_val_build_xpath(&vals[0], "%s/name", dctx->sysr_values_ctx.xpath_root);
sr_val_set_str_data(&vals[0], SR_STRING_T, interface_name);
@@ -245,23 +245,30 @@ static int sw_interface_dump_cb_inner(
sr_val_build_xpath(&vals[5], "%s/enabled",
dctx->sysr_values_ctx.xpath_root);
+ sr_val_build_xpath(&vals[7], "%s/admin-status",
+ dctx->sysr_values_ctx.xpath_root);
vals[5].type = SR_BOOL_T;
- vals[5].data.bool_val = reply->admin_up_down;
+ if (reply->flags == IF_STATUS_API_FLAG_ADMIN_UP ||
+ reply->flags == IF_STATUS_API_FLAG_LINK_UP) {
+ vals[5].data.bool_val = true;
+ sr_val_set_str_data(&vals[7], SR_ENUM_T, "UP");
+ } else {
+ vals[5].data.bool_val = false;
+ sr_val_set_str_data(&vals[7], SR_ENUM_T, "DOWN");
+ }
sr_val_build_xpath(&vals[6], "%s/ifindex",
dctx->sysr_values_ctx.xpath_root);
vals[6].type = SR_UINT32_T;
vals[6].data.uint32_val = reply->sw_if_index;
- sr_val_build_xpath(&vals[7], "%s/admin-status",
- dctx->sysr_values_ctx.xpath_root);
- sr_val_set_str_data(&vals[7], SR_ENUM_T,
- reply->admin_up_down ? "UP" : "DOWN");
sr_val_build_xpath(&vals[8], "%s/oper-status",
dctx->sysr_values_ctx.xpath_root);
- sr_val_set_str_data(&vals[8], SR_ENUM_T,
- reply->link_up_down ? "UP" : "DOWN");
+ if (reply->flags == IF_STATUS_API_FLAG_LINK_UP)
+ sr_val_set_str_data(&vals[8], SR_ENUM_T, "UP");
+ else
+ sr_val_set_str_data(&vals[8], SR_ENUM_T, "DOWN");
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[9], "%s/last-change", dctx->sysr_values_ctx.xpath_root);
@@ -307,7 +314,12 @@ static int sw_subinterface_dump_cb_inner(
sr_val_build_xpath(&vals[val_idx], "%s/enabled",
dctx->sysr_values_ctx.xpath_root);
vals[val_idx].type = SR_BOOL_T;
- vals[val_idx++].data.bool_val = reply->admin_up_down;
+ if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
+ reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
+ vals[val_idx++].data.bool_val = true;
+ } else {
+ vals[val_idx++].data.bool_val = false;
+ }
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[val_idx], "%s/name", dctx->sysr_values_ctx.xpath_root);
@@ -319,13 +331,21 @@ static int sw_subinterface_dump_cb_inner(
sr_val_build_xpath(&vals[val_idx], "%s/admin-status",
dctx->sysr_values_ctx.xpath_root);
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T,
- reply->admin_up_down ? "UP" : "DOWN");
+ if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
+ reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "UP");
+ } else {
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "DOWN");
+ }
sr_val_build_xpath(&vals[val_idx], "%s/oper-status",
dctx->sysr_values_ctx.xpath_root);
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T,
- reply->admin_up_down ? "UP" : "DOWN");
+ if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
+ reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "UP");
+ } else {
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "DOWN");
+ }
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[val_idx], "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state/last-change", interface_name, subinterface_index);
@@ -382,19 +402,19 @@ sw_interface_dump_vapi_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
assert (NULL != reply);
sys_sw_interface_dump_ctx *dctx = callback_ctx;
- const char* const dctx_interface_name = (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name;
+ const char* const dctx_interface_name = (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf;
SRP_LOG_DBG("interface_name: '%s', if_name: '%s'", reply->interface_name, dctx_interface_name);
if (dctx->is_subif)
{
- if (is_subinterface((const char*)reply->interface_name,
+ if (is_subinterface((const char*)reply->interface_name.buf,
dctx_interface_name, dctx->subinterface_index))
sw_subinterface_dump_cb_inner(reply, dctx);
}
else
{
- if (0 == strcmp(dctx_interface_name, (char *)reply->interface_name))
+ if (0 == strcmp(dctx_interface_name, (char *)reply->interface_name.buf))
{
dctx->sw_interface_details_query.sw_interface_details = *reply;
dctx->sw_interface_details_query.interface_found = true;
@@ -417,7 +437,7 @@ static vapi_error_e sysr_sw_interface_dump(sys_sw_interface_dump_ctx * dctx)
dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
dump->payload.name_filter_valid = true;
- strcpy((char*)dump->payload.name_filter, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name);
+ strcpy((char*)dump->payload.name_filter.buf, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf);
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, dump, sw_interface_dump_vapi_cb,
dctx));
diff --git a/src/plugins/openconfig/openconfig_local_routing.c b/src/plugins/openconfig/openconfig_local_routing.c
index 5c63eaa..a5f4ffa 100644
--- a/src/plugins/openconfig/openconfig_local_routing.c
+++ b/src/plugins/openconfig/openconfig_local_routing.c
@@ -586,7 +586,7 @@ int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_ho
sr_val_build_xpath(&vals[0], "%s/interface",
dctx->sysr_values_ctx.xpath_root);
sr_val_set_str_data(&vals[0], SR_STRING_T,
- (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name);
+ (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf);
sr_val_build_xpath(&vals[1], "%s/subinterface",
dctx->sysr_values_ctx.xpath_root);
@@ -698,7 +698,7 @@ int next_hop_inner(
return SR_ERR_INVAL_ARG;
}
if (strlen((const char*)
- dctx.sw_interface_details_query.sw_interface_details.interface_name)) {
+ dctx.sw_interface_details_query.sw_interface_details.interface_name.buf)) {
openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_vapi_cb(&dctx);
}
}
diff --git a/src/scvpp/src/sc_vpp_interface.c b/src/scvpp/src/sc_vpp_interface.c
index 73b29ae..6d28571 100644
--- a/src/scvpp/src/sc_vpp_interface.c
+++ b/src/scvpp/src/sc_vpp_interface.c
@@ -34,7 +34,7 @@ void sw_interface_details_query_set_name(sw_interface_details_query_t * query,
memset(query, 0, sizeof(*query));
- strncpy((char*) query->sw_interface_details.interface_name, interface_name,
+ strncpy((char*) query->sw_interface_details.interface_name.buf, interface_name,
sizeof(query->sw_interface_details.interface_name));
}
@@ -68,7 +68,7 @@ bin_api_sw_interface_dump(vapi_payload_sw_interface_details *details)
mp = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
mp->payload.name_filter_valid = 0;
- memset(mp->payload.name_filter, 0, sizeof(mp->payload.name_filter));
+ memset(mp->payload.name_filter.buf, 0, sizeof(mp->payload.name_filter));
assert(NULL != mp);
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, sw_interface_dump_cb, details));
@@ -100,14 +100,23 @@ interface_dump_all_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
vpp_interface_t * iface = &dctx->intfcArray[dctx->num_ifs];
iface->sw_if_index = reply->sw_if_index;
- strncpy(iface->interface_name, reply->interface_name, VPP_INTFC_NAME_LEN);
- iface->l2_address_length = reply->l2_address_length;
- memcpy(iface->l2_address, reply->l2_address, reply->l2_address_length );
+ strncpy(iface->interface_name, reply->interface_name.buf, VPP_INTFC_NAME_LEN);
+ iface->l2_address_length = VPP_MAC_ADDRESS_LEN;
+ memcpy(iface->l2_address, reply->l2_address, VPP_MAC_ADDRESS_LEN);
iface->link_speed = reply->link_speed;
iface->link_mtu = reply->link_mtu;
- iface->admin_up_down = reply->admin_up_down;
- iface->link_up_down = reply->link_up_down;
+ if (reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
+ iface->admin_up_down = 1;
+ iface->link_up_down = 0;
+ } else if (reply->flags == IF_STATUS_API_FLAG_LINK_UP) {
+ //link up -> administratively up
+ iface->admin_up_down = 1;
+ iface->link_up_down = 1;
+ } else {
+ iface->admin_up_down = 0;
+ iface->link_up_down = 0;
+ }
dctx->num_ifs += 1;
@@ -131,7 +140,7 @@ int interface_dump_all(dump_all_ctx * dctx)
dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
dump->payload.name_filter_valid = 0;
- memset(dump->payload.name_filter, 0, sizeof(dump->payload.name_filter));
+ memset(&dump->payload.name_filter, 0, sizeof(dump->payload.name_filter));
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump(g_vapi_ctx_instance, dump, interface_dump_all_cb,
@@ -158,8 +167,8 @@ get_interface_id_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
{
assert(NULL != reply);
- if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name,
- (const char*)reply->interface_name))
+ if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name.buf,
+ (const char*)reply->interface_name.buf))
{
dctx->interface_found = true;
dctx->sw_interface_details = *reply;
@@ -183,8 +192,9 @@ int get_interface_id(sw_interface_details_query_t * sw_interface_details_query)
assert(NULL != mp);
mp->payload.name_filter_valid = true;
- memcpy(mp->payload.name_filter, sw_interface_details_query->sw_interface_details.interface_name,
- sizeof(mp->payload.name_filter));
+ strncpy(mp->payload.name_filter.buf,
+ sw_interface_details_query->sw_interface_details.interface_name.buf,
+ VPP_INTFC_NAME_LEN);
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, get_interface_id_cb, sw_interface_details_query));
if (VAPI_OK != rv)
@@ -217,7 +227,7 @@ bin_api_sw_interface_set_flags(uint32_t if_index, uint8_t up)
assert(NULL != mp);
mp->payload.sw_if_index = if_index;
- mp->payload.admin_up_down = up;
+ mp->payload.flags = IF_STATUS_API_FLAG_ADMIN_UP;
vapi_error_e rv;
VAPI_CALL(vapi_sw_interface_set_flags(g_vapi_ctx_instance, mp, sw_interface_set_flags_cb, NULL));
diff --git a/src/scvpp/src/sc_vpp_ip.c b/src/scvpp/src/sc_vpp_ip.c
index 77e79fb..8307090 100644
--- a/src/scvpp/src/sc_vpp_ip.c
+++ b/src/scvpp/src/sc_vpp_ip.c
@@ -41,11 +41,16 @@ bin_api_sw_interface_add_del_address(u32 sw_if_index, bool is_add, bool is_ipv6,
mp->payload.sw_if_index = sw_if_index;
mp->payload.is_add = is_add;
- mp->payload.is_ipv6 = is_ipv6;
mp->payload.del_all = del_all;
- mp->payload.address_length = address_length;
- if (sc_aton(ip_address, mp->payload.address, sizeof(mp->payload.address)))
- return VAPI_EINVAL;
+
+ mp->payload.prefix.address_length = address_length;
+ if (is_ipv6) {
+ mp->payload.prefix.address.af = ADDRESS_IP6;
+ sc_aton(ip_address, mp->payload.prefix.address.un.ip4, VPP_IP4_ADDRESS_LEN);
+ } else {
+ mp->payload.prefix.address.af = ADDRESS_IP4;
+ sc_aton(ip_address, mp->payload.prefix.address.un.ip6, VPP_IP6_ADDRESS_LEN);
+ }
VAPI_CALL(vapi_sw_interface_add_del_address(g_vapi_ctx_instance, mp,
sw_interface_add_del_address_cb, NULL));
diff --git a/src/scvpp/tests/scvpp_test.c b/src/scvpp/tests/scvpp_test.c
index adc2b55..e50f365 100644
--- a/src/scvpp/tests/scvpp_test.c
+++ b/src/scvpp/tests/scvpp_test.c
@@ -48,7 +48,9 @@ static void test_name2index(void **state)
rc = get_interface_id(&query);
assert_int_equal(rc, 1);
- assert_string_equal(iface_name, query.sw_interface_details.interface_name);
+ //assert_string_equal(iface_name, query.sw_interface_details.interface_name.buf);
+ assert_string_equal(iface_name,
+ vl_api_from_api_string(&query.sw_interface_details.interface_name));
assert_int_equal(query.sw_interface_details.sw_if_index, 1);
}