52 u32 disable_default_route)
56 uword * p, * hash, key;
57 i32 i, i_min, dst_address, ai;
59 i_min = disable_default_route ? 1 : 0;
101 uword * p, fib_index;
103 fib_index = table_index_or_id;
106 if (table_index_or_id == ~0) {
107 table_index_or_id = 0;
152 u32 dst_address_length,
170 hash = _hash_set3 (hash, dst_address_u32,
187 &d, dst_address_length,
191 p =
hash_get (hash, dst_address_u32);
200 u32 dst_address, dst_address_length, adj_index, old_adj_index;
201 uword * hash, is_del;
218 dst_address &= im->
fib_masks[dst_address_length];
253 if (old_adj_index == adj_index
263 is_del ? old_adj_index : adj_index,
268 && old_adj_index != ~0
269 && old_adj_index != adj_index)
277 u32 dst_address_length,
279 u32 next_hop_sw_if_index,
280 u32 next_hop_weight,
u32 adj_index,
281 u32 explicit_fib_index)
287 u32 dst_address_u32, old_mp_adj_index, new_mp_adj_index;
288 u32 dst_adj_index, nh_adj_index;
289 uword * dst_hash, * dst_result;
290 uword * nh_hash, * nh_result;
294 int is_interface_next_hop;
297 if (explicit_fib_index == (
u32)~0)
300 fib_index = explicit_fib_index;
305 is_interface_next_hop = next_hop->
data_u32 == 0;
306 if (adj_index == (
u32)~0)
308 if (is_interface_next_hop)
312 nh_adj_index = *nh_result;
339 adj->
arp.next_hop.ip4.as_u32 == 0)
347 memset (&add_adj, 0,
sizeof(add_adj));
356 nh_adj_index = *nh_result;
361 nh_adj_index = adj_index;
367 dst_result =
hash_get (dst_hash, dst_address_u32);
370 dst_adj_index = dst_result[0];
378 vnm->
api_errno = VNET_API_ERROR_UNKNOWN_DESTINATION;
391 && dst_address_length == 32
393 && adj_index != (
u32)~0)
395 vnm->
api_errno = VNET_API_ERROR_PREFIX_MATCHES_NEXT_HOP;
404 if (dst_adj_index == ~0 && next_hop_weight == 1 && next_hop_sw_if_index == ~0)
425 old_mp_adj_index = dst_adj ? dst_adj->
heap_handle : ~0;
434 vnm->
api_errno = VNET_API_ERROR_NEXT_HOP_NOT_FOUND_MP;
435 error =
clib_error_return (0,
"requested deleting next-hop %U not found in multi-path",
441 if (old_mp_adj_index != ~0)
443 if (new_mp_adj_index != ~0)
446 if (old_mp != new_mp)
470 u32 table_index_or_table_id,
476 u32 dst_address = * (
u32 *) address;
480 dst_address &= im->
fib_masks[address_length];
489 u32 table_index_or_table_id,
494 u8 ** result_lengths)
498 u32 this_length = address_length;
501 _vec_len (*results) = 0;
503 _vec_len (*result_lengths) = 0;
505 while (this_length <= 32 &&
vec_len (results) == 0)
509 if (0 == ((k ^ dst_address) & im->fib_masks[address_length]))
513 vec_add1 (*results, a);
514 vec_add1 (*result_lengths, this_length);
523 u32 table_index_or_table_id,
536 for (l = 0; l <= 32; l++)
545 _vec_len (to_delete) = 0;
579 for (i = 0; i <
vec_len (to_delete); i++)
581 hash = _hash_unset (hash, to_delete[i].data_u32, fib->
old_hash_values);
603 u32 table_index_or_table_id,
609 static u8 * matching_address_lengths;
619 for (l = address_length + 1; l <= 32; l++)
625 &matching_address_lengths);
626 for (i = 0; i <
vec_len (matching_addresses); i++)
647 int lookup_for_responses_to_locally_received_packets,
653 u32 n_left_from, n_left_to_next, * from, * to_next;
661 while (n_left_from > 0)
664 to_next, n_left_to_next);
666 while (n_left_from >= 4 && n_left_to_next >= 2)
676 __attribute__((unused))
u32 pi0, fib_index0, adj_index0, is_tcp_udp0;
677 __attribute__((unused))
u32 pi1, fib_index1, adj_index1, is_tcp_udp1;
678 u32 flow_hash_config0, flow_hash_config1;
679 u32 hash_c0, hash_c1;
696 pi0 = to_next[0] = from[0];
697 pi1 = to_next[1] = from[1];
710 dst_addr0 = &iadj0->
indirect.next_hop.ip4;
711 dst_addr1 = &iadj1->
indirect.next_hop.ip4;
727 if (! lookup_for_responses_to_locally_received_packets)
738 tcp0 = (
void *) (ip0 + 1);
739 tcp1 = (
void *) (ip1 + 1);
741 is_tcp_udp0 = (ip0->
protocol == IP_PROTOCOL_TCP
742 || ip0->
protocol == IP_PROTOCOL_UDP);
743 is_tcp_udp1 = (ip1->
protocol == IP_PROTOCOL_TCP
744 || ip1->
protocol == IP_PROTOCOL_UDP);
746 if (! lookup_for_responses_to_locally_received_packets)
752 if (! lookup_for_responses_to_locally_received_packets)
758 if (! lookup_for_responses_to_locally_received_packets)
764 if (lookup_for_responses_to_locally_received_packets)
813 adj_index0 += (hash_c0 & (adj0->
n_adj - 1));
814 adj_index1 += (hash_c1 & (adj1->
n_adj - 1));
820 (cm, cpu_index, adj_index0, 1,
824 (cm, cpu_index, adj_index1, 1,
833 wrong_next = (next0 != next) + 2*(next1 != next);
870 while (n_left_from > 0 && n_left_to_next > 0)
880 __attribute__((unused))
u32 pi0, fib_index0, adj_index0, is_tcp_udp0;
881 u32 flow_hash_config0, hash_c0;
894 dst_addr0 = &iadj0->
indirect.next_hop.ip4;
905 if (! lookup_for_responses_to_locally_received_packets)
914 tcp0 = (
void *) (ip0 + 1);
916 is_tcp_udp0 = (ip0->
protocol == IP_PROTOCOL_TCP
917 || ip0->
protocol == IP_PROTOCOL_UDP);
919 if (! lookup_for_responses_to_locally_received_packets)
922 if (! lookup_for_responses_to_locally_received_packets)
925 if (! lookup_for_responses_to_locally_received_packets)
928 if (lookup_for_responses_to_locally_received_packets)
958 adj_index0 += (hash_c0 & (adj0->
n_adj - 1));
963 (cm, cpu_index, adj_index0, 1,
978 to_next, n_left_to_next);
1008 u32 if_address_index)
1029 adj->
arp.next_hop.ip4.as_u32 = 0;
1031 packet_type = VNET_L3_PACKET_TYPE_ARP;
1037 packet_type = VNET_L3_PACKET_TYPE_IP4;
1047 &adj->rewrite_header,
1048 sizeof (adj->rewrite_data));
1062 u32 classify_table_index;
1089 classify_table_index = ~0;
1092 if (classify_table_index != (
u32) ~0)
1095 adj->
classify.table_index = classify_table_index;
1101 adj->rewrite_header.sw_if_index = sw_if_index;
1107 adj->rewrite_header.data_bytes = 0;
1130 if (address_length < 32)
1171 u32 if_address_index, elts_before;
1186 ip4_address_t * x = ip_interface_address_get_address (&im->lookup_main, ia);
1188 if (ip4_destination_matches_route (im, address, x, ia->address_length)
1189 || ip4_destination_matches_route (im, x, address, address_length))
1190 return clib_error_create (
"failed to add %U which conflicts with %U for interface %U",
1191 format_ip4_address_and_length, address, address_length,
1192 format_ip4_address_and_length, x, ia->address_length,
1193 format_vnet_sw_if_index_name, vnm, sw_if_index);
1228 address, address_length,
1244 (vm, sw_if_index, address, address_length,
1258 u32 is_admin_up, fib_index;
1272 a = ip_interface_address_get_address (&im->lookup_main, ia);
1274 ip4_add_interface_routes (sw_if_index,
1278 ip4_del_interface_routes (im, fib_index,
1279 a, ia->address_length);
1306 static char * start_nodes[] = {
"ip4-input",
"ip4-input-no-checksum", };
1307 static char * feature_nodes[] = {
1318 feature_nodes,
ARRAY_LEN (feature_nodes));
1322 static char * start_nodes[] = {
"ip4-input",
"ip4-input-no-checksum", };
1323 static char * feature_nodes[] = {
1330 feature_nodes,
ARRAY_LEN (feature_nodes));
1362 .name =
"ip4-lookup",
1363 .vector_size =
sizeof (
u32),
1383 .name =
"ip4-indirect",
1384 .vector_size =
sizeof (
u32),
1427 memset (&h, 0,
sizeof (h));
1432 #define _16(f,v) h.f = clib_host_to_net_u16 (v); 1433 #define _8(f,v) h.f = v; 1434 _16 (l2_type, ETHERNET_ARP_HARDWARE_TYPE_ethernet);
1435 _16 (l3_type, ETHERNET_TYPE_IP4);
1436 _8 (n_l2_address_bytes, 6);
1437 _8 (n_l3_address_bytes, 4);
1438 _16 (opcode, ETHERNET_ARP_OPCODE_request);
1486 s =
format (s,
"fib %d adj-idx %d : %U flow hash: 0x%08x",
1504 s =
format (s,
"tx_sw_if_index %d adj-idx %d : %U flow hash: 0x%08x",
1647 .vector_size =
sizeof (
u32),
1660 .vector_size =
sizeof (
u32),
1673 .vector_size =
sizeof (
u32),
1689 u32 ip_header_length, payload_length_host_byte_order;
1690 u32 n_this_buffer, n_bytes_left;
1692 void * data_this_buffer;
1696 payload_length_host_byte_order = clib_net_to_host_u16 (ip0->
length) - ip_header_length;
1697 sum0 = clib_host_to_net_u32 (payload_length_host_byte_order + (ip0->
protocol << 16));
1707 n_bytes_left = n_this_buffer = payload_length_host_byte_order;
1708 data_this_buffer = (
void *) ip0 + ip_header_length;
1714 n_bytes_left -= n_this_buffer;
1715 if (n_bytes_left == 0)
1737 || ip0->
protocol == IP_PROTOCOL_UDP);
1739 udp0 = (
void *) (ip0 + 1);
1763 u32 * from, * to_next, n_left_from, n_left_to_next;
1773 while (n_left_from > 0)
1777 while (n_left_from >= 4 && n_left_to_next >= 2)
1785 u32 pi0, ip_len0, udp_len0, flags0, next0, fib_index0, adj_index0;
1786 u32 pi1, ip_len1, udp_len1, flags1, next1, fib_index1, adj_index1;
1787 i32 len_diff0, len_diff1;
1788 u8 error0, is_udp0, is_tcp_udp0, good_tcp_udp0, proto0;
1789 u8 error1, is_udp1, is_tcp_udp1, good_tcp_udp1, proto1;
1792 pi0 = to_next[0] = from[0];
1793 pi1 = to_next[1] = from[1];
1797 n_left_to_next -= 2;
1822 is_udp0 = proto0 == IP_PROTOCOL_UDP;
1823 is_udp1 = proto1 == IP_PROTOCOL_UDP;
1824 is_tcp_udp0 = is_udp0 || proto0 == IP_PROTOCOL_TCP;
1825 is_tcp_udp1 = is_udp1 || proto1 == IP_PROTOCOL_TCP;
1837 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1838 good_tcp_udp1 |= is_udp1 && udp1->
checksum == 0;
1844 ip_len0 = clib_net_to_host_u16 (ip0->
length);
1845 ip_len1 = clib_net_to_host_u16 (ip1->
length);
1846 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1847 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1849 len_diff0 = ip_len0 - udp_len0;
1850 len_diff1 = ip_len1 - udp_len1;
1852 len_diff0 = is_udp0 ? len_diff0 : 0;
1853 len_diff1 = is_udp1 ? len_diff1 : 0;
1856 & good_tcp_udp0 & good_tcp_udp1)))
1865 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1874 good_tcp_udp1 |= is_udp1 && udp1->
checksum == 0;
1878 good_tcp_udp0 &= len_diff0 >= 0;
1879 good_tcp_udp1 &= len_diff1 >= 0;
1884 error0 = error1 = IP4_ERROR_UNKNOWN_PROTOCOL;
1886 error0 = len_diff0 < 0 ? IP4_ERROR_UDP_LENGTH : error0;
1887 error1 = len_diff1 < 0 ? IP4_ERROR_UDP_LENGTH : error1;
1889 ASSERT (IP4_ERROR_TCP_CHECKSUM + 1 == IP4_ERROR_UDP_CHECKSUM);
1890 error0 = (is_tcp_udp0 && ! good_tcp_udp0
1891 ? IP4_ERROR_TCP_CHECKSUM + is_udp0
1893 error1 = (is_tcp_udp1 && ! good_tcp_udp1
1894 ? IP4_ERROR_TCP_CHECKSUM + is_udp1
1920 error0 = (error0 == IP4_ERROR_UNKNOWN_PROTOCOL
1925 ? IP4_ERROR_SRC_LOOKUP_MISS
1927 error1 = (error1 == IP4_ERROR_UNKNOWN_PROTOCOL
1932 ? IP4_ERROR_SRC_LOOKUP_MISS
1941 p0->
error = error0 ? error_node->
errors[error0] : 0;
1942 p1->
error = error1 ? error_node->
errors[error1] : 0;
1944 enqueue_code = (next0 != next_index) + 2*(next1 != next_index);
1948 switch (enqueue_code)
1954 n_left_to_next += 1;
1961 n_left_to_next += 1;
1968 n_left_to_next += 2;
1982 while (n_left_from > 0 && n_left_to_next > 0)
1990 u32 pi0, next0, ip_len0, udp_len0, flags0, fib_index0, adj_index0;
1992 u8 error0, is_udp0, is_tcp_udp0, good_tcp_udp0, proto0;
1994 pi0 = to_next[0] = from[0];
1998 n_left_to_next -= 1;
2016 is_udp0 = proto0 == IP_PROTOCOL_UDP;
2017 is_tcp_udp0 = is_udp0 || proto0 == IP_PROTOCOL_TCP;
2026 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
2031 ip_len0 = clib_net_to_host_u16 (ip0->
length);
2032 udp_len0 = clib_net_to_host_u16 (udp0->
length);
2034 len_diff0 = ip_len0 - udp_len0;
2036 len_diff0 = is_udp0 ? len_diff0 : 0;
2047 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
2051 good_tcp_udp0 &= len_diff0 >= 0;
2055 error0 = IP4_ERROR_UNKNOWN_PROTOCOL;
2057 error0 = len_diff0 < 0 ? IP4_ERROR_UDP_LENGTH : error0;
2059 ASSERT (IP4_ERROR_TCP_CHECKSUM + 1 == IP4_ERROR_UDP_CHECKSUM);
2060 error0 = (is_tcp_udp0 && ! good_tcp_udp0
2061 ? IP4_ERROR_TCP_CHECKSUM + is_udp0
2076 error0 = (error0 == IP4_ERROR_UNKNOWN_PROTOCOL
2081 ? IP4_ERROR_SRC_LOOKUP_MISS
2088 p0->
error = error0? error_node->
errors[error0] : 0;
2092 n_left_to_next += 1;
2099 n_left_to_next -= 1;
2111 .name =
"ip4-local",
2112 .vector_size =
sizeof (
u32),
2156 .path =
"show ip local",
2158 .short_help =
"Show ip local protocol table",
2169 u32 * from, * to_next_drop;
2170 uword n_left_from, n_left_to_next_drop, next_index;
2171 static f64 time_last_seed_change = -1e100;
2172 static u32 hash_seeds[3];
2180 if (time_now - time_last_seed_change > 1e-3)
2184 sizeof (hash_seeds));
2185 for (i = 0; i <
ARRAY_LEN (hash_seeds); i++)
2186 hash_seeds[i] = r[i];
2189 for (i = 0; i <
ARRAY_LEN (hash_bitmap); i++)
2192 time_last_seed_change = time_now;
2201 while (n_left_from > 0)
2204 to_next_drop, n_left_to_next_drop);
2206 while (n_left_from > 0 && n_left_to_next_drop > 0)
2211 u32 pi0, adj_index0, a0, b0, c0, m0, sw_if_index0, drop0;
2224 if (adj0->
arp.next_hop.ip4.as_u32)
2238 while ((*etype == clib_host_to_net_u16 (0x8100))
2239 || (*etype == clib_host_to_net_u16 (0x88a8)))
2244 if (*etype == clib_host_to_net_u16 (0x0806))
2256 sw_if_index0 = adj0->rewrite_header.sw_if_index;
2264 c0 &=
BITS (hash_bitmap) - 1;
2268 bm0 = hash_bitmap[c0];
2269 drop0 = (bm0 & m0) != 0;
2272 hash_bitmap[c0] = bm0 | m0;
2276 to_next_drop[0] = pi0;
2278 n_left_to_next_drop -= 1;
2344 .vector_size =
sizeof (
u32),
2357 #define foreach_notrace_ip4_arp_error \ 2370 vnet_pcap_drop_trace_filter_add_del \ 2371 (rt->errors[IP4_ARP_ERROR_##a], \ 2409 vnm->
api_errno = VNET_API_ERROR_NO_MATCHING_INTERFACE;
2411 (0,
"no matching interface address for destination %U (interface %U)",
2454 int rewrite_for_locally_received_packets)
2458 u32 n_left_from, n_left_to_next, * to_next, next_index;
2466 while (n_left_from > 0)
2470 while (n_left_from >= 4 && n_left_to_next >= 2)
2475 u32 pi0, rw_len0, next0, error0, checksum0, adj_index0;
2476 u32 pi1, rw_len1, next1, error1, checksum1, adj_index1;
2477 u32 next0_override, next1_override;
2479 if (rewrite_for_locally_received_packets)
2480 next0_override = next1_override = 0;
2496 pi0 = to_next[0] = from[0];
2497 pi1 = to_next[1] = from[1];
2502 n_left_to_next -= 2;
2507 adj_index0 =
vnet_buffer (p0)->ip.adj_index[adj_rx_tx];
2508 adj_index1 =
vnet_buffer (p1)->ip.adj_index[adj_rx_tx];
2511 ASSERT(adj_index0 && adj_index1);
2516 error0 = error1 = IP4_ERROR_NONE;
2520 if (! rewrite_for_locally_received_packets)
2528 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
2529 checksum1 = ip1->
checksum + clib_host_to_net_u16 (0x0100);
2531 checksum0 += checksum0 >= 0xffff;
2532 checksum1 += checksum1 >= 0xffff;
2543 error0 = ttl0 <= 0 ? IP4_ERROR_TIME_EXPIRED : error0;
2544 error1 = ttl1 <= 0 ? IP4_ERROR_TIME_EXPIRED : error1;
2555 if (rewrite_for_locally_received_packets)
2565 error0 = IP4_ERROR_SPOOFED_LOCAL_PACKETS;
2571 error1 = IP4_ERROR_SPOOFED_LOCAL_PACKETS;
2578 rw_len0 = adj0[0].rewrite_header.data_bytes;
2579 rw_len1 = adj1[0].rewrite_header.data_bytes;
2580 next0 = (error0 == IP4_ERROR_NONE)
2581 ? adj0[0].rewrite_header.next_index : 0;
2583 if (rewrite_for_locally_received_packets)
2584 next0 = next0 && next0_override ? next0_override : next0;
2586 next1 = (error1 == IP4_ERROR_NONE)
2587 ? adj1[0].rewrite_header.next_index : 0;
2589 if (rewrite_for_locally_received_packets)
2590 next1 = next1 && next1_override ? next1_override : next1;
2598 cpu_index, adj_index0,
2605 cpu_index, adj_index1,
2611 ? IP4_ERROR_MTU_EXCEEDED
2614 ? IP4_ERROR_MTU_EXCEEDED
2635 to_next, n_left_to_next,
2636 pi0, pi1, next0, next1);
2639 while (n_left_from > 0 && n_left_to_next > 0)
2644 u32 pi0, rw_len0, adj_index0, next0, error0, checksum0;
2647 if (rewrite_for_locally_received_packets)
2650 pi0 = to_next[0] = from[0];
2654 adj_index0 =
vnet_buffer (p0)->ip.adj_index[adj_rx_tx];
2663 error0 = IP4_ERROR_NONE;
2667 if (! rewrite_for_locally_received_packets)
2671 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
2673 checksum0 += checksum0 >= 0xffff;
2685 error0 = ttl0 <= 0 ? IP4_ERROR_TIME_EXPIRED : error0;
2688 if (rewrite_for_locally_received_packets)
2698 error0 = IP4_ERROR_SPOOFED_LOCAL_PACKETS;
2713 rw_len0 = adj0[0].rewrite_header.data_bytes;
2718 cpu_index, adj_index0,
2724 > adj0[0].rewrite_header.max_l3_packet_bytes
2725 ? IP4_ERROR_MTU_EXCEEDED
2732 adj0[0].rewrite_header.sw_if_index;
2734 next0 = (error0 == IP4_ERROR_NONE)
2735 ? adj0[0].rewrite_header.next_index : 0;
2737 if (rewrite_for_locally_received_packets)
2738 next0 = next0 && next0_override ? next0_override : next0;
2743 n_left_to_next -= 1;
2746 to_next, n_left_to_next,
2780 .name =
"ip4-rewrite-transit",
2781 .vector_size =
sizeof (
u32),
2794 .name =
"ip4-rewrite-local",
2795 .vector_size =
sizeof (
u32),
2797 .sibling_of =
"ip4-rewrite-transit",
2815 u32 sw_if_index, table_id;
2826 if (
unformat (input,
"%d", &table_id))
2851 .path =
"set interface ip table",
2853 .short_help =
"Add/delete FIB table id for interface",
2865 u32 n_left_from, n_left_to_next, * from, * to_next;
2873 while (n_left_from > 0)
2876 to_next, n_left_to_next);
2878 while (n_left_from >= 4 && n_left_to_next >= 2)
2881 u32 pi0, pi1, adj_index0, adj_index1, wrong_next;
2885 u32 fib_index0, fib_index1;
2886 u32 flow_hash_config0, flow_hash_config1;
2902 pi0 = to_next[0] = from[0];
2903 pi1 = to_next[1] = from[1];
2936 (ip0, flow_hash_config0);
2939 (ip1, flow_hash_config1);
2953 (cm, cpu_index, adj_index0, 1,
2957 (cm, cpu_index, adj_index1, 1,
2962 n_left_to_next -= 2;
2965 wrong_next = (next0 != next) + 2*(next1 != next);
2974 n_left_to_next += 1;
2981 n_left_to_next += 1;
2988 n_left_to_next += 2;
3002 while (n_left_from > 0 && n_left_to_next > 0)
3006 u32 pi0, adj_index0;
3010 u32 flow_hash_config0;
3045 (cm, cpu_index, adj_index0, 1,
3050 n_left_to_next -= 1;
3055 n_left_to_next += 1;
3059 to_next, n_left_to_next);
3062 n_left_to_next -= 1;
3077 .name =
"ip4-lookup-multicast",
3078 .vector_size =
sizeof (
u32),
3088 .name =
"ip4-multicast",
3089 .vector_size =
sizeof (
u32),
3137 if (
unformat (input,
"table %d", &table_id))
3139 else if (
unformat (input,
"count %f", &count))
3152 for (i = 0; i < n; i++)
3157 ip4_base_address.
as_u32 =
3158 clib_host_to_net_u32 (1 +
3159 clib_net_to_host_u32 (ip4_base_address.
as_u32));
3171 .path =
"test lookup",
3172 .short_help =
"test lookup",
3183 return VNET_API_ERROR_NO_SUCH_FIB;
3198 u32 flow_hash_config = 0;
3202 if (
unformat (input,
"table %d", &table_id))
3205 else if (unformat (input, #a)) { flow_hash_config |= v; matched=1;} 3221 case VNET_API_ERROR_NO_SUCH_FIB:
3225 clib_warning (
"BUG: illegal flow hash config 0x%x", flow_hash_config);
3233 .path =
"set ip flow-hash",
3235 "set ip table flow-hash table <fib-id> src dst sport dport proto reverse",
3249 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
3252 return VNET_API_ERROR_NO_SUCH_ENTRY;
3265 u32 table_index = ~0;
3266 int table_index_set = 0;
3267 u32 sw_if_index = ~0;
3271 if (
unformat (input,
"table-index %d", &table_index))
3272 table_index_set = 1;
3280 if (table_index_set == 0)
3283 if (sw_if_index == ~0)
3293 case VNET_API_ERROR_NO_MATCHING_INTERFACE:
3296 case VNET_API_ERROR_NO_SUCH_ENTRY:
3303 .path =
"set ip classify",
3305 "set ip classify intfc <int> table-index <index>",
vlib_node_registration_t ip4_miss_node
(constructor) VLIB_REGISTER_NODE (ip4_miss_node)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void ip4_fib_set_adj_index(ip4_main_t *im, ip4_fib_t *fib, u32 flags, u32 dst_address_u32, u32 dst_address_length, u32 adj_index)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
#define vec_zero(var)
Zero all vector elements.
always_inline ip4_address_t * ip4_interface_address_matching_destination(ip4_main_t *im, ip4_address_t *dst, u32 sw_if_index, ip_interface_address_t **result_ia)
always_inline void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
static uword ip4_rewrite_local(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline uword round_pow2(uword x, uword pow2)
always_inline ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t current_leaf, ip4_address_t *dst_address, u32 dst_address_byte_index)
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)
#define VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
uword vlib_error_drop_buffers(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u32 next_buffer_stride, u32 n_buffers, u32 next_index, u32 drop_error_node, u32 drop_error_code)
vlib_node_registration_t ip4_drop_node
(constructor) VLIB_REGISTER_NODE (ip4_drop_node)
u32 * config_index_by_sw_if_index
int vnet_set_ip4_flow_hash(u32 table_id, u32 flow_hash_config)
void vnet_config_init(vlib_main_t *vm, vnet_config_main_t *cm, char *start_node_names[], int n_start_node_names, char *feature_node_names[], int n_feature_node_names)
static uword ip4_drop(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
ip4_add_del_interface_address_callback_t * add_del_interface_address_callbacks
always_inline pg_node_t * pg_get_node(uword node_index)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
uword * interface_route_adj_index_by_sw_if_index
ip_interface_address_t * if_address_pool
vnet_interface_main_t interface_main
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
ip_lookup_next_t lookup_next_index
always_inline u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *a)
ip4_fib_t * find_ip4_fib_by_table_index_or_id(ip4_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv4 fib.
always_inline hash_t * hash_header(void *v)
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
vlib_node_registration_t ip4_indirect_node
(constructor) VLIB_REGISTER_NODE (ip4_indirect_node)
ip_config_main_t rx_config_mains[VNET_N_CAST]
#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)
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *copy_adj, u32 n_adj, u32 *adj_index_return)
always_inline uword ip4_lookup_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int lookup_for_responses_to_locally_received_packets, int is_indirect)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
ip_lookup_main_t lookup_main
void ip4_foreach_matching_route(ip4_main_t *im, u32 table_index_or_table_id, u32 flags, ip4_address_t *address, u32 address_length, ip4_address_t **results, u8 **result_lengths)
u32 * fib_index_by_sw_if_index
always_inline int ip4_is_fragment(ip4_header_t *i)
unformat_function_t unformat_vnet_sw_interface
#define clib_error_report(e)
static u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
#define vec_bytes(v)
Number of data bytes in vector.
static uword ip4_arp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 neighbor_probe_adj_index
format_function_t format_vnet_sw_if_index_name
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
always_inline vlib_main_t * vlib_get_main(void)
u32 * node_index_by_feature_index
void * ip4_get_route(ip4_main_t *im, u32 table_index_or_table_id, u32 flags, u8 *address, u32 address_length)
always_inline u32 ip4_fib_lookup_buffer(ip4_main_t *im, u32 fib_index, ip4_address_t *dst, vlib_buffer_t *b)
#define IP4_FIB_MTRIE_LEAF_EMPTY
always_inline void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
u32 fwd_classify_table_index
vnet_main_t * vnet_get_main(void)
static void ip4_fib_init_adj_index_by_dst_address(ip_lookup_main_t *lm, ip4_fib_t *fib, u32 address_length)
static clib_error_t * show_ip_local_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
void ip4_adjacency_set_interface_route(vnet_main_t *vnm, ip_adjacency_t *adj, u32 sw_if_index, u32 if_address_index)
void ip4_add_del_route_next_hop(ip4_main_t *im, u32 flags, ip4_address_t *dst_address, u32 dst_address_length, ip4_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_weight, u32 adj_index, u32 explicit_fib_index)
#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...
static ip4_fib_t * create_fib_with_table_id(ip4_main_t *im, u32 table_id)
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
#define VLIB_INIT_FUNCTION(x)
static u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
static void ip4_add_interface_routes(u32 sw_if_index, ip4_main_t *im, u32 fib_index, ip_interface_address_t *a)
#define IP_BUFFER_L4_CHECKSUM_CORRECT
always_inline void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
u32 * adjacency_remap_table
u32 vnet_arp_glean_add(u32 fib_index, void *next_hop_arg)
#define hash_foreach(key_var, value_var, h, body)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void ip4_fib_mtrie_add_del_route(ip4_fib_t *fib, ip4_address_t dst_address, u32 dst_address_length, u32 adj_index, u32 is_del)
u32 ip_multipath_adjacency_add_del_next_hop(ip_lookup_main_t *lm, u32 is_del, u32 old_mp_adj_index, u32 next_hop_adj_index, u32 next_hop_weight, u32 *new_mp_adj_index)
always_inline uword pool_elts(void *v)
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define IP4_LOOKUP_NEXT_NODES
#define clib_warning(format, args...)
vlib_node_registration_t ip4_arp_node
(constructor) VLIB_REGISTER_NODE (ip4_arp_node)
static uword ip4_indirect(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline int ip4_header_bytes(ip4_header_t *i)
u32 rev_classify_table_index
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
void ip_del_adjacency(ip_lookup_main_t *lm, u32 adj_index)
#define foreach_notrace_ip4_arp_error
#define VLIB_BUFFER_NEXT_PRESENT
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
always_inline void vlib_buffer_copy_trace_flag(vlib_main_t *vm, vlib_buffer_t *b, u32 bi_target)
always_inline u16 ip_csum_fold(ip_csum_t c)
vnet_api_error_t api_errno
#define pool_elt_at_index(p, i)
uword * fib_index_by_table_id
vlib_node_registration_t ip4_input_node
(constructor) VLIB_REGISTER_NODE (ip4_input_node)
u16 current_length
Nbytes between current data and the end of this buffer.
u32 * classify_table_index_by_sw_if_index
vlib_node_registration_t ip4_local_node
(constructor) VLIB_REGISTER_NODE (ip4_local_node)
clib_error_t * arp_notrace_init(vlib_main_t *vm)
static uword ip4_rewrite_transit(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void ip4_register_protocol(u32 protocol, u32 node_index)
uword os_get_cpu_number(void)
static uword ip4_punt(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
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)
u8 local_next_by_ip_protocol[256]
vnet_hw_interface_class_t srp_hw_interface_class
always_inline void hash_set_flags(void *v, uword flags)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
always_inline void ip4_src_address_for_packet(ip4_main_t *im, vlib_buffer_t *p, ip4_address_t *src, u32 sw_if_index)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
vlib_node_registration_t ip4_punt_node
(constructor) VLIB_REGISTER_NODE (ip4_punt_node)
always_inline u16 ip4_header_checksum(ip4_header_t *i)
vnet_hw_interface_class_t ethernet_hw_interface_class
static u8 * format_ip4_lookup_trace(u8 *s, va_list *args)
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
static uword ip4_miss(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u8 * format_ip4_rewrite_trace(u8 *s, va_list *args)
void ip4_mtrie_init(ip4_fib_mtrie_t *m)
#define CLIB_PREFETCH(addr, size, type)
void ip4_maybe_remap_adjacencies(ip4_main_t *im, u32 table_index_or_table_id, u32 flags)
#define vec_free(V)
Free vector's memory (no header).
void vnet_rewrite_for_sw_interface(vnet_main_t *vnm, vnet_l3_packet_type_t packet_type, u32 sw_if_index, u32 node_index, void *dst_address, vnet_rewrite_header_t *rw, u32 max_rewrite_bytes)
ip4_add_del_interface_address_function_t * function
static clib_error_t * add_del_interface_table(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_memcpy(a, b, c)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
int ip4_lookup_validate(ip4_address_t *a, u32 fib_index0)
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
vlib_node_registration_t ip4_multicast_node
(constructor) VLIB_REGISTER_NODE (ip4_multicast_node)
u8 packet_data[64-1 *sizeof(u32)]
void ip4_delete_matching_routes(ip4_main_t *im, u32 table_index_or_table_id, u32 flags, ip4_address_t *address, u32 address_length)
void ip_lookup_init(ip_lookup_main_t *lm, u32 is_ip6)
#define pool_is_free_index(P, I)
always_inline uword vnet_sw_interface_is_admin_up(vnet_main_t *vnm, u32 sw_if_index)
#define IP4_ROUTE_FLAG_DEL
static clib_error_t * set_ip_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
always_inline uword hash_elts(void *v)
vlib_combined_counter_main_t adjacency_counters
static clib_error_t * ip4_add_del_interface_address_internal(vlib_main_t *vm, u32 sw_if_index, ip4_address_t *new_address, u32 new_length, u32 redistribute, u32 insert_routes, u32 is_del)
#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
u32 * if_address_pool_index_by_sw_if_index
vlib_packet_template_t ip4_arp_request_packet_template
always_inline uword is_pow2(uword x)
#define hash_create(elts, value_bytes)
always_inline uword ip4_rewrite_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int rewrite_for_locally_received_packets)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
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_physmem_alloc, char *fmt,...)
#define IP4_FIB_MTRIE_LEAF_ROOT
ip4_address_t dst_address
#define IP4_ROUTE_FLAG_ADD
#define LOG2_IP_BUFFER_L4_CHECKSUM_CORRECT
#define hash_v3_finalize32(a, b, c)
u32 next_buffer
Next buffer for this linked-list of buffers.
#define VLIB_NODE_FLAG_TRACE
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
vnet_classify_main_t vnet_classify_main
#define IP_FLOW_HASH_DEFAULT
always_inline void ip4_addr_fib_init(ip4_address_fib_t *addr_fib, ip4_address_t *address, u32 fib_index)
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define VLIB_BUFFER_IS_TRACED
vlib_node_registration_t ip4_rewrite_local_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_local_node)
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
always_inline ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
u32 ip4_fib_lookup_with_table(ip4_main_t *im, u32 fib_index, ip4_address_t *dst, u32 disable_default_route)
static uword ip4_local(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_elt(v, i)
Get vector value at index i.
#define ip46_address_reset(ip46)
#define IP_BUFFER_L4_CHECKSUM_COMPUTED
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
struct ip_adjacency_t::@112::@114 arp
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define hash_foreach_pair(p, v, body)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
always_inline u32 ip4_compute_flow_hash(ip4_header_t *ip, u32 flow_hash_config)
#define IP4_ROUTE_FLAG_FIB_INDEX
vnet_sw_interface_t * sw_interfaces
struct ip_adjacency_t::@112::@115 classify
always_inline void vlib_set_next_frame_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 buffer_index)
always_inline uword hash_value_bytes(hash_t *h)
u32 table_index_or_table_id
clib_error_t * ip_interface_address_add_del(ip_lookup_main_t *lm, u32 sw_if_index, void *addr_fib, u32 address_length, u32 is_del, u32 *result_if_address_index)
always_inline void * ip4_next_header(ip4_header_t *i)
static clib_error_t * ip4_sw_interface_admin_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY
struct ip_adjacency_t::@112::@116 indirect
#define clib_mem_unaligned(pointer, type)
#define IP4_ROUTE_FLAG_NOT_LAST_IN_GROUP
static void ip4_del_interface_routes(ip4_main_t *im, u32 fib_index, ip4_address_t *address, u32 address_length)
static uword ip4_lookup_multicast(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
ip_multipath_adjacency_t * multipath_adjacencies
#define VLIB_REGISTER_NODE(x,...)
#define IP4_ROUTE_FLAG_TABLE_ID
always_inline vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
always_inline void ip_call_add_del_adjacency_callbacks(ip_lookup_main_t *lm, u32 adj_index, u32 is_del)
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
ip4_add_del_route_callback_t * add_del_route_callbacks
#define vec_foreach(var, vec)
Vector iterator.
static uword ip4_drop_or_punt(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, ip4_error_t error_code)
always_inline f64 vlib_time_now(vlib_main_t *vm)
uword * adj_index_by_dst_address[33]
#define clib_error_return(e, args...)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ip4_sw_interface_add_del)
always_inline uword pow2_mask(uword x)
static uword ip4_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#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)
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(ip4_sw_interface_admin_up_down)
void ip4_mtrie_maybe_remap_adjacencies(ip_lookup_main_t *lm, ip4_fib_mtrie_t *m)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
#define HASH_FLAG_NO_AUTO_SHRINK
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vlib_node_registration_t ip4_lookup_multicast_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_multicast_node)
ip4_add_del_route_function_t * function
clib_random_buffer_t random_buffer
vnet_config_main_t config_main
static char * ip4_arp_error_strings[]
#define IP4_ROUTE_FLAG_NO_REDISTRIBUTE
ip4_fib_mtrie_leaf_t default_leaf