X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fvxlan%2Fvxlan.c;h=2b8525113254abf1f84fb26ef55c0aba41a2e438;hb=5fb2278cb8badbbfe727acbdcaeda008a7fd2833;hp=4276d6689acf93d23d1dc0bc350a305d18ae9a11;hpb=f8d5e214687c17fba000607336295e054672459d;p=vpp.git diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c index 4276d6689ac..2b852511325 100644 --- a/src/vnet/vxlan/vxlan.c +++ b/src/vnet/vxlan/vxlan.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -241,7 +242,7 @@ vxlan_rewrite (vxlan_tunnel_t * t, bool is_ip6) vxlan_header_t *vxlan; /* Fixed portion of the (outer) ip header */ - memset (&h, 0, sizeof (h)); + clib_memset (&h, 0, sizeof (h)); if (!is_ip6) { ip4_header_t *ip = &h.h4.ip4; @@ -419,7 +420,7 @@ int vnet_vxlan_add_del_tunnel vxlan_tunnel_t *t; pool_get_aligned (vxm->tunnels, t, CLIB_CACHE_LINE_BYTES); - memset (t, 0, sizeof (*t)); + clib_memset (t, 0, sizeof (*t)); dev_instance = t - vxm->tunnels; /* copy from arg structure */ @@ -513,11 +514,11 @@ int vnet_vxlan_add_del_tunnel * re-stack accordingly */ vtep_addr_ref (&t->src); - t->fib_entry_index = fib_table_entry_special_add - (t->encap_fib_index, &tun_dst_pfx, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE); - t->sibling_index = fib_entry_child_add - (t->fib_entry_index, FIB_NODE_TYPE_VXLAN_TUNNEL, dev_instance); + t->fib_entry_index = fib_entry_track (t->encap_fib_index, + &tun_dst_pfx, + FIB_NODE_TYPE_VXLAN_TUNNEL, + dev_instance, + &t->sibling_index); vxlan_tunnel_restack_dpo (t); } else @@ -538,8 +539,9 @@ int vnet_vxlan_add_del_tunnel .frp_addr = zero_addr, .frp_sw_if_index = 0xffffffff, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = FIB_ROUTE_PATH_LOCAL, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; const mfib_prefix_t mpfx = { .fp_proto = fp, @@ -553,17 +555,14 @@ int vnet_vxlan_add_del_tunnel * - the accepting interface is that from the API */ mfib_table_entry_path_update (t->encap_fib_index, - &mpfx, - MFIB_SOURCE_VXLAN, - &path, MFIB_ITF_FLAG_FORWARD); + &mpfx, MFIB_SOURCE_VXLAN, &path); path.frp_sw_if_index = a->mcast_sw_if_index; path.frp_flags = FIB_ROUTE_PATH_FLAG_NONE; + path.frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT; mfei = mfib_table_entry_path_update (t->encap_fib_index, &mpfx, - MFIB_SOURCE_VXLAN, - &path, - MFIB_ITF_FLAG_ACCEPT); + MFIB_SOURCE_VXLAN, &path); /* * Create the mcast adjacency to send traffic to the group @@ -621,8 +620,7 @@ int vnet_vxlan_add_del_tunnel vnet_flow_del (vnm, t->flow_index); vtep_addr_unref (&t->src); - fib_entry_child_remove (t->fib_entry_index, t->sibling_index); - fib_table_entry_delete_index (t->fib_entry_index, FIB_SOURCE_RR); + fib_entry_untrack (t->fib_entry_index, t->sibling_index); } else if (vtep_addr_unref (&t->dst) == 0) { @@ -639,6 +637,17 @@ int vnet_vxlan_add_del_tunnel if (sw_if_indexp) *sw_if_indexp = sw_if_index; + if (a->is_add) + { + /* register udp ports */ + if (!is_ip6 && !udp_is_valid_dst_port (UDP_DST_PORT_vxlan, 1)) + udp_register_dst_port (vxm->vlib_main, UDP_DST_PORT_vxlan, + vxlan4_input_node.index, 1); + if (is_ip6 && !udp_is_valid_dst_port (UDP_DST_PORT_vxlan6, 0)) + udp_register_dst_port (vxm->vlib_main, UDP_DST_PORT_vxlan6, + vxlan6_input_node.index, 0); + } + return 0; } @@ -919,12 +928,38 @@ VLIB_CLI_COMMAND (show_vxlan_tunnel_command, static) = { void vnet_int_vxlan_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable) { + vxlan_main_t *vxm = &vxlan_main; + + if (pool_is_free_index (vxm->vnet_main->interface_main.sw_interfaces, + sw_if_index)) + return; + + is_enable = ! !is_enable; + if (is_ip6) - vnet_feature_enable_disable ("ip6-unicast", "ip6-vxlan-bypass", - sw_if_index, is_enable, 0, 0); + { + if (clib_bitmap_get (vxm->bm_ip6_bypass_enabled_by_sw_if, sw_if_index) + != is_enable) + { + vnet_feature_enable_disable ("ip6-unicast", "ip6-vxlan-bypass", + sw_if_index, is_enable, 0, 0); + vxm->bm_ip6_bypass_enabled_by_sw_if = + clib_bitmap_set (vxm->bm_ip6_bypass_enabled_by_sw_if, + sw_if_index, is_enable); + } + } else - vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass", - sw_if_index, is_enable, 0, 0); + { + if (clib_bitmap_get (vxm->bm_ip4_bypass_enabled_by_sw_if, sw_if_index) + != is_enable) + { + vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass", + sw_if_index, is_enable, 0, 0); + vxm->bm_ip4_bypass_enabled_by_sw_if = + clib_bitmap_set (vxm->bm_ip4_bypass_enabled_by_sw_if, + sw_if_index, is_enable); + } + } } @@ -1082,7 +1117,7 @@ set_ip6_vxlan_bypass (vlib_main_t * vm, VLIB_CLI_COMMAND (set_interface_ip6_vxlan_bypass_command, static) = { .path = "set interface ip6 vxlan-bypass", .function = set_ip6_vxlan_bypass, - .short_help = "set interface ip vxlan-bypass [del]", + .short_help = "set interface ip6 vxlan-bypass [del]", }; /* *INDENT-ON* */ @@ -1099,9 +1134,11 @@ vnet_vxlan_add_del_rx_flow (u32 hw_if_index, u32 t_index, int is_add) vxlan_main_t *vxm = &vxlan_main; vnet_flow_t flow = { .actions = - VNET_FLOW_ACTION_REDIRECT_TO_NODE | VNET_FLOW_ACTION_MARK, + VNET_FLOW_ACTION_REDIRECT_TO_NODE | VNET_FLOW_ACTION_MARK | + VNET_FLOW_ACTION_BUFFER_ADVANCE, .mark_flow_id = t->dev_instance + vxm->flow_id_start, .redirect_node_index = vxlan4_flow_input_node.index, + .buffer_advance = sizeof (ethernet_header_t), .type = VNET_FLOW_TYPE_IP4_VXLAN, .ip4_vxlan = { .src_addr = t->dst.ip4, @@ -1216,6 +1253,9 @@ vxlan_init (vlib_main_t * vm) vnet_flow_get_range (vxm->vnet_main, "vxlan", 1024 * 1024, &vxm->flow_id_start); + vxm->bm_ip4_bypass_enabled_by_sw_if = 0; + vxm->bm_ip6_bypass_enabled_by_sw_if = 0; + /* initialize the ip6 hash */ clib_bihash_init_16_8 (&vxm->vxlan4_tunnel_by_key, "vxlan4", VXLAN_HASH_NUM_BUCKETS, VXLAN_HASH_MEMORY_SIZE); @@ -1226,11 +1266,6 @@ vxlan_init (vlib_main_t * vm) sizeof (ip46_address_t), sizeof (mcast_shared_t)); - udp_register_dst_port (vm, UDP_DST_PORT_vxlan, - vxlan4_input_node.index, /* is_ip4 */ 1); - udp_register_dst_port (vm, UDP_DST_PORT_vxlan6, - vxlan6_input_node.index, /* is_ip4 */ 0); - fib_node_register_type (FIB_NODE_TYPE_VXLAN_TUNNEL, &vxlan_vft); return 0;