aboutsummaryrefslogtreecommitdiffstats
path: root/router/router/tap_inject.h
diff options
context:
space:
mode:
authorJeff Shaw <jeffrey.b.shaw@intel.com>2016-09-21 19:12:46 -0400
committerJeff Shaw <jeffrey.b.shaw@intel.com>2016-10-04 15:58:00 -0400
commitdfae7756baf895957a43944f63bfe0c850b16467 (patch)
treecb8b0c5ae0a09835f9817a8956bd86dbf9a1de57 /router/router/tap_inject.h
parent961580e47e58e9cb7175ec89703bc951c7ce71b2 (diff)
[router] IPv6 support and refactoring.
This change adds support for IPv6 while refactoring most of the original plugin code in the following ways. - Adhere to vpp style guidelines. - Split the netlink, node, and tap processing into separate files named with a "tap_inject" prefix which more accurately represents the functionality. - Implement our own tap management and rx/tx. This is to reduce the overhead of passing packets in and out of vnet tap devices, in favor of directly reading/writing from the tap. - Change how nodes work. Now we have neighbor, rx, and tx nodes. The neighbor node sends ARP replies and ICMP6 neighbor advertisements to the arp-input and icmp6-neighbor-solicitation nodes, respectively, before also injecting the packet to the host, making it possible for both vpp and the host network stack to resolve the next hop. The tx node injects packets into the host by writing to the tap. The rx node reads packets from the tap and sends them on its associated data plane interface. - Simplify the CLI. Instead of creating taps specifically for a given interface we create a tap for all of the Ethernet interfaces with the "enable tap-inject" CLI command. The interfaces are named with a "vpp" prefix, i.e. "vpp0". Also add a "disable tap-inject" option. - Provide ability to enable at configuration time with the tap-inject { enable } stanza. Change-Id: I6b56da606e2da1d793ce6aca222fe4eb5a4e070d Signed-off-by: Jeff Shaw <jeffrey.b.shaw@intel.com>
Diffstat (limited to 'router/router/tap_inject.h')
-rw-r--r--router/router/tap_inject.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/router/router/tap_inject.h b/router/router/tap_inject.h
new file mode 100644
index 0000000..001ab52
--- /dev/null
+++ b/router/router/tap_inject.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016 Intel Corporation
+ *
+ * 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.
+ */
+
+#ifndef _TAP_INJECT_H
+#define _TAP_INJECT_H
+
+#include <vnet/plugin/plugin.h>
+#include <vnet/ip/ip.h>
+
+
+#ifndef ETHER_ADDR_LEN
+#define ETHER_ADDR_LEN 6
+#endif
+
+typedef struct {
+ /*
+ * tap-inject can be enabled or disabled in config file or during runtime.
+ * When disabled in config, it is not possible to enable during runtime.
+ *
+ * When the netlink-only option is used, netlink configuration is monitored
+ * and mirrored to the data plane but no traffic is passed between the host
+ * and the data plane.
+ */
+#define TAP_INJECT_F_CONFIG_ENABLE (1U << 0)
+#define TAP_INJECT_F_CONFIG_DISABLE (1U << 1)
+#define TAP_INJECT_F_CONFIG_NETLINK (1U << 2)
+#define TAP_INJECT_F_ENABLED (1U << 3)
+
+ u32 flags;
+
+ u32 * sw_if_index_to_tap_fd;
+ u32 * sw_if_index_to_tap_if_index;
+ u32 * tap_fd_to_sw_if_index;
+ u32 * tap_if_index_to_sw_if_index;
+
+ u32 * interfaces_to_enable;
+ u32 * interfaces_to_disable;
+
+ u32 * rx_file_descriptors;
+
+ u32 rx_node_index;
+ u32 tx_node_index;
+ u32 neighbor_node_index;
+
+ u32 * rx_buffers;
+
+} tap_inject_main_t;
+
+
+tap_inject_main_t * tap_inject_get_main (void);
+
+void tap_inject_insert_tap (u32 sw_if_index, u32 tap_fd, u32 tap_if_index);
+void tap_inject_delete_tap (u32 sw_if_index);
+
+u32 tap_inject_lookup_tap_fd (u32 sw_if_index);
+u32 tap_inject_lookup_sw_if_index_from_tap_fd (u32 tap_fd);
+u32 tap_inject_lookup_sw_if_index_from_tap_if_index (u32 tap_if_index);
+
+static inline int
+tap_inject_is_enabled (void)
+{
+ tap_inject_main_t * im = tap_inject_get_main ();
+
+ return !!(im->flags & TAP_INJECT_F_ENABLED);
+}
+
+static inline int
+tap_inject_is_config_enabled (void)
+{
+ tap_inject_main_t * im = tap_inject_get_main ();
+
+ return !!(im->flags & TAP_INJECT_F_CONFIG_ENABLE);
+}
+
+static inline int
+tap_inject_is_config_disabled (void)
+{
+ tap_inject_main_t * im = tap_inject_get_main ();
+
+ return !!(im->flags & TAP_INJECT_F_CONFIG_DISABLE);
+}
+
+
+/* Netlink */
+
+void tap_inject_enable_netlink (void);
+
+
+/* Tap */
+
+clib_error_t * tap_inject_tap_connect (vnet_hw_interface_t * hw);
+clib_error_t * tap_inject_tap_disconnect (u32 sw_if_index);
+
+u8 * format_tap_inject_tap_name (u8 * s, va_list * args);
+
+#endif /* _TAP_INJECT_H */