ping: Move to plugin 15/22715/2
authorMohsin Kazmi <sykazmi@cisco.com>
Wed, 9 Oct 2019 16:35:16 +0000 (18:35 +0200)
committerDamjan Marion <dmarion@me.com>
Mon, 14 Oct 2019 22:44:35 +0000 (22:44 +0000)
Type: refactor

Change-Id: I51d5bf54dfd408aa0c406cbdf0f4be10ef19d10d
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
MAINTAINERS
src/plugins/ping/CMakeLists.txt [new file with mode: 0644]
src/plugins/ping/ping.c [moved from src/vnet/ip/ping.c with 99% similarity]
src/plugins/ping/ping.h [moved from src/vnet/ip/ping.h with 96% similarity]
src/vnet/CMakeLists.txt
src/vnet/ip/icmp4.c
src/vnet/ip/icmp4.h
src/vnet/ip/ip4.h

index 7e1b65b..99e792d 100644 (file)
@@ -376,6 +376,11 @@ I: pppoe
 M:     Hongjun Ni <hongjun.ni@intel.com>
 F:     src/plugins/pppoe/
 
+Plugin - Ping
+I:     ping
+M:     Andrew Yourtchenko <ayourtch@gmail.com>
+F:     src/plugins/ping
+
 Plugin - IPv6 Segment Routing Dynamic Proxy
 I:     srv6-ad
 M:     Francois Clad <fclad@cisco.com>
diff --git a/src/plugins/ping/CMakeLists.txt b/src/plugins/ping/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2828f76
--- /dev/null
@@ -0,0 +1,17 @@
+# Copyright (c) 2018 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:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_vpp_plugin(ping
+  SOURCES
+  ping.c
+)
similarity index 99%
rename from src/vnet/ip/ping.c
rename to src/plugins/ping/ping.c
index 3847d83..7d50377 100755 (executable)
  */
 
 #include <stddef.h>
-#include <vnet/ip/ping.h>
+
+#include <vlib/vlib.h>
 #include <vnet/fib/ip6_fib.h>
 #include <vnet/fib/ip4_fib.h>
 #include <vnet/fib/fib_entry.h>
-#include <vlib/vlib.h>
+#include <vnet/plugin/plugin.h>
+#include <vpp/app/version.h>
+
+#include <vnet/ip/icmp4.h>
+#include <ping/ping.h>
 
 ping_main_t ping_main;
 
@@ -1252,6 +1257,13 @@ ping_cli_init (vlib_main_t * vm)
 
 VLIB_INIT_FUNCTION (ping_cli_init);
 
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+    .version = VPP_BUILD_VER,
+    .description = "Ping (ping)",
+};
+/* *INDENT-ON* */
+
 /*
  * fd.io coding-style-patch-verification: ON
  *
similarity index 96%
rename from src/vnet/ip/ping.h
rename to src/plugins/ping/ping.h
index f1faa99..7826945 100644 (file)
@@ -12,8 +12,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef included_vnet_ping_h
-#define included_vnet_ping_h
+#ifndef included_ping_ping_h
+#define included_ping_ping_h
 
 
 #include <vnet/ip/ip.h>
@@ -88,4 +88,4 @@ typedef enum
   ICMP46_ECHO_REPLY_N_NEXT,
 } icmp46_echo_reply_next_t;
 
-#endif /* included_vnet_ping_h */
+#endif /* included_ping_ping_h */
index b107365..9c1bceb 100644 (file)
@@ -454,7 +454,6 @@ list(APPEND VNET_SOURCES
   ip/ip_in_out_acl.c
   ip/ip_punt_drop.c
   ip/lookup.c
-  ip/ping.c
   ip/punt_api.c
   ip/punt.c
   ip/punt_node.c
index 1cf6a93..1fab647 100644 (file)
@@ -41,7 +41,6 @@
 #include <vnet/ip/ip.h>
 #include <vnet/pg/pg.h>
 
-
 static char *icmp_error_strings[] = {
 #define _(f,s) s,
   foreach_icmp4_error
@@ -422,14 +421,6 @@ typedef enum
   IP4_ICMP_ERROR_N_NEXT,
 } ip4_icmp_error_next_t;
 
-void
-icmp4_error_set_vnet_buffer (vlib_buffer_t * b, u8 type, u8 code, u32 data)
-{
-  vnet_buffer (b)->ip.icmp.type = type;
-  vnet_buffer (b)->ip.icmp.code = code;
-  vnet_buffer (b)->ip.icmp.data = data;
-}
-
 static u8
 icmp4_icmp_type_to_error (u8 type)
 {
index ae80514..73bd1f4 100644 (file)
@@ -26,9 +26,9 @@
   _ (OPTION_WITH_ZERO_LENGTH, "option has zero length")                 \
   _ (ECHO_REPLIES_SENT, "echo replies sent")                            \
   _ (DST_LOOKUP_MISS, "icmp6 dst address lookup misses")                \
-  _ (DEST_UNREACH_SENT, "destination unreachable response sent")       \
-  _ (TTL_EXPIRE_SENT, "hop limit exceeded response sent")              \
-  _ (PARAM_PROBLEM_SENT, "parameter problem response sent")            \
+  _ (DEST_UNREACH_SENT, "destination unreachable response sent")        \
+  _ (TTL_EXPIRE_SENT, "hop limit exceeded response sent")               \
+  _ (PARAM_PROBLEM_SENT, "parameter problem response sent")             \
   _ (DROP, "error message dropped")
 
 typedef enum
@@ -46,8 +46,14 @@ typedef struct
 format_function_t format_icmp4_input_trace;
 void ip4_icmp_register_type (vlib_main_t * vm, icmp4_type_t type,
                             u32 node_index);
-void icmp4_error_set_vnet_buffer (vlib_buffer_t * b, u8 type, u8 code,
-                                 u32 data);
+
+static_always_inline void
+icmp4_error_set_vnet_buffer (vlib_buffer_t * b, u8 type, u8 code, u32 data)
+{
+  vnet_buffer (b)->ip.icmp.type = type;
+  vnet_buffer (b)->ip.icmp.code = code;
+  vnet_buffer (b)->ip.icmp.data = data;
+}
 
 #endif /* included_vnet_icmp4_h */
 
index 9da5926..2a3743f 100644 (file)
@@ -281,9 +281,6 @@ uword
 ip4_udp_register_listener (vlib_main_t * vm,
                           u16 dst_port, u32 next_node_index);
 
-void
-ip4_icmp_register_type (vlib_main_t * vm, icmp4_type_t type, u32 node_index);
-
 u16 ip4_tcp_udp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0,
                                  ip4_header_t * ip0);