From ad2ddb1c06f84625e4e5e5fe1748bbcc7df07e97 Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Fri, 17 Nov 2017 23:43:11 +0800 Subject: Replace tap interface using general interface Change-Id: Icd73f00162fb6aabe296c8bb6f2174ad4f6a17b7 Signed-off-by: Hongjun Ni --- src/plugins/pppoe.am | 4 +- src/plugins/pppoe/pppoe.c | 2 +- src/plugins/pppoe/pppoe.h | 8 +- src/plugins/pppoe/pppoe_cp.c | 88 +++++++++++++ src/plugins/pppoe/pppoe_cp_node.c | 255 ++++++++++++++++++++++++++++++++++++ src/plugins/pppoe/pppoe_tap.c | 89 ------------- src/plugins/pppoe/pppoe_tap_node.c | 256 ------------------------------------- test/test_pppoe.py | 4 +- 8 files changed, 352 insertions(+), 354 deletions(-) create mode 100644 src/plugins/pppoe/pppoe_cp.c create mode 100644 src/plugins/pppoe/pppoe_cp_node.c delete mode 100644 src/plugins/pppoe/pppoe_tap.c delete mode 100644 src/plugins/pppoe/pppoe_tap_node.c diff --git a/src/plugins/pppoe.am b/src/plugins/pppoe.am index 06ed60b4978..5db9b7ab92b 100644 --- a/src/plugins/pppoe.am +++ b/src/plugins/pppoe.am @@ -16,8 +16,8 @@ vppplugins_LTLIBRARIES += pppoe_plugin.la pppoe_plugin_la_SOURCES = \ pppoe/pppoe_decap.c \ - pppoe/pppoe_tap.c \ - pppoe/pppoe_tap_node.c \ + pppoe/pppoe_cp.c \ + pppoe/pppoe_cp_node.c \ pppoe/pppoe.c \ pppoe/pppoe_api.c diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c index fe0775ff9df..499b1d7147f 100644 --- a/src/plugins/pppoe/pppoe.c +++ b/src/plugins/pppoe/pppoe.c @@ -726,7 +726,7 @@ pppoe_init (vlib_main_t * vm) pppoe_input_node.index); ethernet_register_input_type (vm, ETHERNET_TYPE_PPPOE_DISCOVERY, - pppoe_tap_dispatch_node.index); + pppoe_cp_dispatch_node.index); return 0; } diff --git a/src/plugins/pppoe/pppoe.h b/src/plugins/pppoe/pppoe.h index b79e4eaae51..77bc88fea60 100644 --- a/src/plugins/pppoe/pppoe.h +++ b/src/plugins/pppoe/pppoe.h @@ -73,7 +73,7 @@ typedef struct _(DROP, "error-drop") \ _(IP4_INPUT, "ip4-input") \ _(IP6_INPUT, "ip6-input" ) \ -_(CP_INPUT, "pppoe-tap-dispatch" ) \ +_(CP_INPUT, "pppoe-cp-dispatch" ) \ typedef enum { @@ -163,7 +163,7 @@ typedef struct u32 *session_index_by_sw_if_index; /* used for pppoe cp path */ - u32 tap_if_index; + u32 cp_if_index; /* API message ID base */ u16 msg_id_base; @@ -177,7 +177,7 @@ typedef struct extern pppoe_main_t pppoe_main; extern vlib_node_registration_t pppoe_input_node; -extern vlib_node_registration_t pppoe_tap_dispatch_node; +extern vlib_node_registration_t pppoe_cp_dispatch_node; typedef struct { @@ -198,7 +198,7 @@ typedef struct { u8 is_add; u32 client_if_index; - u32 tap_if_index; + u32 cp_if_index; } vnet_pppoe_add_del_tap_args_t; always_inline u64 diff --git a/src/plugins/pppoe/pppoe_cp.c b/src/plugins/pppoe/pppoe_cp.c new file mode 100644 index 00000000000..b99bf79679d --- /dev/null +++ b/src/plugins/pppoe/pppoe_cp.c @@ -0,0 +1,88 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2017 Intel 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 + +static clib_error_t * +pppoe_add_del_cp_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + pppoe_main_t *pem = &pppoe_main; + u8 is_add = 1; + u8 cp_if_index_set = 0; + u32 cp_if_index = 0; + clib_error_t *error = NULL; + + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "del")) + { + is_add = 0; + } + else if (unformat (line_input, "cp-if-index %d", &cp_if_index)) + cp_if_index_set = 1; + else + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } + } + + if (cp_if_index_set == 0) + { + error = clib_error_return (0, "cp if index not specified"); + goto done; + } + + if (is_add) + { + pem->cp_if_index = cp_if_index; + } + else + { + pem->cp_if_index = ~0; + } + +done: + unformat_free (line_input); + + return error; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (create_pppoe_cp_cmd, static) = +{ + .path = "create pppoe cp", + .short_help = "create pppoe cp if-name [del]", + .function = pppoe_add_del_cp_command_fn, +}; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/pppoe/pppoe_cp_node.c b/src/plugins/pppoe/pppoe_cp_node.c new file mode 100644 index 00000000000..c73666de744 --- /dev/null +++ b/src/plugins/pppoe/pppoe_cp_node.c @@ -0,0 +1,255 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2017 Intel 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 pemplied. + * See the License for the specific language governing permissions and + * lpemitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include + +vlib_node_registration_t pppoe_cp_dispatch_node; + +#define foreach_pppoe_cp_next \ +_(DROP, "error-drop") \ +_(INTERFACE, "interface-output" ) \ + +typedef enum +{ +#define _(s,n) PPPOE_CP_NEXT_##s, + foreach_pppoe_cp_next +#undef _ + PPPOE_CP_N_NEXT, +} pppoe_cp_next_t; + +typedef struct { + u32 next_index; + u32 sw_if_index; + u32 cp_if_index; + u8 pppoe_code; + u16 ppp_proto; + u32 error; +} pppoe_cp_trace_t; + +static u8 * format_pppoe_cp_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 *); + pppoe_cp_trace_t * t = va_arg (*args, pppoe_cp_trace_t *); + pppoe_main_t * pem = &pppoe_main; + + if (t->sw_if_index != pem->cp_if_index) + { + s = format (s, "PPPoE dispatch from sw_if_index %d next %d error %d \n" + " pppoe_code 0x%x ppp_proto 0x%x", + t->sw_if_index, t->next_index, t->error, + t->pppoe_code, t->ppp_proto); + } + else + { + s = format (s, "PPPoE dispatch from cp_if_index %d next %d error %d \n" + " pppoe_code 0x%x ppp_proto 0x%x", + t->cp_if_index, t->next_index, t->error, + t->pppoe_code, t->ppp_proto); + } + return s; +} + +static uword +pppoe_cp_dispatch (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + u32 n_left_from, next_index, * from, * to_next; + pppoe_main_t * pem = &pppoe_main; + vnet_main_t * vnm = pem->vnet_main; + vnet_interface_main_t * im = &vnm->interface_main; + u32 pkts_decapsulated = 0; + u32 thread_index = vlib_get_thread_index(); + u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; + pppoe_entry_key_t cached_key; + pppoe_entry_result_t cached_result; + + from = vlib_frame_vector_args (from_frame); + n_left_from = from_frame->n_vectors; + + /* Clear the one-entry cache in case session table was updated */ + cached_key.raw = ~0; + cached_result.raw = ~0; /* warning be gone */ + + next_index = node->cached_next_index; + stats_sw_if_index = node->runtime_data[0]; + stats_n_packets = stats_n_bytes = 0; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, + to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0; + vlib_buffer_t * b0; + ethernet_header_t *h0; + pppoe_header_t * pppoe0; + pppoe_entry_key_t key0; + pppoe_entry_result_t result0; + + u32 bucket0; + u32 next0; + u32 error0 = 0; + u32 rx_sw_if_index0=~0, tx_sw_if_index0=~0, len0; + vnet_hw_interface_t *hi; + vnet_sw_interface_t *si; + + bi0 = from[0]; + to_next[0] = bi0; + from += 1; + to_next += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + /* leaves current_data pointing at the pppoe header */ + pppoe0 = vlib_buffer_get_current (b0); + rx_sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; + + if (PREDICT_FALSE (pppoe0->ver_type != PPPOE_VER_TYPE)) + { + error0 = PPPOE_ERROR_BAD_VER_TYPE; + next0 = PPPOE_INPUT_NEXT_DROP; + goto trace00; + } + + vlib_buffer_reset(b0); + h0 = vlib_buffer_get_current (b0); + + if(rx_sw_if_index0 == pem->cp_if_index) + { + pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result, + h0->dst_address, 0, + &key0, &bucket0, &result0); + tx_sw_if_index0 = result0.fields.sw_if_index; + + if (PREDICT_FALSE (tx_sw_if_index0 == ~0)) + { + error0 = PPPOE_ERROR_NO_SUCH_SESSION; + next0 = PPPOE_INPUT_NEXT_DROP; + goto trace00; + } + + next0 = PPPOE_CP_NEXT_INTERFACE; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = tx_sw_if_index0; + + /* set src mac address */ + si = vnet_get_sw_interface(vnm, tx_sw_if_index0); + hi = vnet_get_hw_interface (vnm, si->hw_if_index); + clib_memcpy (vlib_buffer_get_current (b0)+6, hi->hw_address, 6); + } + else + { + pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result, + h0->src_address, 0, + &key0, &bucket0, &result0); + tx_sw_if_index0 = result0.fields.sw_if_index; + + /* learn client session */ + pppoe_learn_process (&pem->link_table, rx_sw_if_index0, + &key0, &cached_key, + &bucket0, &result0); + + next0 = PPPOE_CP_NEXT_INTERFACE; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = pem->cp_if_index; + } + + len0 = vlib_buffer_length_in_chain (vm, b0); + + pkts_decapsulated ++; + stats_n_packets += 1; + stats_n_bytes += len0; + + /* Batch stats increment on the same pppoe session so counter + is not incremented per packet */ + if (PREDICT_FALSE (rx_sw_if_index0 != stats_sw_if_index)) + { + stats_n_packets -= 1; + stats_n_bytes -= len0; + if (stats_n_packets) + vlib_increment_combined_counter + (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, + thread_index, stats_sw_if_index, + stats_n_packets, stats_n_bytes); + stats_n_packets = 1; + stats_n_bytes = len0; + stats_sw_if_index = rx_sw_if_index0; + } + + trace00: + b0->error = error0 ? node->errors[error0] : 0; + + if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) + { + pppoe_cp_trace_t *tr + = vlib_add_trace (vm, node, b0, sizeof (*tr)); + tr->next_index = next0; + tr->error = error0; + tr->sw_if_index = tx_sw_if_index0; + tr->cp_if_index = pem->cp_if_index; + tr->pppoe_code = pppoe0->code; + tr->ppp_proto = clib_net_to_host_u16(pppoe0->ppp_proto); + } + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, + bi0, next0); + } + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + /* Do we still need this now that session tx stats is kept? */ + vlib_node_increment_counter (vm, pppoe_input_node.index, + PPPOE_ERROR_DECAPSULATED, + pkts_decapsulated); + + /* Increment any remaining batch stats */ + if (stats_n_packets) + { + vlib_increment_combined_counter + (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + node->runtime_data[0] = stats_sw_if_index; + } + + return from_frame->n_vectors; +} + +VLIB_REGISTER_NODE (pppoe_cp_dispatch_node) = { + .function = pppoe_cp_dispatch, + .name = "pppoe-cp-dispatch", + /* Takes a vector of packets. */ + .vector_size = sizeof (u32), + + .n_next_nodes = PPPOE_CP_N_NEXT, + .next_nodes = { +#define _(s,n) [PPPOE_CP_NEXT_##s] = n, + foreach_pppoe_cp_next +#undef _ + }, + + .format_trace = format_pppoe_cp_trace, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (pppoe_cp_dispatch_node, pppoe_cp_dispatch) + diff --git a/src/plugins/pppoe/pppoe_tap.c b/src/plugins/pppoe/pppoe_tap.c deleted file mode 100644 index 60cdaafbad0..00000000000 --- a/src/plugins/pppoe/pppoe_tap.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2017 Intel 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 -#include - -static clib_error_t * -pppoe_add_del_tap_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - unformat_input_t _line_input, *line_input = &_line_input; - pppoe_main_t *pem = &pppoe_main; - u8 is_add = 1; - u8 tap_if_index_set = 0; - u32 tap_if_index = 0; - clib_error_t *error = NULL; - - /* Get a line of input. */ - if (!unformat_user (input, unformat_line_input, line_input)) - return 0; - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "del")) - { - is_add = 0; - } - else if (unformat (line_input, "tap-if-index %d", &tap_if_index)) - tap_if_index_set = 1; - else - { - error = clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); - goto done; - } - } - - if (tap_if_index_set == 0) - { - error = clib_error_return (0, "tap if index not specified"); - goto done; - } - - if (is_add) - { - pem->tap_if_index = tap_if_index; - } - else - { - pem->tap_if_index = ~0; - } - -done: - unformat_free (line_input); - - return error; -} - -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (create_pppoe_tap_cmd, static) = -{ - .path = "create pppoe tap", - .short_help = "create pppoe tap if-name [del]", - .function = pppoe_add_del_tap_command_fn, -}; -/* *INDENT-ON* */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/plugins/pppoe/pppoe_tap_node.c b/src/plugins/pppoe/pppoe_tap_node.c deleted file mode 100644 index 92a6a2af73f..00000000000 --- a/src/plugins/pppoe/pppoe_tap_node.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2017 Intel 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 pemplied. - * See the License for the specific language governing permissions and - * lpemitations under the License. - *------------------------------------------------------------------ - */ - -#include -#include -#include - -vlib_node_registration_t pppoe_tap_dispatch_node; - -#define foreach_pppoe_tap_next \ -_(DROP, "error-drop") \ -_(TUNTAP, "tuntap-tx" ) \ -_(INTERFACE, "interface-output" ) \ - -typedef enum -{ -#define _(s,n) PPPOE_TAP_NEXT_##s, - foreach_pppoe_tap_next -#undef _ - PPPOE_TAP_N_NEXT, -} pppoe_tap_next_t; - -typedef struct { - u32 next_index; - u32 sw_if_index; - u32 tap_if_index; - u8 pppoe_code; - u16 ppp_proto; - u32 error; -} pppoe_tap_trace_t; - -static u8 * format_pppoe_tap_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 *); - pppoe_tap_trace_t * t = va_arg (*args, pppoe_tap_trace_t *); - pppoe_main_t * pem = &pppoe_main; - - if (t->sw_if_index != pem->tap_if_index) - { - s = format (s, "PPPoE dispatch from sw_if_index %d next %d error %d \n" - " pppoe_code 0x%x ppp_proto 0x%x", - t->sw_if_index, t->next_index, t->error, - t->pppoe_code, t->ppp_proto); - } - else - { - s = format (s, "PPPoE dispatch from tap_if_index %d next %d error %d \n" - " pppoe_code 0x%x ppp_proto 0x%x", - t->tap_if_index, t->next_index, t->error, - t->pppoe_code, t->ppp_proto); - } - return s; -} - -static uword -pppoe_tap_dispatch (vlib_main_t * vm, - vlib_node_runtime_t * node, - vlib_frame_t * from_frame) -{ - u32 n_left_from, next_index, * from, * to_next; - pppoe_main_t * pem = &pppoe_main; - vnet_main_t * vnm = pem->vnet_main; - vnet_interface_main_t * im = &vnm->interface_main; - u32 pkts_decapsulated = 0; - u32 thread_index = vlib_get_thread_index(); - u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; - pppoe_entry_key_t cached_key; - pppoe_entry_result_t cached_result; - - from = vlib_frame_vector_args (from_frame); - n_left_from = from_frame->n_vectors; - - /* Clear the one-entry cache in case session table was updated */ - cached_key.raw = ~0; - cached_result.raw = ~0; /* warning be gone */ - - next_index = node->cached_next_index; - stats_sw_if_index = node->runtime_data[0]; - stats_n_packets = stats_n_bytes = 0; - - while (n_left_from > 0) - { - u32 n_left_to_next; - - vlib_get_next_frame (vm, node, next_index, - to_next, n_left_to_next); - - while (n_left_from > 0 && n_left_to_next > 0) - { - u32 bi0; - vlib_buffer_t * b0; - ethernet_header_t *h0; - pppoe_header_t * pppoe0; - pppoe_entry_key_t key0; - pppoe_entry_result_t result0; - - u32 bucket0; - u32 next0; - u32 error0 = 0; - u32 rx_sw_if_index0=~0, tx_sw_if_index0=~0, len0; - vnet_hw_interface_t *hi; - vnet_sw_interface_t *si; - - bi0 = from[0]; - to_next[0] = bi0; - from += 1; - to_next += 1; - n_left_from -= 1; - n_left_to_next -= 1; - - b0 = vlib_get_buffer (vm, bi0); - /* leaves current_data pointing at the pppoe header */ - pppoe0 = vlib_buffer_get_current (b0); - rx_sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; - - if (PREDICT_FALSE (pppoe0->ver_type != PPPOE_VER_TYPE)) - { - error0 = PPPOE_ERROR_BAD_VER_TYPE; - next0 = PPPOE_INPUT_NEXT_DROP; - goto trace00; - } - - vlib_buffer_reset(b0); - h0 = vlib_buffer_get_current (b0); - - if(rx_sw_if_index0 == pem->tap_if_index) - { - pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result, - h0->dst_address, 0, - &key0, &bucket0, &result0); - tx_sw_if_index0 = result0.fields.sw_if_index; - - if (PREDICT_FALSE (tx_sw_if_index0 == ~0)) - { - error0 = PPPOE_ERROR_NO_SUCH_SESSION; - next0 = PPPOE_INPUT_NEXT_DROP; - goto trace00; - } - - next0 = PPPOE_TAP_NEXT_INTERFACE; - vnet_buffer(b0)->sw_if_index[VLIB_TX] = tx_sw_if_index0; - - /* set src mac address */ - si = vnet_get_sw_interface(vnm, tx_sw_if_index0); - hi = vnet_get_hw_interface (vnm, si->hw_if_index); - clib_memcpy (vlib_buffer_get_current (b0)+6, hi->hw_address, 6); - } - else - { - pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result, - h0->src_address, 0, - &key0, &bucket0, &result0); - tx_sw_if_index0 = result0.fields.sw_if_index; - - /* learn client session */ - pppoe_learn_process (&pem->link_table, rx_sw_if_index0, - &key0, &cached_key, - &bucket0, &result0); - - next0 = PPPOE_TAP_NEXT_TUNTAP; - vnet_buffer(b0)->sw_if_index[VLIB_TX] = pem->tap_if_index; - } - - len0 = vlib_buffer_length_in_chain (vm, b0); - - pkts_decapsulated ++; - stats_n_packets += 1; - stats_n_bytes += len0; - - /* Batch stats increment on the same pppoe session so counter - is not incremented per packet */ - if (PREDICT_FALSE (rx_sw_if_index0 != stats_sw_if_index)) - { - stats_n_packets -= 1; - stats_n_bytes -= len0; - if (stats_n_packets) - vlib_increment_combined_counter - (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - thread_index, stats_sw_if_index, - stats_n_packets, stats_n_bytes); - stats_n_packets = 1; - stats_n_bytes = len0; - stats_sw_if_index = rx_sw_if_index0; - } - - trace00: - b0->error = error0 ? node->errors[error0] : 0; - - if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) - { - pppoe_tap_trace_t *tr - = vlib_add_trace (vm, node, b0, sizeof (*tr)); - tr->next_index = next0; - tr->error = error0; - tr->sw_if_index = tx_sw_if_index0; - tr->tap_if_index = pem->tap_if_index; - tr->pppoe_code = pppoe0->code; - tr->ppp_proto = clib_net_to_host_u16(pppoe0->ppp_proto); - } - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, - to_next, n_left_to_next, - bi0, next0); - } - - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - } - /* Do we still need this now that session tx stats is kept? */ - vlib_node_increment_counter (vm, pppoe_input_node.index, - PPPOE_ERROR_DECAPSULATED, - pkts_decapsulated); - - /* Increment any remaining batch stats */ - if (stats_n_packets) - { - vlib_increment_combined_counter - (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); - node->runtime_data[0] = stats_sw_if_index; - } - - return from_frame->n_vectors; -} - -VLIB_REGISTER_NODE (pppoe_tap_dispatch_node) = { - .function = pppoe_tap_dispatch, - .name = "pppoe-tap-dispatch", - /* Takes a vector of packets. */ - .vector_size = sizeof (u32), - - .n_next_nodes = PPPOE_TAP_N_NEXT, - .next_nodes = { -#define _(s,n) [PPPOE_TAP_NEXT_##s] = n, - foreach_pppoe_tap_next -#undef _ - }, - - .format_trace = format_pppoe_tap_trace, -}; - -VLIB_NODE_FUNCTION_MULTIARCH (pppoe_tap_dispatch_node, pppoe_tap_dispatch) - diff --git a/test/test_pppoe.py b/test/test_pppoe.py index 1d0aeffda37..13499a32ec8 100644 --- a/test/test_pppoe.py +++ b/test/test_pppoe.py @@ -343,7 +343,7 @@ class TestPPPoE(VppTestCase): # and we should still be able to use the original # try: - gre_if.add_vpp_config() + pppoe_if.add_vpp_config() except Exception: pass else: @@ -400,7 +400,7 @@ class TestPPPoE(VppTestCase): # and we should still be able to use the original # try: - gre_if.remove_vpp_config() + pppoe_if.remove_vpp_config() except Exception: pass else: -- cgit 1.2.3-korg