29 #define foreach_bond_tx_error \ 31 _(IF_DOWN, "interface down") \ 32 _(NO_SLAVE, "no slave") 36 #define _(f,s) BOND_TX_ERROR_##f, 59 s =
format (s,
"src %U, dst %U, %s -> %s",
92 if ((bif_hw->
l2_if_count == 1) && (l2_if_adjust == 1))
145 for (port = 1; port < slave_count; port++)
180 return (c & (slave_count - 1));
182 return c % slave_count;
193 ethertype_p = ð->
type;
197 vlan = (
void *) (eth + 1);
198 ethertype_p = &vlan->
type;
199 if (*ethertype_p == ntohs (ETHERNET_TYPE_VLAN))
202 ethertype_p = &vlan->
type;
215 u16 ethertype, *ethertype_p;
216 u32 *mac1, *mac2, *mac3;
221 if ((ethertype != htons (ETHERNET_TYPE_IP4)) &&
222 (ethertype != htons (ETHERNET_TYPE_IP6)))
228 if (ip_version == 0x4)
242 return (c & (slave_count - 1));
244 return c % slave_count;
246 else if (ip_version == 0x6)
268 return (c & (slave_count - 1));
270 return c % slave_count;
283 u16 ethertype, *ethertype_p;
288 if ((ethertype != htons (ETHERNET_TYPE_IP4)) &&
289 (ethertype != htons (ETHERNET_TYPE_IP6)))
295 if (ip_version == 0x4)
300 is_tcp_udp = (ip4->
protocol == IP_PROTOCOL_TCP) ||
309 return (c & (slave_count - 1));
311 return c % slave_count;
313 else if (ip_version == 0x6)
322 (ip6->
protocol == IP_PROTOCOL_UDP)))
325 tcp = (
void *) (ip6 + 1);
327 else if (ip6->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
331 if ((hbh->
protocol == IP_PROTOCOL_TCP)
332 || (hbh->
protocol == IP_PROTOCOL_UDP))
351 return (c & (slave_count - 1));
353 return c % slave_count;
385 #define _(v,f,s, p) { bond_load_balance_##p }, 397 u32 bi0, bi1, bi2, bi3;
409 u32 sif_if_index, sif_if_index1, sif_if_index2, sif_if_index3;
418 thread_index, bif->sw_if_index,
426 slave_count =
vec_len (bif->active_slaves);
439 thread_index, bif->sw_if_index,
453 while (n_left_from > 0)
455 while (n_left_from >= 4)
457 u32 next0 = 0, next1 = 0, next2 = 0, next3 = 0;
458 u32 port0 = 0, port1 = 0, port2 = 0, port3 = 0;
461 if (n_left_from >= 8)
504 (bond_load_balance_table[bif->lb]).load_balance (vm, node,
508 (bond_load_balance_table[bif->lb]).load_balance (vm, node,
512 (bond_load_balance_table[bif->lb]).load_balance (vm, node,
516 (bond_load_balance_table[bif->lb]).load_balance (vm, node,
531 if (
PREDICT_FALSE ((bif->per_thread_info[thread_index].frame[port0]
533 bif->per_thread_info[thread_index].frame[port0] =
536 if (
PREDICT_FALSE ((bif->per_thread_info[thread_index].frame[port1]
538 bif->per_thread_info[thread_index].frame[port1] =
541 if (
PREDICT_FALSE ((bif->per_thread_info[thread_index].frame[port2]
543 bif->per_thread_info[thread_index].frame[port2] =
546 if (
PREDICT_FALSE ((bif->per_thread_info[thread_index].frame[port3]
548 bif->per_thread_info[thread_index].frame[port3] =
551 f = bif->per_thread_info[thread_index].frame[port0];
557 f = bif->per_thread_info[thread_index].frame[port1];
563 f = bif->per_thread_info[thread_index].frame[port2];
569 f = bif->per_thread_info[thread_index].frame[port3];
631 while (n_left_from > 0)
655 (bond_load_balance_table[bif->lb]).load_balance (vm, node, bif,
661 ((bif->per_thread_info[thread_index].frame[port0] == 0)))
662 bif->per_thread_info[thread_index].frame[port0] =
664 f = bif->per_thread_info[thread_index].frame[port0];
686 for (port = 0; port < slave_count; port++)
688 f = bif->per_thread_info[thread_index].frame[port];
694 bif->per_thread_info[thread_index].frame[port] = 0;
721 uword event_type, *event_data = 0;
731 for (i = 0; i <
vec_len (event_data); i++)
733 hw_if_index = event_data[
i];
747 .name =
"bond-process",
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
static __clib_unused clib_error_t * bond_set_l2_mode_function(vnet_main_t *vnm, struct vnet_hw_interface_t *bif_hw, i32 l2_if_adjust)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
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.
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
u8 runtime_data[0]
Function dependent node-runtime data.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
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_always_inline u32 bond_load_balance_round_robin(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
vnet_interface_main_t interface_main
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
static bond_if_t * bond_get_master_by_sw_if_index(u32 sw_if_index)
void vnet_hw_interface_walk_sw(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_sw_interface_walk_t fn, void *ctx)
Walk the SW interfaces on a HW interface - this is the super interface and any sub-interfaces.
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static_always_inline u32 lb_hash_hash_2_tuples(u64 k0, u32 k1)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void send_ip6_na(vlib_main_t *vm, u32 sw_if_index)
#define BOND_MODULO_SHORTCUT(a)
struct _tcp_header tcp_header_t
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
uword as_uword[16/sizeof(uword)]
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
enum walk_rc_t_ walk_rc_t
Walk return code.
static uword bond_tx_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define static_always_inline
u8 * format_ethernet_address(u8 *s, va_list *args)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
vlib_combined_counter_main_t * combined_sw_if_counters
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static_always_inline u32 bond_load_balance_l23(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
vnet_device_class_t bond_dev_class
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
static_always_inline u16 * bond_locate_ethertype(ethernet_header_t *eth)
bond_if_per_thread_t * per_thread_info
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static_always_inline u32 bond_load_balance_broadcast(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
#define foreach_bond_tx_error
vlib_simple_counter_main_t * sw_if_counters
u32 node_index
Node index.
static char * bond_tx_error_strings[]
void send_ip4_garp(vlib_main_t *vm, u32 sw_if_index)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
static void vnet_put_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index, vlib_frame_t *f)
#define CLIB_PREFETCH(addr, size, type)
ethernet_header_t ethernet
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
static u8 * format_bond_tx_trace(u8 *s, va_list *args)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static walk_rc_t bond_active_interface_switch_cb(vnet_main_t *vnm, u32 sw_if_index, void *arg)
static_always_inline int ethernet_frame_is_tagged(u16 type)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
static_always_inline u32 bond_load_balance_l2(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
VNET_DEVICE_CLASS(bond_dev_class)
#define clib_mem_unaligned(pointer, type)
static vlib_frame_t * vnet_get_frame_to_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline u32 bond_load_balance_active_backup(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
static_always_inline u32 bond_load_balance_l34(vlib_main_t *vm, vlib_node_runtime_t *node, bond_if_t *bif, vlib_buffer_t *b0, uword slave_count)
u8 * format_bond_interface_name(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static __clib_unused clib_error_t * bond_subif_add_del_function(vnet_main_t *vnm, u32 hw_if_index, struct vnet_sw_interface_t *st, int is_add)
#define vec_foreach(var, vec)
Vector iterator.
static_always_inline u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
#define CLIB_CACHE_LINE_BYTES
static clib_error_t * bond_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static uword bond_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)