nat: session cleanup fix
[vpp.git] / src / plugins / nat / in2out.c
index 5cfe058..6cb111c 100755 (executable)
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/fib/ip4_fib.h>
+#include <vnet/udp/udp.h>
 #include <nat/nat.h>
 #include <nat/nat_ipfix_logging.h>
 #include <nat/nat_reass.h>
 #include <nat/nat_inlines.h>
+#include <nat/nat44_inlines.h>
 #include <nat/nat_syslog.h>
 #include <nat/nat_ha.h>
 
@@ -267,6 +269,9 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
   };
   nat44_is_idle_session_ctx_t ctx0;
 
+  nat44_session_try_cleanup (&ip0->src_address, rx_fib_index0, thread_index,
+                            now);
+
   if (PREDICT_FALSE (maximum_sessions_exceeded (sm, thread_index)))
     {
       b0->error = node->errors[SNAT_IN2OUT_ERROR_MAX_SESSIONS_EXCEEDED];
@@ -1032,6 +1037,18 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
                                                                           thread_index,
                                                                           sw_if_index0)))
                        goto trace00;
+
+                     /*
+                      * Send DHCP packets to the ipv4 stack, or we won't
+                      * be able to use dhcp client on the outside interface
+                      */
+                     if (PREDICT_FALSE
+                         ((b0->flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
+                          && proto0 == SNAT_PROTOCOL_UDP
+                          && (udp0->dst_port ==
+                              clib_host_to_net_u16
+                              (UDP_DST_PORT_dhcp_to_server))))
+                       goto trace00;
                    }
                  else
                    {
@@ -1228,6 +1245,18 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
                                                                           thread_index,
                                                                           sw_if_index1)))
                        goto trace01;
+
+                     /*
+                      * Send DHCP packets to the ipv4 stack, or we won't
+                      * be able to use dhcp client on the outside interface
+                      */
+                     if (PREDICT_FALSE
+                         ((b1->flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
+                          && proto1 == SNAT_PROTOCOL_UDP
+                          && (udp1->dst_port ==
+                              clib_host_to_net_u16
+                              (UDP_DST_PORT_dhcp_to_server))))
+                       goto trace01;
                    }
                  else
                    {
@@ -1458,6 +1487,18 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
                                                                           thread_index,
                                                                           sw_if_index0)))
                        goto trace0;
+
+                     /*
+                      * Send DHCP packets to the ipv4 stack, or we won't
+                      * be able to use dhcp client on the outside interface
+                      */
+                     if (PREDICT_FALSE
+                         ((b0->flags & VNET_BUFFER_F_LOCALLY_ORIGINATED)
+                          && proto0 == SNAT_PROTOCOL_UDP
+                          && (udp0->dst_port ==
+                              clib_host_to_net_u16
+                              (UDP_DST_PORT_dhcp_to_server))))
+                       goto trace0;
                    }
                  else
                    {