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.29 by pcg, Sun Mar 13 12:40:20 2005 UTC vs.
Revision 1.46 by pcg, Thu Dec 6 00:35:29 2007 UTC

14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with gvpe; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/ 20*/
21
22// TODO: EDNS0 option to increase dns mtu?
23// TODO: re-write dns packet parsing/creation using a safe mem-buffer
24// to ensure no buffer overflows or similar problems.
21 25
22#include "config.h" 26#include "config.h"
23 27
24#if ENABLE_DNS 28#if ENABLE_DNS
25 29
38#include <unistd.h> 42#include <unistd.h>
39#include <fcntl.h> 43#include <fcntl.h>
40 44
41#include <map> 45#include <map>
42 46
47#include <cstdio> /* bug in libgmp: gmp.h relies on cstdio being included */
43#include <gmp.h> 48#include <gmp.h>
44 49
45#include "netcompat.h" 50#include "netcompat.h"
46 51
47#include "vpn.h" 52#include "vpn.h"
48 53
49#define MIN_POLL_INTERVAL .02 // how often to poll minimally when the server has data
50#define MAX_POLL_INTERVAL 6. // how often to poll minimally when the server has no data 54#define MAX_POLL_INTERVAL 5. // how often to poll minimally when the server has no data
51#define ACTIVITY_INTERVAL 5. 55#define ACTIVITY_INTERVAL 5.
52 56
53#define INITIAL_TIMEOUT 0.1 // retry timeouts 57#define INITIAL_TIMEOUT 0.1 // retry timeouts
54#define INITIAL_SYN_TIMEOUT 10. // retry timeout for initial syn 58#define INITIAL_SYN_TIMEOUT 2. // retry timeout for initial syn
55 59
56#define MIN_SEND_INTERVAL 0.01 // wait at least this time between sending requests
57#define MAX_SEND_INTERVAL 2. // optimistic? 60#define MAX_SEND_INTERVAL 2. // optimistic?
58 61
59#define LATENCY_FACTOR 0.5 // RTT * LATENCY_FACTOR == sending rate
60#define MAX_OUTSTANDING 100 // max. outstanding requests
61#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog 62#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog
62#define MAX_BACKLOG (100*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE 63#define MAX_BACKLOG (64*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE
63 64
64#define MAX_DOMAIN_SIZE 240 // 255 is legal limit, but bind doesn't compress well 65#define MAX_DOMAIN_SIZE 240 // 255 is legal limit, but bind doesn't compress well
65// 240 leaves about 4 bytes of server reply data 66// 240 leaves about 4 bytes of server reply data
66// every two request bytes less give room for one reply byte 67// every request byte less give room for two reply bytes
67 68
68#define SEQNO_MASK 0x3fff 69#define SEQNO_MASK 0x3fff
69#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) ) 70#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) )
70 71
71#define MAX_LBL_SIZE 63 72#define MAX_LBL_SIZE 63
424 u16 max_size; 425 u16 max_size;
425 u8 seq_cdc; 426 u8 seq_cdc;
426 u8 req_cdc; 427 u8 req_cdc;
427 428
428 u8 rep_cdc; 429 u8 rep_cdc;
430 u8 delay; // time in 0.01s units that the server may delay replying packets
429 u8 r2, r3, r4; 431 u8 r3, r4;
430 432
431 u8 r5, r6, r7, r8; 433 u8 r5, r6, r7, r8;
432 434
433 void reset (int clientid); 435 void reset (int clientid);
434 bool valid (); 436 bool valid ();
452 req_cdc = 62; 454 req_cdc = 62;
453 rep_cdc = 0; 455 rep_cdc = 0;
454 max_size = htons (MAX_PKT_SIZE); 456 max_size = htons (MAX_PKT_SIZE);
455 client = htons (clientid); 457 client = htons (clientid);
456 uid = next_uid++; 458 uid = next_uid++;
459 delay = 0;
457 460
458 r2 = r3 = r4 = 0; 461 r3 = r4 = 0;
459 r4 = r5 = r6 = r7 = 0; 462 r4 = r5 = r6 = r7 = 0;
460} 463}
461 464
462bool dns_cfg::valid () 465bool dns_cfg::valid ()
463{ 466{
467 // although the protocol itself allows for some configurability,
468 // only the following encoding/decoding settings are implemented.
464 return id1 == 'G' 469 return id1 == 'G'
465 && id2 == 'V' 470 && id2 == 'V'
466 && id3 == 'P' 471 && id3 == 'P'
467 && id4 == 'E' 472 && id4 == 'E'
468 && seq_cdc == 26 473 && seq_cdc == 26
552 double min_latency; 557 double min_latency;
553 double poll_interval, send_interval; 558 double poll_interval, send_interval;
554 559
555 vector<dns_rcv *> rcvpq; 560 vector<dns_rcv *> rcvpq;
556 561
557 byte_stream rcvdq; int rcvseq; 562 byte_stream rcvdq; int rcvseq; int repseq;
558 byte_stream snddq; int sndseq; 563 byte_stream snddq; int sndseq;
559 564
560 void time_cb (time_watcher &w); time_watcher tw; 565 inline void time_cb (ev::timer &w, int revents); ev::timer tw;
561 void receive_rep (dns_rcv *r); 566 void receive_rep (dns_rcv *r);
562 567
563 dns_connection (connection *c); 568 dns_connection (connection *c);
564 ~dns_connection (); 569 ~dns_connection ();
565}; 570};
584: dns (dns) 589: dns (dns)
585{ 590{
586 timeout = 0; 591 timeout = 0;
587 retry = 0; 592 retry = 0;
588 seqno = 0; 593 seqno = 0;
589 sent = NOW; 594 sent = ev_now ();
590 stdhdr = false; 595 stdhdr = false;
591 596
592 pkt = new dns_packet; 597 pkt = new dns_packet;
593 598
594 pkt->id = next_id (); 599 pkt->id = next_id ();
625void dns_snd::gen_stream_req (int seqno, byte_stream &stream) 630void dns_snd::gen_stream_req (int seqno, byte_stream &stream)
626{ 631{
627 stdhdr = true; 632 stdhdr = true;
628 this->seqno = seqno; 633 this->seqno = seqno;
629 634
630 timeout = NOW + INITIAL_TIMEOUT; 635 timeout = ev_now () + INITIAL_TIMEOUT;
631 636
632 pkt->flags = htons (DEFAULT_CLIENT_FLAGS); 637 pkt->flags = htons (DEFAULT_CLIENT_FLAGS);
633 pkt->qdcount = htons (1); 638 pkt->qdcount = htons (1);
634 639
635 int offs = 6*2; 640 int offs = 6*2;
670 pkt->len = offs; 675 pkt->len = offs;
671} 676}
672 677
673void dns_snd::gen_syn_req () 678void dns_snd::gen_syn_req ()
674{ 679{
675 timeout = NOW + INITIAL_SYN_TIMEOUT; 680 timeout = ev_now () + INITIAL_SYN_TIMEOUT;
676 681
677 pkt->flags = htons (DEFAULT_CLIENT_FLAGS); 682 pkt->flags = htons (DEFAULT_CLIENT_FLAGS);
678 pkt->qdcount = htons (1); 683 pkt->qdcount = htons (1);
679 684
680 int offs = 6 * 2; 685 int offs = 6 * 2;
719///////////////////////////////////////////////////////////////////////////// 724/////////////////////////////////////////////////////////////////////////////
720 725
721dns_connection::dns_connection (connection *c) 726dns_connection::dns_connection (connection *c)
722: c (c) 727: c (c)
723, rcvdq (MAX_BACKLOG * 2) 728, rcvdq (MAX_BACKLOG * 2)
724, snddq (MAX_BACKLOG * 2) 729, snddq (MAX_BACKLOG)
725, tw (this, &dns_connection::time_cb)
726{ 730{
731 tw.set<dns_connection, &dns_connection::time_cb> (this);
732
727 vpn = c->vpn; 733 vpn = c->vpn;
728 734
729 established = false; 735 established = false;
730 736
731 rcvseq = sndseq = 0; 737 rcvseq = repseq = sndseq = 0;
732 738
733 last_sent = last_received = 0; 739 last_sent = last_received = 0;
734 poll_interval = MIN_POLL_INTERVAL; 740 poll_interval = 0.5; // starting here
735 send_interval = 0.5; // starting rate 741 send_interval = 0.5; // starting rate
736 min_latency = INITIAL_TIMEOUT; 742 min_latency = INITIAL_TIMEOUT;
737} 743}
738 744
739dns_connection::~dns_connection () 745dns_connection::~dns_connection ()
746 752
747void dns_connection::receive_rep (dns_rcv *r) 753void dns_connection::receive_rep (dns_rcv *r)
748{ 754{
749 if (r->datalen) 755 if (r->datalen)
750 { 756 {
751 last_received = NOW; 757 last_received = ev_now ();
752 tw.trigger (); 758 tw ();
753 759
754 poll_interval = send_interval; 760 poll_interval = send_interval;
755 } 761 }
756 else 762 else
757 { 763 {
767 773
768 // find next packet 774 // find next packet
769 for (vector<dns_rcv *>::iterator i = rcvpq.end (); i-- != rcvpq.begin (); ) 775 for (vector<dns_rcv *>::iterator i = rcvpq.end (); i-- != rcvpq.begin (); )
770 if (SEQNO_EQ (rcvseq, (*i)->seqno)) 776 if (SEQNO_EQ (rcvseq, (*i)->seqno))
771 { 777 {
778 //printf ("seqno eq %x %x\n", rcvseq, (*i)->seqno);//D
772 // enter the packet into our input stream 779 // enter the packet into our input stream
773 r = *i; 780 r = *i;
774 781
775 // remove the oldest packet, look forward, as it's oldest first 782 // remove the oldest packet, look forward, as it's oldest first
776 for (vector<dns_rcv *>::iterator j = rcvpq.begin (); j != rcvpq.end (); ++j) 783 for (vector<dns_rcv *>::iterator j = rcvpq.begin (); j != rcvpq.end (); ++j)
777 if (SEQNO_EQ ((*j)->seqno, rcvseq - MAX_WINDOW)) 784 if (SEQNO_EQ ((*j)->seqno, rcvseq - MAX_WINDOW))
778 { 785 {
786 //printf ("seqno RR %x %x\n", (*j)->seqno, rcvseq - MAX_WINDOW);//D
779 delete *j; 787 delete *j;
780 rcvpq.erase (j); 788 rcvpq.erase (j);
781 break; 789 break;
782 } 790 }
783 791
790 } 798 }
791 799
792 while (vpn_packet *pkt = rcvdq.get ()) 800 while (vpn_packet *pkt = rcvdq.get ())
793 { 801 {
794 sockinfo si; 802 sockinfo si;
795 si.host = 0x01010101; si.port = htons (c->conf->id); si.prot = PROT_DNSv4; 803 si.host = htonl (c->conf->id); si.port = 0; si.prot = PROT_DNSv4;
796 804
797 vpn->recv_vpn_packet (pkt, si); 805 vpn->recv_vpn_packet (pkt, si);
798 806
799 delete pkt; 807 delete pkt;
800 } 808 }
854 if (0 < client && client <= conns.size ()) 862 if (0 < client && client <= conns.size ())
855 { 863 {
856 connection *c = conns [client - 1]; 864 connection *c = conns [client - 1];
857 dns_connection *dns = c->dns; 865 dns_connection *dns = c->dns;
858 dns_rcv *rcv; 866 dns_rcv *rcv;
859 bool in_seq;
860 867
861 if (dns) 868 if (dns)
862 { 869 {
863 for (vector<dns_rcv *>::iterator i = dns->rcvpq.end (); i-- != dns->rcvpq.begin (); ) 870 for (vector<dns_rcv *>::iterator i = dns->rcvpq.end (); i-- != dns->rcvpq.begin (); )
864 if (SEQNO_EQ ((*i)->seqno, seqno)) 871 if (SEQNO_EQ ((*i)->seqno, seqno))
875 memcpy (pkt.at (0), r->pkt->at (0), offs = r->pkt->len); 882 memcpy (pkt.at (0), r->pkt->at (0), offs = r->pkt->len);
876 883
877 goto duplicate_request; 884 goto duplicate_request;
878 } 885 }
879 886
880 in_seq = dns->rcvseq == seqno;
881
882 // new packet, queue 887 // new packet, queue
883 rcv = new dns_rcv (seqno, data, datalen); 888 rcv = new dns_rcv (seqno, data, datalen);
884 dns->receive_rep (rcv); 889 dns->receive_rep (rcv);
885 } 890 }
886 891
903 dlen -= qlen; 908 dlen -= qlen;
904 909
905 // only put data into in-order sequence packets, if 910 // only put data into in-order sequence packets, if
906 // we receive out-of-order packets we generate empty 911 // we receive out-of-order packets we generate empty
907 // replies 912 // replies
908 while (dlen > 1 && !dns->snddq.empty () && in_seq) 913 //printf ("%d - %d & %x (=%d) < %d\n", seqno, dns->repseq, SEQNO_MASK, (seqno - dns->repseq) & SEQNO_MASK, MAX_WINDOW);//D
914 if (((seqno - dns->repseq) & SEQNO_MASK) <= MAX_WINDOW)
909 { 915 {
916 dns->repseq = seqno;
917
918 while (dlen > 1 && !dns->snddq.empty ())
919 {
910 int txtlen = dlen <= 255 ? dlen - 1 : 255; 920 int txtlen = dlen <= 255 ? dlen - 1 : 255;
911 921
912 if (txtlen > dns->snddq.size ()) 922 if (txtlen > dns->snddq.size ())
913 txtlen = dns->snddq.size (); 923 txtlen = dns->snddq.size ();
914 924
915 pkt[offs++] = txtlen; 925 pkt[offs++] = txtlen;
916 memcpy (pkt.at (offs), dns->snddq.begin (), txtlen); 926 memcpy (pkt.at (offs), dns->snddq.begin (), txtlen);
917 offs += txtlen; 927 offs += txtlen;
918 dns->snddq.remove (txtlen); 928 dns->snddq.remove (txtlen);
919 929
920 dlen -= txtlen + 1; 930 dlen -= txtlen + 1;
931 }
921 } 932 }
922 933
923 // avoid empty TXT rdata 934 // avoid completely empty TXT rdata
924 if (offs == rdlen_offs) 935 if (offs == rdlen_offs)
925 pkt[offs++] = 0; 936 pkt[offs++] = 0;
926 937
927 slog (L_NOISE, "DNS: snddq %d", dns->snddq.size ()); 938 slog (L_NOISE, "DNS: snddq %d", dns->snddq.size ());
928 } 939 }
1008 { 1019 {
1009 dns_connection *dns = (*i)->dns; 1020 dns_connection *dns = (*i)->dns;
1010 connection *c = dns->c; 1021 connection *c = dns->c;
1011 int seqno = (*i)->seqno; 1022 int seqno = (*i)->seqno;
1012 u8 data[MAXSIZE], *datap = data; 1023 u8 data[MAXSIZE], *datap = data;
1024 //printf ("rcv pkt %x\n", seqno);//D
1013 1025
1014 if ((*i)->retry) 1026 if ((*i)->retry)
1015 { 1027 {
1016 dns->send_interval *= 1.01; 1028 dns->send_interval *= 1.01;
1017 if (dns->send_interval > MAX_SEND_INTERVAL) 1029 if (dns->send_interval > MAX_SEND_INTERVAL)
1022#if 0 1034#if 0
1023 dns->send_interval *= 0.999; 1035 dns->send_interval *= 0.999;
1024#endif 1036#endif
1025 // the latency surely puts an upper bound on 1037 // the latency surely puts an upper bound on
1026 // the minimum send interval 1038 // the minimum send interval
1027 double latency = NOW - (*i)->sent; 1039 double latency = ev_now () - (*i)->sent;
1028 1040
1029 if (latency < dns->min_latency) 1041 if (latency < dns->min_latency)
1030 dns->min_latency = latency; 1042 dns->min_latency = latency;
1031 1043
1032 if (dns->send_interval > dns->min_latency * LATENCY_FACTOR) 1044 if (dns->send_interval > dns->min_latency * conf.dns_overlap_factor)
1033 dns->send_interval = dns->min_latency * LATENCY_FACTOR; 1045 dns->send_interval = dns->min_latency * conf.dns_overlap_factor;
1034 1046
1035 if (dns->send_interval < MIN_SEND_INTERVAL) 1047 if (dns->send_interval < conf.dns_send_interval)
1036 dns->send_interval = MIN_SEND_INTERVAL; 1048 dns->send_interval = conf.dns_send_interval;
1037 } 1049 }
1038 1050
1039 delete *i; 1051 delete *i;
1040 dns_sndpq.erase (i); 1052 dns_sndpq.erase (i);
1041 1053
1146 break; 1158 break;
1147 } 1159 }
1148} 1160}
1149 1161
1150void 1162void
1151vpn::dnsv4_ev (io_watcher &w, short revents) 1163vpn::dnsv4_ev (ev::io &w, int revents)
1152{ 1164{
1153 if (revents & EVENT_READ) 1165 if (revents & EV_READ)
1154 { 1166 {
1155 dns_packet *pkt = new dns_packet; 1167 dns_packet *pkt = new dns_packet;
1156 struct sockaddr_in sa; 1168 struct sockaddr_in sa;
1157 socklen_t sa_len = sizeof (sa); 1169 socklen_t sa_len = sizeof (sa);
1158 1170
1174} 1186}
1175 1187
1176bool 1188bool
1177vpn::send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) 1189vpn::send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos)
1178{ 1190{
1179 int client = ntohs (si.port); 1191 int client = ntohl (si.host);
1180 1192
1181 assert (0 < client && client <= conns.size ()); 1193 assert (0 < client && client <= conns.size ());
1182 1194
1183 connection *c = conns [client - 1]; 1195 connection *c = conns [client - 1];
1184 1196
1185 if (!c->dns) 1197 if (!c->dns)
1186 c->dns = new dns_connection (c); 1198 c->dns = new dns_connection (c);
1187 1199
1188 if (!c->dns->snddq.put (pkt)) 1200 if (c->dns->snddq.put (pkt))
1189 return false;
1190
1191 c->dns->tw.trigger (); 1201 c->dns->tw ();
1192 1202
1203 // always return true even if the buffer overflows
1193 return true; 1204 return true;
1194} 1205}
1195 1206
1196void 1207void
1197connection::dnsv4_reset_connection () 1208connection::dnsv4_reset_connection ()
1200} 1211}
1201 1212
1202#define NEXT(w) do { if (next > (w)) next = w; } while (0) 1213#define NEXT(w) do { if (next > (w)) next = w; } while (0)
1203 1214
1204void 1215void
1205dns_connection::time_cb (time_watcher &w) 1216dns_connection::time_cb (ev::timer &w, int revents)
1206{ 1217{
1207 // servers have to be polled 1218 // servers have to be polled
1208 if (THISNODE->dns_port) 1219 if (THISNODE->dns_port)
1209 return; 1220 return;
1210 1221
1211 // check for timeouts and (re)transmit 1222 // check for timeouts and (re)transmit
1212 tstamp next = NOW + poll_interval; 1223 tstamp next = ev::now () + poll_interval;
1213 dns_snd *send = 0; 1224 dns_snd *send = 0;
1214 1225
1215 for (vector<dns_snd *>::iterator i = vpn->dns_sndpq.begin (); 1226 for (vector<dns_snd *>::iterator i = vpn->dns_sndpq.begin ();
1216 i != vpn->dns_sndpq.end (); 1227 i != vpn->dns_sndpq.end ();
1217 ++i) 1228 ++i)
1218 { 1229 {
1219 dns_snd *r = *i; 1230 dns_snd *r = *i;
1220 1231
1221 if (r->timeout <= NOW) 1232 if (r->timeout <= ev_now ())
1222 { 1233 {
1223 if (!send) 1234 if (!send)
1224 { 1235 {
1225 send = r; 1236 send = r;
1226 1237
1227 r->retry++; 1238 r->retry++;
1228 r->timeout = NOW + (r->retry * min_latency * 8.); 1239 r->timeout = ev_now () + (r->retry * min_latency * conf.dns_timeout_factor);
1240 //printf ("RETRY %x (%d, %f)\n", r->seqno, r->retry, r->timeout - ev_now ());//D
1229 1241
1230 // the following code changes the query section a bit, forcing 1242 // the following code changes the query section a bit, forcing
1231 // the forwarder to generate a new request 1243 // the forwarder to generate a new request
1232 if (r->stdhdr) 1244 if (r->stdhdr)
1233 {
1234 //printf ("reencoded header for ID %d retry %d:%d:%d (%p)\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);
1235 //encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry); 1245 encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry);
1236 }
1237 } 1246 }
1238 } 1247 }
1239 else 1248 else
1240 NEXT (r->timeout); 1249 NEXT (r->timeout);
1241 } 1250 }
1252 1261
1253 cfg.reset (THISNODE->id); 1262 cfg.reset (THISNODE->id);
1254 send->gen_syn_req (); 1263 send->gen_syn_req ();
1255 } 1264 }
1256 } 1265 }
1257 else if (vpn->dns_sndpq.size () < MAX_OUTSTANDING 1266 else if (vpn->dns_sndpq.size () < conf.dns_max_outstanding
1258 && !SEQNO_EQ (rcvseq, sndseq - (MAX_WINDOW - 1))) 1267 && !SEQNO_EQ (rcvseq, sndseq - (MAX_WINDOW - 1)))
1259 { 1268 {
1260 if (last_sent + send_interval <= NOW) 1269 if (last_sent + send_interval <= ev_now ())
1261 { 1270 {
1262 //printf ("sending data request etc.\n"); //D 1271 //printf ("sending data request etc.\n"); //D
1263 if (!snddq.empty () || last_received + 1. > NOW) 1272 if (!snddq.empty () || last_received + 1. > ev_now ())
1264 { 1273 {
1265 poll_interval = send_interval; 1274 poll_interval = send_interval;
1266 NEXT (NOW + send_interval); 1275 NEXT (ev_now () + send_interval);
1267 } 1276 }
1268 1277
1269 send = new dns_snd (this); 1278 send = new dns_snd (this);
1270 send->gen_stream_req (sndseq, snddq); 1279 send->gen_stream_req (sndseq, snddq);
1271 send->timeout = NOW + min_latency * 8.; 1280 send->timeout = ev_now () + min_latency * conf.dns_timeout_factor;
1281 //printf ("SEND %x (%f)\n", send->seqno, send->timeout - ev_now (), min_latency, conf.dns_timeout_factor);//D
1272 1282
1273 sndseq = (sndseq + 1) & SEQNO_MASK; 1283 sndseq = (sndseq + 1) & SEQNO_MASK;
1274 } 1284 }
1275 else 1285 else
1276 NEXT (last_sent + send_interval); 1286 NEXT (last_sent + send_interval);
1280 vpn->dns_sndpq.push_back (send); 1290 vpn->dns_sndpq.push_back (send);
1281 } 1291 }
1282 1292
1283 if (send) 1293 if (send)
1284 { 1294 {
1285 last_sent = NOW; 1295 last_sent = ev_now ();
1286 sendto (vpn->dnsv4_fd, 1296 sendto (vpn->dnsv4_fd,
1287 send->pkt->at (0), send->pkt->len, 0, 1297 send->pkt->at (0), send->pkt->len, 0,
1288 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ()); 1298 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ());
1289 } 1299 }
1290 1300
1291 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%d %d)", 1301 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%d %d)",
1292 poll_interval, send_interval, next - NOW, 1302 poll_interval, send_interval, next - ev_now (),
1293 vpn->dns_sndpq.size (), snddq.size (), 1303 vpn->dns_sndpq.size (), snddq.size (),
1294 rcvpq.size ()); 1304 rcvpq.size ());
1295 1305
1296 // TODO: no idea when this happens, but when next < NOW, we have a problem 1306 // TODO: no idea when this happens, but when next < ev_now (), we have a problem
1307 // doesn't seem to happen anymore
1297 if (next < NOW + 0.001) 1308 if (next < ev_now () + 0.001)
1298 next = NOW + 0.1; 1309 next = ev_now () + 0.1;
1299 1310
1300 w.start (next); 1311 w.start (next - ev_now ());
1301} 1312}
1302 1313
1303#endif 1314#endif
1304 1315

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines