Dedicated SW Interface Event

Change-Id: I06a10a4291e61aec3f1396d2514ed6fe3901897a
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
This commit is contained in:
Neale Ranns
2017-08-07 07:53:49 -07:00
committed by Florin Coras
parent e8bad978a1
commit a07bd70800
12 changed files with 65 additions and 50 deletions

View File

@ -972,8 +972,8 @@ static void vl_api_sw_interface_details_t_handler_json
}
#if VPP_API_TEST_BUILTIN == 0
static void vl_api_sw_interface_set_flags_t_handler
(vl_api_sw_interface_set_flags_t * mp)
static void vl_api_sw_interface_event_t_handler
(vl_api_sw_interface_event_t * mp)
{
vat_main_t *vam = &vat_main;
if (vam->interface_event_display)
@ -984,8 +984,8 @@ static void vl_api_sw_interface_set_flags_t_handler
}
#endif
static void vl_api_sw_interface_set_flags_t_handler_json
(vl_api_sw_interface_set_flags_t * mp)
static void vl_api_sw_interface_event_t_handler_json
(vl_api_sw_interface_event_t * mp)
{
/* JSON output not supported */
}
@ -5026,7 +5026,7 @@ _(LLDP_CONFIG_REPLY, lldp_config_reply) \
_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
#define foreach_standalone_reply_msg \
_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
_(SW_INTERFACE_EVENT, sw_interface_event) \
_(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
_(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
_(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
@ -5772,7 +5772,7 @@ api_sw_interface_set_flags (vat_main_t * vam)
vl_api_sw_interface_set_flags_t *mp;
u32 sw_if_index;
u8 sw_if_index_set = 0;
u8 admin_up = 0, link_up = 0;
u8 admin_up = 0;
int ret;
/* Parse args required to build the message */
@ -5782,10 +5782,6 @@ api_sw_interface_set_flags (vat_main_t * vam)
admin_up = 1;
else if (unformat (i, "admin-down"))
admin_up = 0;
else if (unformat (i, "link-up"))
link_up = 1;
else if (unformat (i, "link-down"))
link_up = 0;
else
if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
@ -5805,7 +5801,6 @@ api_sw_interface_set_flags (vat_main_t * vam)
M (SW_INTERFACE_SET_FLAGS, mp);
mp->sw_if_index = ntohl (sw_if_index);
mp->admin_up_down = admin_up;
mp->link_up_down = link_up;
/* send it... */
S (mp);

View File

@ -52,11 +52,11 @@ _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)
* WARNING: replicated pending api refactor completion
*/
static void
send_sw_interface_flags_deleted (vpe_api_main_t * am,
send_sw_interface_event_deleted (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
u32 sw_if_index)
{
vl_api_sw_interface_set_flags_t *mp;
vl_api_sw_interface_event_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
@ -143,7 +143,7 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
return;
vnet_clear_sw_interface_tag (vnm, sw_if_index);
send_sw_interface_flags_deleted (vam, q, sw_if_index);
send_sw_interface_event_deleted (vam, q, sw_if_index);
}
}

View File

@ -4,7 +4,6 @@
@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 deleted - interface was deleted
*/
autoreply define sw_interface_set_flags
{
@ -13,8 +12,6 @@ autoreply define sw_interface_set_flags
u32 sw_if_index;
/* 1 = up, 0 = down */
u8 admin_up_down;
u8 link_up_down;
u8 deleted;
};
/** \brief Set interface MTU
@ -31,6 +28,22 @@ autoreply define sw_interface_set_mtu
u16 mtu;
};
/** \brief Interface Event generated by want_interface_events
@param context - sender context, to match reply w/ request
@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 deleted - interface was deleted
*/
define sw_interface_event
{
u32 context;
u32 sw_if_index;
u8 admin_up_down;
u8 link_up_down;
u8 deleted;
};
/** \brief Register for interface events
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request

View File

@ -571,18 +571,18 @@ event_data_cmp (void *a1, void *a2)
}
static void
send_sw_interface_flags (vpe_api_main_t * am,
send_sw_interface_event (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
vnet_sw_interface_t * swif)
{
vl_api_sw_interface_set_flags_t *mp;
vl_api_sw_interface_event_t *mp;
vnet_main_t *vnm = am->vnet_main;
vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm,
swif->sw_if_index);
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
mp->sw_if_index = ntohl (swif->sw_if_index);
mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
@ -638,7 +638,7 @@ link_state_process (vlib_main_t * vm,
event_data[i]))
{
swif = vnet_get_sw_interface (vnm, event_data[i]);
send_sw_interface_flags (vam, q, swif);
send_sw_interface_event (vam, q, swif);
}
}
}));

View File

@ -59,11 +59,11 @@ _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump)
* WARNING: replicated pending api refactor completion
*/
static void
send_sw_interface_flags_deleted (vpe_api_main_t * am,
send_sw_interface_event_deleted (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
u32 sw_if_index)
{
vl_api_sw_interface_set_flags_t *mp;
vl_api_sw_interface_event_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
@ -196,7 +196,7 @@ vl_api_tap_delete_t_handler (vl_api_tap_delete_t * mp)
vl_msg_api_send_shmem (q, (u8 *) & rmp);
if (!rv)
send_sw_interface_flags_deleted (vam, q, sw_if_index);
send_sw_interface_event_deleted (vam, q, sw_if_index);
}
static void

View File

@ -36,7 +36,7 @@ public class CallbackJVppFacadeNotificationExample {
System.out.println("Successfully connected to VPP");
final AutoCloseable notificationListenerReg =
jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceEventNotificationCallback(
NotificationUtils::printNotification
);

View File

@ -26,10 +26,9 @@ import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.JVppCoreImpl;
import io.fd.vpp.jvpp.core.callback.SwInterfaceSetFlagsCallback;
import io.fd.vpp.jvpp.core.callback.SwInterfaceSetFlagsNotificationCallback;
import io.fd.vpp.jvpp.core.callback.SwInterfaceEventNotificationCallback;
import io.fd.vpp.jvpp.core.callback.WantInterfaceEventsCallback;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsNotification;
import io.fd.vpp.jvpp.core.dto.SwInterfaceEventNotification;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply;
import io.fd.vpp.jvpp.core.dto.WantInterfaceEventsReply;
@ -65,12 +64,12 @@ public class CallbackNotificationApiExample {
testCallbackApi();
}
private static class TestCallback implements SwInterfaceSetFlagsNotificationCallback,
WantInterfaceEventsCallback, SwInterfaceSetFlagsCallback {
private static class TestCallback implements SwInterfaceEventNotificationCallback,
WantInterfaceEventsCallback {
@Override
public void onSwInterfaceSetFlagsNotification(
final SwInterfaceSetFlagsNotification msg) {
public void onSwInterfaceEventNotification(
final SwInterfaceEventNotification msg) {
printNotification(msg);
}
@ -79,11 +78,6 @@ public class CallbackNotificationApiExample {
System.out.println("Interface notification stream updated");
}
@Override
public void onSwInterfaceSetFlagsReply(final SwInterfaceSetFlagsReply swInterfaceSetFlagsReply) {
System.out.println("Interface flags set successfully");
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d%n",

View File

@ -33,7 +33,7 @@ public class FutureApiNotificationExample {
final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, new JVppCoreImpl());
final AutoCloseable notificationListenerReg =
jvppFacade.getNotificationRegistry()
.registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification)) {
.registerSwInterfaceEventNotificationCallback(NotificationUtils::printNotification)) {
System.out.println("Successfully connected to VPP");
jvppFacade.wantInterfaceEvents(getEnableInterfaceNotificationsReq()).toCompletableFuture().get();
System.out.println("Interface events started");

View File

@ -18,14 +18,14 @@ package io.fd.vpp.jvpp.core.examples;
import java.io.PrintStream;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags;
import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsNotification;
import io.fd.vpp.jvpp.core.dto.SwInterfaceEventNotification;
import io.fd.vpp.jvpp.core.dto.WantInterfaceEvents;
final class NotificationUtils {
private NotificationUtils() {}
static PrintStream printNotification(final SwInterfaceSetFlagsNotification msg) {
static PrintStream printNotification(final SwInterfaceEventNotification msg) {
return System.out.printf("Received interface notification: ifc: %s%n", msg);
}
@ -33,7 +33,6 @@ final class NotificationUtils {
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = 0;
swInterfaceSetFlags.adminUpDown = 1;
swInterfaceSetFlags.deleted = 0;
return swInterfaceSetFlags;
}

View File

@ -161,7 +161,6 @@ unconventional_naming_rep_req = {
#
# FIXME no convention in the naming of events (notifications) in vpe.api
notifications_message_suffixes = ("event", "counters")
notification_messages_reused = ["sw_interface_set_flags"]
# messages that must be ignored. These messages are INSUFFICIENTLY marked as disabled in vpe.api
# FIXME
@ -170,7 +169,7 @@ ignored_messages = []
def is_notification(name):
""" Returns true if the structure is a notification regardless of its no other use """
return is_just_notification(name) or name.lower() in notification_messages_reused
return is_just_notification(name)
def is_just_notification(name):

View File

@ -103,6 +103,22 @@ 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)
s = format (s, "admin-up ");
else
s = format (s, "admin-down ");
FINISH;
}
static void *vl_api_sw_interface_event_t_print
(vl_api_sw_interface_event_t * mp, void *handle)
{
u8 *s;
s = format (0, "SCRIPT: sw_interface_event ");
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
if (mp->admin_up_down)
s = format (s, "admin-up ");
else
@ -113,6 +129,9 @@ static void *vl_api_sw_interface_set_flags_t_print
else
s = format (s, "link-down");
if (mp->deleted)
s = format (s, " deleted");
FINISH;
}
@ -3010,6 +3029,7 @@ foreach_custom_print_no_arg_function
_(CREATE_LOOPBACK, create_loopback) \
_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
_(SW_INTERFACE_EVENT, sw_interface_event) \
_(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
_(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
_(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \

View File

@ -550,21 +550,16 @@ class VppPapiProvider(object):
'tag1': tag1,
'tag2': tag2})
def sw_interface_set_flags(self, sw_if_index, admin_up_down,
link_up_down=0, deleted=0):
def sw_interface_set_flags(self, sw_if_index, admin_up_down):
"""
:param admin_up_down:
:param sw_if_index:
:param link_up_down: (Default value = 0)
:param deleted: (Default value = 0)
"""
return self.api(self.papi.sw_interface_set_flags,
{'sw_if_index': sw_if_index,
'admin_up_down': admin_up_down,
'link_up_down': link_up_down,
'deleted': deleted})
'admin_up_down': admin_up_down})
def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,