106 .name =
"ip4-lookup",
107 .vector_size =
sizeof (
u32),
125 n_left =
frame->n_vectors;
134 u32 lbi0, hc0, lbi1, hc1;
265 return frame->n_vectors;
271 .name =
"ip4-load-balance",
272 .vector_size =
sizeof (
u32),
273 .sibling_of =
"ip4-lookup",
278 #ifndef CLIB_MARCH_VARIANT 290 (lm, ia, sw_if_index,
300 *result_ia = result ? ia : 0;
407 pfx_special.
fp_addr.ip4.as_u32 =
418 pfx_special.
fp_addr.ip4.as_u32 =
429 pfx_special.
fp_addr.ip4.as_u32 =
430 address->
as_u32 ^ clib_host_to_net_u32(1);
466 if (classify_table_index != (
u32) ~ 0)
508 .fp_len = address_length,
542 if (address_length <= 30)
547 pfx_special.
fp_len = address_length;
554 pfx_special.
fp_addr.ip4.as_u32 =
564 pfx_special.
fp_addr.ip4.as_u32 =
581 (im, address, sw_if_index, &new_src_ia);
585 pfx_special.
fp_len = address_length;
586 pfx_special.
fp_addr.ip4 = *new_src_addr;
607 else if (address_length == 31)
609 pfx_special.
fp_addr.ip4.as_u32 =
610 address->
as_u32 ^ clib_host_to_net_u32(1);
632 address, address_length);
638 #ifndef CLIB_MARCH_VARIANT 667 sw_if_index, !is_enable, 0, 0);
685 u32 address_length,
u32 is_del)
691 u32 if_address_index;
695 if (sw_if_index == 0)
721 if (im->fib_index_by_sw_if_index[sw_if_index] ==
722 im->fib_index_by_sw_if_index[sif->sw_if_index])
724 foreach_ip_interface_address
725 (&im->lookup_main, ia, sif->sw_if_index,
729 ip_interface_address_get_address
730 (&im->lookup_main, ia);
732 if (ip4_destination_matches_route
733 (im, address, x, ia->address_length) ||
734 ip4_destination_matches_route (im,
740 if ((sw_if_index == sif->sw_if_index) &&
741 (ia->address_length == address_length) &&
742 (x->as_u32 != address->as_u32))
745 if (ia->flags & IP_INTERFACE_ADDRESS_FLAG_STALE)
754 vnm->api_errno = VNET_API_ERROR_ADDRESS_IN_USE;
756 error = clib_error_create
757 (
"failed to add %U on %U which conflicts with %U for interface %U",
758 format_ip4_address_and_length, address,
760 format_vnet_sw_if_index_name, vnm,
762 format_ip4_address_and_length, x,
764 format_vnet_sw_if_index_name, vnm,
778 if (~0 == if_address_index)
780 vnm->api_errno = VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
782 lm->format_address_and_length,
783 addr_fib, address_length,
796 if (~0 != if_address_index)
822 addr_fib, address_length,
828 vnm->api_errno = VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
830 (
"Prefix %U already found on interface %U",
831 lm->format_address_and_length, addr_fib, address_length,
837 addr_fib, address_length,
856 im, ip4_af.fib_index,
858 (lm->if_address_pool, if_address_index));
862 vec_foreach (cb, im->add_del_interface_address_callbacks)
864 address, address_length, if_address_index, is_del);
875 u32 address_length,
u32 is_del)
878 (vm, sw_if_index, address, address_length, is_del);
897 if (ia->address_length <= 30)
901 ipa = ip_interface_address_get_address (&im->lookup_main, ia);
905 .fp_proto = FIB_PROTOCOL_IP4,
907 .ip4.as_u32 = (ipa->as_u32 | ~im->fib_masks[ia->address_length]),
911 ip4_add_subnet_bcast_route
912 (fib_table_get_index_for_sw_if_index(FIB_PROTOCOL_IP4,
927 u32 is_admin_up, fib_index;
933 lookup_main.if_address_pool_index_by_sw_if_index,
944 a = ip_interface_address_get_address (&im->lookup_main, ia);
946 ip4_add_interface_routes (sw_if_index,
950 ip4_del_interface_routes (sw_if_index,
952 a, ia->address_length);
965 .arc_name =
"ip4-unicast",
966 .start_nodes =
VNET_FEATURES (
"ip4-input",
"ip4-input-no-checksum"),
967 .last_in_arc =
"ip4-lookup",
973 .arc_name =
"ip4-unicast",
974 .node_name =
"ip4-flow-classify",
980 .arc_name =
"ip4-unicast",
981 .node_name =
"ip4-inacl",
987 .arc_name =
"ip4-unicast",
988 .node_name =
"ip4-source-and-port-range-check-rx",
994 .arc_name =
"ip4-unicast",
995 .node_name =
"ip4-policer-classify",
1001 .arc_name =
"ip4-unicast",
1002 .node_name =
"ipsec4-input-feature",
1008 .arc_name =
"ip4-unicast",
1009 .node_name =
"vpath-input-ip4",
1015 .arc_name =
"ip4-unicast",
1016 .node_name =
"ip4-vxlan-bypass",
1022 .arc_name =
"ip4-unicast",
1023 .node_name =
"ip4-not-enabled",
1029 .arc_name =
"ip4-unicast",
1030 .node_name =
"ip4-lookup",
1037 .arc_name =
"ip4-multicast",
1038 .start_nodes =
VNET_FEATURES (
"ip4-input",
"ip4-input-no-checksum"),
1039 .last_in_arc =
"ip4-mfib-forward-lookup",
1045 .arc_name =
"ip4-multicast",
1046 .node_name =
"vpath-input-ip4",
1052 .arc_name =
"ip4-multicast",
1053 .node_name =
"ip4-not-enabled",
1059 .arc_name =
"ip4-multicast",
1060 .node_name =
"ip4-mfib-forward-lookup",
1067 .arc_name =
"ip4-output",
1068 .start_nodes =
VNET_FEATURES (
"ip4-rewrite",
"ip4-midchain",
"ip4-dvr-dpo"),
1069 .last_in_arc =
"interface-output",
1075 .arc_name =
"ip4-output",
1076 .node_name =
"ip4-source-and-port-range-check-tx",
1082 .arc_name =
"ip4-output",
1083 .node_name =
"ip4-outacl",
1089 .arc_name =
"ip4-output",
1090 .node_name =
"ipsec4-output-feature",
1097 .arc_name =
"ip4-output",
1098 .node_name =
"interface-output",
1135 sw_if_index, is_add, 0, 0);
1143 #ifndef CLIB_MARCH_VARIANT 1193 #define _16(f,v) h.f = clib_host_to_net_u16 (v); 1194 #define _8(f,v) h.f = v; 1195 _16 (l2_type, ETHERNET_ARP_HARDWARE_TYPE_ethernet);
1196 _16 (l3_type, ETHERNET_TYPE_IP4);
1197 _8 (n_l2_address_bytes, 6);
1198 _8 (n_l3_address_bytes, 4);
1199 _16 (opcode, ETHERNET_ARP_OPCODE_request);
1227 #ifndef CLIB_MARCH_VARIANT 1250 s =
format (s,
"fib %d dpo-idx %d flow hash: 0x%08x",
1266 s =
format (s,
"tx_sw_if_index %d dpo-idx %d : %U flow hash: 0x%08x",
1276 #ifndef CLIB_MARCH_VARIANT 1305 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1320 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
1347 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1371 u32 ip_header_length, payload_length_host_byte_order;
1375 payload_length_host_byte_order =
1376 clib_net_to_host_u16 (ip0->
length) - ip_header_length;
1378 clib_host_to_net_u32 (payload_length_host_byte_order +
1395 payload_length_host_byte_order, (
u8 *) ip0,
1396 ip_header_length, NULL);
1407 || ip0->
protocol == IP_PROTOCOL_UDP);
1409 udp0 = (
void *) (ip0 + 1);
1412 p0->
flags |= (VNET_BUFFER_F_L4_CHECKSUM_COMPUTED
1413 | VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
1419 p0->
flags |= (VNET_BUFFER_F_L4_CHECKSUM_COMPUTED
1420 | ((sum16 == 0) << VNET_BUFFER_F_LOG2_L4_CHECKSUM_CORRECT));
1429 .arc_name =
"ip4-local",
1431 .last_in_arc =
"ip4-local-end-of-arc",
1442 *good_tcp_udp = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
1446 u32 ip_len, udp_len;
1450 ip_len = clib_net_to_host_u16 (ip->
length);
1451 udp_len = clib_net_to_host_u16 (udp->
length);
1453 len_diff = ip_len - udp_len;
1454 *good_tcp_udp &= len_diff >= 0;
1455 *error = len_diff < 0 ? IP4_ERROR_UDP_LENGTH : *error;
1459 #define ip4_local_csum_is_offloaded(_b) \ 1460 _b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM \ 1461 || _b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM 1463 #define ip4_local_need_csum_check(is_tcp_udp, _b) \ 1464 (is_tcp_udp && !(_b->flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED \ 1465 || ip4_local_csum_is_offloaded (_b))) 1467 #define ip4_local_csum_is_valid(_b) \ 1468 (_b->flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT \ 1469 || (ip4_local_csum_is_offloaded (_b))) != 0 1475 u8 is_udp, is_tcp_udp, good_tcp_udp;
1477 is_udp = ih->
protocol == IP_PROTOCOL_UDP;
1478 is_tcp_udp = is_udp || ih->
protocol == IP_PROTOCOL_TCP;
1485 ASSERT (IP4_ERROR_TCP_CHECKSUM + 1 == IP4_ERROR_UDP_CHECKSUM);
1486 *error = (is_tcp_udp && !good_tcp_udp
1487 ? IP4_ERROR_TCP_CHECKSUM + is_udp : *error);
1494 u8 is_udp[2], is_tcp_udp[2], good_tcp_udp[2];
1496 is_udp[0] = ih[0]->
protocol == IP_PROTOCOL_UDP;
1497 is_udp[1] = ih[1]->
protocol == IP_PROTOCOL_UDP;
1499 is_tcp_udp[0] = is_udp[0] || ih[0]->
protocol == IP_PROTOCOL_TCP;
1500 is_tcp_udp[1] = is_udp[1] || ih[1]->
protocol == IP_PROTOCOL_TCP;
1516 error[0] = (is_tcp_udp[0] && !good_tcp_udp[0] ?
1517 IP4_ERROR_TCP_CHECKSUM + is_udp[0] : error[0]);
1518 error[1] = (is_tcp_udp[1] && !good_tcp_udp[1] ?
1519 IP4_ERROR_TCP_CHECKSUM + is_udp[1] : error[1]);
1525 u8 head_of_feature_arc)
1532 if (head_of_feature_arc)
1600 *error0 = ((*error0 == IP4_ERROR_UNKNOWN_PROTOCOL
1602 IP4_ERROR_SPOOFED_LOCAL_PACKETS : *error0);
1603 *error0 = ((*error0 == IP4_ERROR_UNKNOWN_PROTOCOL
1606 IP4_ERROR_SRC_LOOKUP_MISS : *error0);
1609 last_check->
lbi = lbi0;
1610 last_check->
error = *error0;
1611 last_check->
first = 0;
1618 *error0 = last_check->
error;
1633 not_last_hit = last_check->
first;
1688 error[0] = ((error[0] == IP4_ERROR_UNKNOWN_PROTOCOL &&
1690 IP4_ERROR_SPOOFED_LOCAL_PACKETS : error[0]);
1691 error[0] = ((error[0] == IP4_ERROR_UNKNOWN_PROTOCOL &&
1694 ? IP4_ERROR_SRC_LOOKUP_MISS : error[0]);
1696 error[1] = ((error[1] == IP4_ERROR_UNKNOWN_PROTOCOL &&
1698 IP4_ERROR_SPOOFED_LOCAL_PACKETS : error[1]);
1699 error[1] = ((error[1] == IP4_ERROR_UNKNOWN_PROTOCOL &&
1702 ? IP4_ERROR_SRC_LOOKUP_MISS : error[1]);
1705 last_check->
lbi = lbi[1];
1706 last_check->
error = error[1];
1707 last_check->
first = 0;
1719 error[0] = last_check->
error;
1720 error[1] = last_check->
error;
1762 u32 *from, n_left_from;
1779 .error = IP4_ERROR_UNKNOWN_PROTOCOL,
1793 while (n_left_from >= 6)
1806 error[0] = error[1] = IP4_ERROR_UNKNOWN_PROTOCOL;
1817 not_batch = pt[0] ^ pt[1];
1819 if (head_of_feature_arc == 0 || (pt[0] && not_batch == 0))
1844 head_of_feature_arc);
1846 head_of_feature_arc);
1853 while (n_left_from > 0)
1855 error[0] = IP4_ERROR_UNKNOWN_PROTOCOL;
1861 if (head_of_feature_arc == 0 || pt[0])
1870 head_of_feature_arc);
1890 .name =
"ip4-local",
1891 .vector_size =
sizeof (
u32),
1917 .name =
"ip4-local-end-of-arc",
1918 .vector_size =
sizeof (
u32),
1921 .sibling_of =
"ip4-local",
1925 .arc_name =
"ip4-local",
1926 .node_name =
"ip4-local-end-of-arc",
1931 #ifndef CLIB_MARCH_VARIANT 1995 .path =
"show ip local",
1997 .short_help =
"show ip local",
2013 #if CLIB_ARCH_IS_BIG_ENDIAN 2014 #define IP4_MCAST_ADDR_MASK 0x007fffff 2016 #define IP4_MCAST_ADDR_MASK 0xffff7f00 2021 u16 adj_packet_bytes,
bool df,
u16 * next,
2022 u8 is_midchain,
u32 * error)
2024 if (packet_len > adj_packet_bytes)
2026 *error = IP4_ERROR_MTU_EXCEEDED;
2030 (b, ICMP4_destination_unreachable,
2031 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set,
2059 checksum = ip->
checksum - clib_host_to_net_u16 (0x0100);
2060 checksum += checksum >= 0xffff;
2085 checksum = ip->
checksum + clib_host_to_net_u16 (0x0100);
2086 checksum += checksum >= 0xffff;
2098 *error = IP4_ERROR_TIME_EXPIRED;
2101 ICMP4_time_exceeded_ttl_exceeded_in_transit,
2108 (b->
flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM));
2116 int do_counters,
int is_midchain,
int is_mcast)
2132 #if (CLIB_N_PREFETCHES >= 8) 2133 if (n_left_from >= 6)
2136 for (i = 2; i < 6; i++)
2142 while (n_left_from >= 8)
2146 u32 rw_len0, error0, adj_index0;
2147 u32 rw_len1, error1, adj_index1;
2148 u32 tx_sw_if_index0, tx_sw_if_index1;
2163 thread_index, adj_index0);
2165 thread_index, adj_index1);
2171 error0 = error1 = IP4_ERROR_NONE;
2181 rw_len0 = adj0[0].rewrite_header.data_bytes;
2182 rw_len1 = adj1[0].rewrite_header.data_bytes;
2183 vnet_buffer (b[0])->ip.save_rewrite_length = rw_len0;
2184 vnet_buffer (b[1])->ip.save_rewrite_length = rw_len1;
2195 u16 ip0_len = clib_net_to_host_u16 (ip0->
length);
2196 u16 ip1_len = clib_net_to_host_u16 (ip1->
length);
2198 if (b[0]->
flags & VNET_BUFFER_F_GSO)
2200 if (b[1]->
flags & VNET_BUFFER_F_GSO)
2204 adj0[0].rewrite_header.max_l3_packet_bytes,
2207 next + 0, is_midchain, &error0);
2209 adj1[0].rewrite_header.max_l3_packet_bytes,
2212 next + 1, is_midchain, &error1);
2216 error0 = ((adj0[0].rewrite_header.sw_if_index ==
2218 IP4_ERROR_SAME_INTERFACE : error0);
2219 error1 = ((adj1[0].rewrite_header.sw_if_index ==
2221 IP4_ERROR_SAME_INTERFACE : error1);
2228 u32 next_index = adj0[0].rewrite_header.next_index;
2231 tx_sw_if_index0 = adj0[0].rewrite_header.sw_if_index;
2241 next[0] = next_index;
2250 if (error0 == IP4_ERROR_MTU_EXCEEDED)
2255 u32 next_index = adj1[0].rewrite_header.next_index;
2258 tx_sw_if_index1 = adj1[0].rewrite_header.sw_if_index;
2267 next[1] = next_index;
2276 if (error1 == IP4_ERROR_MTU_EXCEEDED)
2291 if (error0 == IP4_ERROR_NONE)
2298 if (error1 == IP4_ERROR_NONE)
2308 if (error0 == IP4_ERROR_NONE)
2310 if (error1 == IP4_ERROR_NONE)
2317 if (error0 == IP4_ERROR_NONE)
2319 adj0->rewrite_header.dst_mcast_offset,
2321 if (error1 == IP4_ERROR_NONE)
2323 adj1->rewrite_header.dst_mcast_offset,
2331 #elif (CLIB_N_PREFETCHES >= 4) 2334 while (n_left_from >= 1)
2338 u32 rw_len0, error0, adj_index0;
2339 u32 tx_sw_if_index0;
2367 thread_index, adj_index0);
2372 error0 = IP4_ERROR_NONE;
2380 rw_len0 = adj0[0].rewrite_header.data_bytes;
2381 vnet_buffer (b[0])->ip.save_rewrite_length = rw_len0;
2384 u16 ip0_len = clib_net_to_host_u16 (ip0->
length);
2386 if (b[0]->
flags & VNET_BUFFER_F_GSO)
2390 adj0[0].rewrite_header.max_l3_packet_bytes,
2393 next + 0, is_midchain, &error0);
2397 error0 = ((adj0[0].rewrite_header.sw_if_index ==
2399 IP4_ERROR_SAME_INTERFACE : error0);
2406 u32 next_index = adj0[0].rewrite_header.next_index;
2408 tx_sw_if_index0 = adj0[0].rewrite_header.sw_if_index;
2417 next[0] = next_index;
2449 adj0->rewrite_header.dst_mcast_offset,
2455 if (error0 == IP4_ERROR_MTU_EXCEEDED)
2465 while (n_left_from > 0)
2469 u32 rw_len0, adj_index0, error0;
2470 u32 tx_sw_if_index0;
2478 thread_index, adj_index0);
2482 error0 = IP4_ERROR_NONE;
2488 rw_len0 = adj0[0].rewrite_header.data_bytes;
2489 vnet_buffer (b[0])->ip.save_rewrite_length = rw_len0;
2492 u16 ip0_len = clib_net_to_host_u16 (ip0->
length);
2493 if (b[0]->
flags & VNET_BUFFER_F_GSO)
2497 adj0[0].rewrite_header.max_l3_packet_bytes,
2500 next + 0, is_midchain, &error0);
2504 error0 = ((adj0[0].rewrite_header.sw_if_index ==
2506 IP4_ERROR_SAME_INTERFACE : error0);
2513 u32 next_index = adj0[0].rewrite_header.next_index;
2515 tx_sw_if_index0 = adj0[0].rewrite_header.sw_if_index;
2524 next[0] = next_index;
2544 thread_index, adj_index0, 1,
2554 adj0->rewrite_header.dst_mcast_offset,
2561 if (error0 == IP4_ERROR_MTU_EXCEEDED)
2583 int do_counters,
int is_midchain,
int is_mcast)
2586 is_midchain, is_mcast);
2673 .name =
"ip4-rewrite",
2674 .vector_size =
sizeof (
u32),
2687 .name =
"ip4-rewrite-bcast",
2688 .vector_size =
sizeof (
u32),
2691 .sibling_of =
"ip4-rewrite",
2695 .name =
"ip4-rewrite-mcast",
2696 .vector_size =
sizeof (
u32),
2699 .sibling_of =
"ip4-rewrite",
2703 .name =
"ip4-mcast-midchain",
2704 .vector_size =
sizeof (
u32),
2707 .sibling_of =
"ip4-rewrite",
2711 .name =
"ip4-midchain",
2712 .vector_size =
sizeof (
u32),
2714 .sibling_of =
"ip4-rewrite",
2750 if (
unformat (input,
"table %d", &table_id))
2754 if ((fib) && (fib->
index != table_id))
2758 else if (
unformat (input,
"count %f", &count))
2771 for (i = 0; i < n; i++)
2776 ip4_base_address.
as_u32 =
2777 clib_host_to_net_u32 (1 +
2778 clib_net_to_host_u32 (ip4_base_address.
as_u32));
2809 .path =
"test lookup",
2810 .short_help =
"test lookup <ipv4-addr> [table <fib-id>] [count <nn>]",
2815 #ifndef CLIB_MARCH_VARIANT 2823 if (~0 == fib_index)
2824 return VNET_API_ERROR_NO_SUCH_FIB;
2840 u32 flow_hash_config = 0;
2845 if (
unformat (input,
"table %d", &table_id))
2848 else if (unformat (input, #a)) { flow_hash_config |= v; matched=1;} 2865 case VNET_API_ERROR_NO_SUCH_FIB:
2869 clib_warning (
"BUG: illegal flow hash config 0x%x", flow_hash_config);
2962 .path =
"set ip flow-hash",
2964 "set ip flow-hash table <table-id> [src] [dst] [sport] [dport] [proto] [reverse]",
2969 #ifndef CLIB_MARCH_VARIANT 2982 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
2985 return VNET_API_ERROR_NO_SUCH_ENTRY;
2992 if (NULL != if_addr)
2997 .fp_addr.ip4 = *if_addr,
3005 if (table_index != (
u32) ~ 0)
3036 u32 table_index = ~0;
3037 int table_index_set = 0;
3043 if (
unformat (input,
"table-index %d", &table_index))
3044 table_index_set = 1;
3052 if (table_index_set == 0)
3055 if (sw_if_index == ~0)
3065 case VNET_API_ERROR_NO_MATCHING_INTERFACE:
3068 case VNET_API_ERROR_NO_SUCH_ENTRY:
3087 .path =
"set ip classify",
3089 "set ip classify intfc <interface> table-index <classify-idx>",
3106 "invalid heap-size parameter `%U'",
vlib_node_registration_t ip4_mcast_midchain_node
(constructor) VLIB_REGISTER_NODE (ip4_mcast_midchain_node)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
u16 lb_n_buckets
number of buckets in the load-balance.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
fib_protocol_t fp_proto
protocol type
static ip_interface_prefix_t * ip_get_interface_prefix(ip_lookup_main_t *lm, ip_interface_prefix_key_t *k)
u32 mfib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, mfib_source_t src)
Get the index of the FIB for a Table-ID.
#define ip4_local_need_csum_check(is_tcp_udp, _b)
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)
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
static clib_error_t * ip4_config(vlib_main_t *vm, unformat_input_t *input)
static uword ip4_local_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int head_of_feature_arc)
int vnet_set_ip4_flow_hash(u32 table_id, u32 flow_hash_config)
static int fib_urpf_check_size(index_t ui)
Data-Plane function to check the size of an uRPF list, (i.e.
void ip_frag_set_vnet_buffer(vlib_buffer_t *b, u16 mtu, u8 next_index, u8 flags)
format_function_t format_vlib_node_name
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 ip4_del_interface_prefix_routes(ip4_main_t *im, u32 sw_if_index, u32 fib_index, ip4_address_t *address, u32 address_length)
void ip4_mfib_interface_enable_disable(u32 sw_if_index, int is_enable)
Add/remove the interface from the accepting list of the special MFIB entries.
Route added as a result of interface configuration.
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
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 * ip4_lookup_init(vlib_main_t *vm)
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 ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step(const ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t current_leaf, const ip4_address_t *dst_address, u32 dst_address_byte_index)
Lookup step.
vnet_interface_main_t interface_main
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
static int ip4_lookup_validate(ip4_address_t *a, u32 fib_index0)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
#define clib_memcpy_fast(a, b, c)
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
static const dpo_id_t * load_balance_get_fwd_bucket(const load_balance_t *lb, u16 bucket)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static clib_error_t * test_lookup_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword ip4_lookup_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
char * ip4_error_strings[]
ip_lookup_main_t lookup_main
union ip_adjacency_t_::@137 sub_type
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
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)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
static_always_inline void adj_midchain_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
VNET_FEATURE_ARC_INIT(ip4_unicast, static)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static u32 ip4_lookup(gid_ip4_table_t *db, u32 vni, ip_prefix_t *key)
static void ip4_del_interface_routes(u32 sw_if_index, ip4_main_t *im, u32 fib_index, ip4_address_t *address, u32 address_length)
u8 mcast_feature_arc_index
Feature arc indices.
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
enum vnet_sw_interface_flags_t_ vnet_sw_interface_flags_t
static void ip4_local_check_l4_csum_x2(vlib_main_t *vm, vlib_buffer_t **b, ip4_header_t **ih, u8 *error)
static int ip4_is_fragment(const ip4_header_t *i)
static pg_node_t * pg_get_node(uword node_index)
static void ip4_local_check_l4_csum(vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ih, u8 *error)
#define clib_memcpy(d, s, n)
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
u8 output_feature_arc_index
static u16 ip_calculate_l4_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip_csum_t sum0, u32 payload_length, u8 *iph, u32 ip_header_size, u8 *l4h)
vl_api_ip_proto_t protocol
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
static clib_error_t * show_ip_local_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ip4_enable_disable_interface_callback_t * enable_disable_interface_callbacks
Functions to call when interface becomes IPv4 enabled/disable.
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
static uword pow2_mask(uword x)
static void ip4_add_interface_routes(u32 sw_if_index, ip4_main_t *im, u32 fib_index, ip_interface_address_t *a)
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
#define ip4_local_csum_is_valid(_b)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Aggregate type for a prefix.
#define clib_error_return(e, args...)
struct ip_adjacency_t_::@137::@139 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
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 void * ip4_next_header(ip4_header_t *i)
#define clib_error_create(args...)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
#define vlib_call_init_function(vm, x)
static clib_error_t * vnet_feature_init(vlib_main_t *vm)
static u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
From the stored slot value extract the LB index value.
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
void ip4_directed_broadcast(u32 sw_if_index, u8 enable)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_registration_t ip4_input_node
Global ip4 input node.
void vlib_packet_template_init(vlib_main_t *vm, vlib_packet_template_t *t, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_alloc, char *fmt,...)
u32 * classify_table_index_by_sw_if_index
First table index to use for this interface, ~0 => none.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
vlib_node_registration_t ip4_local_node
(constructor) VLIB_REGISTER_NODE (ip4_local_node)
index_t classify_dpo_create(dpo_proto_t proto, u32 classify_table_index)
dpo_type_t dpoi_type
the type
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
void ip4_register_protocol(u32 protocol, u32 node_index)
uword mtrie_heap_size
Heapsize for the Mtries.
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)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u8 * ip_enabled_by_sw_if_index
#define pool_put(P, E)
Free an object E in pool P.
static_always_inline void * vnet_feature_arc_start_w_cfg_index(u8 arc, u32 sw_if_index, u32 *next, vlib_buffer_t *b, u32 cfg_index)
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)
void ip4_unregister_protocol(u32 protocol)
ip4_main_t ip4_main
Global ip4 main structure.
u8 local_next_by_ip_protocol[256]
Table mapping ip protocol to ip[46]-local node next index.
static void vlib_prefetch_combined_counter(const vlib_combined_counter_main_t *cm, u32 thread_index, u32 index)
Pre-fetch a per-thread combined counter for the given object index.
vl_api_address_union_t src_address
void vnet_sw_interface_update_unnumbered(u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable)
load_balance_main_t load_balance_main
The one instance of load-balance main.
ip_interface_address_flags_t flags
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
vlib_combined_counter_main_t adjacency_counters
Adjacency packet counters.
ip4_fib_mtrie_t mtrie
Mtrie for fast lookups.
static u8 * format_ip4_lookup_trace(u8 *s, va_list *args)
static void ip4_add_interface_prefix_routes(ip4_main_t *im, u32 sw_if_index, u32 fib_index, ip_interface_address_t *a)
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
#define IP4_LOOKUP_NEXT_NODES
static u8 * format_ip4_rewrite_trace(u8 *s, va_list *args)
u32 ip_interface_address_find(ip_lookup_main_t *lm, void *addr_fib, u32 address_length)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
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 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)
sll srl srl sll sra u16x4 i
ip4_enable_disable_interface_function_t * function
#define vec_free(V)
Free vector's memory (no header).
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
clib_error_t * ip_interface_address_add(ip_lookup_main_t *lm, u32 sw_if_index, void *addr_fib, u32 address_length, u32 *result_if_address_index)
ip4_add_del_interface_address_function_t * function
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
void fib_table_set_flow_hash_config(u32 fib_index, fib_protocol_t proto, flow_hash_config_t hash_config)
Set the flow hash configured used by the table.
static ip4_address_t * ip4_interface_address_matching_destination(ip4_main_t *im, const ip4_address_t *dst, u32 sw_if_index, ip_interface_address_t **result_ia)
#define clib_warning(format, args...)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static void ip4_local_check_src(vlib_buffer_t *b, ip4_header_t *ip0, ip4_local_last_check_t *last_check, u8 *error0)
#define IP4_MCAST_ADDR_MASK
This bits of an IPv4 address to mask to construct a multicast MAC address.
static clib_error_t * set_ip_flow_hash_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t * unformat_edit
#define vlib_prefetch_buffer_data(b, type)
void ip_lookup_init(ip_lookup_main_t *lm, u32 is_ip6)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
vlib_combined_counter_main_t lbm_via_counters
static clib_error_t * set_ip_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_main_t vlib_node_runtime_t * node
clib_error_t * ip_interface_address_del(ip_lookup_main_t *lm, vnet_main_t *vnm, u32 address_index, void *addr_fib, u32 address_length, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * ip4_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
struct _vnet_classify_main vnet_classify_main_t
#define foreach_flow_hash_bit
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
vlib_packet_template_t ip4_arp_request_packet_template
Template used to generate IP4 ARP packets.
static clib_error_t * ip4_mtrie_module_init(vlib_main_t *vm)
vlib_node_registration_t ip4_load_balance_node
(constructor) VLIB_REGISTER_NODE (ip4_load_balance_node)
index_t lb_urpf
This is the index of the uRPF list for this LB.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
manual_print typedef address
static ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step_one(const ip4_fib_mtrie_t *m, const ip4_address_t *dst_address)
Lookup step number 1.
u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
static load_balance_t * load_balance_get(index_t lbi)
static clib_error_t * fib_module_init(vlib_main_t *vm)
static void ip4_addr_fib_init(ip4_address_fib_t *addr_fib, const ip4_address_t *address, u32 fib_index)
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
u32 ia_cfg_index
feature [arc] config index
vlib_node_registration_t ip4_midchain_node
(constructor) VLIB_REGISTER_NODE (ip4_midchain_node)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vnet_classify_main_t vnet_classify_main
vlib_node_registration_t ip4_rewrite_mcast_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_mcast_node)
#define clib_mem_unaligned(pointer, type)
vlib_node_registration_t ip4_rewrite_bcast_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_bcast_node)
#define VNET_FEATURES(...)
static vlib_main_t * vlib_get_main(void)
static uword vnet_sw_interface_is_admin_up(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 void clib_memset_u16(void *p, u16 val, uword count)
#define vec_elt(v, i)
Get vector value at index i.
static_always_inline void ip4_ttl_and_checksum_check(vlib_buffer_t *b, ip4_header_t *ip, u16 *next, u32 *error)
u8 ucast_feature_arc_index
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
static_always_inline void ip4_ttl_inc(vlib_buffer_t *b, ip4_header_t *ip)
static void vnet_ip_mcast_fixup_header(u32 dst_mcast_mask, u32 dst_mcast_offset, u32 *addr, u8 *packet0)
index_t dpoi_index
the index of objects of that type
VNET_FEATURE_INIT(ip4_flow_classify, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
mhash_t prefix_to_if_prefix_index
Hash table mapping prefix to index in interface prefix pool.
ip_interface_prefix_key_t key
VLIB buffer representation.
static u8 ip4_local_classify(vlib_buffer_t *b, ip4_header_t *ip, u16 *next)
Determine packet type and next node.
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
The default route source.
u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
A collection of combined counters.
static void ip4_add_subnet_bcast_route(u32 fib_index, fib_prefix_t *pfx, u32 sw_if_index)
static clib_error_t * ip4_sw_interface_admin_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static uword ip4_rewrite_inline_with_gso(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_counters, int is_midchain, int is_mcast)
u8 packet_data[64 - 1 *sizeof(u32)]
static clib_error_t * mfib_module_init(vlib_main_t *vm)
static uword ip4_source_and_port_range_check_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static vnet_sw_interface_flags_t vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
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)
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
index_t ip4_fib_table_lookup_lb(ip4_fib_t *fib, const ip4_address_t *addr)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define IP4_HEADER_FLAG_DONT_FRAGMENT
u16 flags
Copy of main node flags.
u16 dpoi_next_node
The next VLIB node to follow.
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ip4_sw_interface_add_del)
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void vnet_calc_checksums_inline(vlib_main_t *vm, vlib_buffer_t *b, int is_ip4, int is_ip6, int with_gso)
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
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define vnet_rewrite_two_headers(rw0, rw1, p0, p1, most_likely_size)
#define CLIB_CACHE_LINE_BYTES
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(ip4_sw_interface_admin_up_down)
This adjacency/interface has output features configured.
vnet_feature_arc_registration_t vnet_feat_arc_ip4_local
ip_interface_prefix_t * if_prefix_pool
Pool of prefixes containing addresses assigned to interfaces.
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword ip4_source_and_port_range_check_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u16 ip4_header_checksum(ip4_header_t *i)
const ip46_address_t ADJ_BCAST_ADDR
The special broadcast address (to construct a broadcast adjacency.
static int adj_are_counters_enabled(void)
Get the global configuration option for enabling per-adj counters.
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
vlib_node_registration_t ip4_local_end_of_arc_node
(constructor) VLIB_REGISTER_NODE (ip4_local_end_of_arc_node)
static_always_inline void vnet_feature_arc_start(u8 arc, u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)