~ubuntu-branches/ubuntu/wily/maradns/wily-proposed

« back to all changes in this revision

Viewing changes to deadwood-3.2.07/update/3.2.06/deadwood-3.2.05-Server-fail.patch

  • Committer: Package Import Robot
  • Author(s): Dariusz Dwornikowski, Tomasz Buchert, Dariusz Dwornikowski
  • Date: 2015-03-27 18:34:08 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20150327183408-wnfachdkdjt96yu6
Tags: 2.0.11-1
[ Tomasz Buchert ]
* Imported Upstream version 2.0.11

[ Dariusz Dwornikowski ]
* d/patches: 
  - refreshed all patches for new deadwood version
  - removed generating of random prime on build (Closes: #785536) 
* d/rules: date taken from changelog (Closes: #785535)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
If there was a glueless NS record, Deadwood started processing the NS
 
2
referral, but sent a server fail to the DNS thingy (instead of sending
 
3
nothing until the NS record is worked out).
 
4
 
 
5
This patch fixes that.
 
6
 
 
7
diff --git a/deadwood-github/src/DwSocket.h b/deadwood-github/src/DwSocket.h
 
8
index f07f150..4722361 100644
 
9
--- a/deadwood-github/src/DwSocket.h
 
10
+++ b/deadwood-github/src/DwSocket.h
 
11
@@ -317,7 +317,7 @@ dw_str *make_dns_packet(dw_str *question, dw_str *answer, int32_t id);
 
12
 
 
13
 /* Given a remote number, a C-string with the packet to send them, and
 
14
  * the length of that string, make a connection to a remote server */
 
15
-void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
16
+int make_remote_connection(int32_t n, unsigned char *packet, int len,
 
17
         dw_str *query, SOCKET x_socket_num);
 
18
 
 
19
 /* Forward a remote reply back to the client */
 
20
diff --git a/deadwood-github/src/DwUdpSocket.c b/deadwood-github/src/DwUdpSocket.c
 
21
index 16f3242..d11f5d6 100644
 
22
--- a/deadwood-github/src/DwUdpSocket.c
 
23
+++ b/deadwood-github/src/DwUdpSocket.c
 
24
@@ -176,7 +176,7 @@ SOCKET setup_server(sockaddr_all_T *server, ip_addr_T *addr) {
 
25
 
 
26
 /* Given a remote number, a C-string with the packet to send them, and
 
27
  * the length of that string, make a connection to a remote server */
 
28
-void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
29
+int make_remote_connection(int32_t n, unsigned char *packet, int len,
 
30
      dw_str *query, SOCKET x_socket_num) {
 
31
         sockaddr_all_T server;
 
32
         SOCKET s = 0;
 
33
@@ -187,13 +187,13 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
34
 
 
35
         if(rem[n].socket != x_socket_num || /* Already used (sanity check) */
 
36
            rem[n].recurse_depth > 32) { /* Infinite recursion protection */
 
37
-                return;
 
38
+                return -1;
 
39
         }
 
40
 
 
41
         /* Get a random query ID to send to the remote server */
 
42
         rnum = set_dns_qid(packet,len,dwr_rng(rng_seed));
 
43
         if(rnum == -1) {
 
44
-                return;
 
45
+                return -1;
 
46
         }
 
47
 
 
48
         /* Get IP of remote server and open a socket to them */
 
49
@@ -211,15 +211,15 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
50
         }
 
51
         dw_log_ip("Making connection to IP",&addr,128);
 
52
         if(addr.len == 0) { /* Failed to get upstream IP */
 
53
-                return;
 
54
+                return -1;
 
55
         } else if(addr.len == 4 || addr.len == 16) { /* IPv4/IPv6 IP */
 
56
                 s = setup_server(&server,&addr);
 
57
         } else if(addr.glueless != 0) { /* Glueless NS referral */
 
58
                 dwx_do_ns_glueless(addr,n);
 
59
-                return;
 
60
+                return 2;
 
61
         }
 
62
         if(s == INVALID_SOCKET) { /* Failed to make socket */
 
63
-                return;
 
64
+                return -1;
 
65
         }
 
66
 
 
67
 #ifdef IPV6
 
68
@@ -234,7 +234,7 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
69
             (connect(s, (struct sockaddr *)&server, inet_len) == -1) ||
 
70
             (send(s,packet,len,0) < 0)) {
 
71
                 closesocket(s);
 
72
-                return;
 
73
+                return -1;
 
74
         }
 
75
 
 
76
         /* OK, now note the pending connection */
 
77
@@ -244,6 +244,7 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
 
78
         }
 
79
         rem[n].socket = s;
 
80
         rem[n].remote_id = rnum;
 
81
+       return 1;
 
82
 }
 
83
 
 
84
 /* Send a server failure back to the client when the server is overloaded.
 
85
@@ -324,21 +325,24 @@ void zap_inflight(dw_str *query) {
 
86
 }
 
87
 
 
88
 /* Make a new UDP connection on remote pending connection b */
 
89
-void make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
 
90
+int make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
 
91
         dw_str *answer = 0, *check = 0;
 
92
-        int counter = 0;
 
93
+        int counter = 0, z = 0;
 
94
 
 
95
         /* Make a new remote connection */
 
96
         if(rem[b].socket != INVALID_SOCKET) { /* Sanity check */
 
97
-                return;
 
98
+                return -1;
 
99
         }
 
100
         rem[b].query = dw_get_dname_type(a,12,len);
 
101
         dwc_lower_case(rem[b].query);
 
102
         rem[b].local = dw_malloc(num_alloc * sizeof(local_T *));
 
103
         if(rem[b].local == 0) {
 
104
-                return;
 
105
+                return -1;
 
106
         }
 
107
-        make_remote_connection(b,a,len,rem[b].query,INVALID_SOCKET);
 
108
+        z = make_remote_connection(b,a,len,rem[b].query,INVALID_SOCKET);
 
109
+       if(z != 1) {
 
110
+               return z;
 
111
+       }
 
112
 
 
113
         for(counter = 0; counter < num_alloc; counter++) {
 
114
                 rem[b].local[counter] = 0;
 
115
@@ -355,6 +359,7 @@ void make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
 
116
                 }
 
117
                 dw_destroy(answer);
 
118
         }
 
119
+       return 1;
 
120
 }
 
121
 
 
122
 /* Send a local DNS request to the upstream (remote) server; this
 
123
@@ -382,7 +387,9 @@ int forward_local_udp_packet(SOCKET sock, int32_t local_id,
 
124
                         return -1;
 
125
                 } else { /* Create new connection */
 
126
                         reset_rem(b);
 
127
-                        make_new_udp_connect(b,a,len,num_alloc);
 
128
+                        if(make_new_udp_connect(b,a,len,num_alloc) == 2) {
 
129
+                               return 0;
 
130
+                       }
 
131
                 }
 
132
         } else { /* Add new local to already inflight connection */
 
133
                 if(rem[b].num_locals >= num_alloc - 2) {
 
134