24 #ifndef CLIB_MARCH_VARIANT 28 #define foreach_bond_input_error \ 30 _(IF_DOWN, "interface down") \ 31 _(PASS_THRU, "pass through (CDP, LLDP, slow protocols)") 35 #define _(f,s) BOND_INPUT_ERROR_##f, 54 s =
format (s,
"src %U, dst %U, %U -> %U",
80 return ((eth->
type == htons (ETHERNET_TYPE_CDP)) ||
82 (snap->protocol == htons (0x2000)) &&
83 (snap->oui[0] == 0) && (snap->oui[1] == 0) &&
84 (snap->oui[2] == 0x0C)));
90 u32 * n_rx_packets,
u32 * n_rx_bytes)
92 u16 *ethertype_p, ethertype;
102 if (
PREDICT_TRUE ((ethertype != htons (ETHERNET_TYPE_SLOW_PROTOCOLS))
104 && (ethertype != htons (ETHERNET_TYPE_802_1_LLDP))))
113 vlan = (
void *) (eth + 1);
114 ethertype_p = &vlan->
type;
116 if (ethertype == ntohs (ETHERNET_TYPE_VLAN))
119 ethertype_p = &vlan->
type;
122 if (
PREDICT_TRUE ((ethertype != htons (ETHERNET_TYPE_SLOW_PROTOCOLS))
123 && (ethertype != htons (ETHERNET_TYPE_CDP))
124 && (ethertype != htons (ETHERNET_TYPE_802_1_LLDP))))
138 u32 * last_slave_sw_if_index,
u32 slave_sw_if_index,
145 if (
PREDICT_TRUE (*last_slave_sw_if_index == slave_sw_if_index))
148 *last_slave_sw_if_index = slave_sw_if_index;
161 *bond_sw_if_index = slave_sw_if_index;
162 *error = node->
errors[BOND_INPUT_ERROR_IF_DOWN];
179 u32 last_slave_sw_if_index = ~0;
180 u32 bond_sw_if_index = 0;
183 u32 n_rx_bytes = 0, n_rx_packets = 0;
189 n_left = frame->n_vectors;
195 sw_if_index = sw_if_indices;
219 x |= sw_if_index[0] ^ last_slave_sw_if_index;
220 x |= sw_if_index[1] ^ last_slave_sw_if_index;
221 x |= sw_if_index[2] ^ last_slave_sw_if_index;
222 x |= sw_if_index[3] ^ last_slave_sw_if_index;
226 next[0] = next[1] = next[2] = next[3] = next_index;
237 &n_rx_packets, &n_rx_bytes);
239 &n_rx_packets, &n_rx_bytes);
241 &n_rx_packets, &n_rx_bytes);
243 &n_rx_packets, &n_rx_bytes);
249 &bond_sw_if_index, b[0], &next_index, &error);
250 next[0] = next_index;
255 &n_rx_packets, &n_rx_bytes);
258 &bond_sw_if_index, b[1], &next_index, &error);
259 next[1] = next_index;
264 &n_rx_packets, &n_rx_bytes);
267 &bond_sw_if_index, b[2], &next_index, &error);
268 next[2] = next_index;
273 &n_rx_packets, &n_rx_bytes);
276 &bond_sw_if_index, b[3], &next_index, &error);
277 next[3] = next_index;
282 &n_rx_packets, &n_rx_bytes);
301 &bond_sw_if_index, b[0], &next_index, &error);
302 next[0] = next_index;
307 &n_rx_packets, &n_rx_bytes);
320 n_left = frame->n_vectors;
322 sw_if_index = sw_if_indices;
350 BOND_INPUT_ERROR_NONE, frame->n_vectors);
352 return frame->n_vectors;
363 .name =
"bond-input",
364 .vector_size =
sizeof (
u32),
381 .arc_name =
"device-input",
382 .node_name =
"bond-input",
#define foreach_bond_input_error
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(bond_sw_interface_up_down)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * bond_input_init(vlib_main_t *vm)
vnet_interface_main_t interface_main
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
#define clib_memcpy_fast(a, b, c)
u16 current_length
Nbytes between current data and the end of this buffer.
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
void bond_enable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
format_function_t format_vnet_sw_if_index_name
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(bond_hw_interface_up_down)
vlib_node_registration_t bond_input_node
(constructor) VLIB_REGISTER_NODE (bond_input_node)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
static void bond_update_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *last_slave_sw_if_index, u32 slave_sw_if_index, u32 *bond_sw_if_index, vlib_buffer_t *b, u32 *next_index, vlib_error_t *error)
#define VLIB_INIT_FUNCTION(x)
vlib_combined_counter_main_t * combined_sw_if_counters
vnet_hw_interface_flags_t flags
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static clib_error_t * bond_sw_interface_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static void bond_sw_if_idx_rewrite(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, u32 bond_sw_if_index, u32 *n_rx_packets, u32 *n_rx_bytes)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 node_index
Node index.
static u8 * format_bond_input_trace(u8 *s, va_list *args)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
ethernet_header_t ethernet
void bond_disable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
#define vlib_prefetch_buffer_data(b, type)
VNET_FEATURE_INIT(bond_input, static)
static_always_inline u8 packet_is_cdp(ethernet_header_t *eth)
static bond_if_t * bond_get_master_by_dev_instance(u32 dev_instance)
static_always_inline int ethernet_frame_is_tagged(u16 type)
#define clib_mem_unaligned(pointer, type)
static char * bond_input_error_strings[]
#define VNET_FEATURES(...)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static clib_error_t * bond_hw_interface_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static slave_if_t * bond_get_slave_by_sw_if_index(u32 sw_if_index)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE