28 uword max_rewrite_bytes)
40 #define MPLS_GRE_OUTPUT_NEXT_POST_REWRITE 1 50 u32 * from, * to_next, n_left_from, n_left_to_next;
61 while (n_left_from > 0)
70 while (n_left_from >= 4 && n_left_to_next >= 2)
73 u32 bi0, next0, bi1, next1;
75 u32 sw_if_index0, sw_if_index1;
167 to_next, n_left_to_next,
168 bi0, bi1, next0, next1);
171 while (n_left_from > 0 && n_left_to_next > 0)
221 to_next, n_left_to_next,
236 u32 dev_instance = va_arg (*args,
u32);
237 return format (s,
"mpls-gre%d", dev_instance);
242 u32 dev_instance = va_arg (*args,
u32);
245 s =
format (s,
"MPLS-GRE tunnel: id %d\n", dev_instance);
250 .name =
"MPLS-GRE tunnel device",
255 .no_flatten_output_chains = 1,
258 .admin_up_down_function = 0;
280 uword max_rewrite_bytes)
292 #define MPLS_ETH_OUTPUT_NEXT_OUTPUT 1 302 u32 * from, * to_next, n_left_from, n_left_to_next;
313 while (n_left_from > 0)
322 while (n_left_from >= 4 && n_left_to_next >= 2)
325 u32 bi0, next0, bi1, next1;
327 u32 sw_if_index0, sw_if_index1;
421 to_next, n_left_to_next,
422 bi0, bi1, next0, next1);
424 while (n_left_from > 0 && n_left_to_next > 0)
475 to_next, n_left_to_next,
483 MPLS_ERROR_PKTS_ENCAP, frame->
n_vectors);
490 u32 dev_instance = va_arg (*args,
u32);
491 return format (s,
"mpls-eth%d", dev_instance);
496 u32 dev_instance = va_arg (*args,
u32);
499 s =
format (s,
"MPLS-ETH tunnel: id %d\n", dev_instance);
504 .name =
"MPLS-ETH tunnel device",
509 .no_flatten_output_chains = 1,
512 .admin_up_down_function = 0;
523 .unformat_header = unformat_mpls_eth_header,
528 #define foreach_mpls_post_rewrite_next \ 529 _ (IP4_LOOKUP, "ip4-lookup") 532 #define _(s,n) MPLS_POST_REWRITE_NEXT_##s, 544 u32 n_left_from, next_index, * from, * to_next;
545 u16 old_l0 = 0, old_l1 = 0;
552 while (n_left_from > 0)
557 to_next, n_left_to_next);
559 while (n_left_from >= 4 && n_left_to_next >= 2)
564 u32 next0 = MPLS_POST_REWRITE_NEXT_IP4_LOOKUP;
565 u32 next1 = MPLS_POST_REWRITE_NEXT_IP4_LOOKUP;
620 to_next, n_left_to_next,
621 bi0, bi1, next0, next1);
624 while (n_left_from > 0 && n_left_to_next > 0)
629 u32 next0 = MPLS_POST_REWRITE_NEXT_IP4_LOOKUP;
657 to_next, n_left_to_next,
664 MPLS_ERROR_PKTS_ENCAP, from_frame->
n_vectors);
670 .name =
"mpls-post-rewrite",
672 .vector_size =
sizeof (
u32),
674 .runtime_data_bytes = 0,
678 #define _(s,n) [MPLS_POST_REWRITE_NEXT_##s] = n, 689 ip4_gre_and_mpls_header_t * h0;
690 u8 * rewrite_data = 0;
700 clib_warning (
"no label for inner fib index %d, dst %U",
708 memset (rewrite_data, 0,
sizeof (*h0));
710 h0 = (ip4_gre_and_mpls_header_t *) rewrite_data;
716 h0->gre.
protocol = clib_host_to_net_u16(GRE_PROTOCOL_mpls_unicast);
725 return (rewrite_data);
732 u32 inner_fib_id,
u32 outer_fib_id,
733 u32 * tunnel_sw_if_index,
743 int need_route_add_del = 1;
744 u32 inner_fib_index = 0;
745 u32 outer_fib_index = 0;
749 int found_tunnel = 0;
751 u32 hw_if_index = ~0;
759 if (tunnel_sw_if_index == 0)
760 tunnel_sw_if_index = &dummy;
762 *tunnel_sw_if_index = ~0;
764 if (inner_fib_id != (
u32)~0)
770 return VNET_API_ERROR_NO_SUCH_INNER_FIB;
771 inner_fib_index = p[0];
774 if (outer_fib_id != 0)
780 return VNET_API_ERROR_NO_SUCH_FIB;
781 outer_fib_index = p[0];
791 if (!memcmp (&tp->tunnel_src, src, sizeof (*src))
792 && !memcmp (&tp->tunnel_dst, dst, sizeof (*dst))
793 && !memcmp (&tp->intfc_address, intfc, sizeof (*intfc))
794 && tp->inner_fib_index == inner_fib_index)
796 ip4_fib_t * fib = vec_elt_at_index (im->fibs, inner_fib_index);
797 uword * hash = fib->adj_index_by_dst_address[mask_width];
798 uword key = intfc->as_u32 & im->fib_masks[mask_width];
799 uword *p = hash_get (hash, key);
811 e = mpls_encap_by_fib_and_dest (mm, inner_fib_index,
814 return VNET_API_ERROR_NO_SUCH_LABEL;
822 need_route_add_del = 0;
830 if (is_add == 0 && found_tunnel == 0)
831 return VNET_API_ERROR_NO_SUCH_ENTRY;
835 return VNET_API_ERROR_NO_SUCH_LABEL;
838 memset (tp, 0,
sizeof (*tp));
840 if (
vec_len (mm->free_gre_sw_if_indices) > 0)
843 mm->free_gre_sw_if_indices[
vec_len(mm->free_gre_sw_if_indices)-1];
844 _vec_len (mm->free_gre_sw_if_indices) -= 1;
846 hi->dev_instance = tp - mm->gre_tunnels;
847 hi->hw_instance = tp - mm->gre_tunnels;
854 tp - mm->gre_tunnels);
859 (vnm->vlib_main,
hi->tx_node_index,
865 *tunnel_sw_if_index =
hi->sw_if_index;
869 tp->hw_if_index = hw_if_index;
872 tp->tunnel_src.as_u32 = src->as_u32;
873 tp->tunnel_dst.as_u32 = dst->as_u32;
874 tp->intfc_address.as_u32 = intfc->as_u32;
875 tp->mask_width = mask_width;
876 tp->inner_fib_index = inner_fib_index;
877 tp->outer_fib_index = outer_fib_index;
878 tp->encap_index = e - mm->encaps;
879 tp->l2_only = l2_only;
882 memset(&adj, 0,
sizeof (adj));
883 adj.explicit_fib_index = ~0;
887 if (rewrite_data == 0)
889 if (*tunnel_sw_if_index != ~0)
894 vec_add1 (mm->free_gre_sw_if_indices, tp->hw_if_index);
897 return VNET_API_ERROR_NO_SUCH_LABEL;
903 tp->rewrite_data = rewrite_data;
911 rewrite_data,
vec_len(rewrite_data));
919 if (need_route_add_del && !l2_only)
930 tp->inner_fib_index);
934 memset (&a, 0,
sizeof (a));
948 if (is_add == 0 && found_tunnel)
953 vec_add1 (mm->free_gre_sw_if_indices, tp->hw_if_index);
972 u32 * tunnels_to_delete = 0;
979 return VNET_API_ERROR_NO_SUCH_INNER_FIB;
984 if (tp->inner_fib_index == fib_index)
985 vec_add1 (tunnels_to_delete, tp - mm->gre_tunnels);
990 for (i = 0; i <
vec_len(tunnels_to_delete); i++) {
1000 memset (&a, 0,
sizeof (a));
1031 int src_set = 0, dst_set = 0, intfc_set = 0;
1033 u32 inner_fib_id = (
u32)~0;
1034 u32 outer_fib_id = 0;
1038 u32 tunnel_intfc_sw_if_index = ~0;
1046 if (
unformat (line_input,
"src %U",
1049 else if (
unformat (line_input,
"dst %U",
1052 else if (
unformat (line_input,
"intfc %U/%d",
1055 else if (
unformat (line_input,
"inner-fib-id %d", &inner_fib_id))
1057 else if (
unformat (line_input,
"outer-fib-id %d", &outer_fib_id))
1059 else if (
unformat (line_input,
"del"))
1061 else if (
unformat (line_input,
"l2-only"))
1079 inner_fib_id, outer_fib_id,
1080 &tunnel_intfc_sw_if_index,
1090 case VNET_API_ERROR_NO_SUCH_INNER_FIB:
1093 case VNET_API_ERROR_NO_SUCH_FIB:
1097 case VNET_API_ERROR_NO_SUCH_ENTRY:
1100 case VNET_API_ERROR_NO_SUCH_LABEL:
1115 .path =
"create mpls gre tunnel",
1117 "create mpls gre tunnel [del] src <addr> dst <addr> intfc <addr>/<mw>",
1124 u32 entry_index = va_arg (*args,
u32);
1145 s =
format (s,
"[%d]: src %U, dst %U, adj %U/%d, labels %U\n",
1153 s =
format (s,
" inner fib index %d, outer fib index %d",
1158 s =
format (s,
"[%d]: src %U, dst %U, key %U, labels %U\n",
1165 s =
format (s,
" l2 interface %d, outer fib index %d",
1177 s =
format (s,
"[%d]: dst %U, adj %U/%d, labels %U\n",
1185 s =
format (s,
" tx on %U, rx fib index %d",
1206 vlib_cli_output (vm,
"%U", format_mpls_gre_tunnel, gt);
1217 vlib_cli_output (vm,
"%U", format_mpls_ethernet_tunnel, et);
1227 .path =
"show mpls tunnel",
1228 .short_help =
"show mpls tunnel",
1247 u8 * rewrite_data = 0;
1258 clib_warning (
"no label for inner fib index %d, dst %U",
1273 return (rewrite_data);
1281 u32 * tunnel_sw_if_index,
1291 int need_route_add_del = 1;
1292 u32 inner_fib_index = 0;
1296 int found_tunnel = 0;
1298 u32 hw_if_index = ~0;
1305 if (tunnel_sw_if_index == 0)
1306 tunnel_sw_if_index = &dummy;
1308 *tunnel_sw_if_index = ~0;
1310 if (inner_fib_id != (
u32)~0)
1316 return VNET_API_ERROR_NO_SUCH_FIB;
1317 inner_fib_index = p[0];
1327 if (!memcmp (&tp->tunnel_dst, dst, sizeof (*dst))
1328 && !memcmp (&tp->intfc_address, intfc, sizeof (*intfc))
1329 && tp->inner_fib_index == inner_fib_index)
1331 ip4_fib_t * fib = vec_elt_at_index (im->fibs, inner_fib_index);
1332 uword * hash = fib->adj_index_by_dst_address[mask_width];
1333 uword key = intfc->as_u32 & im->fib_masks[mask_width];
1334 uword *p = hash_get (hash, key);
1344 e = mpls_encap_by_fib_and_dest (mm, inner_fib_index,
1347 return VNET_API_ERROR_NO_SUCH_LABEL;
1356 need_route_add_del = 0;
1364 if (is_add == 0 && found_tunnel == 0)
1365 return VNET_API_ERROR_NO_SUCH_ENTRY;
1369 return VNET_API_ERROR_NO_SUCH_LABEL;
1372 memset (tp, 0,
sizeof (*tp));
1374 if (
vec_len (mm->free_eth_sw_if_indices) > 0)
1377 mm->free_eth_sw_if_indices[
vec_len(mm->free_eth_sw_if_indices)-1];
1378 _vec_len (mm->free_eth_sw_if_indices) -= 1;
1380 hi->dev_instance = tp - mm->eth_tunnels;
1381 hi->hw_instance = tp - mm->eth_tunnels;
1386 (vnm, mpls_eth_device_class.index, tp - mm->eth_tunnels,
1387 mpls_eth_hw_interface_class.index,
1388 tp - mm->eth_tunnels);
1393 (vnm->vlib_main,
hi->tx_node_index,
1399 *tunnel_sw_if_index =
hi->sw_if_index;
1403 tp->hw_if_index = hw_if_index;
1406 clib_memcpy(tp->tunnel_dst, dst, sizeof (tp->tunnel_dst));
1407 tp->intfc_address.as_u32 = intfc->as_u32;
1408 tp->mask_width = mask_width;
1409 tp->inner_fib_index = inner_fib_index;
1410 tp->encap_index = e - mm->encaps;
1411 tp->tx_sw_if_index = tx_sw_if_index;
1412 tp->l2_only = l2_only;
1415 memset(&adj, 0,
sizeof (adj));
1416 adj.explicit_fib_index = ~0;
1420 if (rewrite_data == 0)
1422 if (*tunnel_sw_if_index != ~0)
1427 vec_add1 (mm->free_eth_sw_if_indices, tp->hw_if_index);
1431 return VNET_API_ERROR_NO_SUCH_LABEL;
1436 VNET_L3_PACKET_TYPE_MPLS_UNICAST,
1440 &adj.rewrite_header,
1441 sizeof (adj.rewrite_data));
1447 vec_insert (rewrite_data, adj.rewrite_header.data_bytes, 0);
1450 sizeof (adj.rewrite_data)),
1451 adj.rewrite_header.data_bytes);
1454 sizeof(adj.rewrite_data),
1460 tp->rewrite_data = rewrite_data;
1468 if (need_route_add_del && !l2_only)
1479 tp->inner_fib_index);
1483 memset (&a, 0,
sizeof (a));
1496 if (is_add == 0 && found_tunnel)
1501 vec_add1 (mm->free_eth_sw_if_indices, tp->hw_if_index);
1519 int dst_set = 0, intfc_set = 0;
1521 u32 inner_fib_id = (
u32)~0;
1526 u32 sw_if_index = ~0;
1534 if (
unformat (line_input,
"dst %U",
1537 else if (
unformat (line_input,
"adj %U/%d",
1540 else if (
unformat (line_input,
"tx-intfc %U",
1543 else if (
unformat (line_input,
"fib-id %d", &inner_fib_id))
1545 else if (
unformat (line_input,
"l2-only"))
1547 else if (
unformat (line_input,
"del"))
1565 inner_fib_id, tx_sw_if_index,
1575 case VNET_API_ERROR_NO_SUCH_FIB:
1579 case VNET_API_ERROR_NO_SUCH_ENTRY:
1582 case VNET_API_ERROR_NO_SUCH_LABEL:
1592 return clib_error_return (0,
"vnet_mpls_ethernet_add_del_tunnel returned %d", rv);
1600 .path =
"create mpls ethernet tunnel",
1602 "create mpls ethernet tunnel [del] dst <mac-addr> intfc <addr>/<mw>",
1609 u32 policy_tunnel_index)
1613 u8 * rewrite_data = 0;
1619 return VNET_API_ERROR_NO_SUCH_ENTRY;
1623 memset (&adj, 0,
sizeof (adj));
1628 VNET_L3_PACKET_TYPE_MPLS_UNICAST,
1632 &adj.rewrite_header,
1633 sizeof (adj.rewrite_data));
1635 vec_validate (rewrite_data, adj.rewrite_header.data_bytes -1);
1639 sizeof (adj.rewrite_data)),
1640 adj.rewrite_header.data_bytes);
1663 u32 * tunnel_sw_if_index,
1664 u32 classify_table_index,
1665 u32 * new_tunnel_index,
1675 int need_route_add_del = 1;
1676 u32 inner_fib_index = 0;
1679 int found_tunnel = 0;
1681 u32 hw_if_index = ~0;
1688 if (tunnel_sw_if_index == 0)
1689 tunnel_sw_if_index = &dummy;
1691 *tunnel_sw_if_index = ~0;
1693 if (inner_fib_id != (
u32)~0)
1699 return VNET_API_ERROR_NO_SUCH_FIB;
1700 inner_fib_index = p[0];
1710 if (!memcmp (&tp->tunnel_dst, dst, sizeof (*dst))
1711 && !memcmp (&tp->intfc_address, intfc, sizeof (*intfc))
1712 && tp->inner_fib_index == inner_fib_index)
1714 ip4_fib_t * fib = vec_elt_at_index (im->fibs, inner_fib_index);
1715 uword * hash = fib->adj_index_by_dst_address[mask_width];
1716 uword key = intfc->as_u32 & im->fib_masks[mask_width];
1717 uword *p = hash_get (hash, key);
1734 need_route_add_del = 0;
1742 if (is_add == 0 && found_tunnel == 0)
1743 return VNET_API_ERROR_NO_SUCH_ENTRY;
1746 memset (tp, 0,
sizeof (*tp));
1748 if (
vec_len (mm->free_eth_sw_if_indices) > 0)
1751 mm->free_eth_sw_if_indices[
vec_len(mm->free_eth_sw_if_indices)-1];
1752 _vec_len (mm->free_eth_sw_if_indices) -= 1;
1754 hi->dev_instance = tp - mm->eth_tunnels;
1755 hi->hw_instance = tp - mm->eth_tunnels;
1760 (vnm, mpls_eth_device_class.index, tp - mm->eth_tunnels,
1761 mpls_eth_hw_interface_class.index,
1762 tp - mm->eth_tunnels);
1767 (vnm->vlib_main,
hi->tx_node_index,
1773 *tunnel_sw_if_index =
hi->sw_if_index;
1777 tp->hw_if_index = hw_if_index;
1780 clib_memcpy(tp->tunnel_dst, dst, sizeof (tp->tunnel_dst));
1781 tp->intfc_address.as_u32 = intfc->as_u32;
1782 tp->mask_width = mask_width;
1783 tp->inner_fib_index = inner_fib_index;
1784 tp->encap_index = e - mm->encaps;
1785 tp->tx_sw_if_index = tx_sw_if_index;
1786 tp->l2_only = l2_only;
1788 if (new_tunnel_index)
1789 *new_tunnel_index = tp - mm->eth_tunnels;
1792 memset(&adj, 0,
sizeof (adj));
1793 adj.explicit_fib_index = ~0;
1795 adj.classify.table_index = classify_table_index;
1803 if (need_route_add_del && !l2_only)
1814 tp->inner_fib_index);
1818 memset (&a, 0,
sizeof (a));
1831 if (is_add == 0 && found_tunnel)
1836 vec_add1 (mm->free_eth_sw_if_indices, tp->hw_if_index);
1853 int dst_set = 0, intfc_set = 0;
1855 u32 inner_fib_id = (
u32)~0;
1856 u32 classify_table_index = (
u32)~0;
1857 u32 new_tunnel_index;
1869 if (
unformat (line_input,
"dst %U",
1872 else if (
unformat (line_input,
"adj %U/%d",
1875 else if (
unformat (line_input,
"tx-intfc %U",
1878 else if (
unformat (line_input,
"classify-table-index %d",
1879 &classify_table_index))
1881 else if (
unformat (line_input,
"fib-id %d", &inner_fib_id))
1883 else if (
unformat (line_input,
"l2-only"))
1885 else if (
unformat (line_input,
"del"))
1892 if (classify_table_index == ~0)
1906 inner_fib_id, tx_sw_if_index,
1908 classify_table_index,
1917 case VNET_API_ERROR_NO_SUCH_FIB:
1921 case VNET_API_ERROR_NO_SUCH_ENTRY:
1924 case VNET_API_ERROR_NO_SUCH_LABEL:
1934 return clib_error_return (0,
"vnet_mpls_ethernet_add_del_policy_tunnel returned %d", rv);
1942 .path =
"create mpls ethernet policy tunnel",
1944 "create mpls ethernet policy tunnel [del] dst <mac-addr> intfc <addr>/<mw>\n" 1945 " classify-table-index <nn>",
#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.
u8 * format_mpls_encap_index(u8 *s, va_list *args)
int vnet_mpls_gre_delete_fib_tunnels(u32 fib_id)
sll srl srl sll sra u16x4 i
u32 * free_gre_sw_if_indices
static u32 vnet_mpls_uc_get_label(u32 label_exp_s_ttl)
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)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
format_function_t format_mpls_eth_header_with_length
ip4_address_t intfc_address
static uword mpls_gre_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
int vnet_mpls_ethernet_add_del_tunnel(u8 *dst, ip4_address_t *intfc, u32 mask_width, u32 inner_fib_id, u32 tx_sw_if_index, u32 *tunnel_sw_if_index, u8 l2_only, u8 is_add)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *copy_adj, u32 n_adj, u32 *adj_index_return)
static u8 * format_mpls_eth_tunnel_name(u8 *s, va_list *args)
static clib_error_t * mpls_policy_encap_init(vlib_main_t *vm)
#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
unformat_function_t unformat_vnet_sw_interface
void ip4_maybe_remap_adjacencies(ip4_main_t *im, u32 table_index_or_table_id, u32 flags)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
#define MPLS_ETH_OUTPUT_NEXT_OUTPUT
vnet_main_t * vnet_get_main(void)
u8 * format_mpls_eth_tx_trace(u8 *s, va_list *args)
u8 * format_ethernet_address(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static u8 * format_mpls_gre_tunnel_name(u8 *s, va_list *args)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static uword mpls_post_rewrite(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_warning(format, args...)
#define vlib_call_init_function(vm, x)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
mpls_gre_tunnel_t * gre_tunnels
ip4_address_t intfc_address
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
format_function_t format_mpls_gre_header_with_length
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_node_registration_t mpls_policy_encap_node
(constructor) VLIB_REGISTER_NODE (mpls_policy_encap_node)
#define MPLS_GRE_OUTPUT_NEXT_POST_REWRITE
#define foreach_mpls_post_rewrite_next
#define pool_put(P, E)
Free an object E in pool P.
static uword mpls_eth_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
vlib_node_registration_t mpls_input_node
(constructor) VLIB_REGISTER_NODE (mpls_input_node)
static void * vnet_rewrite_get_data_internal(vnet_rewrite_header_t *rw, int max_size)
static clib_error_t * show_mpls_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#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.
void vnet_rewrite_for_tunnel(vnet_main_t *vnm, u32 tx_sw_if_index, u32 rewrite_node_index, u32 post_rewrite_node_index, vnet_rewrite_header_t *rw, u8 *rewrite_data, u32 rewrite_length)
#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.
#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).
vnet_device_class_t mpls_gre_device_class
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
This packet needs to be classified.
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
int vnet_mpls_ethernet_add_del_policy_tunnel(u8 *dst, ip4_address_t *intfc, u32 mask_width, u32 inner_fib_id, u32 tx_sw_if_index, u32 *tunnel_sw_if_index, u32 classify_table_index, u32 *new_tunnel_index, u8 l2_only, u8 is_add)
#define CLIB_PREFETCH(addr, size, type)
#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)
static void vnet_rewrite_set_data_internal(vnet_rewrite_header_t *rw, int max_size, void *data, int data_bytes)
u8 * format_mpls_ethernet_tunnel(u8 *s, va_list *args)
#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.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
mpls_eth_tunnel_t * eth_tunnels
#define IP4_ROUTE_FLAG_DEL
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
ip4_fib_t * fibs
Vector of FIBs.
VLIB_DEVICE_TX_FUNCTION_MULTIARCH(mpls_gre_device_class, mpls_gre_interface_tx)
clib_error_t * mpls_interface_init(vlib_main_t *vm)
ip4_address_t dst_address
#define IP4_ROUTE_FLAG_ADD
int vnet_mpls_policy_tunnel_add_rewrite(mpls_main_t *mm, mpls_encap_t *e, u32 policy_tunnel_index)
mpls_encap_t * mpls_encap_by_fib_and_dest(mpls_main_t *mm, u32 rx_fib, u32 dst_address)
#define VLIB_BUFFER_IS_TRACED
vlib_node_registration_t mpls_post_rewrite_node
(constructor) VLIB_REGISTER_NODE (mpls_post_rewrite_node)
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vnet_hw_interface_class_t mpls_gre_hw_interface_class
static u8 * mpls_ethernet_rewrite(mpls_main_t *mm, mpls_eth_tunnel_t *t)
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unformat_function_t unformat_mpls_gre_header
static u8 * format_mpls_eth_device(u8 *s, va_list *args)
#define IP4_ROUTE_FLAG_FIB_INDEX
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
u32 table_index_or_table_id
u8 * format_mpls_gre_tx_trace(u8 *s, va_list *args)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
ip4_main_t ip4_main
Global ip4 main structure.
This packet is to be rewritten and forwarded to the next processing node.
static uword mpls_gre_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static clib_error_t * create_mpls_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword mpls_eth_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static clib_error_t * create_mpls_ethernet_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static u8 * format_mpls_gre_device(u8 *s, va_list *args)
static u8 * mpls_gre_rewrite(mpls_main_t *mm, mpls_gre_tunnel_t *t)
uword * adj_index_by_dst_address[33]
#define clib_error_return(e, args...)
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *args)
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
int vnet_mpls_gre_add_del_tunnel(ip4_address_t *src, ip4_address_t *dst, ip4_address_t *intfc, u32 mask_width, u32 inner_fib_id, u32 outer_fib_id, u32 *tunnel_sw_if_index, u8 l2_only, u8 is_add)
static clib_error_t * create_mpls_ethernet_policy_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)
mpls_unicast_header_t * labels
u8 * format_mpls_gre_tunnel(u8 *s, va_list *args)
static uword pool_elts(void *v)
Number of active elements in a pool.