X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fipip%2Fipip.c;h=05460fbbe34f2904c27a3d2c5d31cd54a1c342e4;hb=59ff918ea;hp=5d4070842056d2f9a1e3f230db1288c5f07c1480;hpb=4c3ba81709bab8f9fcdef650e7f742fe9ddbae32;p=vpp.git diff --git a/src/vnet/ipip/ipip.c b/src/vnet/ipip/ipip.c index 5d407084205..05460fbbe34 100644 --- a/src/vnet/ipip/ipip.c +++ b/src/vnet/ipip/ipip.c @@ -75,8 +75,10 @@ ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index, ip4->src_address.as_u32 = t->tunnel_src.ip4.as_u32; ip4->dst_address.as_u32 = t->tunnel_dst.ip4.as_u32; ip4->checksum = ip4_header_checksum (ip4); - if (t->tc_tos != 0xFF) - ip4->tos = t->tc_tos; + if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)) + ip4_header_set_dscp (ip4, t->dscp); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_SET_DF) + ip4_header_set_df (ip4); break; case IPIP_TRANSPORT_IP6: @@ -84,14 +86,14 @@ ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index, ip6 = (ip6_header_t *) rewrite; ip6->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 (6 << 28); - if (t->tc_tos != 0xFF) - ip6_set_traffic_class_network_order (ip6, t->tc_tos); ip6->hop_limit = 64; /* fixup ip6 header length and protocol after-the-fact */ ip6->src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0]; ip6->src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1]; ip6->dst_address.as_u64[0] = t->tunnel_dst.ip6.as_u64[0]; ip6->dst_address.as_u64[1] = t->tunnel_dst.ip6.as_u64[1]; + if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)) + ip6_set_dscp_network_order (ip6, t->dscp); break; default: @@ -102,7 +104,7 @@ ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index, } static void -ipip4_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b, +ipip4_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b, const void *data) { ip4_header_t *ip4; @@ -114,15 +116,25 @@ ipip4_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b, { case VNET_LINK_IP6: ip4->protocol = IP_PROTOCOL_IPV6; - if (t->tc_tos == 0xFF) - ip4->tos = - ip6_traffic_class_network_order ((const ip6_header_t *) (ip4 + 1)); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP) + ip4_header_set_dscp (ip4, + ip6_dscp_network_order ((ip6_header_t *) (ip4 + + 1))); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN) + ip4_header_set_ecn (ip4, + ip6_ecn_network_order ((ip6_header_t *) (ip4 + + 1))); break; case VNET_LINK_IP4: ip4->protocol = IP_PROTOCOL_IP_IN_IP; - if (t->tc_tos == 0xFF) - ip4->tos = ((ip4_header_t *) (ip4 + 1))->tos; + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP) + ip4_header_set_dscp (ip4, ip4_header_get_dscp (ip4 + 1)); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN) + ip4_header_set_ecn (ip4, ip4_header_get_ecn (ip4 + 1)); + if ((t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DF) && + ip4_header_get_df (ip4 + 1)) + ip4_header_set_df (ip4); break; default: @@ -133,7 +145,7 @@ ipip4_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b, } static void -ipip6_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b, +ipip6_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b, const void *data) { ip6_header_t *ip6; @@ -151,17 +163,20 @@ ipip6_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b, { case VNET_LINK_IP6: ip6->protocol = IP_PROTOCOL_IPV6; - if (t->tc_tos == 0xFF) - ip6_set_traffic_class_network_order (ip6, - ip6_traffic_class_network_order ((const ip6_header_t *) (ip6 + 1))); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP) + ip6_set_dscp_network_order (ip6, ip6_dscp_network_order (ip6 + 1)); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN) + ip6_set_ecn_network_order (ip6, ip6_ecn_network_order (ip6 + 1)); break; case VNET_LINK_IP4: ip6->protocol = IP_PROTOCOL_IP_IN_IP; - if (t->tc_tos == 0xFF) - ip6_set_traffic_class_network_order (ip6, - ((ip4_header_t *) (ip6 + - 1))->tos); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP) + ip6_set_dscp_network_order + (ip6, ip4_header_get_dscp ((ip4_header_t *) (ip6 + 1))); + if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN) + ip6_set_ecn_network_order + (ip6, ip4_header_get_ecn ((ip4_header_t *) (ip6 + 1))); break; default: @@ -297,6 +312,23 @@ ipip_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) return /* no error */ 0; } +static int +ipip_tunnel_desc (u32 sw_if_index, + ip46_address_t * src, ip46_address_t * dst, u8 * is_l2) +{ + ipip_tunnel_t *t; + + t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index); + if (!t) + return -1; + + *src = t->tunnel_src; + *dst = t->tunnel_dst; + *is_l2 = 0; + + return (0); +} + /* *INDENT-OFF* */ VNET_DEVICE_CLASS(ipip_device_class) = { .name = "IPIP tunnel device", @@ -304,6 +336,7 @@ VNET_DEVICE_CLASS(ipip_device_class) = { .format_device = format_ipip_device, .format_tx_trace = format_ipip_tx_trace, .admin_up_down_function = ipip_interface_admin_up_down, + .ip_tun_desc = ipip_tunnel_desc, #ifdef SOON .clear counter = 0; #endif @@ -366,7 +399,8 @@ ipip_tunnel_db_remove (ipip_tunnel_t * t) int ipip_add_tunnel (ipip_transport_t transport, u32 instance, ip46_address_t * src, ip46_address_t * dst, - u32 fib_index, u8 tc_tos, u32 * sw_if_indexp) + u32 fib_index, tunnel_encap_decap_flags_t flags, + ip_dscp_t dscp, u32 * sw_if_indexp) { ipip_main_t *gm = &ipip_main; vnet_main_t *vnm = gm->vnet_main; @@ -382,7 +416,11 @@ ipip_add_tunnel (ipip_transport_t transport, }; t = ipip_tunnel_db_find (&key); if (t) - return VNET_API_ERROR_IF_ALREADY_EXISTS; + { + if (sw_if_indexp) + sw_if_indexp[0] = t->sw_if_index; + return VNET_API_ERROR_IF_ALREADY_EXISTS; + } pool_get_aligned (gm->tunnels, t, CLIB_CACHE_LINE_BYTES); clib_memset (t, 0, sizeof (*t)); @@ -412,9 +450,10 @@ ipip_add_tunnel (ipip_transport_t transport, t->hw_if_index = hw_if_index; t->fib_index = fib_index; t->sw_if_index = sw_if_index; - t->tc_tos = tc_tos; - + t->dscp = dscp; + t->flags = flags; t->transport = transport; + vec_validate_init_empty (gm->tunnel_index_by_sw_if_index, sw_if_index, ~0); gm->tunnel_index_by_sw_if_index[sw_if_index] = t_idx;