Hi,

Florin Coras <fcoras.li...@gmail.com> schrieb am Mi., 21. Nov. 2018 um
18:33 Uhr:

>
> On Nov 21, 2018, at 8:55 AM, Andreas Schultz <
> andreas.schu...@travelping.com> wrote:
>
> Florin Coras <fcoras.li...@gmail.com> schrieb am Mi., 21. Nov. 2018 um
> 17:18 Uhr:
>
>> Hi Andreas,
>>
>> The trace lower suggests your tcp connection was freed but you still got
>> data for it. tcp-input and the checks in established should prevent that
>> from happening and the session layer should not receive any events after
>> the transport notifies it that the session will cleaned up.
>>
> I've found a way to reproduce the problem with a mostly unmodified vpp
(see attached patch for the changes).
It turns that the crash is triggered when a tcp client is aborting
(resetting) the connection the hard way with a RST.

A normal connection close looks like this:

Client      Server (VPP)
----- [FIN,ACK] ---->
<---- [FIN,ACK] -----
------- [ACK] ------>

The crash occurs when the connection is aborted like this:

Client      Server (VPP)
----- [RST,ACK] ---->

For the unmodified VPP the crash looks like this:

Thread 1 "vpp_main" received signal SIGSEGV, Segmentation fault.
0x00007ffff76abda8 in tcp_handle_postponed_dequeues (wrk=0x7fffb7313b80) at
/usr/src/components/vpp/src/vnet/tcp/tcp_input.c:530
530       tc->flags &= ~TCP_CONN_DEQ_PENDING;
(gdb) bt
#0  0x00007ffff76abda8 in tcp_handle_postponed_dequeues
(wrk=0x7fffb7313b80) at /usr/src/components/vpp/src/vnet/tcp/tcp_input.c:530
#1  0x00007ffff76b1a6c in tcp46_established_inline (vm=0x7ffff708f340
<vlib_global_main>, node=0x7fffb927a3c0, frame=0x7fffb7619800, is_ip4=1) at
/usr/src/components/vpp/src/vnet/tcp/tcp_input.c:2160
#2  0x00007ffff76b1b01 in tcp4_established (vm=0x7ffff708f340
<vlib_global_main>, node=0x7fffb927a3c0, from_frame=0x7fffb7619800) at
/usr/src/components/vpp/src/vnet/tcp/tcp_input.c:2171
#3  0x00007ffff70043ec in dispatch_node (vm=0x7ffff708f340
<vlib_global_main>, node=0x7fffb927a3c0, type=VLIB_NODE_TYPE_INTERNAL,
dispatch_state=VLIB_NODE_STATE_POLLING, frame=0x7fffb7619800,
last_time_stamp=67427903546971)
    at /usr/src/components/vpp/src/vlib/main.c:1154
#4  0x00007ffff70049cc in dispatch_pending_node (vm=0x7ffff708f340
<vlib_global_main>, pending_frame_index=5, last_time_stamp=67427903546971)
at /usr/src/components/vpp/src/vlib/main.c:1312
#5  0x00007ffff700665f in vlib_main_or_worker_loop (vm=0x7ffff708f340
<vlib_global_main>, is_main=1) at
/usr/src/components/vpp/src/vlib/main.c:1739
#6  0x00007ffff7006e38 in vlib_main_loop (vm=0x7ffff708f340
<vlib_global_main>) at /usr/src/components/vpp/src/vlib/main.c:1813
#7  0x00007ffff7007be4 in vlib_main (vm=0x7ffff708f340 <vlib_global_main>,
input=0x7fffb6bfffb0) at /usr/src/components/vpp/src/vlib/main.c:2006
#8  0x00007ffff7062b90 in thread0 (arg=140737337946944) at
/usr/src/components/vpp/src/vlib/unix/main.c:606
#9  0x00007ffff6e73c98 in clib_calljmp () from
/usr/src/components/vpp/build-root/install-vpp_debug-native/vpp/lib/libvppinfra.so.19.01
#10 0x00007fffffffd230 in ?? ()
#11 0x00007ffff706305d in vlib_unix_main (argc=34, argv=0x555555694230) at
/usr/src/components/vpp/src/vlib/unix/main.c:675
#12 0x000055555555d404 in main (argc=34, argv=0x555555694230) at
/usr/src/components/vpp/src/vpp/vnet/main.c:272

The reason I discovered this is that my VPP HTTP server is sending a 302
redirect with a Location header. In this case wget is doing something with
the connection that leads to the RST instead of a normal FIN.

Regards
Andreas


-- 
-- 
Dipl.-Inform. Andreas Schultz

----------------------- enabling your networks ----------------------
Travelping GmbH                     Phone:  +49-391-81 90 99 0
Roentgenstr. 13                     Fax:    +49-391-81 90 99 299
39108 Magdeburg                     Email:  i...@travelping.com
GERMANY                             Web:    http://www.travelping.com

Company Registration: Amtsgericht Stendal        Reg No.:   HRB 10578
Geschaeftsfuehrer: Holger Winkelmann          VAT ID No.: DE236673780
---------------------------------------------------------------------
diff --git a/src/vnet/session-apps/http_server.c b/src/vnet/session-apps/http_server.c
index 79c2d4a7b..41001f8bf 100644
--- a/src/vnet/session-apps/http_server.c
+++ b/src/vnet/session-apps/http_server.c
@@ -96,6 +96,15 @@ static const char *http_response =
     "Pragma: no-cache\r\n"
     "Content-Length: %d\r\n\r\n%s";
 
+static const char *http_redirect =
+  "HTTP/1.1 302 OK\r\n"
+  "Location: %v\r\n"
+  "Content-Type: text/html\r\n"
+  "Cache-Control: private, no-cache, must-revalidate\r\n"
+  "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n"
+  "Connection: close\r\n"
+  "Pragma: no-cache\r\n" "Content-Length: %d\r\n\r\n%s";
+
 static const char *http_error_template =
     "HTTP/1.1 %s\r\n"
     "Content-Type: text/html\r\n"
@@ -416,6 +425,10 @@ out:
   /* Cleanup */
   vec_free (request);
   hsm->rx_buf[s->thread_index] = request;
+
+  clib_warning("Session Disconnect");
+  stream_session_disconnect (s);
+
   return 0;
 }
 
@@ -585,6 +598,7 @@ http_server_create_command_fn (vlib_main_t * vm,
   http_server_main_t *hsm = &http_server_main;
   int rv, is_static = 0;
   u64 seg_size;
+  u8 *redirect = NULL;
   u8 *html;
 
   hsm->prealloc_fifos = 0;
@@ -594,6 +608,8 @@ http_server_create_command_fn (vlib_main_t * vm,
     {
       if (unformat (input, "static"))
 	is_static = 1;
+      if (unformat (input, "redirect %v", &redirect))
+	;
       else if (unformat (input, "prealloc-fifos %d", &hsm->prealloc_fifos))
 	;
       else if (unformat (input, "private-segment-size %U",
@@ -620,7 +636,14 @@ http_server_create_command_fn (vlib_main_t * vm,
 
   vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
 
-  if (is_static)
+  if (redirect)
+    {
+      http_server_session_cb_vft.builtin_app_rx_callback =
+	http_server_rx_callback_static;
+      html = format (0, html_header_static);
+      static_http = format (0, http_redirect, redirect, vec_len (html), html);
+    }
+  else if (is_static)
     {
       http_server_session_cb_vft.builtin_app_rx_callback =
 	http_server_rx_callback_static;
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11370): https://lists.fd.io/g/vpp-dev/message/11370
Mute This Topic: https://lists.fd.io/mt/19343385/21656
Mute #vnet: https://lists.fd.io/mk?hashtag=vnet&subid=1480452
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to