summaryrefslogtreecommitdiffstats
path: root/src/vnet/vxlan-gpe/decap.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-03vxlan-gpe: simplify counter codeZhiyong Yang1-22/+10
Type: style Change-Id: Ia50867a853388d9f69571815ddcdaadfc47206bc Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
2019-03-28Typos. A bunch of typos I've been collecting.Paul Vinciguerra1-1/+1
Change-Id: I53ab8d17914e6563110354e4052109ac02bf8f3b Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-06vxlan*: migrate old MULTIARCH macros to VLIB_NODE_FNFilip Tehlar1-33/+44
Change-Id: Ide23bb3d82024118214902850821a8184fe65dfc Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2018-10-23c11 safe string handling supportDave Barach1-2/+2
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach <dave@barachs.net>
2018-07-19Remove unused argument to vlib_feature_nextDamjan Marion1-6/+3
Change-Id: Ieb8b53977fc8484c19780941e232ee072b667de3 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-07-11avoid using thread local storage for thread indexDamjan Marion1-1/+1
It is cheaper to get thread index from vlib_main_t if available... Change-Id: I4582e160d06d9d7fccdc54271912f0635da79b50 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-12-13make "test-all" target pass againGabriel Ganne1-0/+9
The "test-all" target is still never called as part of any continuous test (as it probably should) but at least it can now be expected to succeed. VXLAN-GPE: * decapsulate Ethernet to "l2-input" instead of "ethernet-input" otherwise the inner mac address get checked against the interface one (external) and packet gets dropped (mac mismatch) * set packet input sw_if_index to unicast vxlan tunnel for learning TEST: * VXLAN: * reduce the number of share tunnels: => reduce test duration by half => no functional change * VXLAN-GPE: * fix test TearDown() cli: command is "show vxlan-gpe" only * remove vxlan-gpe specific tests as the were a duplicated of the BridgeDomain one and already inherited. * disable test_mcast_rcv() and test_mcast_flood() tests * P2PEthernetAPI: * remove test: "create 100k of p2p subifs" there already is a "create 1k p2p subifs" so this one is a load test and not a unit test. See: lists.fd.io/pipermail/vpp-dev/2017-November/007280.html Change-Id: Icafb83769eb560cbdeb3dc6d1f1d3c23c0901cd9 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
2017-12-13VPP-275 Coding standards cleanup - vnet/vnet/vxlan-gpesharath reddy1-587/+652
Change-Id: Ifabb8d22d20bc1031664d5f004e74cd363759ab6 Signed-off-by: sharath reddy <sharathkumarboyanapally@gmail.com>
2017-07-14vnet_buffer_t flags cleanupDamjan Marion1-9/+9
Change-Id: I123eccea98abafeb31f25d2a162501e2eded60d4 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-06-06Rework vxlan-gpe to support FIB 2.0 and bypass modeHongjun Ni1-17/+462
Change-Id: I0324f945bdb4dd3b19151be6f3ce24a47a000104 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
2017-04-06Use thread local storage for thread indexDamjan Marion1-5/+5
This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+733
Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion <damarion@cisco.com>
ld } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2020 Cisco and/or its affiliates.
 * Copyright (c) 2020 Doc.ai 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 <wireguard/wireguard.h>
#include <wireguard/wireguard_peer.h>

#define foreach_wg_handoff_error  \
_(CONGESTION_DROP, "congestion drop")

typedef enum
{
#define _(sym,str) WG_HANDOFF_ERROR_##sym,
  foreach_wg_handoff_error
#undef _
    HANDOFF_N_ERROR,
} ipsec_handoff_error_t;

static char *wg_handoff_error_strings[] = {
#define _(sym,string) string,
  foreach_wg_handoff_error
#undef _
};

typedef enum
{
  WG_HANDOFF_HANDSHAKE,
  WG_HANDOFF_INP_DATA,
  WG_HANDOFF_OUT_TUN,
} wg_handoff_mode_t;

typedef struct wg_handoff_trace_t_
{
  u32 next_worker_index;
  index_t peer;
} wg_handoff_trace_t;

static u8 *
format_wg_handoff_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 *);
  wg_handoff_trace_t *t = va_arg (*args, wg_handoff_trace_t *);

  s = format (s, "next-worker %d peer %d", t->next_worker_index, t->peer);

  return s;
}

static_always_inline uword
wg_handoff (vlib_main_t * vm,
	    vlib_node_runtime_t * node,
	    vlib_frame_t * frame, u32 fq_index, wg_handoff_mode_t mode)
{
  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
  u32 n_enq, n_left_from, *from;
  wg_main_t *wmp;

  wmp = &wg_main;
  from = vlib_frame_vector_args (frame);
  n_left_from = frame->n_vectors;
  vlib_get_buffers (vm, from, bufs, n_left_from);

  b = bufs;
  ti = thread_indices;

  while (n_left_from > 0)
    {
      const wg_peer_t *peer;
      index_t peeri = INDEX_INVALID;

      if (PREDICT_FALSE (mode == WG_HANDOFF_HANDSHAKE))
	{
	  ti[0] = 0;
	}
      else if (mode == WG_HANDOFF_INP_DATA)
	{
	  message_data_t *data = vlib_buffer_get_current (b[0]);
	  u32 *entry =
	    wg_index_table_lookup (&wmp->index_table, data->receiver_index);
	  peeri = *entry;
	  peer = wg_peer_get (peeri);

	  ti[0] = peer->input_thread_index;
	}
      else
	{
	  peeri =
	    wg_peer_get_by_adj_index (vnet_buffer (b[0])->
				      ip.adj_index[VLIB_TX]);
	  peer = wg_peer_get (peeri);
	  ti[0] = peer->output_thread_index;
	}

      if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
	{
	  wg_handoff_trace_t *t =
	    vlib_add_trace (vm, node, b[0], sizeof (*t));
	  t->next_worker_index = ti[0];
	  t->peer = peeri;
	}

      n_left_from -= 1;
      ti += 1;
      b += 1;
    }

  n_enq = vlib_buffer_enqueue_to_thread (vm, fq_index, from,
					 thread_indices, frame->n_vectors, 1);

  if (n_enq < frame->n_vectors)
    vlib_node_increment_counter (vm, node->node_index,
				 WG_HANDOFF_ERROR_CONGESTION_DROP,
				 frame->n_vectors - n_enq);

  return n_enq;
}

VLIB_NODE_FN (wg_handshake_handoff) (vlib_main_t * vm,
				     vlib_node_runtime_t * node,
				     vlib_frame_t * from_frame)
{
  wg_main_t *wmp = &wg_main;

  return wg_handoff (vm, node, from_frame, wmp->in_fq_index,
		     WG_HANDOFF_HANDSHAKE);
}

VLIB_NODE_FN (wg_input_data_handoff) (vlib_main_t * vm,
				      vlib_node_runtime_t * node,
				      vlib_frame_t * from_frame)
{
  wg_main_t *wmp = &wg_main;

  return wg_handoff (vm, node, from_frame, wmp->in_fq_index,
		     WG_HANDOFF_INP_DATA);
}

VLIB_NODE_FN (wg_output_tun_handoff) (vlib_main_t * vm,
				      vlib_node_runtime_t * node,
				      vlib_frame_t * from_frame)
{
  wg_main_t *wmp = &wg_main;

  return wg_handoff (vm, node, from_frame, wmp->out_fq_index,
		     WG_HANDOFF_OUT_TUN);
}

/* *INDENT-OFF* */
VLIB_REGISTER_NODE (wg_handshake_handoff) =
{
  .name = "wg-handshake-handoff",
  .vector_size = sizeof (u32),
  .format_trace = format_wg_handoff_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,
  .n_errors = ARRAY_LEN (wg_handoff_error_strings),
  .error_strings = wg_handoff_error_strings,
  .n_next_nodes = 1,
  .next_nodes = {
    [0] = "error-drop",
  },
};

VLIB_REGISTER_NODE (wg_input_data_handoff) =
{
  .name = "wg-input-data-handoff",
  .vector_size = sizeof (u32),
  .format_trace = format_wg_handoff_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,
  .n_errors = ARRAY_LEN (wg_handoff_error_strings),
  .error_strings = wg_handoff_error_strings,
  .n_next_nodes = 1,
  .next_nodes = {
    [0] = "error-drop",
  },
};

VLIB_REGISTER_NODE (wg_output_tun_handoff) =
{
  .name = "wg-output-tun-handoff",
  .vector_size = sizeof (u32),
  .format_trace = format_wg_handoff_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,
  .n_errors = ARRAY_LEN (wg_handoff_error_strings),
  .error_strings = wg_handoff_error_strings,
  .n_next_nodes = 1,
  .next_nodes =  {
    [0] = "error-drop",
  },
};
/* *INDENT-ON* */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */