summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/ethernet/node.c3
-rw-r--r--vnet/vnet/gre/gre.c45
-rw-r--r--vnet/vnet/gre/gre.h2
-rw-r--r--vnet/vnet/gre/interface.c38
-rw-r--r--vnet/vnet/gre/node.c28
-rw-r--r--vnet/vnet/gre/packet.h1
6 files changed, 90 insertions, 27 deletions
diff --git a/vnet/vnet/ethernet/node.c b/vnet/vnet/ethernet/node.c
index 74d4f476d7a..a8a4fcd074d 100644
--- a/vnet/vnet/ethernet/node.c
+++ b/vnet/vnet/ethernet/node.c
@@ -238,7 +238,8 @@ determine_next_node (ethernet_main_t * em,
{
*next0 = em->l2_next;
// record the L2 len and reset the buffer so the L2 header is preserved
- vnet_buffer (b0)->l2.l2_len = b0->current_data;
+ u32 eth_start = vnet_buffer (b0)->ethernet.start_of_ethernet_header;
+ vnet_buffer (b0)->l2.l2_len = b0->current_data - eth_start;
vlib_buffer_advance (b0, -ethernet_buffer_header_size (b0));
// check for common IP/MPLS ethertypes
diff --git a/vnet/vnet/gre/gre.c b/vnet/vnet/gre/gre.c
index 6d375159818..f00977c8cd6 100644
--- a/vnet/vnet/gre/gre.c
+++ b/vnet/vnet/gre/gre.c
@@ -283,17 +283,25 @@ gre_interface_tx (vlib_main_t * vm,
vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->outer_fib_index;
vnet_buffer (b1)->sw_if_index[VLIB_TX] = t->outer_fib_index;
- ip0 = vlib_buffer_get_current (b0);
- gre_protocol0 = clib_net_to_host_u16 (0x800);
- gre_protocol0 =
- ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
- 0x86DD : gre_protocol0;
-
- ip1 = vlib_buffer_get_current (b1);
- gre_protocol1 = clib_net_to_host_u16 (0x800);
- gre_protocol1 =
- ((ip1->ip_version_and_header_length & 0xF0) == 0x60) ?
- 0x86DD : gre_protocol1;
+ if (PREDICT_FALSE(t->teb))
+ {
+ gre_protocol0 = clib_net_to_host_u16(GRE_PROTOCOL_teb);
+ gre_protocol1 = clib_net_to_host_u16(GRE_PROTOCOL_teb);
+ }
+ else
+ {
+ ip0 = vlib_buffer_get_current (b0);
+ gre_protocol0 = clib_net_to_host_u16 (0x800);
+ gre_protocol0 =
+ ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
+ 0x86DD : gre_protocol0;
+
+ ip1 = vlib_buffer_get_current (b1);
+ gre_protocol1 = clib_net_to_host_u16 (0x800);
+ gre_protocol1 =
+ ((ip1->ip_version_and_header_length & 0xF0) == 0x60) ?
+ 0x86DD : gre_protocol1;
+ }
vlib_buffer_advance (b0, -sizeof(*h0));
vlib_buffer_advance (b1, -sizeof(*h1));
@@ -366,10 +374,17 @@ gre_interface_tx (vlib_main_t * vm,
vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->outer_fib_index;
ip0 = vlib_buffer_get_current (b0);
- gre_protocol0 = clib_net_to_host_u16 (0x800);
- gre_protocol0 =
- ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
- 0x86DD : gre_protocol0;
+ if (PREDICT_FALSE(t->teb))
+ {
+ gre_protocol0 = clib_net_to_host_u16(GRE_PROTOCOL_teb);
+ }
+ else
+ {
+ gre_protocol0 = clib_net_to_host_u16 (0x800);
+ gre_protocol0 =
+ ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
+ 0x86DD : gre_protocol0;
+ }
vlib_buffer_advance (b0, -sizeof(*h0));
diff --git a/vnet/vnet/gre/gre.h b/vnet/vnet/gre/gre.h
index d875be990c6..ad599d2f09e 100644
--- a/vnet/vnet/gre/gre.h
+++ b/vnet/vnet/gre/gre.h
@@ -55,6 +55,7 @@ typedef struct {
u32 outer_fib_index;
u32 hw_if_index;
u32 sw_if_index;
+ u8 teb;
} gre_tunnel_t;
typedef struct {
@@ -127,6 +128,7 @@ typedef struct {
ip4_address_t src, dst;
u32 outer_fib_id;
+ u8 teb;
} vnet_gre_add_del_tunnel_args_t;
int vnet_gre_add_del_tunnel
diff --git a/vnet/vnet/gre/interface.c b/vnet/vnet/gre/interface.c
index 03591e1ff41..864c384b992 100644
--- a/vnet/vnet/gre/interface.c
+++ b/vnet/vnet/gre/interface.c
@@ -26,10 +26,11 @@ u8 * format_gre_tunnel (u8 * s, va_list * args)
gre_main_t * gm = &gre_main;
s = format (s,
- "[%d] %U (src) %U (dst) outer_fib_index %d",
+ "[%d] %U (src) %U (dst) payload %s outer_fib_index %d",
t - gm->tunnels,
format_ip4_address, &t->tunnel_src,
format_ip4_address, &t->tunnel_dst,
+ (t->teb ? "teb" : "ip"),
t->outer_fib_index);
return s;
}
@@ -47,6 +48,8 @@ int vnet_gre_add_del_tunnel
u32 outer_fib_index;
uword * p;
u64 key;
+ u8 address[6];
+ clib_error_t *error;
key = (u64)a->src.as_u32 << 32 | (u64)a->dst.as_u32;
p = hash_get (gm->tunnel_by_key, key);
@@ -87,12 +90,34 @@ int vnet_gre_add_del_tunnel
(&im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP], sw_if_index);
vnet_interface_counter_unlock(im);
} else {
+ if (a->teb)
+ {
+ /* Default MAC address (d00b:eed0:0000 + sw_if_index) */
+ memset (address, 0, sizeof (address));
+ address[0] = 0xd0;
+ address[1] = 0x0b;
+ address[2] = 0xee;
+ address[3] = 0xd0;
+ address[4] = t - gm->tunnels;
+
+ error = ethernet_register_interface
+ (vnm,
+ gre_device_class.index, t - gm->tunnels, address, &hw_if_index,
+ 0);
+
+ if (error)
+ {
+ clib_error_report (error);
+ return VNET_API_ERROR_INVALID_REGISTRATION;
+ }
+ } else {
hw_if_index = vnet_register_interface
(vnm, gre_device_class.index, t - gm->tunnels,
gre_hw_interface_class.index,
t - gm->tunnels);
- hi = vnet_get_hw_interface (vnm, hw_if_index);
- sw_if_index = hi->sw_if_index;
+ }
+ hi = vnet_get_hw_interface (vnm, hw_if_index);
+ sw_if_index = hi->sw_if_index;
}
t->hw_if_index = hw_if_index;
@@ -112,6 +137,7 @@ int vnet_gre_add_del_tunnel
/* Standard default gre MTU. */
hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] = 9000;
+ t->teb = a->teb;
clib_memcpy (&t->tunnel_src, &a->src, sizeof (t->tunnel_src));
clib_memcpy (&t->tunnel_dst, &a->dst, sizeof (t->tunnel_dst));
@@ -156,6 +182,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
vnet_gre_add_del_tunnel_args_t _a, * a = &_a;
ip4_address_t src, dst;
u32 outer_fib_id = 0;
+ u8 teb = 0;
int rv;
u32 num_m_args = 0;
u8 is_add = 1;
@@ -174,6 +201,8 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
num_m_args++;
else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
;
+ else if (unformat (line_input, "teb"))
+ teb = 1;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
@@ -189,6 +218,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
memset (a, 0, sizeof (*a));
a->is_add = is_add;
a->outer_fib_id = outer_fib_id;
+ a->teb = teb;
clib_memcpy(&a->src, &src, sizeof(src));
clib_memcpy(&a->dst, &dst, sizeof(dst));
@@ -214,7 +244,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
.path = "create gre tunnel",
.short_help = "create gre tunnel src <addr> dst <addr> "
- "[outer-fib-id <fib>] [del]",
+ "[outer-fib-id <fib>] [teb] [del]",
.function = create_gre_tunnel_command_fn,
};
diff --git a/vnet/vnet/gre/node.c b/vnet/vnet/gre/node.c
index 97f9dac2e2b..d5ea4b65ddb 100644
--- a/vnet/vnet/gre/node.c
+++ b/vnet/vnet/gre/node.c
@@ -23,6 +23,7 @@
#define foreach_gre_input_next \
_(PUNT, "error-punt") \
_(DROP, "error-drop") \
+_(ETHERNET_INPUT, "ethernet-input") \
_(IP4_INPUT, "ip4-input") \
_(IP6_INPUT, "ip6-input")
@@ -160,9 +161,11 @@ gre_input (vlib_main_t * vm,
: b1->error;
next1 = verr1 ? GRE_INPUT_NEXT_DROP : next1;
+
/* RPF check for ip4/ip6 input */
- if (PREDICT_FALSE(next0 == GRE_INPUT_NEXT_IP4_INPUT
- || next0 == GRE_INPUT_NEXT_IP6_INPUT))
+ if (PREDICT_FALSE(next0 == GRE_INPUT_NEXT_IP4_INPUT
+ || next0 == GRE_INPUT_NEXT_IP6_INPUT
+ || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT))
{
u64 key = ((u64)(vnet_buffer(b0)->gre.dst) << 32) |
(u64)(vnet_buffer(b0)->gre.src);
@@ -207,11 +210,13 @@ gre_input (vlib_main_t * vm,
len /* bytes */);
vnet_buffer(b0)->sw_if_index[VLIB_TX] = tunnel_fib_index;
+ vnet_buffer(b0)->sw_if_index[VLIB_RX] = tunnel_sw_if_index;
}
drop0:
- if (PREDICT_FALSE(next1 == GRE_INPUT_NEXT_IP4_INPUT
- || next1 == GRE_INPUT_NEXT_IP6_INPUT))
+ if (PREDICT_FALSE(next1 == GRE_INPUT_NEXT_IP4_INPUT
+ || next1 == GRE_INPUT_NEXT_IP6_INPUT
+ || next1 == GRE_INPUT_NEXT_ETHERNET_INPUT))
{
u64 key = ((u64)(vnet_buffer(b1)->gre.dst) << 32) |
(u64)(vnet_buffer(b1)->gre.src);
@@ -256,6 +261,7 @@ drop0:
len /* bytes */);
vnet_buffer(b1)->sw_if_index[VLIB_TX] = tunnel_fib_index;
+ vnet_buffer(b1)->sw_if_index[VLIB_RX] = tunnel_sw_if_index;
}
drop1:
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -326,11 +332,13 @@ drop1:
: b0->error;
next0 = verr0 ? GRE_INPUT_NEXT_DROP : next0;
+
/* For IP payload we need to find source interface
so we can increase counters and help forward node to
pick right FIB */
- if (PREDICT_FALSE(next0 == GRE_INPUT_NEXT_IP4_INPUT
- || next0 == GRE_INPUT_NEXT_IP6_INPUT))
+ if (PREDICT_FALSE(next0 == GRE_INPUT_NEXT_IP4_INPUT
+ || next0 == GRE_INPUT_NEXT_IP6_INPUT
+ || next0 == GRE_INPUT_NEXT_ETHERNET_INPUT))
{
u64 key = ((u64)(vnet_buffer(b0)->gre.dst) << 32) |
(u64)(vnet_buffer(b0)->gre.src);
@@ -375,6 +383,7 @@ drop1:
len /* bytes */);
vnet_buffer(b0)->sw_if_index[VLIB_TX] = tunnel_fib_index;
+ vnet_buffer(b0)->sw_if_index[VLIB_RX] = tunnel_sw_if_index;
}
drop:
@@ -476,7 +485,7 @@ gre_setup_node (vlib_main_t * vm, u32 node_index)
static clib_error_t * gre_input_init (vlib_main_t * vm)
{
gre_input_runtime_t * rt;
- vlib_node_t *ip4_input, *ip6_input, *mpls_unicast_input;
+ vlib_node_t *ethernet_input, *ip4_input, *ip6_input, *mpls_unicast_input;
{
clib_error_t * error;
@@ -494,6 +503,8 @@ static clib_error_t * gre_input_init (vlib_main_t * vm)
/* 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");
+ ASSERT(ethernet_input);
ip4_input = vlib_get_node_by_name (vm, (u8 *)"ip4-input");
ASSERT(ip4_input);
ip6_input = vlib_get_node_by_name (vm, (u8 *)"ip6-input");
@@ -501,6 +512,9 @@ static clib_error_t * gre_input_init (vlib_main_t * vm)
mpls_unicast_input = vlib_get_node_by_name (vm, (u8 *)"mpls-gre-input");
ASSERT(mpls_unicast_input);
+ gre_register_input_protocol (vm, GRE_PROTOCOL_teb,
+ ethernet_input->index);
+
gre_register_input_protocol (vm, GRE_PROTOCOL_ip4,
ip4_input->index);
diff --git a/vnet/vnet/gre/packet.h b/vnet/vnet/gre/packet.h
index 573f2624bf8..cc2ccda9eff 100644
--- a/vnet/vnet/gre/packet.h
+++ b/vnet/vnet/gre/packet.h
@@ -21,6 +21,7 @@
#define foreach_gre_protocol \
_ (0x0800, ip4) \
_ (0x86DD, ip6) \
+_ (0x6558, teb) \
_ (0x0806, arp) \
_ (0x8847, mpls_unicast) \
_ (0x894F, nsh)