Browse code

Fixed client hang when server don't PUSH (aka the NO_SOUP_FOR_YOU patch)

Solves bug ticket 13
<https://community.openvpn.net/openvpn/ticket/13>

When the client sends PUSH_REQUESTS, it waits until the server sends PUSH_REPLY.
If the server do not have anything to push to the client nothing happens. The
client will then regularly send new PUSH_REQUESTS until it gets an answer, which
results in not completing the connection negotiation.

This patch makes the server send an empty PUSH_REPLY when it has nothing to more
to push to the client.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: James Yonan <james@openvpn.net>

David Sommerseth authored on 2010/06/13 07:35:55
Showing 1 changed files
... ...
@@ -177,6 +177,7 @@ send_push_reply (struct context *c)
177 177
   static char cmd[] = "PUSH_REPLY";
178 178
   const int extra = 64; /* extra space for possible trailing ifconfig and push-continuation */
179 179
   const int safe_cap = BCAP (&buf) - extra;
180
+  bool push_sent = false;
180 181
 
181 182
   buf_printf (&buf, cmd);
182 183
 
... ...
@@ -192,6 +193,7 @@ send_push_reply (struct context *c)
192 192
 		const bool status = send_control_channel_string (c, BSTR (&buf), D_PUSH);
193 193
 		if (!status)
194 194
 		  goto fail;
195
+		push_sent = true;
195 196
 		multi_push = true;
196 197
 		buf_reset_len (&buf);
197 198
 		buf_printf (&buf, cmd);
... ...
@@ -218,6 +220,21 @@ send_push_reply (struct context *c)
218 218
     {
219 219
       const bool status = send_control_channel_string (c, BSTR (&buf), D_PUSH);
220 220
       if (!status)
221
+        goto fail;
222
+      push_sent = true;
223
+    }
224
+
225
+  /* If nothing have been pushed, send an empty push,
226
+   * as the client is expecting a response
227
+   */
228
+  if (!push_sent)
229
+    {
230
+      bool status = false;
231
+
232
+      buf_reset_len (&buf);
233
+      buf_printf (&buf, cmd);
234
+      status = send_control_channel_string (c, BSTR(&buf), D_PUSH);
235
+      if (!status)
221 236
 	goto fail;
222 237
     }
223 238