FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ip4_forward.c File Reference
+ Include dependency graph for ip4_forward.c:

Go to the source code of this file.

Data Structures

struct  ip4_forward_next_trace_t
 
struct  ip4_local_last_check_t
 

Macros

#define ip4_local_csum_is_offloaded(_b)
 
#define ip4_local_need_csum_check(is_tcp_udp, _b)
 
#define ip4_local_csum_is_valid(_b)
 
#define IP4_MCAST_ADDR_MASK   0xffff7f00
 This bits of an IPv4 address to mask to construct a multicast MAC address. More...
 

Enumerations

enum  ip_local_packet_type_e { IP_LOCAL_PACKET_TYPE_L4, IP_LOCAL_PACKET_TYPE_NAT, IP_LOCAL_PACKET_TYPE_FRAG }
 
enum  ip4_rewrite_next_t { IP4_REWRITE_NEXT_DROP, IP4_REWRITE_NEXT_ICMP_ERROR, IP4_REWRITE_NEXT_FRAGMENT, IP4_REWRITE_N_NEXT }
 

Functions

VLIB_NODE_FN() ip4_lookup_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 IPv4 lookup node. More...
 
static u8format_ip4_lookup_trace (u8 *s, va_list *args)
 
VLIB_NODE_FN() ip4_load_balance_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
ip4_address_tip4_interface_first_address (ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
 
static void ip4_add_subnet_bcast_route (u32 fib_index, fib_prefix_t *pfx, u32 sw_if_index)
 
static void ip4_add_interface_prefix_routes (ip4_main_t *im, u32 sw_if_index, u32 fib_index, ip_interface_address_t *a)
 
static void ip4_add_interface_routes (u32 sw_if_index, ip4_main_t *im, u32 fib_index, ip_interface_address_t *a)
 
static void ip4_del_interface_prefix_routes (ip4_main_t *im, u32 sw_if_index, u32 fib_index, ip4_address_t *address, u32 address_length)
 
static void ip4_del_interface_routes (u32 sw_if_index, ip4_main_t *im, u32 fib_index, ip4_address_t *address, u32 address_length)
 
void ip4_sw_interface_enable_disable (u32 sw_if_index, u32 is_enable)
 
static clib_error_tip4_add_del_interface_address_internal (vlib_main_t *vm, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 is_del)
 
clib_error_tip4_add_del_interface_address (vlib_main_t *vm, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 is_del)
 
void ip4_directed_broadcast (u32 sw_if_index, u8 enable)
 
static clib_error_tip4_sw_interface_admin_up_down (vnet_main_t *vnm, u32 sw_if_index, u32 flags)
 
 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (ip4_sw_interface_admin_up_down)
 
 VNET_FEATURE_ARC_INIT (ip4_unicast, static)
 
 VNET_FEATURE_INIT (ip4_flow_classify, static)
 
 VNET_FEATURE_INIT (ip4_inacl, static)
 
 VNET_FEATURE_INIT (ip4_source_and_port_range_check_rx, static)
 
 VNET_FEATURE_INIT (ip4_policer_classify, static)
 
 VNET_FEATURE_INIT (ip4_ipsec, static)
 
 VNET_FEATURE_INIT (ip4_vpath, static)
 
 VNET_FEATURE_INIT (ip4_vxlan_bypass, static)
 
 VNET_FEATURE_INIT (ip4_not_enabled, static)
 
 VNET_FEATURE_INIT (ip4_lookup, static)
 
 VNET_FEATURE_ARC_INIT (ip4_multicast, static)
 
 VNET_FEATURE_INIT (ip4_vpath_mc, static)
 
 VNET_FEATURE_INIT (ip4_mc_not_enabled, static)
 
 VNET_FEATURE_INIT (ip4_lookup_mc, static)
 
 VNET_FEATURE_ARC_INIT (ip4_output, static)
 
 VNET_FEATURE_INIT (ip4_source_and_port_range_check_tx, static)
 
 VNET_FEATURE_INIT (ip4_outacl, static)
 
 VNET_FEATURE_INIT (ip4_ipsec_output, static)
 
 VNET_FEATURE_INIT (ip4_interface_output, static)
 
static clib_error_tip4_sw_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
 
 VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip4_sw_interface_add_del)
 
static clib_error_tip4_lookup_init (vlib_main_t *vm)
 
u8format_ip4_forward_next_trace (u8 *s, va_list *args)
 
static u8format_ip4_rewrite_trace (u8 *s, va_list *args)
 
void ip4_forward_next_trace (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, vlib_rx_or_tx_t which_adj_index)
 
u16 ip4_tcp_udp_compute_checksum (vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
 
u32 ip4_tcp_udp_validate_checksum (vlib_main_t *vm, vlib_buffer_t *p0)
 
 VNET_FEATURE_ARC_INIT (ip4_local)
 
static void ip4_local_l4_csum_validate (vlib_main_t *vm, vlib_buffer_t *p, ip4_header_t *ip, u8 is_udp, u8 *error, u8 *good_tcp_udp)
 
static void ip4_local_check_l4_csum (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ih, u8 *error)
 
static void ip4_local_check_l4_csum_x2 (vlib_main_t *vm, vlib_buffer_t **b, ip4_header_t **ih, u8 *error)
 
static void ip4_local_set_next_and_error (vlib_node_runtime_t *error_node, vlib_buffer_t *b, u16 *next, u8 error, u8 head_of_feature_arc)
 
static void ip4_local_check_src (vlib_buffer_t *b, ip4_header_t *ip0, ip4_local_last_check_t *last_check, u8 *error0)
 
static void ip4_local_check_src_x2 (vlib_buffer_t **b, ip4_header_t **ip, ip4_local_last_check_t *last_check, u8 *error)
 
static u8 ip4_local_classify (vlib_buffer_t *b, ip4_header_t *ip, u16 *next)
 Determine packet type and next node. More...
 
static uword ip4_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int head_of_feature_arc)
 
VLIB_NODE_FN() ip4_local_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() ip4_local_end_of_arc_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VNET_FEATURE_INIT (ip4_local_end_of_arc, static)
 
void ip4_register_protocol (u32 protocol, u32 node_index)
 
void ip4_unregister_protocol (u32 protocol)
 
static clib_error_tshow_ip_local_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static void ip4_mtu_check (vlib_buffer_t *b, u16 packet_len, u16 adj_packet_bytes, bool df, u16 *next, u8 is_midchain, u32 *error)
 
static_always_inline void ip4_ttl_inc (vlib_buffer_t *b, ip4_header_t *ip)
 
static_always_inline void ip4_ttl_and_checksum_check (vlib_buffer_t *b, ip4_header_t *ip, u16 *next, u32 *error)
 
static uword ip4_rewrite_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_counters, int is_midchain, int is_mcast)
 
VLIB_NODE_FN() ip4_rewrite_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 IPv4 rewrite node. More...
 
VLIB_NODE_FN() ip4_rewrite_bcast_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() ip4_midchain_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() ip4_rewrite_mcast_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() ip4_mcast_midchain_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static int ip4_lookup_validate (ip4_address_t *a, u32 fib_index0)
 
static clib_error_ttest_lookup_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tset_ip_flow_hash_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
int vnet_set_ip4_classify_intfc (vlib_main_t *vm, u32 sw_if_index, u32 table_index)
 
static clib_error_tset_ip_classify_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 

Variables

vlib_node_registration_t ip4_lookup_node
 (constructor) VLIB_REGISTER_NODE (ip4_lookup_node) More...
 
vlib_node_registration_t ip4_load_balance_node
 (constructor) VLIB_REGISTER_NODE (ip4_load_balance_node) More...
 
ip4_main_t ip4_main
 Global ip4 main structure. More...
 
vlib_node_registration_t ip4_local_node
 (constructor) VLIB_REGISTER_NODE (ip4_local_node) More...
 
vlib_node_registration_t ip4_local_end_of_arc_node
 (constructor) VLIB_REGISTER_NODE (ip4_local_end_of_arc_node) More...
 
static vlib_cli_command_t show_ip_local
 (constructor) VLIB_CLI_COMMAND (show_ip_local) More...
 
vlib_node_registration_t ip4_rewrite_node
 (constructor) VLIB_REGISTER_NODE (ip4_rewrite_node) More...
 
vlib_node_registration_t ip4_rewrite_bcast_node
 (constructor) VLIB_REGISTER_NODE (ip4_rewrite_bcast_node) More...
 
vlib_node_registration_t ip4_rewrite_mcast_node
 (constructor) VLIB_REGISTER_NODE (ip4_rewrite_mcast_node) More...
 
vlib_node_registration_t ip4_mcast_midchain_node
 (constructor) VLIB_REGISTER_NODE (ip4_mcast_midchain_node) More...
 
vlib_node_registration_t ip4_midchain_node
 (constructor) VLIB_REGISTER_NODE (ip4_midchain_node) More...
 
static vlib_cli_command_t lookup_test_command
 (constructor) VLIB_CLI_COMMAND (lookup_test_command) More...
 
static vlib_cli_command_t set_ip_flow_hash_command
 (constructor) VLIB_CLI_COMMAND (set_ip_flow_hash_command) More...
 
static vlib_cli_command_t set_ip_classify_command
 (constructor) VLIB_CLI_COMMAND (set_ip_classify_command) More...
 

Macro Definition Documentation

◆ ip4_local_csum_is_offloaded

#define ip4_local_csum_is_offloaded (   _b)
Value:
((_b->flags & VNET_BUFFER_F_OFFLOAD) && \
(vnet_buffer (_b)->oflags & \
(VNET_BUFFER_OFFLOAD_F_TCP_CKSUM | VNET_BUFFER_OFFLOAD_F_UDP_CKSUM)))

Definition at line 1420 of file ip4_forward.c.

◆ ip4_local_csum_is_valid

#define ip4_local_csum_is_valid (   _b)
Value:
(_b->flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT \

Definition at line 1429 of file ip4_forward.c.

◆ ip4_local_need_csum_check

#define ip4_local_need_csum_check (   is_tcp_udp,
  _b 
)
Value:
(is_tcp_udp && !(_b->flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED \

Definition at line 1425 of file ip4_forward.c.

◆ IP4_MCAST_ADDR_MASK

#define IP4_MCAST_ADDR_MASK   0xffff7f00

This bits of an IPv4 address to mask to construct a multicast MAC address.

Definition at line 1978 of file ip4_forward.c.

Enumeration Type Documentation

◆ ip4_rewrite_next_t

Enumerator
IP4_REWRITE_NEXT_DROP 
IP4_REWRITE_NEXT_ICMP_ERROR 
IP4_REWRITE_NEXT_FRAGMENT 
IP4_REWRITE_N_NEXT 

Definition at line 1963 of file ip4_forward.c.

◆ ip_local_packet_type_e

Enumerator
IP_LOCAL_PACKET_TYPE_L4 
IP_LOCAL_PACKET_TYPE_NAT 
IP_LOCAL_PACKET_TYPE_FRAG 

Definition at line 1686 of file ip4_forward.c.

Function Documentation

◆ format_ip4_forward_next_trace()

u8* format_ip4_forward_next_trace ( u8 s,
va_list *  args 
)

Definition at line 1190 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ format_ip4_lookup_trace()

static u8 * format_ip4_lookup_trace ( u8 s,
va_list *  args 
)
static

Definition at line 1204 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ format_ip4_rewrite_trace()

static u8* format_ip4_rewrite_trace ( u8 s,
va_list *  args 
)
static

Definition at line 1220 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_add_del_interface_address()

clib_error_t* ip4_add_del_interface_address ( vlib_main_t vm,
u32  sw_if_index,
ip4_address_t address,
u32  address_length,
u32  is_del 
)

Definition at line 833 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_add_del_interface_address_internal()

static clib_error_t* ip4_add_del_interface_address_internal ( vlib_main_t vm,
u32  sw_if_index,
ip4_address_t address,
u32  address_length,
u32  is_del 
)
static

Definition at line 643 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_add_interface_prefix_routes()

static void ip4_add_interface_prefix_routes ( ip4_main_t im,
u32  sw_if_index,
u32  fib_index,
ip_interface_address_t a 
)
static

Definition at line 345 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_add_interface_routes()

static void ip4_add_interface_routes ( u32  sw_if_index,
ip4_main_t im,
u32  fib_index,
ip_interface_address_t a 
)
static

Definition at line 447 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_add_subnet_bcast_route()

static void ip4_add_subnet_bcast_route ( u32  fib_index,
fib_prefix_t pfx,
u32  sw_if_index 
)
static

Definition at line 306 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_del_interface_prefix_routes()

static void ip4_del_interface_prefix_routes ( ip4_main_t im,
u32  sw_if_index,
u32  fib_index,
ip4_address_t address,
u32  address_length 
)
static

Definition at line 497 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_del_interface_routes()

static void ip4_del_interface_routes ( u32  sw_if_index,
ip4_main_t im,
u32  fib_index,
ip4_address_t address,
u32  address_length 
)
static

Definition at line 582 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_directed_broadcast()

void ip4_directed_broadcast ( u32  sw_if_index,
u8  enable 
)

Definition at line 843 of file ip4_forward.c.

+ Here is the caller graph for this function:

◆ ip4_forward_next_trace()

void ip4_forward_next_trace ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
vlib_rx_or_tx_t  which_adj_index 
)

Definition at line 1240 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_interface_first_address()

ip4_address_t* ip4_interface_first_address ( ip4_main_t im,
u32  sw_if_index,
ip_interface_address_t **  result_ia 
)

Definition at line 281 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_load_balance_node()

VLIB_NODE_FN() ip4_load_balance_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 114 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_local_check_l4_csum()

static void ip4_local_check_l4_csum ( vlib_main_t vm,
vlib_buffer_t b,
ip4_header_t ih,
u8 error 
)
inlinestatic

Definition at line 1434 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_check_l4_csum_x2()

static void ip4_local_check_l4_csum_x2 ( vlib_main_t vm,
vlib_buffer_t **  b,
ip4_header_t **  ih,
u8 error 
)
inlinestatic

Definition at line 1453 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_check_src()

static void ip4_local_check_src ( vlib_buffer_t b,
ip4_header_t ip0,
ip4_local_last_check_t last_check,
u8 error0 
)
inlinestatic

Definition at line 1516 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_check_src_x2()

static void ip4_local_check_src_x2 ( vlib_buffer_t **  b,
ip4_header_t **  ip,
ip4_local_last_check_t last_check,
u8 error 
)
inlinestatic

Definition at line 1585 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_classify()

static u8 ip4_local_classify ( vlib_buffer_t b,
ip4_header_t ip,
u16 next 
)
inlinestatic

Determine packet type and next node.

The expectation is that all packets that are not L4 will skip checksums and source checks.

Definition at line 1700 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_end_of_arc_node()

VLIB_NODE_FN() ip4_local_end_of_arc_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 1870 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_local_inline()

static uword ip4_local_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  head_of_feature_arc 
)
inlinestatic

Definition at line 1720 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_l4_csum_validate()

static void ip4_local_l4_csum_validate ( vlib_main_t vm,
vlib_buffer_t p,
ip4_header_t ip,
u8  is_udp,
u8 error,
u8 good_tcp_udp 
)
inlinestatic

Definition at line 1397 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_local_node()

VLIB_NODE_FN() ip4_local_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 1843 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_local_set_next_and_error()

static void ip4_local_set_next_and_error ( vlib_node_runtime_t error_node,
vlib_buffer_t b,
u16 next,
u8  error,
u8  head_of_feature_arc 
)
inlinestatic

Definition at line 1485 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_lookup_init()

static clib_error_t* ip4_lookup_init ( vlib_main_t vm)
static

Definition at line 1109 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_lookup_node()

VLIB_NODE_FN() ip4_lookup_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

IPv4 lookup node.

Node Identifier:
ip4-lookup

This is the main IPv4 lookup dispatch node.

Parameters
vmvlib_main_t corresponding to the current thread
nodevlib_node_runtime_t
framevlib_frame_t whose contents should be dispatched
Graph mechanics: buffer metadata, next index usage

Uses:

  • vnet_buffer(b)->sw_if_index[VLIB_RX]
    • Indicates the sw_if_index value of the interface that the packet was received on.
  • vnet_buffer(b)->sw_if_index[VLIB_TX]
    • When the value is ~0 then the node performs a longest prefix match (LPM) for the packet destination address in the FIB attached to the receive interface.
    • Otherwise perform LPM for the packet destination address in the indicated FIB. In this case [VLIB_TX] is a FIB index value (0, 1, ...) and not a VRF id.

Sets:

  • vnet_buffer(b)->ip.adj_index[VLIB_TX]
    • The lookup result adjacency index.

Next Index:

  • Dispatches the packet to the node index found in ip_adjacency_t adj->lookup_next_index (where adj is the lookup result adjacency).

Definition at line 95 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_lookup_validate()

static int ip4_lookup_validate ( ip4_address_t a,
u32  fib_index0 
)
static

Definition at line 2666 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_mcast_midchain_node()

VLIB_NODE_FN() ip4_mcast_midchain_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 2608 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_midchain_node()

VLIB_NODE_FN() ip4_midchain_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 2588 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_mtu_check()

static void ip4_mtu_check ( vlib_buffer_t b,
u16  packet_len,
u16  adj_packet_bytes,
bool  df,
u16 next,
u8  is_midchain,
u32 error 
)
inlinestatic

Definition at line 1982 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_register_protocol()

void ip4_register_protocol ( u32  protocol,
u32  node_index 
)

Definition at line 1895 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_rewrite_bcast_node()

VLIB_NODE_FN() ip4_rewrite_bcast_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 2578 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_rewrite_inline()

static uword ip4_rewrite_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  do_counters,
int  is_midchain,
int  is_mcast 
)
inlinestatic

Definition at line 2074 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_rewrite_mcast_node()

VLIB_NODE_FN() ip4_rewrite_mcast_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 2598 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_rewrite_node()

VLIB_NODE_FN() ip4_rewrite_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

IPv4 rewrite node.

Node Identifier:
ip4-rewrite

This is the IPv4 transit-rewrite node: decrement TTL, fix the ipv4 header checksum, fetch the ip adjacency, check the outbound mtu, apply the adjacency rewrite, and send pkts to the adjacency rewrite header's rewrite_next_index.

Parameters
vmvlib_main_t corresponding to the current thread
nodevlib_node_runtime_t
framevlib_frame_t whose contents should be dispatched
Graph mechanics: buffer metadata, next index usage

Uses:

  • vnet_buffer(b)->ip.adj_index[VLIB_TX]
    • the rewrite adjacency index
  • adj->lookup_next_index
    • Must be IP_LOOKUP_NEXT_REWRITE or IP_LOOKUP_NEXT_ARP, otherwise the packet will be dropped.
  • adj->rewrite_header
    • Rewrite string length, rewrite string, next_index

Sets:

  • b->current_data, b->current_length
    • Updated net of applying the rewrite string

Next Indices:

  • adj->rewrite_header.next_index or ip4-drop

Definition at line 2569 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_sw_interface_add_del()

static clib_error_t* ip4_sw_interface_add_del ( vnet_main_t vnm,
u32  sw_if_index,
u32  is_add 
)
static

Definition at line 1065 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ ip4_sw_interface_admin_up_down()

static clib_error_t* ip4_sw_interface_admin_up_down ( vnet_main_t vnm,
u32  sw_if_index,
u32  flags 
)
static

Definition at line 883 of file ip4_forward.c.

◆ ip4_sw_interface_enable_disable()

void ip4_sw_interface_enable_disable ( u32  sw_if_index,
u32  is_enable 
)

Definition at line 601 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_tcp_udp_compute_checksum()

u16 ip4_tcp_udp_compute_checksum ( vlib_main_t vm,
vlib_buffer_t p0,
ip4_header_t ip0 
)

Definition at line 1328 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_tcp_udp_validate_checksum()

u32 ip4_tcp_udp_validate_checksum ( vlib_main_t vm,
vlib_buffer_t p0 
)

Definition at line 1361 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_ttl_and_checksum_check()

static_always_inline void ip4_ttl_and_checksum_check ( vlib_buffer_t b,
ip4_header_t ip,
u16 next,
u32 error 
)

Definition at line 2034 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_ttl_inc()

static_always_inline void ip4_ttl_inc ( vlib_buffer_t b,
ip4_header_t ip 
)

Definition at line 2012 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_unregister_protocol()

void ip4_unregister_protocol ( u32  protocol)

Definition at line 1907 of file ip4_forward.c.

+ Here is the caller graph for this function:

◆ set_ip_classify_command_fn()

static clib_error_t* set_ip_classify_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2965 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ set_ip_flow_hash_command_fn()

static clib_error_t* set_ip_flow_hash_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2763 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ show_ip_local_command_fn()

static clib_error_t* show_ip_local_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1918 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ test_lookup_command_fn()

static clib_error_t* test_lookup_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2684 of file ip4_forward.c.

+ Here is the call graph for this function:

◆ VNET_FEATURE_ARC_INIT() [1/4]

VNET_FEATURE_ARC_INIT ( ip4_local  )

◆ VNET_FEATURE_ARC_INIT() [2/4]

VNET_FEATURE_ARC_INIT ( ip4_multicast  ,
static   
)

◆ VNET_FEATURE_ARC_INIT() [3/4]

VNET_FEATURE_ARC_INIT ( ip4_output  ,
static   
)

◆ VNET_FEATURE_ARC_INIT() [4/4]

VNET_FEATURE_ARC_INIT ( ip4_unicast  ,
static   
)

◆ VNET_FEATURE_INIT() [1/17]

VNET_FEATURE_INIT ( ip4_flow_classify  ,
static   
)

◆ VNET_FEATURE_INIT() [2/17]

VNET_FEATURE_INIT ( ip4_inacl  ,
static   
)

◆ VNET_FEATURE_INIT() [3/17]

VNET_FEATURE_INIT ( ip4_interface_output  ,
static   
)

◆ VNET_FEATURE_INIT() [4/17]

VNET_FEATURE_INIT ( ip4_ipsec  ,
static   
)

◆ VNET_FEATURE_INIT() [5/17]

VNET_FEATURE_INIT ( ip4_ipsec_output  ,
static   
)

◆ VNET_FEATURE_INIT() [6/17]

VNET_FEATURE_INIT ( ip4_local_end_of_arc  ,
static   
)

◆ VNET_FEATURE_INIT() [7/17]

VNET_FEATURE_INIT ( ip4_lookup  ,
static   
)

◆ VNET_FEATURE_INIT() [8/17]

VNET_FEATURE_INIT ( ip4_lookup_mc  ,
static   
)

◆ VNET_FEATURE_INIT() [9/17]

VNET_FEATURE_INIT ( ip4_mc_not_enabled  ,
static   
)

◆ VNET_FEATURE_INIT() [10/17]

VNET_FEATURE_INIT ( ip4_not_enabled  ,
static   
)

◆ VNET_FEATURE_INIT() [11/17]

VNET_FEATURE_INIT ( ip4_outacl  ,
static   
)

◆ VNET_FEATURE_INIT() [12/17]

VNET_FEATURE_INIT ( ip4_policer_classify  ,
static   
)

◆ VNET_FEATURE_INIT() [13/17]

VNET_FEATURE_INIT ( ip4_source_and_port_range_check_rx  ,
static   
)

◆ VNET_FEATURE_INIT() [14/17]

VNET_FEATURE_INIT ( ip4_source_and_port_range_check_tx  ,
static   
)

◆ VNET_FEATURE_INIT() [15/17]

VNET_FEATURE_INIT ( ip4_vpath  ,
static   
)

◆ VNET_FEATURE_INIT() [16/17]

VNET_FEATURE_INIT ( ip4_vpath_mc  ,
static   
)

◆ VNET_FEATURE_INIT() [17/17]

VNET_FEATURE_INIT ( ip4_vxlan_bypass  ,
static   
)

◆ vnet_set_ip4_classify_intfc()

int vnet_set_ip4_classify_intfc ( vlib_main_t vm,
u32  sw_if_index,
u32  table_index 
)

Definition at line 2904 of file ip4_forward.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VNET_SW_INTERFACE_ADD_DEL_FUNCTION()

VNET_SW_INTERFACE_ADD_DEL_FUNCTION ( ip4_sw_interface_add_del  )

◆ VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION()

VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION ( ip4_sw_interface_admin_up_down  )

Variable Documentation

◆ ip4_load_balance_node

vlib_node_registration_t ip4_load_balance_node
Initial value:
=
{
.name = "ip4-load-balance",
.vector_size = sizeof (u32),
.sibling_of = "ip4-lookup",
.format_trace = format_ip4_lookup_trace,
}

(constructor) VLIB_REGISTER_NODE (ip4_load_balance_node)

Definition at line 269 of file ip4_forward.c.

◆ ip4_local_end_of_arc_node

vlib_node_registration_t ip4_local_end_of_arc_node
Initial value:
= {
.name = "ip4-local-end-of-arc",
.vector_size = sizeof (u32),
.sibling_of = "ip4-local",
}

(constructor) VLIB_REGISTER_NODE (ip4_local_end_of_arc_node)

Definition at line 1878 of file ip4_forward.c.

◆ ip4_local_node

vlib_node_registration_t ip4_local_node
Initial value:
=
{
.name = "ip4-local",
.vector_size = sizeof (u32),
.n_errors = IP4_N_ERROR,
.error_strings = ip4_error_strings,
.n_next_nodes = IP_LOCAL_N_NEXT,
.next_nodes =
{
[IP_LOCAL_NEXT_DROP] = "ip4-drop",
[IP_LOCAL_NEXT_PUNT] = "ip4-punt",
[IP_LOCAL_NEXT_UDP_LOOKUP] = "ip4-udp-lookup",
[IP_LOCAL_NEXT_ICMP] = "ip4-icmp-input",
[IP_LOCAL_NEXT_REASSEMBLY] = "ip4-full-reassembly",
},
}

(constructor) VLIB_REGISTER_NODE (ip4_local_node)

Definition at line 1850 of file ip4_forward.c.

◆ ip4_lookup_node

vlib_node_registration_t ip4_lookup_node
Initial value:
=
{
.name = "ip4-lookup",
.vector_size = sizeof (u32),
.format_trace = format_ip4_lookup_trace,
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP4_LOOKUP_NEXT_NODES,
}

(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)

Definition at line 104 of file ip4_forward.c.

◆ ip4_main

ip4_main_t ip4_main

Global ip4 main structure.

Definition at line 1105 of file ip4_forward.c.

◆ ip4_mcast_midchain_node

vlib_node_registration_t ip4_mcast_midchain_node
Initial value:
= {
.name = "ip4-mcast-midchain",
.vector_size = sizeof (u32),
.format_trace = format_ip4_rewrite_trace,
.sibling_of = "ip4-rewrite",
}

(constructor) VLIB_REGISTER_NODE (ip4_mcast_midchain_node)

Definition at line 2649 of file ip4_forward.c.

◆ ip4_midchain_node

vlib_node_registration_t ip4_midchain_node
Initial value:
= {
.name = "ip4-midchain",
.vector_size = sizeof (u32),
.format_trace = format_ip4_rewrite_trace,
.sibling_of = "ip4-rewrite",
}

(constructor) VLIB_REGISTER_NODE (ip4_midchain_node)

Definition at line 2657 of file ip4_forward.c.

◆ ip4_rewrite_bcast_node

vlib_node_registration_t ip4_rewrite_bcast_node
Initial value:
= {
.name = "ip4-rewrite-bcast",
.vector_size = sizeof (u32),
.format_trace = format_ip4_rewrite_trace,
.sibling_of = "ip4-rewrite",
}

(constructor) VLIB_REGISTER_NODE (ip4_rewrite_bcast_node)

Definition at line 2633 of file ip4_forward.c.

◆ ip4_rewrite_mcast_node

vlib_node_registration_t ip4_rewrite_mcast_node
Initial value:
= {
.name = "ip4-rewrite-mcast",
.vector_size = sizeof (u32),
.format_trace = format_ip4_rewrite_trace,
.sibling_of = "ip4-rewrite",
}

(constructor) VLIB_REGISTER_NODE (ip4_rewrite_mcast_node)

Definition at line 2641 of file ip4_forward.c.

◆ ip4_rewrite_node

vlib_node_registration_t ip4_rewrite_node
Initial value:
= {
.name = "ip4-rewrite",
.vector_size = sizeof (u32),
.format_trace = format_ip4_rewrite_trace,
.n_next_nodes = IP4_REWRITE_N_NEXT,
.next_nodes = {
[IP4_REWRITE_NEXT_DROP] = "ip4-drop",
[IP4_REWRITE_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[IP4_REWRITE_NEXT_FRAGMENT] = "ip4-frag",
},
}

(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)

Definition at line 2619 of file ip4_forward.c.

◆ lookup_test_command

vlib_cli_command_t lookup_test_command
static
Initial value:
=
{
.path = "test lookup",
.short_help = "test lookup <ipv4-addr> [table <fib-id>] [count <nn>]",
}

(constructor) VLIB_CLI_COMMAND (lookup_test_command)

Definition at line 2754 of file ip4_forward.c.

◆ set_ip_classify_command

vlib_cli_command_t set_ip_classify_command
static
Initial value:
=
{
.path = "set ip classify",
.short_help =
"set ip classify intfc <interface> table-index <classify-idx>",
}

(constructor) VLIB_CLI_COMMAND (set_ip_classify_command)

Definition at line 3018 of file ip4_forward.c.

◆ set_ip_flow_hash_command

vlib_cli_command_t set_ip_flow_hash_command
static
Initial value:
=
{
.path = "set ip flow-hash",
.short_help =
"set ip flow-hash table <table-id> [src] [dst] [sport] [dport] [proto] [reverse]",
}

(constructor) VLIB_CLI_COMMAND (set_ip_flow_hash_command)

Definition at line 2893 of file ip4_forward.c.

◆ show_ip_local

vlib_cli_command_t show_ip_local
static
Initial value:
=
{
.path = "show ip local",
.short_help = "show ip local",
}

(constructor) VLIB_CLI_COMMAND (show_ip_local)

Definition at line 1955 of file ip4_forward.c.

ip4_local_csum_is_offloaded
#define ip4_local_csum_is_offloaded(_b)
Definition: ip4_forward.c:1420
IP4_REWRITE_NEXT_ICMP_ERROR
@ IP4_REWRITE_NEXT_ICMP_ERROR
Definition: ip4_forward.c:1966
IP4_LOOKUP_NEXT_NODES
#define IP4_LOOKUP_NEXT_NODES
Definition: adj.h:108
IP_LOCAL_N_NEXT
@ IP_LOCAL_N_NEXT
Definition: lookup.h:116
format_ip4_lookup_trace
static u8 * format_ip4_lookup_trace(u8 *s, va_list *args)
Definition: ip4_forward.c:1204
format_ip4_rewrite_trace
static u8 * format_ip4_rewrite_trace(u8 *s, va_list *args)
Definition: ip4_forward.c:1220
IP4_N_ERROR
@ IP4_N_ERROR
Definition: ip4_error.h:97
IP_LOCAL_NEXT_ICMP
@ IP_LOCAL_NEXT_ICMP
Definition: lookup.h:114
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
IP_LOCAL_NEXT_REASSEMBLY
@ IP_LOCAL_NEXT_REASSEMBLY
Definition: lookup.h:115
format_ip4_forward_next_trace
u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
Definition: ip4_forward.c:1190
IP4_REWRITE_NEXT_FRAGMENT
@ IP4_REWRITE_NEXT_FRAGMENT
Definition: ip4_forward.c:1967
test_lookup_command_fn
static clib_error_t * test_lookup_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_forward.c:2684
IP4_REWRITE_NEXT_DROP
@ IP4_REWRITE_NEXT_DROP
Definition: ip4_forward.c:1965
show_ip_local_command_fn
static clib_error_t * show_ip_local_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_forward.c:1918
u32
unsigned int u32
Definition: types.h:88
ip4_error_strings
char * ip4_error_strings[]
Definition: ip4_input.c:377
IP_LOCAL_NEXT_UDP_LOOKUP
@ IP_LOCAL_NEXT_UDP_LOOKUP
Definition: lookup.h:113
IP_LOCAL_NEXT_DROP
@ IP_LOCAL_NEXT_DROP
Definition: lookup.h:111
IP4_REWRITE_N_NEXT
@ IP4_REWRITE_N_NEXT
Definition: ip4_forward.c:1968
IP_LOOKUP_N_NEXT
@ IP_LOOKUP_N_NEXT
Definition: adj.h:91
set_ip_classify_command_fn
static clib_error_t * set_ip_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_forward.c:2965
IP_LOCAL_NEXT_PUNT
@ IP_LOCAL_NEXT_PUNT
Definition: lookup.h:112
set_ip_flow_hash_command_fn
static clib_error_t * set_ip_flow_hash_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_forward.c:2763