aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gre/CMakeLists.txt35
-rw-r--r--src/plugins/gre/FEATURE.yaml (renamed from src/vnet/gre/FEATURE.yaml)0
-rw-r--r--src/plugins/gre/error.def (renamed from src/vnet/gre/error.def)0
-rw-r--r--src/plugins/gre/gre.api (renamed from src/vnet/gre/gre.api)0
-rw-r--r--src/plugins/gre/gre.c (renamed from src/vnet/gre/gre.c)195
-rw-r--r--src/plugins/gre/gre.h (renamed from src/vnet/gre/gre.h)2
-rw-r--r--src/plugins/gre/gre_api.c (renamed from src/vnet/gre/gre_api.c)84
-rw-r--r--src/plugins/gre/interface.c (renamed from src/vnet/gre/interface.c)169
-rw-r--r--src/plugins/gre/node.c (renamed from src/vnet/gre/node.c)220
-rw-r--r--src/plugins/gre/pg.c (renamed from src/vnet/gre/pg.c)14
-rw-r--r--src/plugins/gre/plugin.c26
-rw-r--r--src/plugins/nsh/nsh.c2
-rw-r--r--src/vnet/CMakeLists.txt17
13 files changed, 374 insertions, 390 deletions
diff --git a/src/plugins/gre/CMakeLists.txt b/src/plugins/gre/CMakeLists.txt
new file mode 100644
index 00000000000..60fe540b968
--- /dev/null
+++ b/src/plugins/gre/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright (c) 2023 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(gre
+ SOURCES
+ gre.c
+ node.c
+ gre_api.c
+ interface.c
+ pg.c
+ plugin.c
+
+ MULTIARCH_SOURCES
+ node.c
+ gre.c
+
+ INSTALL_HEADERS
+ gre.h
+ error.def
+
+ API_FILES
+ gre.api
+
+)
+
diff --git a/src/vnet/gre/FEATURE.yaml b/src/plugins/gre/FEATURE.yaml
index 4b35b870dc3..4b35b870dc3 100644
--- a/src/vnet/gre/FEATURE.yaml
+++ b/src/plugins/gre/FEATURE.yaml
diff --git a/src/vnet/gre/error.def b/src/plugins/gre/error.def
index 161ecc1d874..161ecc1d874 100644
--- a/src/vnet/gre/error.def
+++ b/src/plugins/gre/error.def
diff --git a/src/vnet/gre/gre.api b/src/plugins/gre/gre.api
index 9c69ba4007d..9c69ba4007d 100644
--- a/src/vnet/gre/gre.api
+++ b/src/plugins/gre/gre.api
diff --git a/src/vnet/gre/gre.c b/src/plugins/gre/gre.c
index dc735e6a77b..a15717475f8 100644
--- a/src/vnet/gre/gre.c
+++ b/src/plugins/gre/gre.c
@@ -16,9 +16,11 @@
*/
#include <vnet/vnet.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
#include <vnet/adj/adj_midchain.h>
#include <vnet/tunnel/tunnel_dp.h>
+#include <vpp/app/version.h>
+#include <vnet/plugin/plugin.h>
extern gre_main_t gre_main;
@@ -44,7 +46,6 @@ typedef struct
} ip6_and_gre_union_t;
#endif /* CLIB_MARCH_VARIANT */
-
/* Packet trace structure */
typedef struct
{
@@ -59,25 +60,24 @@ typedef struct
ip46_address_t dst;
} gre_tx_trace_t;
-extern u8 *format_gre_tx_trace (u8 * s, va_list * args);
+extern u8 *format_gre_tx_trace (u8 *s, va_list *args);
#ifndef CLIB_MARCH_VARIANT
u8 *
-format_gre_tx_trace (u8 * s, va_list * args)
+format_gre_tx_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
gre_tx_trace_t *t = va_arg (*args, gre_tx_trace_t *);
- s = format (s, "GRE: tunnel %d len %d src %U dst %U",
- t->tunnel_id, t->length,
- format_ip46_address, &t->src, IP46_TYPE_ANY,
+ s = format (s, "GRE: tunnel %d len %d src %U dst %U", t->tunnel_id,
+ t->length, format_ip46_address, &t->src, IP46_TYPE_ANY,
format_ip46_address, &t->dst, IP46_TYPE_ANY);
return s;
}
u8 *
-format_gre_protocol (u8 * s, va_list * args)
+format_gre_protocol (u8 *s, va_list *args)
{
gre_protocol_t p = va_arg (*args, u32);
gre_main_t *gm = &gre_main;
@@ -92,7 +92,7 @@ format_gre_protocol (u8 * s, va_list * args)
}
u8 *
-format_gre_header_with_length (u8 * s, va_list * args)
+format_gre_header_with_length (u8 *s, va_list *args)
{
gre_main_t *gm = &gre_main;
gre_header_t *h = va_arg (*args, gre_header_t *);
@@ -113,17 +113,16 @@ format_gre_header_with_length (u8 * s, va_list * args)
gre_protocol_info_t *pi = gre_get_protocol_info (gm, p);
vlib_node_t *node = vlib_get_node (gm->vlib_main, pi->node_index);
if (node->format_buffer)
- s = format (s, "\n%U%U",
- format_white_space, indent,
- node->format_buffer, (void *) (h + 1),
- max_header_bytes - header_bytes);
+ s =
+ format (s, "\n%U%U", format_white_space, indent, node->format_buffer,
+ (void *) (h + 1), max_header_bytes - header_bytes);
}
return s;
}
u8 *
-format_gre_header (u8 * s, va_list * args)
+format_gre_header (u8 *s, va_list *args)
{
gre_header_t *h = va_arg (*args, gre_header_t *);
return format (s, "%U", format_gre_header_with_length, h, 0);
@@ -131,8 +130,7 @@ format_gre_header (u8 * s, va_list * args)
/* Returns gre protocol as an int in host byte order. */
uword
-unformat_gre_protocol_host_byte_order (unformat_input_t * input,
- va_list * args)
+unformat_gre_protocol_host_byte_order (unformat_input_t *input, va_list *args)
{
u16 *result = va_arg (*args, u16 *);
gre_main_t *gm = &gre_main;
@@ -151,18 +149,17 @@ unformat_gre_protocol_host_byte_order (unformat_input_t * input,
}
uword
-unformat_gre_protocol_net_byte_order (unformat_input_t * input,
- va_list * args)
+unformat_gre_protocol_net_byte_order (unformat_input_t *input, va_list *args)
{
u16 *result = va_arg (*args, u16 *);
if (!unformat_user (input, unformat_gre_protocol_host_byte_order, result))
return 0;
- *result = clib_host_to_net_u16 ((u16) * result);
+ *result = clib_host_to_net_u16 ((u16) *result);
return 1;
}
uword
-unformat_gre_header (unformat_input_t * input, va_list * args)
+unformat_gre_header (unformat_input_t *input, va_list *args)
{
u8 **result = va_arg (*args, u8 **);
gre_header_t _h, *h = &_h;
@@ -209,9 +206,8 @@ gre_proto_from_vnet_link (vnet_link_t link)
}
static u8 *
-gre_build_rewrite (vnet_main_t * vnm,
- u32 sw_if_index,
- vnet_link_t link_type, const void *dst_address)
+gre_build_rewrite (vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type,
+ const void *dst_address)
{
gre_main_t *gm = &gre_main;
const ip46_address_t *dst;
@@ -276,8 +272,8 @@ gre_build_rewrite (vnet_main_t * vnm,
}
static void
-gre44_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+gre44_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
tunnel_encap_decap_flags_t flags;
ip4_and_gre_header_t *ip0;
@@ -294,8 +290,8 @@ gre44_fixup (vlib_main_t * vm,
}
static void
-gre64_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+gre64_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
tunnel_encap_decap_flags_t flags;
ip4_and_gre_header_t *ip0;
@@ -312,8 +308,8 @@ gre64_fixup (vlib_main_t * vm,
}
static void
-grex4_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+grex4_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
ip4_header_t *ip0;
@@ -326,8 +322,8 @@ grex4_fixup (vlib_main_t * vm,
}
static void
-gre46_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+gre46_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
tunnel_encap_decap_flags_t flags;
ip6_and_gre_header_t *ip0;
@@ -337,15 +333,14 @@ gre46_fixup (vlib_main_t * vm,
/* Fixup the payload length field in the GRE tunnel encap that was applied
* at the midchain node */
- ip0->ip6.payload_length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
- sizeof (ip0->ip6));
+ ip0->ip6.payload_length = clib_host_to_net_u16 (
+ vlib_buffer_length_in_chain (vm, b0) - sizeof (ip0->ip6));
tunnel_encap_fixup_4o6 (flags, b0, (ip4_header_t *) (ip0 + 1), &ip0->ip6);
}
static void
-gre66_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+gre66_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
tunnel_encap_decap_flags_t flags;
ip6_and_gre_header_t *ip0;
@@ -355,15 +350,14 @@ gre66_fixup (vlib_main_t * vm,
/* Fixup the payload length field in the GRE tunnel encap that was applied
* at the midchain node */
- ip0->ip6.payload_length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
- sizeof (ip0->ip6));
+ ip0->ip6.payload_length = clib_host_to_net_u16 (
+ vlib_buffer_length_in_chain (vm, b0) - sizeof (ip0->ip6));
tunnel_encap_fixup_6o6 (flags, (ip6_header_t *) (ip0 + 1), &ip0->ip6);
}
static void
-grex6_fixup (vlib_main_t * vm,
- const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+grex6_fixup (vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0,
+ const void *data)
{
ip6_and_gre_header_t *ip0;
@@ -371,9 +365,8 @@ grex6_fixup (vlib_main_t * vm,
/* Fixup the payload length field in the GRE tunnel encap that was applied
* at the midchain node */
- ip0->ip6.payload_length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
- sizeof (ip0->ip6));
+ ip0->ip6.payload_length = clib_host_to_net_u16 (
+ vlib_buffer_length_in_chain (vm, b0) - sizeof (ip0->ip6));
}
/**
@@ -401,7 +394,7 @@ gre_get_fixup (fib_protocol_t fproto, vnet_link_t lt)
}
void
-gre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
+gre_update_adj (vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
{
gre_main_t *gm = &gre_main;
gre_tunnel_t *t;
@@ -420,12 +413,11 @@ gre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
af |= ADJ_FLAG_MIDCHAIN_IP_STACK;
- adj_nbr_midchain_update_rewrite
- (ai, gre_get_fixup (t->tunnel_dst.fp_proto,
- adj_get_link_type (ai)),
- uword_to_pointer (t->flags, void *), af,
- gre_build_rewrite (vnm, sw_if_index, adj_get_link_type (ai),
- &t->tunnel_dst.fp_addr));
+ adj_nbr_midchain_update_rewrite (
+ ai, gre_get_fixup (t->tunnel_dst.fp_proto, adj_get_link_type (ai)),
+ uword_to_pointer (t->flags, void *), af,
+ gre_build_rewrite (vnm, sw_if_index, adj_get_link_type (ai),
+ &t->tunnel_dst.fp_addr));
gre_tunnel_stack (ai);
}
@@ -446,15 +438,12 @@ mgre_mk_complete_walk (adj_index_t ai, void *data)
if (!(ctx->t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
af |= ADJ_FLAG_MIDCHAIN_IP_STACK;
- adj_nbr_midchain_update_rewrite
- (ai, gre_get_fixup (ctx->t->tunnel_dst.fp_proto,
- adj_get_link_type (ai)),
- uword_to_pointer (ctx->t->flags, void *),
- af,
- gre_build_rewrite (vnet_get_main (),
- ctx->t->sw_if_index,
- adj_get_link_type (ai),
- &teib_entry_get_nh (ctx->ne)->fp_addr));
+ adj_nbr_midchain_update_rewrite (
+ ai, gre_get_fixup (ctx->t->tunnel_dst.fp_proto, adj_get_link_type (ai)),
+ uword_to_pointer (ctx->t->flags, void *), af,
+ gre_build_rewrite (vnet_get_main (), ctx->t->sw_if_index,
+ adj_get_link_type (ai),
+ &teib_entry_get_nh (ctx->ne)->fp_addr));
teib_entry_adj_stack (ctx->ne, ai);
@@ -466,9 +455,9 @@ mgre_mk_incomplete_walk (adj_index_t ai, void *data)
{
gre_tunnel_t *t = data;
- adj_nbr_midchain_update_rewrite (ai, gre_get_fixup (t->tunnel_dst.fp_proto,
- adj_get_link_type (ai)),
- NULL, ADJ_FLAG_NONE, NULL);
+ adj_nbr_midchain_update_rewrite (
+ ai, gre_get_fixup (t->tunnel_dst.fp_proto, adj_get_link_type (ai)), NULL,
+ ADJ_FLAG_NONE, NULL);
adj_midchain_delegate_unstack (ai);
@@ -476,7 +465,7 @@ mgre_mk_incomplete_walk (adj_index_t ai, void *data)
}
void
-mgre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
+mgre_update_adj (vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
{
gre_main_t *gm = &gre_main;
ip_adjacency_t *adj;
@@ -488,8 +477,8 @@ mgre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
t = pool_elt_at_index (gm->tunnels, ti);
- ne = teib_entry_find_46 (sw_if_index,
- adj->ia_nh_proto, &adj->sub_type.nbr.next_hop);
+ ne = teib_entry_find_46 (sw_if_index, adj->ia_nh_proto,
+ &adj->sub_type.nbr.next_hop);
if (NULL == ne)
{
@@ -500,13 +489,9 @@ mgre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
return;
}
- mgre_walk_ctx_t ctx = {
- .t = t,
- .ne = ne
- };
- adj_nbr_walk_nh (sw_if_index,
- adj->ia_nh_proto,
- &adj->sub_type.nbr.next_hop, mgre_mk_complete_walk, &ctx);
+ mgre_walk_ctx_t ctx = { .t = t, .ne = ne };
+ adj_nbr_walk_nh (sw_if_index, adj->ia_nh_proto, &adj->sub_type.nbr.next_hop,
+ mgre_mk_complete_walk, &ctx);
}
#endif /* CLIB_MARCH_VARIANT */
@@ -521,9 +506,8 @@ typedef enum
* L3 traffic uses the adj-midchains.
*/
static_always_inline u32
-gre_encap_inline (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame, gre_tunnel_type_t type)
+gre_encap_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame, gre_tunnel_type_t type)
{
gre_main_t *gm = &gre_main;
u32 *from, n_left_from;
@@ -539,8 +523,8 @@ gre_encap_inline (vlib_main_t * vm,
while (n_left_from >= 2)
{
- if (PREDICT_FALSE
- (sw_if_index[0] != vnet_buffer (b[0])->sw_if_index[VLIB_TX]))
+ if (PREDICT_FALSE (sw_if_index[0] !=
+ vnet_buffer (b[0])->sw_if_index[VLIB_TX]))
{
const vnet_hw_interface_t *hi;
sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
@@ -548,8 +532,8 @@ gre_encap_inline (vlib_main_t * vm,
gt[0] = &gm->tunnels[hi->dev_instance];
adj_index[0] = gt[0]->l2_adj_index;
}
- if (PREDICT_FALSE
- (sw_if_index[1] != vnet_buffer (b[1])->sw_if_index[VLIB_TX]))
+ if (PREDICT_FALSE (sw_if_index[1] !=
+ vnet_buffer (b[1])->sw_if_index[VLIB_TX]))
{
const vnet_hw_interface_t *hi;
sw_if_index[1] = vnet_buffer (b[1])->sw_if_index[VLIB_TX];
@@ -592,8 +576,7 @@ gre_encap_inline (vlib_main_t * vm,
if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
{
- gre_tx_trace_t *tr = vlib_add_trace (vm, node,
- b[0], sizeof (*tr));
+ gre_tx_trace_t *tr = vlib_add_trace (vm, node, b[0], sizeof (*tr));
tr->tunnel_id = gt[0] - gm->tunnels;
tr->src = gt[0]->tunnel_src;
tr->dst = gt[0]->tunnel_dst.fp_addr;
@@ -601,8 +584,7 @@ gre_encap_inline (vlib_main_t * vm,
}
if (PREDICT_FALSE (b[1]->flags & VLIB_BUFFER_IS_TRACED))
{
- gre_tx_trace_t *tr = vlib_add_trace (vm, node,
- b[1], sizeof (*tr));
+ gre_tx_trace_t *tr = vlib_add_trace (vm, node, b[1], sizeof (*tr));
tr->tunnel_id = gt[1] - gm->tunnels;
tr->src = gt[1]->tunnel_src;
tr->dst = gt[1]->tunnel_dst.fp_addr;
@@ -616,8 +598,8 @@ gre_encap_inline (vlib_main_t * vm,
while (n_left_from >= 1)
{
- if (PREDICT_FALSE
- (sw_if_index[0] != vnet_buffer (b[0])->sw_if_index[VLIB_TX]))
+ if (PREDICT_FALSE (sw_if_index[0] !=
+ vnet_buffer (b[0])->sw_if_index[VLIB_TX]))
{
const vnet_hw_interface_t *hi;
sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
@@ -646,8 +628,7 @@ gre_encap_inline (vlib_main_t * vm,
if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
{
- gre_tx_trace_t *tr = vlib_add_trace (vm, node,
- b[0], sizeof (*tr));
+ gre_tx_trace_t *tr = vlib_add_trace (vm, node, b[0], sizeof (*tr));
tr->tunnel_id = gt[0] - gm->tunnels;
tr->src = gt[0]->tunnel_src;
tr->dst = gt[0]->tunnel_dst.fp_addr;
@@ -658,32 +639,29 @@ gre_encap_inline (vlib_main_t * vm,
n_left_from -= 1;
}
- vlib_buffer_enqueue_to_single_next (vm, node, from,
- GRE_ENCAP_NEXT_L2_MIDCHAIN,
- frame->n_vectors);
+ vlib_buffer_enqueue_to_single_next (
+ vm, node, from, GRE_ENCAP_NEXT_L2_MIDCHAIN, frame->n_vectors);
- vlib_node_increment_counter (vm, node->node_index,
- GRE_ERROR_PKTS_ENCAP, frame->n_vectors);
+ vlib_node_increment_counter (vm, node->node_index, GRE_ERROR_PKTS_ENCAP,
+ frame->n_vectors);
return frame->n_vectors;
}
static char *gre_error_strings[] = {
-#define gre_error(n,s) s,
+#define gre_error(n, s) s,
#include "error.def"
#undef gre_error
};
-VLIB_NODE_FN (gre_teb_encap_node) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (gre_teb_encap_node)
+(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
{
return (gre_encap_inline (vm, node, frame, GRE_TUNNEL_TYPE_TEB));
}
-VLIB_NODE_FN (gre_erspan_encap_node) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (gre_erspan_encap_node)
+(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
{
return (gre_encap_inline (vm, node, frame, GRE_TUNNEL_TYPE_ERSPAN));
}
@@ -719,7 +697,7 @@ VLIB_REGISTER_NODE (gre_erspan_encap_node) =
#ifndef CLIB_MARCH_VARIANT
static u8 *
-format_gre_tunnel_name (u8 * s, va_list * args)
+format_gre_tunnel_name (u8 *s, va_list *args)
{
u32 dev_instance = va_arg (*args, u32);
gre_main_t *gm = &gre_main;
@@ -733,7 +711,7 @@ format_gre_tunnel_name (u8 * s, va_list * args)
}
static u8 *
-format_gre_device (u8 * s, va_list * args)
+format_gre_device (u8 *s, va_list *args)
{
u32 dev_instance = va_arg (*args, u32);
CLIB_UNUSED (int verbose) = va_arg (*args, int);
@@ -743,8 +721,8 @@ format_gre_device (u8 * s, va_list * args)
}
static int
-gre_tunnel_desc (u32 sw_if_index,
- ip46_address_t * src, ip46_address_t * dst, u8 * is_l2)
+gre_tunnel_desc (u32 sw_if_index, ip46_address_t *src, ip46_address_t *dst,
+ u8 *is_l2)
{
gre_main_t *gm = &gre_main;
gre_tunnel_t *t;
@@ -776,7 +754,8 @@ VNET_DEVICE_CLASS (gre_device_class) = {
#ifdef SOON
.clear counter = 0;
#endif
-};
+}
+;
VNET_HW_INTERFACE_CLASS (gre_hw_interface_class) = {
.name = "GRE",
@@ -799,7 +778,7 @@ VNET_HW_INTERFACE_CLASS (mgre_hw_interface_class) = {
#endif /* CLIB_MARCH_VARIANT */
static void
-add_protocol (gre_main_t * gm, gre_protocol_t protocol, char *protocol_name)
+add_protocol (gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
{
gre_protocol_info_t *pi;
u32 i;
@@ -816,7 +795,7 @@ add_protocol (gre_main_t * gm, gre_protocol_t protocol, char *protocol_name)
}
static clib_error_t *
-gre_init (vlib_main_t * vm)
+gre_init (vlib_main_t *vm)
{
gre_main_t *gm = &gre_main;
clib_error_t *error;
@@ -850,7 +829,7 @@ gre_init (vlib_main_t * vm)
gm->seq_num_by_key =
hash_create_mem (0, sizeof (gre_sn_key_t), sizeof (uword));
-#define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
+#define _(n, s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
foreach_gre_protocol
#undef _
return vlib_call_init_function (vm, gre_input_init);
diff --git a/src/vnet/gre/gre.h b/src/plugins/gre/gre.h
index ea085bf0fa1..9e17efcf7ef 100644
--- a/src/vnet/gre/gre.h
+++ b/src/plugins/gre/gre.h
@@ -32,7 +32,7 @@ extern vnet_hw_interface_class_t mgre_hw_interface_class;
typedef enum
{
#define gre_error(n,s) GRE_ERROR_##n,
-#include <vnet/gre/error.def>
+#include <gre/error.def>
#undef gre_error
GRE_N_ERROR,
} gre_error_t;
diff --git a/src/vnet/gre/gre_api.c b/src/plugins/gre/gre_api.c
index 59a1d3d738d..f8e3ea654fc 100644
--- a/src/vnet/gre/gre_api.c
+++ b/src/plugins/gre/gre_api.c
@@ -23,26 +23,26 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
#include <vnet/fib/fib_table.h>
#include <vnet/tunnel/tunnel_types_api.h>
#include <vnet/ip/ip_types_api.h>
-#include <vnet/gre/gre.api_enum.h>
-#include <vnet/gre/gre.api_types.h>
+#include <gre/gre.api_enum.h>
+#include <gre/gre.api_types.h>
#define REPLY_MSG_ID_BASE gre_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
static int
-gre_tunnel_type_decode (vl_api_gre_tunnel_type_t in, gre_tunnel_type_t * out)
+gre_tunnel_type_decode (vl_api_gre_tunnel_type_t in, gre_tunnel_type_t *out)
{
switch (in)
{
-#define _(n, v) \
- case GRE_API_TUNNEL_TYPE_##n: \
- *out = GRE_TUNNEL_TYPE_##n; \
- return (0);
+#define _(n, v) \
+ case GRE_API_TUNNEL_TYPE_##n: \
+ *out = GRE_TUNNEL_TYPE_##n; \
+ return (0);
foreach_gre_tunnel_type
#undef _
}
@@ -57,10 +57,10 @@ gre_tunnel_type_encode (gre_tunnel_type_t in)
switch (in)
{
-#define _(n, v) \
- case GRE_TUNNEL_TYPE_##n: \
- out = GRE_API_TUNNEL_TYPE_##n; \
- break;
+#define _(n, v) \
+ case GRE_TUNNEL_TYPE_##n: \
+ out = GRE_API_TUNNEL_TYPE_##n; \
+ break;
foreach_gre_tunnel_type
#undef _
}
@@ -68,10 +68,10 @@ gre_tunnel_type_encode (gre_tunnel_type_t in)
return (out);
}
-static void vl_api_gre_tunnel_add_del_t_handler
- (vl_api_gre_tunnel_add_del_t * mp)
+static void
+vl_api_gre_tunnel_add_del_t_handler (vl_api_gre_tunnel_add_del_t *mp)
{
- vnet_gre_tunnel_add_del_args_t _a = { }, *a = &_a;
+ vnet_gre_tunnel_add_del_args_t _a = {}, *a = &_a;
vl_api_gre_tunnel_add_del_reply_t *rmp;
tunnel_encap_decap_flags_t flags;
u32 sw_if_index = ~0;
@@ -119,40 +119,38 @@ static void vl_api_gre_tunnel_add_del_t_handler
out:
/* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GRE_TUNNEL_ADD_DEL_REPLY,
- ({
- rmp->sw_if_index = ntohl (sw_if_index);
- }));
+ REPLY_MACRO2 (VL_API_GRE_TUNNEL_ADD_DEL_REPLY,
+ ({ rmp->sw_if_index = ntohl (sw_if_index); }));
/* *INDENT-ON* */
}
-static void send_gre_tunnel_details
- (gre_tunnel_t * t, vl_api_gre_tunnel_dump_t * mp)
+static void
+send_gre_tunnel_details (gre_tunnel_t *t, vl_api_gre_tunnel_dump_t *mp)
{
vl_api_gre_tunnel_details_t *rmp;
/* *INDENT-OFF* */
- REPLY_MACRO_DETAILS2(VL_API_GRE_TUNNEL_DETAILS,
- ({
- ip_address_encode (&t->tunnel_src, IP46_TYPE_ANY, &rmp->tunnel.src);
- ip_address_encode (&t->tunnel_dst.fp_addr, IP46_TYPE_ANY, &rmp->tunnel.dst);
-
- rmp->tunnel.outer_table_id =
- htonl (fib_table_get_table_id
- (t->outer_fib_index, t->tunnel_dst.fp_proto));
-
- rmp->tunnel.type = gre_tunnel_type_encode (t->type);
- rmp->tunnel.mode = tunnel_mode_encode (t->mode);
- rmp->tunnel.flags = tunnel_encap_decap_flags_encode (t->flags);
- rmp->tunnel.instance = htonl (t->user_instance);
- rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
- rmp->tunnel.session_id = htons (t->session_id);
- }));
+ REPLY_MACRO_DETAILS2 (
+ VL_API_GRE_TUNNEL_DETAILS, ({
+ ip_address_encode (&t->tunnel_src, IP46_TYPE_ANY, &rmp->tunnel.src);
+ ip_address_encode (&t->tunnel_dst.fp_addr, IP46_TYPE_ANY,
+ &rmp->tunnel.dst);
+
+ rmp->tunnel.outer_table_id = htonl (
+ fib_table_get_table_id (t->outer_fib_index, t->tunnel_dst.fp_proto));
+
+ rmp->tunnel.type = gre_tunnel_type_encode (t->type);
+ rmp->tunnel.mode = tunnel_mode_encode (t->mode);
+ rmp->tunnel.flags = tunnel_encap_decap_flags_encode (t->flags);
+ rmp->tunnel.instance = htonl (t->user_instance);
+ rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
+ rmp->tunnel.session_id = htons (t->session_id);
+ }));
/* *INDENT-ON* */
}
static void
-vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
+vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t *mp)
{
vl_api_registration_t *reg;
gre_main_t *gm = &gre_main;
@@ -169,9 +167,9 @@ vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
{
/* *INDENT-OFF* */
pool_foreach (t, gm->tunnels)
- {
- send_gre_tunnel_details(t, mp);
- }
+ {
+ send_gre_tunnel_details (t, mp);
+ }
/* *INDENT-ON* */
}
@@ -196,10 +194,10 @@ vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
*/
/* API definitions */
#include <vnet/format_fns.h>
-#include <vnet/gre/gre.api.c>
+#include <gre/gre.api.c>
static clib_error_t *
-gre_api_hookup (vlib_main_t * vm)
+gre_api_hookup (vlib_main_t *vm)
{
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/gre/interface.c b/src/plugins/gre/interface.c
index bb0be865664..8d93ebd0cf5 100644
--- a/src/vnet/gre/interface.c
+++ b/src/plugins/gre/interface.c
@@ -16,7 +16,7 @@
*/
#include <vnet/vnet.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
#include <vnet/ip/format.h>
#include <vnet/fib/fib_table.h>
#include <vnet/adj/adj_midchain.h>
@@ -26,15 +26,16 @@
#include <vnet/teib/teib.h>
u8 *
-format_gre_tunnel_type (u8 * s, va_list * args)
+format_gre_tunnel_type (u8 *s, va_list *args)
{
gre_tunnel_type_t type = va_arg (*args, int);
switch (type)
{
-#define _(n, v) case GRE_TUNNEL_TYPE_##n: \
- s = format (s, "%s", v); \
- break;
+#define _(n, v) \
+ case GRE_TUNNEL_TYPE_##n: \
+ s = format (s, "%s", v); \
+ break;
foreach_gre_tunnel_type
#undef _
}
@@ -43,15 +44,15 @@ format_gre_tunnel_type (u8 * s, va_list * args)
}
static u8 *
-format_gre_tunnel (u8 * s, va_list * args)
+format_gre_tunnel (u8 *s, va_list *args)
{
gre_tunnel_t *t = va_arg (*args, gre_tunnel_t *);
s = format (s, "[%d] instance %d src %U dst %U fib-idx %d sw-if-idx %d ",
- t->dev_instance, t->user_instance,
- format_ip46_address, &t->tunnel_src, IP46_TYPE_ANY,
- format_ip46_address, &t->tunnel_dst.fp_addr, IP46_TYPE_ANY,
- t->outer_fib_index, t->sw_if_index);
+ t->dev_instance, t->user_instance, format_ip46_address,
+ &t->tunnel_src, IP46_TYPE_ANY, format_ip46_address,
+ &t->tunnel_dst.fp_addr, IP46_TYPE_ANY, t->outer_fib_index,
+ t->sw_if_index);
s = format (s, "payload %U ", format_gre_tunnel_type, t->type);
s = format (s, "%U ", format_tunnel_mode, t->mode);
@@ -66,22 +67,22 @@ format_gre_tunnel (u8 * s, va_list * args)
}
static gre_tunnel_t *
-gre_tunnel_db_find (const vnet_gre_tunnel_add_del_args_t * a,
- u32 outer_fib_index, gre_tunnel_key_t * key)
+gre_tunnel_db_find (const vnet_gre_tunnel_add_del_args_t *a,
+ u32 outer_fib_index, gre_tunnel_key_t *key)
{
gre_main_t *gm = &gre_main;
uword *p;
if (!a->is_ipv6)
{
- gre_mk_key4 (a->src.ip4, a->dst.ip4, outer_fib_index,
- a->type, a->mode, a->session_id, &key->gtk_v4);
+ gre_mk_key4 (a->src.ip4, a->dst.ip4, outer_fib_index, a->type, a->mode,
+ a->session_id, &key->gtk_v4);
p = hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
}
else
{
- gre_mk_key6 (&a->src.ip6, &a->dst.ip6, outer_fib_index,
- a->type, a->mode, a->session_id, &key->gtk_v6);
+ gre_mk_key6 (&a->src.ip6, &a->dst.ip6, outer_fib_index, a->type, a->mode,
+ a->session_id, &key->gtk_v6);
p = hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6);
}
@@ -92,7 +93,7 @@ gre_tunnel_db_find (const vnet_gre_tunnel_add_del_args_t * a,
}
static void
-gre_tunnel_db_add (gre_tunnel_t * t, gre_tunnel_key_t * key)
+gre_tunnel_db_add (gre_tunnel_t *t, gre_tunnel_key_t *key)
{
gre_main_t *gm = &gre_main;
@@ -107,7 +108,7 @@ gre_tunnel_db_add (gre_tunnel_t * t, gre_tunnel_key_t * key)
}
static void
-gre_tunnel_db_remove (gre_tunnel_t * t, gre_tunnel_key_t * key)
+gre_tunnel_db_remove (gre_tunnel_t *t, gre_tunnel_key_t *key)
{
gre_main_t *gm = &gre_main;
@@ -213,7 +214,7 @@ mgre_adj_walk_cb (adj_index_t ai, void *ctx)
}
static void
-gre_tunnel_restack (gre_tunnel_t * gt)
+gre_tunnel_restack (gre_tunnel_t *gt)
{
fib_protocol_t proto;
@@ -235,8 +236,8 @@ gre_tunnel_restack (gre_tunnel_t * gt)
}
static void
-gre_teib_mk_key (const gre_tunnel_t * t,
- const teib_entry_t * ne, gre_tunnel_key_t * key)
+gre_teib_mk_key (const gre_tunnel_t *t, const teib_entry_t *ne,
+ gre_tunnel_key_t *key)
{
const fib_prefix_t *nh;
@@ -244,22 +245,20 @@ gre_teib_mk_key (const gre_tunnel_t * t,
/* construct the key using mode P2P so it can be found in the DP */
if (FIB_PROTOCOL_IP4 == nh->fp_proto)
- gre_mk_key4 (t->tunnel_src.ip4,
- nh->fp_addr.ip4,
- teib_entry_get_fib_index (ne),
- t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v4);
+ gre_mk_key4 (t->tunnel_src.ip4, nh->fp_addr.ip4,
+ teib_entry_get_fib_index (ne), t->type, TUNNEL_MODE_P2P, 0,
+ &key->gtk_v4);
else
- gre_mk_key6 (&t->tunnel_src.ip6,
- &nh->fp_addr.ip6,
- teib_entry_get_fib_index (ne),
- t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v6);
+ gre_mk_key6 (&t->tunnel_src.ip6, &nh->fp_addr.ip6,
+ teib_entry_get_fib_index (ne), t->type, TUNNEL_MODE_P2P, 0,
+ &key->gtk_v6);
}
/**
* An TEIB entry has been added
*/
static void
-gre_teib_entry_added (const teib_entry_t * ne)
+gre_teib_entry_added (const teib_entry_t *ne)
{
gre_main_t *gm = &gre_main;
const ip_address_t *nh;
@@ -290,20 +289,16 @@ gre_teib_entry_added (const teib_entry_t * ne)
/* update the rewrites for each of the adjacencies for this peer (overlay)
* using the next-hop (underlay) */
- mgre_walk_ctx_t ctx = {
- .t = t,
- .ne = ne
- };
+ mgre_walk_ctx_t ctx = { .t = t, .ne = ne };
nh = teib_entry_get_peer (ne);
- adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
- (AF_IP4 == ip_addr_version (nh) ?
- FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6),
- &ip_addr_46 (nh), mgre_mk_complete_walk, &ctx);
+ adj_nbr_walk_nh (
+ teib_entry_get_sw_if_index (ne),
+ (AF_IP4 == ip_addr_version (nh) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6),
+ &ip_addr_46 (nh), mgre_mk_complete_walk, &ctx);
}
static void
-gre_teib_entry_deleted (const teib_entry_t * ne)
+gre_teib_entry_deleted (const teib_entry_t *ne)
{
gre_main_t *gm = &gre_main;
const ip_address_t *nh;
@@ -330,11 +325,10 @@ gre_teib_entry_deleted (const teib_entry_t * ne)
nh = teib_entry_get_peer (ne);
/* make all the adjacencies incomplete */
- adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
- (AF_IP4 == ip_addr_version (nh) ?
- FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6),
- &ip_addr_46 (nh), mgre_mk_incomplete_walk, t);
+ adj_nbr_walk_nh (
+ teib_entry_get_sw_if_index (ne),
+ (AF_IP4 == ip_addr_version (nh) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6),
+ &ip_addr_46 (nh), mgre_mk_incomplete_walk, t);
}
static walk_rc_t
@@ -362,8 +356,8 @@ gre_tunnel_add_teib_walk (index_t nei, void *ctx)
}
static int
-vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
- u32 outer_fib_index, u32 * sw_if_indexp)
+vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t *a, u32 outer_fib_index,
+ u32 *sw_if_indexp)
{
gre_main_t *gm = &gre_main;
vnet_main_t *vnm = gm->vnet_main;
@@ -381,8 +375,8 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
clib_memset (t, 0, sizeof (*t));
/* Reconcile the real dev_instance and a possible requested instance */
- u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
- u32 u_idx = a->instance; /* user specified instance */
+ u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
+ u32 u_idx = a->instance; /* user specified instance */
if (u_idx == ~0)
u_idx = t_idx;
if (hash_get (gm->instance_used, u_idx))
@@ -392,8 +386,8 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
}
hash_set (gm->instance_used, u_idx, 1);
- t->dev_instance = t_idx; /* actual */
- t->user_instance = u_idx; /* name */
+ t->dev_instance = t_idx; /* actual */
+ t->user_instance = u_idx; /* name */
t->type = a->type;
t->mode = a->mode;
@@ -417,8 +411,9 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
vnet_eth_interface_registration_t eir = {};
/* Default MAC address (d00b:eed0:0000 + sw_if_index) */
- u8 address[6] =
- { 0xd0, 0x0b, 0xee, 0xd0, (u8) (t_idx >> 8), (u8) t_idx };
+ u8 address[6] = {
+ 0xd0, 0x0b, 0xee, 0xd0, (u8) (t_idx >> 8), (u8) t_idx
+ };
eir.dev_class_index = gre_device_class.index;
eir.dev_instance = t_idx;
@@ -500,8 +495,8 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
if (t->type != GRE_TUNNEL_TYPE_L3)
{
- t->l2_adj_index = adj_nbr_add_or_lock
- (t->tunnel_dst.fp_proto, VNET_LINK_ETHERNET, &zero_addr, sw_if_index);
+ t->l2_adj_index = adj_nbr_add_or_lock (
+ t->tunnel_dst.fp_proto, VNET_LINK_ETHERNET, &zero_addr, sw_if_index);
vnet_set_interface_l3_output_node (gm->vlib_main, sw_if_index,
(u8 *) "tunnel-output-no-count");
gre_update_adj (vnm, t->sw_if_index, t->l2_adj_index);
@@ -522,8 +517,8 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
}
static int
-vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
- u32 outer_fib_index, u32 * sw_if_indexp)
+vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t *a, u32 outer_fib_index,
+ u32 *sw_if_indexp)
{
gre_main_t *gm = &gre_main;
vnet_main_t *vnm = gm->vnet_main;
@@ -539,7 +534,7 @@ vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
teib_walk_itf (t->sw_if_index, gre_tunnel_delete_teib_walk, t);
sw_if_index = t->sw_if_index;
- vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
+ vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */);
/* make sure tunnel is removed from l2 bd or xconnect */
set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0,
@@ -578,14 +573,12 @@ vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
}
int
-vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
- u32 * sw_if_indexp)
+vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t *a, u32 *sw_if_indexp)
{
u32 outer_fib_index;
- outer_fib_index = fib_table_find ((a->is_ipv6 ?
- FIB_PROTOCOL_IP6 :
- FIB_PROTOCOL_IP4), a->outer_table_id);
+ outer_fib_index = fib_table_find (
+ (a->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4), a->outer_table_id);
if (~0 == outer_fib_index)
return VNET_API_ERROR_NO_SUCH_FIB;
@@ -603,7 +596,7 @@ vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
}
clib_error_t *
-gre_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
+gre_interface_admin_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags)
{
gre_main_t *gm = &gre_main;
vnet_hw_interface_t *hi;
@@ -628,7 +621,7 @@ gre_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
vnet_hw_interface_set_flags (vnm, hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
else
- vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
+ vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */);
gre_tunnel_restack (t);
@@ -636,14 +629,13 @@ gre_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
}
static clib_error_t *
-create_gre_tunnel_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+create_gre_tunnel_command_fn (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
vnet_gre_tunnel_add_del_args_t _a, *a = &_a;
- ip46_address_t src = ip46_address_initializer, dst =
- ip46_address_initializer;
+ ip46_address_t src = ip46_address_initializer,
+ dst = ip46_address_initializer;
u32 instance = ~0;
u32 outer_table_id = 0;
gre_tunnel_type_t t_type = GRE_TUNNEL_TYPE_L3;
@@ -677,10 +669,8 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
t_type = GRE_TUNNEL_TYPE_TEB;
else if (unformat (line_input, "erspan %d", &session_id))
t_type = GRE_TUNNEL_TYPE_ERSPAN;
- else
- if (unformat
- (line_input, "flags %U", unformat_tunnel_encap_decap_flags,
- &flags))
+ else if (unformat (line_input, "flags %U",
+ unformat_tunnel_encap_decap_flags, &flags))
;
else
{
@@ -710,8 +700,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
if (ip46_address_is_ip4 (&src) != ip46_address_is_ip4 (&dst))
{
- error =
- clib_error_return (0, "src and dst address must be the same AF");
+ error = clib_error_return (0, "src and dst address must be the same AF");
goto done;
}
@@ -746,15 +735,14 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
error = clib_error_return (0, "GRE tunnel doesn't exist");
goto done;
case VNET_API_ERROR_INVALID_SESSION_ID:
- error = clib_error_return (0, "session ID %d out of range\n",
- session_id);
+ error =
+ clib_error_return (0, "session ID %d out of range\n", session_id);
goto done;
case VNET_API_ERROR_INSTANCE_IN_USE:
error = clib_error_return (0, "Instance is in use");
goto done;
default:
- error =
- clib_error_return (0, "vnet_gre_tunnel_add_del returned %d", rv);
+ error = clib_error_return (0, "vnet_gre_tunnel_add_del returned %d", rv);
goto done;
}
@@ -768,16 +756,15 @@ done:
VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
.path = "create gre tunnel",
.short_help = "create gre tunnel src <addr> dst <addr> [instance <n>] "
- "[outer-fib-id <fib>] [teb | erspan <session-id>] [del] "
- "[multipoint]",
+ "[outer-fib-id <fib>] [teb | erspan <session-id>] [del] "
+ "[multipoint]",
.function = create_gre_tunnel_command_fn,
};
/* *INDENT-ON* */
static clib_error_t *
-show_gre_tunnel_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+show_gre_tunnel_command_fn (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
{
gre_main_t *gm = &gre_main;
gre_tunnel_t *t;
@@ -798,9 +785,9 @@ show_gre_tunnel_command_fn (vlib_main_t * vm,
{
/* *INDENT-OFF* */
pool_foreach (t, gm->tunnels)
- {
- vlib_cli_output (vm, "%U", format_gre_tunnel, t);
- }
+ {
+ vlib_cli_output (vm, "%U", format_gre_tunnel, t);
+ }
/* *INDENT-ON* */
}
else
@@ -815,8 +802,8 @@ show_gre_tunnel_command_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
- .path = "show gre tunnel",
- .function = show_gre_tunnel_command_fn,
+ .path = "show gre tunnel",
+ .function = show_gre_tunnel_command_fn,
};
/* *INDENT-ON* */
@@ -827,7 +814,7 @@ const static teib_vft_t gre_teib_vft = {
/* force inclusion from application's main.c */
clib_error_t *
-gre_interface_init (vlib_main_t * vm)
+gre_interface_init (vlib_main_t *vm)
{
teib_register (&gre_teib_vft);
diff --git a/src/vnet/gre/node.c b/src/plugins/gre/node.c
index fdd3118bf3c..7ee22c3cb11 100644
--- a/src/vnet/gre/node.c
+++ b/src/plugins/gre/node.c
@@ -17,21 +17,21 @@
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
#include <vnet/mpls/mpls.h>
#include <vppinfra/sparse_vec.h>
-#define foreach_gre_input_next \
-_(PUNT, "error-punt") \
-_(DROP, "error-drop") \
-_(ETHERNET_INPUT, "ethernet-input") \
-_(IP4_INPUT, "ip4-input") \
-_(IP6_INPUT, "ip6-input") \
-_(MPLS_INPUT, "mpls-input")
+#define foreach_gre_input_next \
+ _ (PUNT, "error-punt") \
+ _ (DROP, "error-drop") \
+ _ (ETHERNET_INPUT, "ethernet-input") \
+ _ (IP4_INPUT, "ip4-input") \
+ _ (IP6_INPUT, "ip6-input") \
+ _ (MPLS_INPUT, "mpls-input")
typedef enum
{
-#define _(s,n) GRE_INPUT_NEXT_##s,
+#define _(s, n) GRE_INPUT_NEXT_##s,
foreach_gre_input_next
#undef _
GRE_INPUT_N_NEXT,
@@ -45,20 +45,19 @@ typedef struct
ip46_address_t dst;
} gre_rx_trace_t;
-extern u8 *format_gre_rx_trace (u8 * s, va_list * args);
+extern u8 *format_gre_rx_trace (u8 *s, va_list *args);
#ifndef CLIB_MARCH_VARIANT
u8 *
-format_gre_rx_trace (u8 * s, va_list * args)
+format_gre_rx_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
gre_rx_trace_t *t = va_arg (*args, gre_rx_trace_t *);
- s = format (s, "GRE: tunnel %d len %d src %U dst %U",
- t->tunnel_id, clib_net_to_host_u16 (t->length),
- format_ip46_address, &t->src, IP46_TYPE_ANY,
- format_ip46_address, &t->dst, IP46_TYPE_ANY);
+ s = format (s, "GRE: tunnel %d len %d src %U dst %U", t->tunnel_id,
+ clib_net_to_host_u16 (t->length), format_ip46_address, &t->src,
+ IP46_TYPE_ANY, format_ip46_address, &t->dst, IP46_TYPE_ANY);
return s;
}
#endif /* CLIB_MARCH_VARIANT */
@@ -71,12 +70,11 @@ typedef struct
} gre_input_runtime_t;
always_inline void
-gre_trace (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t * b,
- u32 tun_sw_if_index, const ip6_header_t * ip6,
- const ip4_header_t * ip4, int is_ipv6)
+gre_trace (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b,
+ u32 tun_sw_if_index, const ip6_header_t *ip6,
+ const ip4_header_t *ip4, int is_ipv6)
{
- gre_rx_trace_t *tr = vlib_add_trace (vm, node,
- b, sizeof (*tr));
+ gre_rx_trace_t *tr = vlib_add_trace (vm, node, b, sizeof (*tr));
tr->tunnel_id = tun_sw_if_index;
if (is_ipv6)
{
@@ -97,14 +95,14 @@ gre_trace (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t * b,
}
always_inline void
-gre_tunnel_get (const gre_main_t * gm, vlib_node_runtime_t * node,
- vlib_buffer_t * b, u16 * next, const gre_tunnel_key_t * key,
- gre_tunnel_key_t * cached_key, u32 * tun_sw_if_index,
- u32 * cached_tun_sw_if_index, int is_ipv6)
+gre_tunnel_get (const gre_main_t *gm, vlib_node_runtime_t *node,
+ vlib_buffer_t *b, u16 *next, const gre_tunnel_key_t *key,
+ gre_tunnel_key_t *cached_key, u32 *tun_sw_if_index,
+ u32 *cached_tun_sw_if_index, int is_ipv6)
{
const uword *p;
- p = is_ipv6 ? hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6)
- : hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
+ p = is_ipv6 ? hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6) :
+ hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
if (PREDICT_FALSE (!p))
{
*next = GRE_INPUT_NEXT_DROP;
@@ -124,8 +122,7 @@ gre_tunnel_get (const gre_main_t * gm, vlib_node_runtime_t * node,
}
always_inline uword
-gre_input (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame,
+gre_input (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame,
const int is_ipv6)
{
gre_main_t *gm = &gre_main;
@@ -217,23 +214,23 @@ gre_input (vlib_main_t * vm,
type[0] = ni[0].tunnel_type;
type[1] = ni[1].tunnel_type;
- b[0]->error = nidx[0] == SPARSE_VEC_INVALID_INDEX
- ? node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
- : node->errors[GRE_ERROR_NONE];
- b[1]->error = nidx[1] == SPARSE_VEC_INVALID_INDEX
- ? node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
- : node->errors[GRE_ERROR_NONE];
+ b[0]->error = nidx[0] == SPARSE_VEC_INVALID_INDEX ?
+ node->errors[GRE_ERROR_UNKNOWN_PROTOCOL] :
+ node->errors[GRE_ERROR_NONE];
+ b[1]->error = nidx[1] == SPARSE_VEC_INVALID_INDEX ?
+ node->errors[GRE_ERROR_UNKNOWN_PROTOCOL] :
+ node->errors[GRE_ERROR_NONE];
version[0] = clib_net_to_host_u16 (gre[0]->flags_and_version);
version[1] = clib_net_to_host_u16 (gre[1]->flags_and_version);
version[0] &= GRE_VERSION_MASK;
version[1] &= GRE_VERSION_MASK;
- b[0]->error = version[0]
- ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[0]->error;
+ b[0]->error =
+ version[0] ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[0]->error;
next[0] = version[0] ? GRE_INPUT_NEXT_DROP : next[0];
- b[1]->error = version[1]
- ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[1]->error;
+ b[1]->error =
+ version[1] ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[1]->error;
next[1] = version[1] ? GRE_INPUT_NEXT_DROP : next[1];
len[0] = vlib_buffer_length_in_chain (vm, b[0]);
@@ -242,27 +239,23 @@ gre_input (vlib_main_t * vm,
/* always search for P2P types in the DP */
if (is_ipv6)
{
- gre_mk_key6 (&ip6[0]->dst_address,
- &ip6[0]->src_address,
- vnet_buffer (b[0])->ip.fib_index,
- type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
- gre_mk_key6 (&ip6[1]->dst_address,
- &ip6[1]->src_address,
- vnet_buffer (b[1])->ip.fib_index,
- type[1], TUNNEL_MODE_P2P, 0, &key[1].gtk_v6);
+ gre_mk_key6 (&ip6[0]->dst_address, &ip6[0]->src_address,
+ vnet_buffer (b[0])->ip.fib_index, type[0],
+ TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
+ gre_mk_key6 (&ip6[1]->dst_address, &ip6[1]->src_address,
+ vnet_buffer (b[1])->ip.fib_index, type[1],
+ TUNNEL_MODE_P2P, 0, &key[1].gtk_v6);
matched[0] = gre_match_key6 (&cached_key.gtk_v6, &key[0].gtk_v6);
matched[1] = gre_match_key6 (&cached_key.gtk_v6, &key[1].gtk_v6);
}
else
{
- gre_mk_key4 (ip4[0]->dst_address,
- ip4[0]->src_address,
- vnet_buffer (b[0])->ip.fib_index,
- type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
- gre_mk_key4 (ip4[1]->dst_address,
- ip4[1]->src_address,
- vnet_buffer (b[1])->ip.fib_index,
- type[1], TUNNEL_MODE_P2P, 0, &key[1].gtk_v4);
+ gre_mk_key4 (ip4[0]->dst_address, ip4[0]->src_address,
+ vnet_buffer (b[0])->ip.fib_index, type[0],
+ TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
+ gre_mk_key4 (ip4[1]->dst_address, ip4[1]->src_address,
+ vnet_buffer (b[1])->ip.fib_index, type[1],
+ TUNNEL_MODE_P2P, 0, &key[1].gtk_v4);
matched[0] = gre_match_key4 (&cached_key.gtk_v4, &key[0].gtk_v4);
matched[1] = gre_match_key4 (&cached_key.gtk_v4, &key[1].gtk_v4);
}
@@ -271,33 +264,27 @@ gre_input (vlib_main_t * vm,
tun_sw_if_index[1] = cached_tun_sw_if_index;
if (PREDICT_FALSE (!matched[0]))
gre_tunnel_get (gm, node, b[0], &next[0], &key[0], &cached_key,
- &tun_sw_if_index[0], &cached_tun_sw_if_index,
- is_ipv6);
+ &tun_sw_if_index[0], &cached_tun_sw_if_index, is_ipv6);
if (PREDICT_FALSE (!matched[1]))
gre_tunnel_get (gm, node, b[1], &next[1], &key[1], &cached_key,
- &tun_sw_if_index[1], &cached_tun_sw_if_index,
- is_ipv6);
+ &tun_sw_if_index[1], &cached_tun_sw_if_index, is_ipv6);
if (PREDICT_TRUE (next[0] > GRE_INPUT_NEXT_DROP))
{
- vlib_increment_combined_counter (&gm->vnet_main->
- interface_main.combined_sw_if_counters
- [VNET_INTERFACE_COUNTER_RX],
- vm->thread_index,
- tun_sw_if_index[0],
- 1 /* packets */ ,
- len[0] /* bytes */ );
+ vlib_increment_combined_counter (
+ &gm->vnet_main->interface_main
+ .combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX],
+ vm->thread_index, tun_sw_if_index[0], 1 /* packets */,
+ len[0] /* bytes */);
vnet_buffer (b[0])->sw_if_index[VLIB_RX] = tun_sw_if_index[0];
}
if (PREDICT_TRUE (next[1] > GRE_INPUT_NEXT_DROP))
{
- vlib_increment_combined_counter (&gm->vnet_main->
- interface_main.combined_sw_if_counters
- [VNET_INTERFACE_COUNTER_RX],
- vm->thread_index,
- tun_sw_if_index[1],
- 1 /* packets */ ,
- len[1] /* bytes */ );
+ vlib_increment_combined_counter (
+ &gm->vnet_main->interface_main
+ .combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX],
+ vm->thread_index, tun_sw_if_index[1], 1 /* packets */,
+ len[1] /* bytes */);
vnet_buffer (b[1])->sw_if_index[VLIB_RX] = tun_sw_if_index[1];
}
@@ -366,51 +353,46 @@ gre_input (vlib_main_t * vm,
next[0] = ni[0].next_index;
type[0] = ni[0].tunnel_type;
- b[0]->error = nidx[0] == SPARSE_VEC_INVALID_INDEX
- ? node->errors[GRE_ERROR_UNKNOWN_PROTOCOL]
- : node->errors[GRE_ERROR_NONE];
+ b[0]->error = nidx[0] == SPARSE_VEC_INVALID_INDEX ?
+ node->errors[GRE_ERROR_UNKNOWN_PROTOCOL] :
+ node->errors[GRE_ERROR_NONE];
version[0] = clib_net_to_host_u16 (gre[0]->flags_and_version);
version[0] &= GRE_VERSION_MASK;
- b[0]->error = version[0]
- ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[0]->error;
+ b[0]->error =
+ version[0] ? node->errors[GRE_ERROR_UNSUPPORTED_VERSION] : b[0]->error;
next[0] = version[0] ? GRE_INPUT_NEXT_DROP : next[0];
len[0] = vlib_buffer_length_in_chain (vm, b[0]);
if (is_ipv6)
{
- gre_mk_key6 (&ip6[0]->dst_address,
- &ip6[0]->src_address,
- vnet_buffer (b[0])->ip.fib_index,
- type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
+ gre_mk_key6 (&ip6[0]->dst_address, &ip6[0]->src_address,
+ vnet_buffer (b[0])->ip.fib_index, type[0],
+ TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
matched[0] = gre_match_key6 (&cached_key.gtk_v6, &key[0].gtk_v6);
}
else
{
- gre_mk_key4 (ip4[0]->dst_address,
- ip4[0]->src_address,
- vnet_buffer (b[0])->ip.fib_index,
- type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
+ gre_mk_key4 (ip4[0]->dst_address, ip4[0]->src_address,
+ vnet_buffer (b[0])->ip.fib_index, type[0],
+ TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
matched[0] = gre_match_key4 (&cached_key.gtk_v4, &key[0].gtk_v4);
}
tun_sw_if_index[0] = cached_tun_sw_if_index;
if (PREDICT_FALSE (!matched[0]))
gre_tunnel_get (gm, node, b[0], &next[0], &key[0], &cached_key,
- &tun_sw_if_index[0], &cached_tun_sw_if_index,
- is_ipv6);
+ &tun_sw_if_index[0], &cached_tun_sw_if_index, is_ipv6);
if (PREDICT_TRUE (next[0] > GRE_INPUT_NEXT_DROP))
{
- vlib_increment_combined_counter (&gm->vnet_main->
- interface_main.combined_sw_if_counters
- [VNET_INTERFACE_COUNTER_RX],
- vm->thread_index,
- tun_sw_if_index[0],
- 1 /* packets */ ,
- len[0] /* bytes */ );
+ vlib_increment_combined_counter (
+ &gm->vnet_main->interface_main
+ .combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX],
+ vm->thread_index, tun_sw_if_index[0], 1 /* packets */,
+ len[0] /* bytes */);
vnet_buffer (b[0])->sw_if_index[VLIB_RX] = tun_sw_if_index[0];
}
@@ -427,30 +409,27 @@ gre_input (vlib_main_t * vm,
vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
- vlib_node_increment_counter (vm,
- is_ipv6 ? gre6_input_node.index :
- gre4_input_node.index, GRE_ERROR_PKTS_DECAP,
- n_left_from);
+ vlib_node_increment_counter (
+ vm, is_ipv6 ? gre6_input_node.index : gre4_input_node.index,
+ GRE_ERROR_PKTS_DECAP, n_left_from);
return frame->n_vectors;
}
-VLIB_NODE_FN (gre4_input_node) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+VLIB_NODE_FN (gre4_input_node)
+(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
{
return gre_input (vm, node, from_frame, /* is_ip6 */ 0);
}
-VLIB_NODE_FN (gre6_input_node) (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+VLIB_NODE_FN (gre6_input_node)
+(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
{
return gre_input (vm, node, from_frame, /* is_ip6 */ 1);
}
static char *gre_error_strings[] = {
-#define gre_error(n,s) s,
+#define gre_error(n, s) s,
#include "error.def"
#undef gre_error
};
@@ -466,7 +445,7 @@ VLIB_REGISTER_NODE (gre4_input_node) = {
.n_next_nodes = GRE_INPUT_N_NEXT,
.next_nodes = {
-#define _(s,n) [GRE_INPUT_NEXT_##s] = n,
+#define _(s, n) [GRE_INPUT_NEXT_##s] = n,
foreach_gre_input_next
#undef _
},
@@ -488,7 +467,7 @@ VLIB_REGISTER_NODE (gre6_input_node) = {
.n_next_nodes = GRE_INPUT_N_NEXT,
.next_nodes = {
-#define _(s,n) [GRE_INPUT_NEXT_##s] = n,
+#define _(s, n) [GRE_INPUT_NEXT_##s] = n,
foreach_gre_input_next
#undef _
},
@@ -501,9 +480,8 @@ VLIB_REGISTER_NODE (gre6_input_node) = {
#ifndef CLIB_MARCH_VARIANT
void
-gre_register_input_protocol (vlib_main_t * vm,
- gre_protocol_t protocol, u32 node_index,
- gre_tunnel_type_t tunnel_type)
+gre_register_input_protocol (vlib_main_t *vm, gre_protocol_t protocol,
+ u32 node_index, gre_tunnel_type_t tunnel_type)
{
gre_main_t *em = &gre_main;
gre_protocol_info_t *pi;
@@ -531,7 +509,7 @@ gre_register_input_protocol (vlib_main_t * vm,
}
static void
-gre_setup_node (vlib_main_t * vm, u32 node_index)
+gre_setup_node (vlib_main_t *vm, u32 node_index)
{
vlib_node_t *n = vlib_get_node (vm, node_index);
pg_node_t *pn = pg_get_node (node_index);
@@ -542,7 +520,7 @@ gre_setup_node (vlib_main_t * vm, u32 node_index)
}
static clib_error_t *
-gre_input_init (vlib_main_t * vm)
+gre_input_init (vlib_main_t *vm)
{
gre_main_t *gm = &gre_main;
vlib_node_t *ethernet_input, *ip4_input, *ip6_input, *mpls_unicast_input;
@@ -557,9 +535,9 @@ gre_input_init (vlib_main_t * vm)
gre_setup_node (vm, gre4_input_node.index);
gre_setup_node (vm, gre6_input_node.index);
- gm->next_by_protocol = sparse_vec_new
- ( /* elt bytes */ sizeof (gm->next_by_protocol[0]),
- /* bits in index */ BITS (((gre_header_t *) 0)->protocol));
+ gm->next_by_protocol =
+ sparse_vec_new (/* elt bytes */ sizeof (gm->next_by_protocol[0]),
+ /* bits in index */ BITS (((gre_header_t *) 0)->protocol));
/* These could be moved to the supported protocol input node defn's */
ethernet_input = vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
@@ -571,14 +549,14 @@ gre_input_init (vlib_main_t * vm)
mpls_unicast_input = vlib_get_node_by_name (vm, (u8 *) "mpls-input");
ASSERT (mpls_unicast_input);
- gre_register_input_protocol (vm, GRE_PROTOCOL_teb,
- ethernet_input->index, GRE_TUNNEL_TYPE_TEB);
+ gre_register_input_protocol (vm, GRE_PROTOCOL_teb, ethernet_input->index,
+ GRE_TUNNEL_TYPE_TEB);
- gre_register_input_protocol (vm, GRE_PROTOCOL_ip4,
- ip4_input->index, GRE_TUNNEL_TYPE_L3);
+ gre_register_input_protocol (vm, GRE_PROTOCOL_ip4, ip4_input->index,
+ GRE_TUNNEL_TYPE_L3);
- gre_register_input_protocol (vm, GRE_PROTOCOL_ip6,
- ip6_input->index, GRE_TUNNEL_TYPE_L3);
+ gre_register_input_protocol (vm, GRE_PROTOCOL_ip6, ip6_input->index,
+ GRE_TUNNEL_TYPE_L3);
gre_register_input_protocol (vm, GRE_PROTOCOL_mpls_unicast,
mpls_unicast_input->index, GRE_TUNNEL_TYPE_L3);
diff --git a/src/vnet/gre/pg.c b/src/plugins/gre/pg.c
index 38a3a07ebad..91c9e487899 100644
--- a/src/vnet/gre/pg.c
+++ b/src/plugins/gre/pg.c
@@ -17,7 +17,7 @@
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
typedef struct
{
@@ -26,14 +26,14 @@ typedef struct
} pg_gre_header_t;
static inline void
-pg_gre_header_init (pg_gre_header_t * e)
+pg_gre_header_init (pg_gre_header_t *e)
{
pg_edit_init (&e->flags_and_version, gre_header_t, flags_and_version);
pg_edit_init (&e->protocol, gre_header_t, protocol);
}
uword
-unformat_pg_gre_header (unformat_input_t * input, va_list * args)
+unformat_pg_gre_header (unformat_input_t *input, va_list *args)
{
pg_stream_t *s = va_arg (*args, pg_stream_t *);
pg_gre_header_t *h;
@@ -46,8 +46,7 @@ unformat_pg_gre_header (unformat_input_t * input, va_list * args)
pg_edit_set_fixed (&h->flags_and_version, 0);
error = 1;
- if (!unformat (input, "%U",
- unformat_pg_edit,
+ if (!unformat (input, "%U", unformat_pg_edit,
unformat_gre_protocol_net_byte_order, &h->protocol))
goto done;
@@ -64,8 +63,8 @@ unformat_pg_gre_header (unformat_input_t * input, va_list * args)
pg_node = pg_get_node (pi->node_index);
}
- if (pg_node && pg_node->unformat_edit
- && unformat_user (input, pg_node->unformat_edit, s))
+ if (pg_node && pg_node->unformat_edit &&
+ unformat_user (input, pg_node->unformat_edit, s))
;
}
@@ -76,7 +75,6 @@ done:
return error == 0;
}
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/gre/plugin.c b/src/plugins/gre/plugin.c
new file mode 100644
index 00000000000..b92ec0b6dcd
--- /dev/null
+++ b/src/plugins/gre/plugin.c
@@ -0,0 +1,26 @@
+/*
+ * plugin.c: gre
+ *
+ * Copyright (c) 2023 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.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/plugin/plugin.h>
+#include <vpp/app/version.h>
+
+// register a plugin
+VLIB_PLUGIN_REGISTER () = {
+ .version = VPP_BUILD_VER,
+ .description = "Generic Routing Encapsulation (GRE) plugin",
+};
diff --git a/src/plugins/nsh/nsh.c b/src/plugins/nsh/nsh.c
index 391fa8dbac5..3c804e9934c 100644
--- a/src/plugins/nsh/nsh.c
+++ b/src/plugins/nsh/nsh.c
@@ -18,7 +18,7 @@
#include <vnet/vnet.h>
#include <vnet/plugin/plugin.h>
#include <nsh/nsh.h>
-#include <vnet/gre/gre.h>
+#include <gre/gre.h>
#include <vxlan/vxlan.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
#include <vnet/l2/l2_classify.h>
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index c1c9acc41a0..5aada92e8d9 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -668,27 +668,10 @@ list(APPEND VNET_API_FILES udp/udp.api)
##############################################################################
# Tunnel protocol: gre
##############################################################################
-list(APPEND VNET_SOURCES
- gre/gre.c
- gre/node.c
- gre/interface.c
- gre/pg.c
- gre/gre_api.c
-)
-
-list(APPEND VNET_MULTIARCH_SOURCES
- gre/node.c
- gre/gre.c
-)
-
list(APPEND VNET_HEADERS
- gre/gre.h
gre/packet.h
- gre/error.def
)
-list(APPEND VNET_API_FILES gre/gre.api)
-
##############################################################################
# Tunnel protocol: ipip
##############################################################################