aboutsummaryrefslogtreecommitdiffstats
path: root/vpp
diff options
context:
space:
mode:
authorAlexander Popovsky (apopovsk) <apopovsk@cisco.com>2016-10-05 22:31:23 -0700
committerJohn Lo <loj@cisco.com>2016-10-07 15:31:50 +0000
commit4a7e58bf481adb843707eec4a81213776a6d5212 (patch)
tree18e80de3e457e618752dbbe3740104e9f292dc14 /vpp
parent02c826c6abf8dc5ca95b05b219532d9bb0f10312 (diff)
VPP-395 Add udp-punt node(s) and API
Uses existing UDP local API in order to register requested UDP port punt to the host. CLI: set punt udp [del] <port> API: punt protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del] * Only UDP (l4-protocol = 17) is supported at this time Change-Id: I9232af1c891d1ed174d77f3e0dfe60c4b9d85e40 Signed-off-by: Alex Popovsky <apopovsk@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r--vpp/vpp-api/api.c25
-rw-r--r--vpp/vpp-api/custom_dump.c27
-rw-r--r--vpp/vpp-api/vpe.api30
3 files changed, 77 insertions, 5 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 028e67bc245..a7382492160 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -2,7 +2,7 @@
*------------------------------------------------------------------
* api.c - message handler registration
*
- * Copyright (c) 2010 Cisco and/or its affiliates.
+ * Copyright (c) 2010-2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -87,6 +87,7 @@
#include <vnet/flow/flow_report.h>
#include <vnet/ipsec-gre/ipsec_gre.h>
#include <vnet/flow/flow_report_classify.h>
+#include <vnet/ip/punt.h>
#undef BIHASH_TYPE
#undef __included_bihash_template_h__
@@ -423,7 +424,8 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
_(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
_(DELETE_SUBIF, delete_subif) \
-_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)
+_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
+_(PUNT, punt)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
@@ -8505,6 +8507,25 @@ static void
REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
}
+static void
+vl_api_punt_t_handler (vl_api_punt_t * mp)
+{
+ vl_api_punt_reply_t *rmp;
+ vlib_main_t *vm = vlib_get_main ();
+ int rv = 0;
+ clib_error_t *error;
+
+ error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
+ ntohs (mp->l4_port), mp->is_add);
+ if (error)
+ {
+ rv = -1;
+ clib_error_report (error);
+ }
+
+ REPLY_MACRO (VL_API_PUNT_REPLY);
+}
+
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c
index 4689776ac58..718e5646abf 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -2,7 +2,7 @@
*------------------------------------------------------------------
* custom_dump.c - pretty-print API messages for replay
*
- * Copyright (c) 2014 Cisco and/or its affiliates.
+ * Copyright (c) 2014-2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -2771,6 +2771,28 @@ static void *vl_api_l2_interface_pbb_tag_rewrite_t_print
FINISH;
}
+static void *
+vl_api_punt_t_print (vl_api_punt_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: punt ");
+
+ if (mp->ipv != (u8) ~ 0)
+ s = format (s, "ip %d ", mp->ipv);
+
+ s = format (s, "protocol %d ", mp->l4_protocol);
+
+ if (mp->l4_port != (u16) ~ 0)
+ s = format (s, "port %d ", ntohs (mp->l4_port));
+
+ if (!mp->is_add)
+ s = format (s, "del ");
+
+ FINISH;
+}
+
+
#define foreach_custom_print_no_arg_function \
_(lisp_eid_table_vni_dump) \
_(lisp_map_resolver_dump) \
@@ -2932,7 +2954,8 @@ _(LISP_LOCATOR_DUMP, lisp_locator_dump) \
_(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
_(DELETE_SUBIF, delete_subif) \
-_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)
+_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
+_(PUNT, punt)
void
vl_msg_api_custom_dump_configure (api_main_t * am)
{
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 6924aef9587..0f1b0a8f455 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -1,6 +1,6 @@
/* Hey Emacs use -*- mode: C -*- */
/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
+ * Copyright (c) 2015-2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -5154,3 +5154,31 @@ define l2_interface_pbb_tag_rewrite_reply
u32 context;
i32 retval;
};
+
+/** \brief Punt traffic to the host
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - add punt if non-zero, else delete
+ @param ipv - L3 protocol 4 - IPv4, 6 - IPv6, ~0 - All
+ @param l4_protocol - L4 protocol to be punted, only UDP (0x11) is supported
+ @param l4_port - TCP/UDP port to be punted
+*/
+define punt {
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ u8 ipv;
+ u8 l4_protocol;
+ u16 l4_port;
+};
+
+/** \brief Reply to the punt request
+ @param context - sender context which was passed in the request
+ @param retval - return code of punt request
+*/
+define punt_reply
+{
+ u32 context;
+ i32 retval;
+};
+