#include <vnet/ip/reass/ip4_sv_reass.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/ipfix_logging.h>
#include <nat/lib/nat_proto.h>
#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/fib/ip4_fib.h>
#include <vppinfra/error.h>
#include <vppinfra/elog.h>
#include <nat/det44/det44_inlines.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/nat_inlines.h>
typedef enum
#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/fib/ip4_fib.h>
#include <vppinfra/error.h>
#include <vppinfra/elog.h>
#include <nat/det44/det44_inlines.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/nat_inlines.h>
typedef enum
#include <nat/lib/lib.h>
#include <nat/lib/alloc.h>
-#include <nat/lib/inlines.h>
typedef struct
{
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <vnet/ip/ip4_to_ip6.h>
#include <nat/dslite/dslite.h>
#include <nat/lib/nat_syslog.h>
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <vnet/ip/ip4_to_ip6.h>
#include <nat/dslite/dslite.h>
typedef enum
+++ /dev/null
-/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @brief Common NAT inline functions
- */
-#ifndef included_nat_inlines_h__
-#define included_nat_inlines_h__
-
-#include <vnet/ip/icmp46_packet.h>
-
-static_always_inline u64
-icmp_type_is_error_message (u8 icmp_type)
-{
- int bmp = 0;
- bmp |= 1 << ICMP4_destination_unreachable;
- bmp |= 1 << ICMP4_time_exceeded;
- bmp |= 1 << ICMP4_parameter_problem;
- bmp |= 1 << ICMP4_source_quench;
- bmp |= 1 << ICMP4_redirect;
- bmp |= 1 << ICMP4_alternate_host_address;
-
- return (1ULL << icmp_type) & bmp;
-}
-
-#endif /* included_nat_inlines_h__ */
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
#include <vlibmemory/api.h>
#include <vppinfra/atomics.h>
#include <nat/lib/ipfix_logging.h>
-#include <nat/lib/inlines.h>
vlib_node_registration_t nat_ipfix_flush_node;
nat_ipfix_logging_main_t nat_ipfix_logging_main;
#include <vnet/syslog/syslog.h>
#include <nat/lib/nat_syslog.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/nat_syslog_constants.h>
#include <vlibapi/api.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
/* default number of worker handoff frame queue elements */
#define NAT_FQ_NELTS_DEFAULT 64
#include <nat/lib/log.h>
#include <nat/lib/ipfix_logging.h>
#include <nat/nat44-ed/nat44_ed.h>
+#include <vnet/ip/ip4_to_ip6.h>
always_inline void
init_ed_k (clib_bihash_kv_16_8_t *kv, u32 l_addr, u16 l_port, u32 r_addr,
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/ip/ip4.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/ip/ip_table.h>
#include <vnet/ip/reass/ip4_sv_reass.h>
#include <vnet/fib/fib_table.h>
#include <vppinfra/hash.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/nat_proto.h>
/* default number of worker handoff frame queue elements */
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/udp/udp_local.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/udp/udp_local.h>
#include <vnet/fib/ip4_fib.h>
#include <vppinfra/crc32.h>
#include <vnet/fib/ip4_fib.h>
+#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/ip/reass/ip4_sv_reass.h>
#include <vnet/ip/reass/ip6_sv_reass.h>
#include <vnet/ip/reass/ip4_sv_reass.h>
#include <nat/lib/lib.h>
-#include <nat/lib/inlines.h>
#include <nat/lib/nat_inlines.h>
#include <nat/nat64/nat64_db.h>
#include <vnet/fib/fib_table.h>
#include <nat/lib/ipfix_logging.h>
#include <nat/lib/nat_syslog.h>
-#include <nat/lib/inlines.h>
#include <nat/nat64/nat64_db.h>
int
#define frag_id_4to6(id) (id)
+always_inline u64
+icmp_type_is_error_message (u8 icmp_type)
+{
+ int bmp = 0;
+ bmp |= 1 << ICMP4_destination_unreachable;
+ bmp |= 1 << ICMP4_time_exceeded;
+ bmp |= 1 << ICMP4_parameter_problem;
+ bmp |= 1 << ICMP4_source_quench;
+ bmp |= 1 << ICMP4_redirect;
+ bmp |= 1 << ICMP4_alternate_host_address;
+
+ return (1ULL << icmp_type) & bmp;
+}
+
/**
* @brief Get TCP/UDP port number or ICMP id from IPv4 packet.
*
* - outer ICMP header length (2*sizeof (icmp46_header_t))
* - inner IP header length
* - first 8 bytes of payload of original packet in case of ICMP error
+ *
+ * Also make sure we only attempt to parse payload as IP packet if it's
+ * an ICMP error.
*/
else if (clib_net_to_host_u16 (ip->length) >=
- 2 * sizeof (ip4_header_t) + 2 * sizeof (icmp46_header_t) + 8)
+ 2 * sizeof (ip4_header_t) + 2 * sizeof (icmp46_header_t) +
+ 8 &&
+ icmp_type_is_error_message (icmp->type))
{
ip = (ip4_header_t *) (icmp + 2);
if (PREDICT_TRUE ((ip->protocol == IP_PROTOCOL_TCP) ||
if (dst_port)
*dst_port = ((u16 *) (icmp))[2];
}
- else if (clib_net_to_host_u16 (ip6->payload_length) >= 64)
+ /*
+ * if there is enough data and ICMP type indicates ICMP error, then parse
+ * inner packet
+ *
+ * ICMP6 errors are:
+ * 1 - destination_unreachable
+ * 2 - packet_too_big
+ * 3 - time_exceeded
+ * 4 - parameter_problem
+ */
+ else if (clib_net_to_host_u16 (ip6->payload_length) >= 64 &&
+ icmp->type >= ICMP6_destination_unreachable &&
+ icmp->type <= ICMP6_parameter_problem)
{
u16 ip6_pay_len;
ip6_header_t *inner_ip6;