71 int lookup_for_responses_to_locally_received_packets)
75 u32 n_left_from, n_left_to_next, * from, * to_next;
83 while (n_left_from > 0)
86 to_next, n_left_to_next);
88 while (n_left_from >= 8 && n_left_to_next >= 4)
92 __attribute__((unused))
tcp_header_t * tcp0, * tcp1, * tcp2, * tcp3;
97 ip4_address_t * dst_addr0, *dst_addr1, *dst_addr2, *dst_addr3;
98 __attribute__((unused))
u32 pi0, fib_index0, lb_index0, is_tcp_udp0;
99 __attribute__((unused))
u32 pi1, fib_index1, lb_index1, is_tcp_udp1;
100 __attribute__((unused))
u32 pi2, fib_index2, lb_index2, is_tcp_udp2;
101 __attribute__((unused))
u32 pi3, fib_index3, lb_index3, is_tcp_udp3;
104 u32 hash_c0, hash_c1, hash_c2, hash_c3;
105 const dpo_id_t *dpo0, *dpo1, *dpo2, *dpo3;
127 pi0 = to_next[0] = from[0];
128 pi1 = to_next[1] = from[1];
129 pi2 = to_next[2] = from[2];
130 pi3 = to_next[3] = from[3];
166 if (! lookup_for_responses_to_locally_received_packets)
181 tcp0 = (
void *) (ip0 + 1);
182 tcp1 = (
void *) (ip1 + 1);
183 tcp2 = (
void *) (ip2 + 1);
184 tcp3 = (
void *) (ip3 + 1);
186 is_tcp_udp0 = (ip0->
protocol == IP_PROTOCOL_TCP
187 || ip0->
protocol == IP_PROTOCOL_UDP);
188 is_tcp_udp1 = (ip1->
protocol == IP_PROTOCOL_TCP
189 || ip1->
protocol == IP_PROTOCOL_UDP);
190 is_tcp_udp2 = (ip2->
protocol == IP_PROTOCOL_TCP
191 || ip2->
protocol == IP_PROTOCOL_UDP);
192 is_tcp_udp3 = (ip1->
protocol == IP_PROTOCOL_TCP
193 || ip1->
protocol == IP_PROTOCOL_UDP);
195 if (! lookup_for_responses_to_locally_received_packets)
203 if (! lookup_for_responses_to_locally_received_packets)
211 if (! lookup_for_responses_to_locally_received_packets)
219 if (lookup_for_responses_to_locally_received_packets)
306 (cm, cpu_index, lb_index0, 1,
310 (cm, cpu_index, lb_index1, 1,
314 (cm, cpu_index, lb_index2, 1,
318 (cm, cpu_index, lb_index3, 1,
323 to_next, n_left_to_next,
325 next0, next1, next2, next3);
328 while (n_left_from > 0 && n_left_to_next > 0)
338 __attribute__((unused))
u32 pi0, fib_index0, is_tcp_udp0, lbi0;
356 if (! lookup_for_responses_to_locally_received_packets)
365 tcp0 = (
void *) (ip0 + 1);
367 is_tcp_udp0 = (ip0->
protocol == IP_PROTOCOL_TCP
368 || ip0->
protocol == IP_PROTOCOL_UDP);
370 if (! lookup_for_responses_to_locally_received_packets)
373 if (! lookup_for_responses_to_locally_received_packets)
376 if (! lookup_for_responses_to_locally_received_packets)
379 if (lookup_for_responses_to_locally_received_packets)
411 (cm, cpu_index, lbi0, 1,
425 to_next, n_left_to_next);
487 .name =
"ip4-lookup",
488 .vector_size =
sizeof (
u32),
503 u32 n_left_from, n_left_to_next, * from, * to_next;
514 while (n_left_from > 0)
517 to_next, n_left_to_next);
520 while (n_left_from > 0 && n_left_to_next > 0)
549 (cm, cpu_index, lbi0, 1,
563 to_next, n_left_to_next);
580 .name =
"ip4-load-balance",
581 .vector_size =
sizeof (
u32),
582 .sibling_of =
"ip4-lookup",
606 *result_ia = result ? ia : 0;
620 .fp_addr.ip4 = *address,
648 u32 classify_table_index =
650 if (classify_table_index != (
u32) ~0)
658 classify_table_index));
692 .fp_addr.ip4 = *address,
716 u32 lookup_feature_index;
751 lookup_feature_index,
757 lookup_feature_index,
775 u32 if_address_index, elts_before;
796 ip4_address_t * x = ip_interface_address_get_address (&im->lookup_main, ia);
798 if (ip4_destination_matches_route (im, address, x, ia->address_length)
799 || ip4_destination_matches_route (im, x, address, address_length))
800 return clib_error_create (
"failed to add %U which conflicts with %U for interface %U",
801 format_ip4_address_and_length, address, address_length,
802 format_ip4_address_and_length, x, ia->address_length,
803 format_vnet_sw_if_index_name, vnm, sw_if_index);
836 address, address_length,
852 (vm, sw_if_index, address, address_length,
858 .node_name =
"ip4-flow-classify",
864 .node_name =
"ip4-inacl",
870 .node_name =
"ip4-source-check-via-rx",
877 .node_name =
"ip4-source-check-via-any",
884 .node_name =
"ip4-source-and-port-range-check-rx",
891 .node_name =
"ip4-policer-classify",
898 .node_name =
"ipsec-input-ip4",
904 .node_name =
"vpath-input-ip4",
910 .node_name =
"ip4-lookup",
916 .node_name =
"ip4-drop",
924 .node_name =
"vpath-input-ip4",
930 .node_name =
"ip4-lookup-multicast",
936 .node_name =
"ip4-drop",
942 {
"ip4-input",
"ip4-input-no-checksum"};
946 "ip4-rewrite-transit",
952 .node_name =
"ip4-source-and-port-range-check-tx",
961 .node_name =
"interface-output",
975 int feature_start_len;
1094 memset (&h, 0,
sizeof (h));
1099 #define _16(f,v) h.f = clib_host_to_net_u16 (v); 1100 #define _8(f,v) h.f = v; 1101 _16 (l2_type, ETHERNET_ARP_HARDWARE_TYPE_ethernet);
1102 _16 (l3_type, ETHERNET_TYPE_IP4);
1103 _8 (n_l2_address_bytes, 6);
1104 _8 (n_l3_address_bytes, 4);
1105 _16 (opcode, ETHERNET_ARP_OPCODE_request);
1153 s =
format (s,
"fib %d dpo-idx %d flow hash: 0x%08x",
1169 s =
format (s,
"tx_sw_if_index %d dpo-idx %d : %U flow hash: 0x%08x",
1307 .vector_size =
sizeof (
u32),
1322 .vector_size =
sizeof (
u32),
1340 u32 ip_header_length, payload_length_host_byte_order;
1341 u32 n_this_buffer, n_bytes_left;
1343 void * data_this_buffer;
1347 payload_length_host_byte_order = clib_net_to_host_u16 (ip0->
length) - ip_header_length;
1348 sum0 = clib_host_to_net_u32 (payload_length_host_byte_order + (ip0->
protocol << 16));
1358 n_bytes_left = n_this_buffer = payload_length_host_byte_order;
1359 data_this_buffer = (
void *) ip0 + ip_header_length;
1365 n_bytes_left -= n_this_buffer;
1366 if (n_bytes_left == 0)
1388 || ip0->
protocol == IP_PROTOCOL_UDP);
1390 udp0 = (
void *) (ip0 + 1);
1414 u32 * from, * to_next, n_left_from, n_left_to_next;
1424 while (n_left_from > 0)
1428 while (n_left_from >= 4 && n_left_to_next >= 2)
1437 u32 pi0, ip_len0, udp_len0, flags0, next0, fib_index0, lbi0;
1438 u32 pi1, ip_len1, udp_len1, flags1, next1, fib_index1, lbi1;
1439 i32 len_diff0, len_diff1;
1440 u8 error0, is_udp0, is_tcp_udp0, good_tcp_udp0, proto0;
1441 u8 error1, is_udp1, is_tcp_udp1, good_tcp_udp1, proto1;
1444 pi0 = to_next[0] = from[0];
1445 pi1 = to_next[1] = from[1];
1449 n_left_to_next -= 2;
1474 is_udp0 = proto0 == IP_PROTOCOL_UDP;
1475 is_udp1 = proto1 == IP_PROTOCOL_UDP;
1476 is_tcp_udp0 = is_udp0 || proto0 == IP_PROTOCOL_TCP;
1477 is_tcp_udp1 = is_udp1 || proto1 == IP_PROTOCOL_TCP;
1489 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1490 good_tcp_udp1 |= is_udp1 && udp1->
checksum == 0;
1496 ip_len0 = clib_net_to_host_u16 (ip0->
length);
1497 ip_len1 = clib_net_to_host_u16 (ip1->
length);
1498 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1499 udp_len1 = clib_net_to_host_u16 (udp1->
length);
1501 len_diff0 = ip_len0 - udp_len0;
1502 len_diff1 = ip_len1 - udp_len1;
1504 len_diff0 = is_udp0 ? len_diff0 : 0;
1505 len_diff1 = is_udp1 ? len_diff1 : 0;
1508 & good_tcp_udp0 & good_tcp_udp1)))
1517 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1526 good_tcp_udp1 |= is_udp1 && udp1->
checksum == 0;
1530 good_tcp_udp0 &= len_diff0 >= 0;
1531 good_tcp_udp1 &= len_diff1 >= 0;
1536 error0 = error1 = IP4_ERROR_UNKNOWN_PROTOCOL;
1538 error0 = len_diff0 < 0 ? IP4_ERROR_UDP_LENGTH : error0;
1539 error1 = len_diff1 < 0 ? IP4_ERROR_UDP_LENGTH : error1;
1541 ASSERT (IP4_ERROR_TCP_CHECKSUM + 1 == IP4_ERROR_UDP_CHECKSUM);
1542 error0 = (is_tcp_udp0 && ! good_tcp_udp0
1543 ? IP4_ERROR_TCP_CHECKSUM + is_udp0
1545 error1 = (is_tcp_udp1 && ! good_tcp_udp1
1546 ? IP4_ERROR_TCP_CHECKSUM + is_udp1
1575 error0 = ((error0 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1577 IP4_ERROR_SPOOFED_LOCAL_PACKETS :
1579 error0 = ((error0 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1582 ? IP4_ERROR_SRC_LOOKUP_MISS
1584 error1 = ((error1 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1586 IP4_ERROR_SPOOFED_LOCAL_PACKETS :
1588 error1 = ((error1 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1591 ? IP4_ERROR_SRC_LOOKUP_MISS
1600 p0->
error = error0 ? error_node->
errors[error0] : 0;
1601 p1->
error = error1 ? error_node->
errors[error1] : 0;
1603 enqueue_code = (next0 != next_index) + 2*(next1 != next_index);
1607 switch (enqueue_code)
1613 n_left_to_next += 1;
1620 n_left_to_next += 1;
1627 n_left_to_next += 2;
1641 while (n_left_from > 0 && n_left_to_next > 0)
1648 u32 pi0, next0, ip_len0, udp_len0, flags0, fib_index0, lbi0;
1650 u8 error0, is_udp0, is_tcp_udp0, good_tcp_udp0, proto0;
1654 pi0 = to_next[0] = from[0];
1658 n_left_to_next -= 1;
1676 is_udp0 = proto0 == IP_PROTOCOL_UDP;
1677 is_tcp_udp0 = is_udp0 || proto0 == IP_PROTOCOL_TCP;
1686 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1691 ip_len0 = clib_net_to_host_u16 (ip0->
length);
1692 udp_len0 = clib_net_to_host_u16 (udp0->
length);
1694 len_diff0 = ip_len0 - udp_len0;
1696 len_diff0 = is_udp0 ? len_diff0 : 0;
1707 good_tcp_udp0 |= is_udp0 && udp0->
checksum == 0;
1711 good_tcp_udp0 &= len_diff0 >= 0;
1715 error0 = IP4_ERROR_UNKNOWN_PROTOCOL;
1717 error0 = len_diff0 < 0 ? IP4_ERROR_UDP_LENGTH : error0;
1719 ASSERT (IP4_ERROR_TCP_CHECKSUM + 1 == IP4_ERROR_UDP_CHECKSUM);
1720 error0 = (is_tcp_udp0 && ! good_tcp_udp0
1721 ? IP4_ERROR_TCP_CHECKSUM + is_udp0
1737 error0 = ((error0 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1739 IP4_ERROR_SPOOFED_LOCAL_PACKETS :
1741 error0 = ((error0 == IP4_ERROR_UNKNOWN_PROTOCOL &&
1744 ? IP4_ERROR_SRC_LOOKUP_MISS
1751 p0->
error = error0? error_node->
errors[error0] : 0;
1755 n_left_to_next += 1;
1762 n_left_to_next -= 1;
1774 .name =
"ip4-local",
1775 .vector_size =
sizeof (
u32),
1834 .path =
"show ip local",
1836 .short_help =
"show ip local",
1849 u32 * from, * to_next_drop;
1850 uword n_left_from, n_left_to_next_drop, next_index;
1851 static f64 time_last_seed_change = -1e100;
1852 static u32 hash_seeds[3];
1860 if (time_now - time_last_seed_change > 1e-3)
1864 sizeof (hash_seeds));
1865 for (i = 0; i <
ARRAY_LEN (hash_seeds); i++)
1866 hash_seeds[i] = r[i];
1869 for (i = 0; i <
ARRAY_LEN (hash_bitmap); i++)
1872 time_last_seed_change = time_now;
1881 while (n_left_from > 0)
1884 to_next_drop, n_left_to_next_drop);
1886 while (n_left_from > 0 && n_left_to_next_drop > 0)
1888 u32 pi0, adj_index0, a0, b0, c0, m0, sw_if_index0, drop0;
1906 sw_if_index0 = adj0->rewrite_header.sw_if_index;
1925 c0 &=
BITS (hash_bitmap) - 1;
1929 bm0 = hash_bitmap[c0];
1930 drop0 = (bm0 & m0) != 0;
1933 hash_bitmap[c0] = bm0 | m0;
1937 to_next_drop[0] = pi0;
1939 n_left_to_next_drop -= 1;
2052 .vector_size =
sizeof (
u32),
2067 .name =
"ip4-glean",
2068 .vector_size =
sizeof (
u32),
2081 #define foreach_notrace_ip4_arp_error \ 2094 vnet_pcap_drop_trace_filter_add_del \ 2095 (rt->errors[IP4_ARP_ERROR_##a], \ 2133 vnm->
api_errno = VNET_API_ERROR_NO_MATCHING_INTERFACE;
2135 (0,
"no matching interface address for destination %U (interface %U)",
2179 int rewrite_for_locally_received_packets,
2184 u32 n_left_from, n_left_to_next, * to_next, next_index;
2193 while (n_left_from > 0)
2197 while (n_left_from >= 4 && n_left_to_next >= 2)
2202 u32 pi0, rw_len0, next0, error0, checksum0, adj_index0;
2203 u32 pi1, rw_len1, next1, error1, checksum1, adj_index1;
2204 u32 next0_override, next1_override;
2205 u32 tx_sw_if_index0, tx_sw_if_index1;
2207 if (rewrite_for_locally_received_packets)
2208 next0_override = next1_override = 0;
2224 pi0 = to_next[0] = from[0];
2225 pi1 = to_next[1] = from[1];
2230 n_left_to_next -= 2;
2235 adj_index0 =
vnet_buffer (p0)->ip.adj_index[adj_rx_tx];
2236 adj_index1 =
vnet_buffer (p1)->ip.adj_index[adj_rx_tx];
2239 ASSERT(adj_index0 && adj_index1);
2244 error0 = error1 = IP4_ERROR_NONE;
2249 if (! rewrite_for_locally_received_packets)
2257 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
2258 checksum1 = ip1->
checksum + clib_host_to_net_u16 (0x0100);
2260 checksum0 += checksum0 >= 0xffff;
2261 checksum1 += checksum1 >= 0xffff;
2278 error0 = IP4_ERROR_TIME_EXPIRED;
2281 ICMP4_time_exceeded_ttl_exceeded_in_transit, 0);
2286 error1 = IP4_ERROR_TIME_EXPIRED;
2289 ICMP4_time_exceeded_ttl_exceeded_in_transit, 0);
2302 if (rewrite_for_locally_received_packets)
2313 rw_len0 = adj0[0].rewrite_header.data_bytes;
2314 rw_len1 = adj1[0].rewrite_header.data_bytes;
2315 vnet_buffer(p0)->ip.save_rewrite_length = rw_len0;
2316 vnet_buffer(p1)->ip.save_rewrite_length = rw_len1;
2320 ? IP4_ERROR_MTU_EXCEEDED
2323 ? IP4_ERROR_MTU_EXCEEDED
2326 next0 = (error0 == IP4_ERROR_NONE)
2327 ? adj0[0].rewrite_header.next_index : next0;
2329 if (rewrite_for_locally_received_packets)
2330 next0 = next0 && next0_override ? next0_override : next0;
2332 next1 = (error1 == IP4_ERROR_NONE)
2333 ? adj1[0].rewrite_header.next_index : next1;
2335 if (rewrite_for_locally_received_packets)
2336 next1 = next1 && next1_override ? next1_override : next1;
2344 cpu_index, adj_index0,
2351 cpu_index, adj_index1,
2361 tx_sw_if_index0 = adj0[0].rewrite_header.sw_if_index;
2383 tx_sw_if_index1 = adj1[0].rewrite_header.sw_if_index;
2413 to_next, n_left_to_next,
2414 pi0, pi1, next0, next1);
2417 while (n_left_from > 0 && n_left_to_next > 0)
2422 u32 pi0, rw_len0, adj_index0, next0, error0, checksum0;
2424 u32 tx_sw_if_index0;
2426 if (rewrite_for_locally_received_packets)
2429 pi0 = to_next[0] = from[0];
2433 adj_index0 =
vnet_buffer (p0)->ip.adj_index[adj_rx_tx];
2442 error0 = IP4_ERROR_NONE;
2446 if (! rewrite_for_locally_received_packets)
2450 checksum0 = ip0->
checksum + clib_host_to_net_u16 (0x0100);
2452 checksum0 += checksum0 >= 0xffff;
2470 error0 = IP4_ERROR_TIME_EXPIRED;
2474 ICMP4_time_exceeded_ttl_exceeded_in_transit, 0);
2478 if (rewrite_for_locally_received_packets)
2494 rw_len0 = adj0[0].rewrite_header.data_bytes;
2495 vnet_buffer(p0)->ip.save_rewrite_length = rw_len0;
2500 cpu_index, adj_index0,
2506 > adj0[0].rewrite_header.max_l3_packet_bytes
2507 ? IP4_ERROR_MTU_EXCEEDED
2518 tx_sw_if_index0 = adj0[0].rewrite_header.sw_if_index;
2521 next0 = adj0[0].rewrite_header.next_index;
2542 if (rewrite_for_locally_received_packets)
2543 next0 = next0 && next0_override ? next0_override : next0;
2548 n_left_to_next -= 1;
2551 to_next, n_left_to_next,
2659 .name =
"ip4-rewrite-transit",
2660 .vector_size =
sizeof (
u32),
2676 .name =
"ip4-midchain",
2677 .vector_size =
sizeof (
u32),
2681 .sibling_of =
"ip4-rewrite-transit",
2688 .name =
"ip4-rewrite-local",
2689 .vector_size =
sizeof (
u32),
2691 .sibling_of =
"ip4-rewrite-transit",
2707 u32 sw_if_index, table_id;
2718 if (
unformat (input,
"%d", &table_id))
2769 .path =
"set interface ip table",
2771 .short_help =
"set interface ip table <interface> <table-id>",
2783 u32 n_left_from, n_left_to_next, * from, * to_next;
2791 while (n_left_from > 0)
2794 to_next, n_left_to_next);
2796 while (n_left_from >= 4 && n_left_to_next >= 2)
2799 u32 pi0, pi1, lb_index0, lb_index1, wrong_next;
2802 u32 fib_index0, fib_index1;
2820 pi0 = to_next[0] = from[0];
2821 pi1 = to_next[1] = from[1];
2869 (cm, cpu_index, lb_index0, 1,
2873 (cm, cpu_index, lb_index1, 1,
2878 n_left_to_next -= 2;
2881 wrong_next = (next0 != next) + 2*(next1 != next);
2890 n_left_to_next += 1;
2897 n_left_to_next += 1;
2904 n_left_to_next += 2;
2918 while (n_left_from > 0 && n_left_to_next > 0)
2960 (cm, cpu_index, lb_index0, 1,
2965 n_left_to_next -= 1;
2970 n_left_to_next += 1;
2974 to_next, n_left_to_next);
2977 n_left_to_next -= 1;
2992 .name =
"ip4-lookup-multicast",
2993 .vector_size =
sizeof (
u32),
2994 .sibling_of =
"ip4-lookup",
3004 .name =
"ip4-multicast",
3005 .vector_size =
sizeof (
u32),
3051 if (
unformat (input,
"table %d", &table_id))
3055 if ((fib) && (fib->
index != table_id))
3059 else if (
unformat (input,
"count %f", &count))
3072 for (i = 0; i < n; i++)
3077 ip4_base_address.
as_u32 =
3078 clib_host_to_net_u32 (1 +
3079 clib_net_to_host_u32 (ip4_base_address.
as_u32));
3109 .path =
"test lookup",
3110 .short_help =
"test lookup <ipv4-addr> [table <fib-id>] [count <nn>]",
3122 return VNET_API_ERROR_NO_SUCH_FIB;
3137 u32 flow_hash_config = 0;
3141 if (
unformat (input,
"table %d", &table_id))
3144 else if (unformat (input, #a)) { flow_hash_config |= v; matched=1;} 3160 case VNET_API_ERROR_NO_SUCH_FIB:
3164 clib_warning (
"BUG: illegal flow hash config 0x%x", flow_hash_config);
3256 .path =
"set ip flow-hash",
3258 "set ip flow-hash table <table-id> [src] [dst] [sport] [dport] [proto] [reverse]",
3274 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
3277 return VNET_API_ERROR_NO_SUCH_ENTRY;
3284 if (
NULL != if_addr)
3289 .fp_addr.ip4 = *if_addr,
3297 if (table_index != (
u32) ~0)
3329 u32 table_index = ~0;
3330 int table_index_set = 0;
3331 u32 sw_if_index = ~0;
3335 if (
unformat (input,
"table-index %d", &table_index))
3336 table_index_set = 1;
3344 if (table_index_set == 0)
3347 if (sw_if_index == ~0)
3357 case VNET_API_ERROR_NO_MATCHING_INTERFACE:
3360 case VNET_API_ERROR_NO_SUCH_ENTRY:
3378 .path =
"set ip classify",
3380 "set ip classify intfc <interface> table-index <classify-idx>",
vnet_config_main_t config_main
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
u16 lb_n_buckets
number of buckets in the load-balance.
ip_lookup_next_t
Common (IP4/IP6) next index stored in adjacency.
u32 ip4_unicast_rx_feature_drop
Built-in unicast feature path indice, see vnet_feature_arc_init()
static uword ip4_rewrite_local(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
IPv4 local rewrite node.
uword * tx_sw_if_has_ip_output_features
any-tx-feature-enabled interface bitmap
vlib_combined_counter_main_t lbm_to_counters
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)
sll srl srl sll sra u16x4 i
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
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)
u32 ip4_multicast_rx_feature_vpath
Built-in multicast feature path index.
static vlib_node_registration_t ip4_drop_node
(constructor) VLIB_REGISTER_NODE (ip4_drop_node)
static char * feature_start_nodes[]
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.
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
Functions to call when interface address changes.
u32 ip4_unicast_tx_feature_source_and_port_range_check
Built-in unicast feature path index, see vnet_feature_arc_init()
u32 ip4_unicast_rx_feature_source_reachable_via_any
Built-in unicast feature path index, see vnet_feature_arc_init()
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
static vlib_main_t * vlib_get_main(void)
static void vlib_set_next_frame_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, u32 next_index, u32 buffer_index)
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
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)
VNET_IP4_UNICAST_FEATURE_INIT(ip4_flow_classify, static)
VNET_IP4_TX_FEATURE_INIT(ip4_source_and_port_range_check_tx, static)
vnet_interface_main_t interface_main
static uword ip4_midchain(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
vnet_feature_registration_t * next_feature[VNET_N_IP_FEAT]
Feature path configuration lists.
static int ip4_header_bytes(ip4_header_t *i)
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
u32 ip4_multicast_rx_feature_drop
Built-in multicast feature path indices.
static f64 vlib_time_now(vlib_main_t *vm)
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.
static void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
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)
struct ip_adjacency_t_::@164::@165 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
u32 * config_index_by_sw_if_index
#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)
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
static clib_error_t * ip4_feature_init(vlib_main_t *vm, ip4_main_t *im)
ip_lookup_main_t lookup_main
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
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.
unformat_function_t unformat_vnet_sw_interface
static uword ip4_arp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
u32 ip4_unicast_rx_feature_flow_classify
Built-in unicast feature path index, see vnet_feature_arc_init()
u32 neighbor_probe_adj_index
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static char * tx_feature_start_nodes[]
#define IP4_FIB_MTRIE_LEAF_EMPTY
static pg_node_t * pg_get_node(uword node_index)
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,...)
static ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t current_leaf, const ip4_address_t *dst_address, u32 dst_address_byte_index)
u32 ip4_unicast_rx_feature_policer_classify
Built-in unicast feature path index, see vnet_feature_arc_init()
vnet_main_t * vnet_get_main(void)
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.
#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...
u32 ip4_unicast_rx_feature_ipsec
Built-in unicast feature path indix, see vnet_feature_arc_init()
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
#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 u32 ip4_tcp_udp_validate_checksum(vlib_main_t *vm, vlib_buffer_t *p0)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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 IP_BUFFER_L4_CHECKSUM_CORRECT
Aggregrate type for a prefix.
#define IP4_LOOKUP_NEXT_NODES
#define clib_warning(format, args...)
vlib_node_registration_t ip4_arp_node
(constructor) VLIB_REGISTER_NODE (ip4_arp_node)
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
static void * ip4_next_header(ip4_header_t *i)
u16 fp_len
The mask length.
u32 ip4_unicast_rx_feature_check_access
Built-in unicast feature path index, see vnet_feature_arc_init()
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
#define foreach_notrace_ip4_arp_error
adj_index_t fib_entry_get_adj(fib_node_index_t fib_entry_index)
static u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
#define VLIB_BUFFER_NEXT_PRESENT
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
static int ip4_is_fragment(ip4_header_t *i)
vnet_api_error_t api_errno
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.
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
vlib_node_registration_t ip4_input_node
Global ip4 input node.
u16 current_length
Nbytes between current data and the end of this buffer.
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.
static 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)
#define ORDER_CONSTRAINTS
clib_error_t * vnet_feature_arc_init(vlib_main_t *vm, vnet_config_main_t *vcm, char **feature_start_nodes, int num_feature_start_nodes, vnet_feature_registration_t *first_reg, char ***feature_nodes)
Initialize a feature graph arc.
clib_error_t * arp_notrace_init(vlib_main_t *vm)
static uword ip4_rewrite_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int rewrite_for_locally_received_packets, int is_midchain)
dpo_type_t dpoi_type
the type
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
static uword ip4_rewrite_transit(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
IPv4 transit rewrite node.
void ip4_register_protocol(u32 protocol, u32 node_index)
static uword ip4_arp_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_glean)
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 * ip_enabled_by_sw_if_index
static uword ip4_glean(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
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 uword ip4_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
load_balance_main_t load_balance_main
The one instance of load-balance main.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
VNET_IP4_MULTICAST_FEATURE_INIT(ip4_vpath_mc, static)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_combined_counter_main_t adjacency_counters
Adjacency packet counters.
u32 ip4_multicast_rx_feature_lookup
Built-in multicast feature path index.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static vlib_node_registration_t ip4_punt_node
(constructor) VLIB_REGISTER_NODE (ip4_punt_node)
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 u8 * format_ip4_rewrite_trace(u8 *s, va_list *args)
static uword ip4_policer_classify(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
union ip_adjacency_t_::@164 sub_type
static void vlib_buffer_copy_trace_flag(vlib_main_t *vm, vlib_buffer_t *b, u32 bi_target)
vnet_feature_config_main_t feature_config_mains[VNET_N_IP_FEAT]
rx unicast, multicast, tx interface/feature configuration.
#define CLIB_PREFETCH(addr, size, type)
#define MPLS_LABEL_INVALID
#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.
u32 ip4_unicast_rx_feature_source_reachable_via_rx
Built-in unicast feature path index, see vnet_feature_arc_init()
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
u32 ip4_unicast_rx_feature_lookup
Built-in unicast feature path index, see vnet_feature_arc_init()
ip4_add_del_interface_address_function_t * function
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
static clib_error_t * add_del_interface_table(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define clib_memcpy(a, b, c)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
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
static vlib_node_registration_t ip4_multicast_node
(constructor) VLIB_REGISTER_NODE (ip4_multicast_node)
u8 packet_data[64-1 *sizeof(u32)]
u32 fib_node_index_t
A typedef of a node index.
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.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
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 void ip4_addr_fib_init(ip4_address_fib_t *addr_fib, ip4_address_t *address, u32 fib_index)
static clib_error_t * set_ip_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#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.
u32 ip4_tx_feature_interface_output
Built-in tx feature path index.
vlib_node_registration_t ip4_load_balance_node
(constructor) VLIB_REGISTER_NODE (ip4_load_balance_node)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
#define IP4_FIB_MTRIE_LEAF_ROOT
index_t lb_urpf
This is the index of the uRPF list for this LB.
static char * rx_feature_start_nodes[]
#define LOG2_IP_BUFFER_L4_CHECKSUM_CORRECT
static load_balance_t * load_balance_get(index_t lbi)
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define hash_v3_finalize32(a, b, c)
vlib_node_registration_t ip4_glean_node
(constructor) VLIB_REGISTER_NODE (ip4_glean_node)
u32 next_buffer
Next buffer for this linked-list of buffers.
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
vlib_node_registration_t ip4_midchain_node
(constructor) VLIB_REGISTER_NODE (ip4_midchain_node)
#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
Route added as a result of interface configuration.
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
struct ip_adjacency_t_::@164::@167 glean
IP_LOOKUP_NEXT_GLEAN.
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
#define VLIB_BUFFER_IS_TRACED
vlib_node_registration_t ip4_rewrite_local_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_local_node)
static uword is_pow2(uword x)
static uword ip4_local(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
#define IP_BUFFER_L4_CHECKSUM_COMPUTED
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, fib_protocol_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, mpls_label_t next_hop_label, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
index_t dpoi_index
the index of objects of that type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u8 * format_ip4_forward_next_trace(u8 *s, va_list *args)
ip_lookup_next_t lookup_next_index
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define DPO_INVALID
An initialiser for DPos declared on the stack.
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)
A collection of combined counters.
static uword ip4_flow_classify(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
flow_hash_config_t flow_hash_config
#define clib_mem_unaligned(pointer, type)
static void ip4_del_interface_routes(ip4_main_t *im, u32 fib_index, ip4_address_t *address, u32 address_length)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
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.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
static uword ip4_source_and_port_range_check_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
char ** feature_nodes[VNET_N_IP_FEAT]
Save results for show command.
#define VLIB_REGISTER_NODE(x,...)
u32 ip4_unicast_rx_feature_vpath
Built-in unicast feature path index, see vnet_feature_arc_init()
u32 ip4_unicast_rx_feature_source_and_port_range_check
Built-in unicast feature path index, see vnet_feature_arc_init()
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
This packet is to be rewritten and forwarded to the next processing node.
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)
static uword ip4_drop_or_punt(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, ip4_error_t error_code)
u16 dpoi_next_node
The next VLIB node to follow.
#define clib_error_return(e, args...)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ip4_sw_interface_add_del)
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
static uword ip4_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
IPv4 lookup node.
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)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static int ip4_src_address_for_packet(ip_lookup_main_t *lm, u32 sw_if_index, ip4_address_t *src)
static vlib_node_registration_t ip4_lookup_multicast_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_multicast_node)
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)
clib_random_buffer_t random_buffer
static u16 ip_csum_fold(ip_csum_t c)
struct ip_adjacency_t_::@164::@166 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
static char * ip4_arp_error_strings[]
static 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)
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
ip4_fib_mtrie_leaf_t default_leaf
static 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)
static uword pool_elts(void *v)
Number of active elements in a pool.