ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn_dns.C
(Generate patch)

Comparing gvpe/src/vpn_dns.C (file contents):
Revision 1.11 by pcg, Fri Mar 4 08:45:24 2005 UTC vs.
Revision 1.17 by pcg, Sat Mar 5 03:47:05 2005 UTC

43 43
44#include "netcompat.h" 44#include "netcompat.h"
45 45
46#include "vpn.h" 46#include "vpn.h"
47 47
48#define MIN_POLL_INTERVAL .2 // how often to poll minimally when the server is having data 48#define MIN_POLL_INTERVAL .02 // how often to poll minimally when the server has data
49#define MAX_POLL_INTERVAL 6. // how often to poll minimally when the server has no data 49#define MAX_POLL_INTERVAL 6. // how often to poll minimally when the server has no data
50#define ACTIVITY_INTERVAL 5. 50#define ACTIVITY_INTERVAL 5.
51 51
52#define INITIAL_TIMEOUT 1. 52#define INITIAL_TIMEOUT 0.1 // retry timeouts
53#define INITIAL_SYN_TIMEOUT 2. 53#define INITIAL_SYN_TIMEOUT 10. // retry timeout for initial syn
54 54
55#define MIN_SEND_INTERVAL 0.001 55#define MIN_SEND_INTERVAL 0.01 // wait at least this time between sending requests
56#define MAX_SEND_INTERVAL 0.5 // optimistic? 56#define MAX_SEND_INTERVAL 0.5 // optimistic?
57 57
58#define MAX_OUTSTANDING 400 // max. outstanding requests 58#define MAX_OUTSTANDING 10 // max. outstanding requests
59#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING 59#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog
60#define MAX_BACKLOG (100*1024) // size of protocol backlog, must be > MAXSIZE 60#define MAX_BACKLOG (100*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE
61 61
62#define MAX_DOMAIN_SIZE 220 // 255 is legal limit, but bind doesn't compress well 62#define MAX_DOMAIN_SIZE 220 // 255 is legal limit, but bind doesn't compress well
63// 240 leaves about 4 bytes of server reply data 63// 240 leaves about 4 bytes of server reply data
64// every two request byte sless give room for one reply byte 64// every two request bytes less give room for one reply byte
65 65
66#define SEQNO_MASK 0xffff 66#define SEQNO_MASK 0x3fff
67#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) ) 67#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) )
68 68
69#define MAX_LBL_SIZE 63 69#define MAX_LBL_SIZE 63
70#define MAX_PKT_SIZE 512 70#define MAX_PKT_SIZE 512
71 71
265 265
266///////////////////////////////////////////////////////////////////////////// 266/////////////////////////////////////////////////////////////////////////////
267 267
268#define HDRSIZE 6 268#define HDRSIZE 6
269 269
270inline void encode_header (char *data, int clientid, int seqno) 270inline void encode_header (char *data, int clientid, int seqno, int retry = 0)
271{ 271{
272 u8 hdr[3] = { clientid, seqno >> 8, seqno }; 272 seqno &= SEQNO_MASK;
273
274 u8 hdr[3] = {
275 clientid,
276 (seqno >> 8) | (retry << 6),
277 seqno,
278 };
273 279
274 assert (clientid < 256); 280 assert (clientid < 256);
275 281
276 cdc26.encode (data, hdr, 3); 282 cdc26.encode (data, hdr, 3);
277} 283}
281 u8 hdr[3]; 287 u8 hdr[3];
282 288
283 cdc26.decode (hdr, data, HDRSIZE); 289 cdc26.decode (hdr, data, HDRSIZE);
284 290
285 clientid = hdr[0]; 291 clientid = hdr[0];
286 seqno = (hdr[1] << 8) | hdr[2]; 292 seqno = ((hdr[1] << 8) | hdr[2]) & SEQNO_MASK;
287} 293}
288 294
289///////////////////////////////////////////////////////////////////////////// 295/////////////////////////////////////////////////////////////////////////////
290 296
291struct byte_stream 297struct byte_stream
320} 326}
321 327
322void byte_stream::remove (int count) 328void byte_stream::remove (int count)
323{ 329{
324 if (count > fill) 330 if (count > fill)
325 abort (); 331 assert (count <= fill);
326 332
327 memmove (data, data + count, fill -= count); 333 memmove (data, data + count, fill -= count);
328} 334}
329 335
330bool byte_stream::put (u8 *data, unsigned int datalen) 336bool byte_stream::put (u8 *data, unsigned int datalen)
350 return true; 356 return true;
351} 357}
352 358
353vpn_packet *byte_stream::get () 359vpn_packet *byte_stream::get ()
354{ 360{
355 int len = (data [0] << 8) | data [1]; 361 unsigned int len = (data [0] << 8) | data [1];
356 362
357 if (len > MAXSIZE && fill >= 2) 363 if (len > MAXSIZE && fill >= 2)
358 abort (); // TODO handle this gracefully, connection reset 364 assert (len <= MAXSIZE || fill < 2); // TODO handle this gracefully, connection reset
359 365
360 if (fill < len + 2) 366 if (fill < len + 2)
361 return 0; 367 return 0;
362 368
363 vpn_packet *pkt = new vpn_packet; 369 vpn_packet *pkt = new vpn_packet;
422 428
423 version = 1; 429 version = 1;
424 430
425 rrtype = RR_TYPE_TXT; 431 rrtype = RR_TYPE_TXT;
426 flags = 0; 432 flags = 0;
427 def_ttl = 0; 433 def_ttl = 1;
428 rcv_cdc = 0; 434 rcv_cdc = 0;
429 snd_cdc = 62; 435 snd_cdc = 62;
430 max_size = ntohs (MAX_PKT_SIZE); 436 max_size = ntohs (MAX_PKT_SIZE);
431 client = ntohs (clientid); 437 client = ntohs (clientid);
432 uid = next_uid++; 438 uid = next_uid++;
499 dns_packet *pkt; 505 dns_packet *pkt;
500 tstamp timeout, sent; 506 tstamp timeout, sent;
501 int retry; 507 int retry;
502 struct dns_connection *dns; 508 struct dns_connection *dns;
503 int seqno; 509 int seqno;
510 bool stdhdr;
504 511
505 void gen_stream_req (int seqno, byte_stream &stream); 512 void gen_stream_req (int seqno, byte_stream &stream);
506 void gen_syn_req (const dns_cfg &cfg); 513 void gen_syn_req (const dns_cfg &cfg);
507 514
508 dns_snd (dns_connection *dns); 515 dns_snd (dns_connection *dns);
528{ 535{
529 timeout = 0; 536 timeout = 0;
530 retry = 0; 537 retry = 0;
531 seqno = 0; 538 seqno = 0;
532 sent = NOW; 539 sent = NOW;
540 stdhdr = false;
533 541
534 pkt = new dns_packet; 542 pkt = new dns_packet;
535 543
536 pkt->id = next_id (); 544 pkt->id = next_id ();
537} 545}
564 } 572 }
565} 573}
566 574
567void dns_snd::gen_stream_req (int seqno, byte_stream &stream) 575void dns_snd::gen_stream_req (int seqno, byte_stream &stream)
568{ 576{
577 stdhdr = true;
569 this->seqno = seqno; 578 this->seqno = seqno;
570 579
571 timeout = NOW + INITIAL_TIMEOUT; 580 timeout = NOW + INITIAL_TIMEOUT;
572 581
573 pkt->flags = htons (DEFAULT_CLIENT_FLAGS); 582 pkt->flags = htons (DEFAULT_CLIENT_FLAGS);
668 677
669 bool established; 678 bool established;
670 679
671 tstamp last_received; 680 tstamp last_received;
672 tstamp last_sent; 681 tstamp last_sent;
682 double last_latency;
673 double poll_interval, send_interval; 683 double poll_interval, send_interval;
674 684
675 vector<dns_rcv *> rcvpq; 685 vector<dns_rcv *> rcvpq;
676 686
677 byte_stream rcvdq; int rcvseq; 687 byte_stream rcvdq; int rcvseq;
696 706
697 rcvseq = sndseq = 0; 707 rcvseq = sndseq = 0;
698 708
699 last_sent = last_received = 0; 709 last_sent = last_received = 0;
700 poll_interval = MIN_POLL_INTERVAL; 710 poll_interval = MIN_POLL_INTERVAL;
701 send_interval = 0.2; // starting rate 711 send_interval = 0.5; // starting rate
712 last_latency = INITIAL_TIMEOUT;
702} 713}
703 714
704dns_connection::~dns_connection () 715dns_connection::~dns_connection ()
705{ 716{
706 for (vector<dns_rcv *>::iterator i = rcvpq.begin (); 717 for (vector<dns_rcv *>::iterator i = rcvpq.begin ();
714 if (r->datalen) 725 if (r->datalen)
715 { 726 {
716 last_received = NOW; 727 last_received = NOW;
717 tw.trigger (); 728 tw.trigger ();
718 729
719 poll_interval *= 0.99; 730 poll_interval = send_interval;
720 if (poll_interval > MIN_POLL_INTERVAL)
721 poll_interval = MIN_POLL_INTERVAL;
722 } 731 }
723 else 732 else
724 { 733 {
725 poll_interval *= 1.1; 734 poll_interval *= 1.5;
726 if (poll_interval > MAX_POLL_INTERVAL) 735 if (poll_interval > MAX_POLL_INTERVAL)
727 poll_interval = MAX_POLL_INTERVAL; 736 poll_interval = MAX_POLL_INTERVAL;
728 } 737 }
729 738
730 rcvpq.push_back (r); 739 rcvpq.push_back (r);
748 } 757 }
749 758
750 rcvseq = (rcvseq + 1) & SEQNO_MASK; 759 rcvseq = (rcvseq + 1) & SEQNO_MASK;
751 760
752 if (!rcvdq.put (r->data, r->datalen)) 761 if (!rcvdq.put (r->data, r->datalen))
762 {
763 slog (L_ERR, "DNS: !rcvdq.put (r->data, r->datalen)");
753 abort (); // MUST never overflow, can be caused by data corruption, TODO 764 abort (); // MUST never overflow, can be caused by data corruption, TODO
765 }
754 766
755 while (vpn_packet *pkt = rcvdq.get ()) 767 while (vpn_packet *pkt = rcvdq.get ())
756 { 768 {
757 sockinfo si; 769 sockinfo si;
758 si.host = 0; si.port = 0; si.prot = PROT_DNSv4; 770 si.host = 0; si.port = 0; si.prot = PROT_DNSv4;
788 pkt.qdcount = htons (1); 800 pkt.qdcount = htons (1);
789 pkt.ancount = 0; 801 pkt.ancount = 0;
790 pkt.nscount = 0; // should be self, as other nameservers reply like this 802 pkt.nscount = 0; // should be self, as other nameservers reply like this
791 pkt.arcount = 0; // a record for self, as other nameservers reply like this 803 pkt.arcount = 0; // a record for self, as other nameservers reply like this
792 804
793 pkt.flags = htons (DEFAULT_SERVER_FLAGS | FLAG_RCODE_NXDOMAIN); 805 pkt.flags = htons (DEFAULT_SERVER_FLAGS | FLAG_RCODE_SERVFAIL);
794 806
795 int dlen = strlen (THISNODE->domain); 807 int dlen = strlen (THISNODE->domain);
796 808
797 if (qclass == RR_CLASS_IN 809 if (qclass == RR_CLASS_IN
798 && qlen > dlen + 1 810 && qlen > dlen + 1
817 if (0 < client && client <= conns.size ()) 829 if (0 < client && client <= conns.size ())
818 { 830 {
819 connection *c = conns [client - 1]; 831 connection *c = conns [client - 1];
820 dns_connection *dns = c->dns; 832 dns_connection *dns = c->dns;
821 dns_rcv *rcv; 833 dns_rcv *rcv;
834 bool in_seq;
822 835
823 if (dns) 836 if (dns)
824 { 837 {
825 for (vector<dns_rcv *>::iterator i = dns->rcvpq.end (); i-- != dns->rcvpq.begin (); ) 838 for (vector<dns_rcv *>::iterator i = dns->rcvpq.end (); i-- != dns->rcvpq.begin (); )
826 if (SEQNO_EQ ((*i)->seqno, seqno)) 839 if (SEQNO_EQ ((*i)->seqno, seqno))
827 { 840 {
828 // already seen that request: simply reply with the cached reply 841 // already seen that request: simply reply with the cached reply
829 dns_rcv *r = *i; 842 dns_rcv *r = *i;
830 843
831 printf ("DUPLICATE %d\n", htons (r->pkt->id));//D 844 slog (L_DEBUG, "DNS: duplicate packet received ID %d, SEQ %d", htons (r->pkt->id), seqno);
845
846 // refresh header & id, as the retry count could have changed
847 memcpy (r->pkt->at (6 * 2 + 1), pkt.at (6 * 2 + 1), HDRSIZE);
848 r->pkt->id = pkt.id;
832 849
833 memcpy (pkt.at (0), r->pkt->at (0), offs = r->pkt->len); 850 memcpy (pkt.at (0), r->pkt->at (0), offs = r->pkt->len);
834 pkt.id = r->pkt->id; 851
835 goto duplicate_request; 852 goto duplicate_request;
836 } 853 }
854
855 in_seq = dns->rcvseq == seqno;
837 856
838 // new packet, queue 857 // new packet, queue
839 rcv = new dns_rcv (seqno, data, datalen); 858 rcv = new dns_rcv (seqno, data, datalen);
840 dns->receive_rep (rcv); 859 dns->receive_rep (rcv);
841 } 860 }
854 // bind doesn't compress well, so reduce further by one label length 873 // bind doesn't compress well, so reduce further by one label length
855 dlen -= qlen; 874 dlen -= qlen;
856 875
857 if (dns) 876 if (dns)
858 { 877 {
878 // only put data into in-order sequence packets, if
879 // we receive out-of-order packets we generate empty
880 // replies
859 while (dlen > 1 && !dns->snddq.empty ()) 881 while (dlen > 1 && !dns->snddq.empty () && in_seq)
860 { 882 {
861 int txtlen = dlen <= 255 ? dlen - 1 : 255; 883 int txtlen = dlen <= 255 ? dlen - 1 : 255;
862 884
863 if (txtlen > dns->snddq.size ()) 885 if (txtlen > dns->snddq.size ())
864 txtlen = dns->snddq.size (); 886 txtlen = dns->snddq.size ();
872 } 894 }
873 895
874 // avoid empty TXT rdata 896 // avoid empty TXT rdata
875 if (offs == rdlen_offs) 897 if (offs == rdlen_offs)
876 pkt[offs++] = 0; 898 pkt[offs++] = 0;
899
900 slog (L_NOISE, "DNS: snddq %d", dns->snddq.size ());
877 } 901 }
878 else 902 else
879 { 903 {
880 // send RST 904 // send RST
881 pkt [offs++] = CMD_IP_1; pkt [offs++] = CMD_IP_2; pkt [offs++] = CMD_IP_3; 905 pkt [offs++] = CMD_IP_1; pkt [offs++] = CMD_IP_2; pkt [offs++] = CMD_IP_3;
912 pkt [offs++] = RR_CLASS_IN >> 8; pkt [offs++] = RR_CLASS_IN; // class 936 pkt [offs++] = RR_CLASS_IN >> 8; pkt [offs++] = RR_CLASS_IN; // class
913 pkt [offs++] = 0; pkt [offs++] = 0; 937 pkt [offs++] = 0; pkt [offs++] = 0;
914 pkt [offs++] = 0; pkt [offs++] = cfg.def_ttl; // TTL 938 pkt [offs++] = 0; pkt [offs++] = cfg.def_ttl; // TTL
915 pkt [offs++] = 0; pkt [offs++] = 4; // rdlength 939 pkt [offs++] = 0; pkt [offs++] = 4; // rdlength
916 940
917 slog (L_INFO, _("DNS tunnel: client %d tries to connect"), client); 941 slog (L_INFO, _("DNS: client %d tries to connect"), client);
918 942
919 pkt [offs++] = CMD_IP_1; pkt [offs++] = CMD_IP_2; pkt [offs++] = CMD_IP_3; 943 pkt [offs++] = CMD_IP_1; pkt [offs++] = CMD_IP_2; pkt [offs++] = CMD_IP_3;
920 pkt [offs++] = CMD_IP_REJ; 944 pkt [offs++] = CMD_IP_REJ;
921 945
922 if (0 < client && client <= conns.size ()) 946 if (0 < client && client <= conns.size ())
953 i != dns_sndpq.end (); 977 i != dns_sndpq.end ();
954 ++i) 978 ++i)
955 if ((*i)->pkt->id == pkt.id) 979 if ((*i)->pkt->id == pkt.id)
956 { 980 {
957 dns_connection *dns = (*i)->dns; 981 dns_connection *dns = (*i)->dns;
982 connection *c = dns->c;
958 int seqno = (*i)->seqno; 983 int seqno = (*i)->seqno;
959 u8 data[MAXSIZE], *datap = data; 984 u8 data[MAXSIZE], *datap = data;
960 985
961 if ((*i)->retry) 986 if ((*i)->retry)
962 { 987 {
963 dns->send_interval *= 1.01; 988 dns->send_interval *= 1.01;
964 if (dns->send_interval < MAX_SEND_INTERVAL) 989 if (dns->send_interval > MAX_SEND_INTERVAL)
965 dns->send_interval = MAX_SEND_INTERVAL; 990 dns->send_interval = MAX_SEND_INTERVAL;
966 } 991 }
967 else 992 else
968 { 993 {
994#if 1
969 dns->send_interval *= 0.99; 995 dns->send_interval *= 0.999;
996#endif
970 if (dns->send_interval < MIN_SEND_INTERVAL) 997 if (dns->send_interval < MIN_SEND_INTERVAL)
971 dns->send_interval = MIN_SEND_INTERVAL; 998 dns->send_interval = MIN_SEND_INTERVAL;
972 999
973 // the latency surely puts an upper bound on 1000 // the latency surely puts an upper bound on
974 // the minimum send interval 1001 // the minimum send interval
1002 double latency = NOW - (*i)->sent;
1003 dns->last_latency = latency;
1004
975 if (dns->send_interval > NOW - (*i)->sent) 1005 if (dns->send_interval > latency)
976 dns->send_interval = NOW - (*i)->sent; 1006 dns->send_interval = latency;
977 } 1007 }
978 1008
979 delete *i; 1009 delete *i;
980 dns_sndpq.erase (i); 1010 dns_sndpq.erase (i);
981 1011
1031 1061
1032 if (ip [0] == CMD_IP_1 1062 if (ip [0] == CMD_IP_1
1033 && ip [1] == CMD_IP_2 1063 && ip [1] == CMD_IP_2
1034 && ip [2] == CMD_IP_3) 1064 && ip [2] == CMD_IP_3)
1035 { 1065 {
1036 slog (L_TRACE, _("got tunnel meta command %02x"), ip [3]); 1066 slog (L_TRACE, _("DNS: got tunnel meta command %02x"), ip [3]);
1037 1067
1038 if (ip [3] == CMD_IP_RST) 1068 if (ip [3] == CMD_IP_RST)
1039 { 1069 {
1040 slog (L_DEBUG, _("got tunnel RST request")); 1070 slog (L_DEBUG, _("DNS: got tunnel RST request"));
1041 1071
1042 connection *c = dns->c;
1043 delete c->dns; c->dns = 0; 1072 delete dns; c->dns = 0;
1044 1073
1045 return; 1074 return;
1046 } 1075 }
1047 else if (ip [3] == CMD_IP_SYN) 1076 else if (ip [3] == CMD_IP_SYN)
1077 {
1078 slog (L_DEBUG, _("DNS: got tunnel SYN reply, server likes us."));
1048 dns->established = true; 1079 dns->established = true;
1080 }
1081 else if (ip [3] == CMD_IP_REJ)
1082 {
1083 slog (L_DEBUG, _("DNS: got tunnel REJ reply, server does not like us, aborting."));
1084 abort ();
1085 }
1049 else 1086 else
1050 slog (L_INFO, _("got unknown meta command %02x"), ip [3]); 1087 slog (L_INFO, _("DNS: got unknown meta command %02x"), ip [3]);
1051 } 1088 }
1052 else 1089 else
1053 slog (L_INFO, _("got spurious a record %d.%d.%d.%d"), 1090 slog (L_INFO, _("DNS: got spurious a record %d.%d.%d.%d"),
1054 ip [0], ip [1], ip [2], ip [3]); 1091 ip [0], ip [1], ip [2], ip [3]);
1055 1092
1056 return; 1093 return;
1057 } 1094 }
1058 1095
1059 int client, rseqno; 1096 int client, rseqno;
1060 decode_header (qname, client, rseqno); 1097 decode_header (qname, client, rseqno);
1061 1098
1062 if (client != THISNODE->id) 1099 if (client != THISNODE->id)
1063 { 1100 {
1064 slog (L_INFO, _("got dns tunnel response with wrong clientid, ignoring")); 1101 slog (L_INFO, _("DNS: got dns tunnel response with wrong clientid, ignoring"));
1065 datap = 0; 1102 datap = 0;
1066 } 1103 }
1067 else if (rseqno != seqno) 1104 else if (rseqno != seqno)
1068 { 1105 {
1069 slog (L_DEBUG, _("got dns tunnel response with wrong seqno, badly caching nameserver?")); 1106 slog (L_DEBUG, _("DNS: got dns tunnel response with wrong seqno, badly caching nameserver?"));
1070 datap = 0; 1107 datap = 0;
1071 } 1108 }
1072 } 1109 }
1073 } 1110 }
1074 1111
1118 dns->tw.trigger (); 1155 dns->tw.trigger ();
1119 1156
1120 return true; 1157 return true;
1121} 1158}
1122 1159
1160void
1161connection::dnsv4_reset_connection ()
1162{
1163 //delete dns; dns = 0; //TODO
1164}
1165
1123#define NEXT(w) do { if (next > (w)) next = w; } while (0) 1166#define NEXT(w) do { if (next > (w)) next = w; } while (0)
1124 1167
1125void 1168void
1126dns_connection::time_cb (time_watcher &w) 1169dns_connection::time_cb (time_watcher &w)
1127{ 1170{
1144 if (!send) 1187 if (!send)
1145 { 1188 {
1146 send = r; 1189 send = r;
1147 1190
1148 r->retry++; 1191 r->retry++;
1149 r->timeout = NOW + r->retry; 1192 r->timeout = NOW + (r->retry * last_latency * 8.);
1193
1194 // the following code changes the query section a bit, forcing
1195 // the forwarder to generate a new request
1196 if (r->stdhdr)
1197 {
1198 //printf ("reencoded header for ID %d retry %d:%d:%d\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);printf ("reencoded header for ID %d retry %d:%d:%d\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);
1199 //encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry);
1200 }
1150 } 1201 }
1151 } 1202 }
1152 else 1203 else
1153 NEXT (r->timeout); 1204 NEXT (r->timeout);
1154 } 1205 }
1167 1218
1168 cfg.reset (THISNODE->id); 1219 cfg.reset (THISNODE->id);
1169 send->gen_syn_req (cfg); 1220 send->gen_syn_req (cfg);
1170 } 1221 }
1171 } 1222 }
1172 else if (vpn->dns_sndpq.size () < MAX_OUTSTANDING) 1223 else if (vpn->dns_sndpq.size () < MAX_OUTSTANDING
1224 && !SEQNO_EQ (rcvseq, sndseq - (MAX_WINDOW - 1)))
1173 { 1225 {
1226 if (!snddq.empty ())
1227 {
1228 poll_interval = send_interval;
1229 NEXT (NOW + send_interval);
1230 }
1231
1174 send = new dns_snd (this); 1232 send = new dns_snd (this);
1175 send->gen_stream_req (sndseq, snddq); 1233 send->gen_stream_req (sndseq, snddq);
1234 send->timeout = NOW + last_latency * 8.;
1176 1235
1177 sndseq = (sndseq + 1) & SEQNO_MASK; 1236 sndseq = (sndseq + 1) & SEQNO_MASK;
1178 } 1237 }
1179 1238
1180 if (send) 1239 if (send)
1182 } 1241 }
1183 1242
1184 if (send) 1243 if (send)
1185 { 1244 {
1186 last_sent = NOW; 1245 last_sent = NOW;
1187
1188 sendto (vpn->dnsv4_fd, 1246 sendto (vpn->dnsv4_fd,
1189 send->pkt->at (0), send->pkt->len, 0, 1247 send->pkt->at (0), send->pkt->len, 0,
1190 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ()); 1248 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ());
1191 } 1249 }
1192 } 1250 }
1193 else 1251 else
1194 NEXT (last_sent + send_interval); 1252 NEXT (last_sent + send_interval);
1195 1253
1196 //printf ("pi %f si %f N %f (%d:%d)\n", poll_interval, send_interval, next - NOW, vpn->dns_sndpq.size (), snddq.size ()); 1254 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%d)",
1255 poll_interval, send_interval, next - NOW,
1256 vpn->dns_sndpq.size (), snddq.size ());
1197 1257
1198 // TODO: no idea when this happens, but when next < NOW, we have a problem 1258 // TODO: no idea when this happens, but when next < NOW, we have a problem
1199 if (next < NOW + 0.0001) 1259 if (next < NOW + 0.0001)
1200 next = NOW + 0.1; 1260 next = NOW + 0.1;
1201 1261

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines