Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtpu-upf-bypass: Bypass first route lookup #362

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions upf/upf_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,83 @@ VLIB_CLI_COMMAND (upf_show_pfcp_heartbeat_config_command, static) =
};
/* *INDENT-ON* */

static clib_error_t *
set_ip_gtpu_upf_bypass (u32 is_ip6,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
clib_error_t *error = 0;
u32 sw_if_index, is_enable;

sw_if_index = ~0;
is_enable = 1;

if (!unformat_user (input, unformat_line_input, line_input))
return 0;

while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat_user
(line_input, unformat_vnet_sw_interface, vnm, &sw_if_index))
;
else if (unformat (line_input, "del"))
is_enable = 0;
else
{
error = unformat_parse_error (line_input);
goto done;
}
}

if (~0 == sw_if_index)
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, line_input);
goto done;
}

if (is_ip6)
vnet_feature_enable_disable ("ip6-unicast", "ip6-gtpu-upf-bypass",
sw_if_index, is_enable, 0, 0);
else
vnet_feature_enable_disable ("ip4-unicast", "ip4-gtpu-upf-bypass",
sw_if_index, is_enable, 0, 0);

done:
unformat_free (line_input);

return error;
}

static clib_error_t *
set_ip4_gtpu_upf_bypass (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
return set_ip_gtpu_upf_bypass (0, input, cmd);
}

/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_ip_gtpu_upf_bypass_command, static) = {
.path = "set interface ip gtpu-upf-bypass",
.function = set_ip4_gtpu_upf_bypass,
.short_help = "set interface ip gtpu-upf-bypass <interface> [del]",
};
/* *INDENT-ON* */

static clib_error_t *
set_ip6_gtpu_upf_bypass (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
return set_ip_gtpu_upf_bypass (1, input, cmd);
}

VLIB_CLI_COMMAND (set_interface_ip6_gtpu_upf_bypass_command, static) = {
.path = "set interface ip6 gtpu-upf-bypass",
.function = set_ip6_gtpu_upf_bypass,
.short_help = "set interface ip6 gtpu-upf-bypass <interface> [del]",
};

/*
* fd.io coding-style-patch-verification: ON
*
Expand Down
35 changes: 23 additions & 12 deletions upf/upf_gtpu_decap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,10 +1525,12 @@ ip_gtpu_upf_bypass_inline (vlib_main_t * vm,
ip4_address_t addr4; /* last IPv4 address matching a local VTEP address */
ip6_address_t addr6; /* last IPv6 address matching a local VTEP address */
#endif
vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;

from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
vlib_get_buffers (vm, from, bufs, n_left_from);

if (node->flags & VLIB_NODE_FLAG_TRACE)
ip4_forward_next_trace (vm, node, frame, VLIB_TX);
Expand Down Expand Up @@ -1558,16 +1560,11 @@ ip_gtpu_upf_bypass_inline (vlib_main_t * vm,

/* Prefetch next iteration. */
{
vlib_buffer_t *p2, *p3;

p2 = vlib_get_buffer (vm, from[2]);
p3 = vlib_get_buffer (vm, from[3]);
vlib_prefetch_buffer_header (b[2], LOAD);
vlib_prefetch_buffer_header (b[3], LOAD);

vlib_prefetch_buffer_header (p2, LOAD);
vlib_prefetch_buffer_header (p3, LOAD);

CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (b[2]->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (b[3]->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
}

bi0 = to_next[0] = from[0];
Expand All @@ -1577,8 +1574,9 @@ ip_gtpu_upf_bypass_inline (vlib_main_t * vm,
to_next += 2;
n_left_to_next -= 2;

b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
b0 = b[0];
b1 = b[1];
b += 2;
if (is_ip4)
{
ip40 = vlib_buffer_get_current (b0);
Expand Down Expand Up @@ -1816,7 +1814,8 @@ ip_gtpu_upf_bypass_inline (vlib_main_t * vm,
to_next += 1;
n_left_to_next -= 1;

b0 = vlib_get_buffer (vm, bi0);
b0 = b[0];
b++;
if (is_ip4)
ip40 = vlib_buffer_get_current (b0);
else
Expand Down Expand Up @@ -1944,6 +1943,12 @@ VLIB_NODE_FN (ip4_gtpu_upf_bypass_node) (vlib_main_t * vm,
}

/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip4_gtpu_bypass, static) = {
.arc_name = "ip4-unicast",
.node_name = "ip4-gtpu-upf-bypass",
.runs_before = VNET_FEATURES ("ip4-lookup"),
};

VLIB_REGISTER_NODE (ip4_gtpu_upf_bypass_node) = {
.name = "ip4-gtpu-upf-bypass",
.vector_size = sizeof (u32),
Expand Down Expand Up @@ -1978,6 +1983,12 @@ VLIB_NODE_FN (ip6_gtpu_upf_bypass_node) (vlib_main_t * vm,
}

/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip6_gtpu_bypass, static) = {
.arc_name = "ip6-unicast",
.node_name = "ip6-gtpu-upf-bypass",
.runs_before = VNET_FEATURES ("ip6-lookup"),
};

VLIB_REGISTER_NODE (ip6_gtpu_upf_bypass_node) = {
.name = "ip6-gtpu-upf_bypass",
.vector_size = sizeof (u32),
Expand Down