From 9918b996343535f3c1354bf2977a5a2b6ccc31a3 Mon Sep 17 00:00:00 2001 From: MissValeska Date: Tue, 18 Mar 2014 18:29:15 -0700 Subject: [PATCH] We are having a LOT of weird issues now, I need to do a lot of debugging, Please help. --- src/dns_wrapper.c | 23 ++++++++++++----------- src/inet.c | 10 +++++++--- src/mark.c | 1 + 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/dns_wrapper.c b/src/dns_wrapper.c index 5970997..091b8df 100644 --- a/src/dns_wrapper.c +++ b/src/dns_wrapper.c @@ -2,7 +2,7 @@ * (c) Copyright 2005 Andrea Lo Pumo aka AlpT * * This source code is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published + * modify it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * @@ -20,7 +20,7 @@ * * The DNS wrapper listens to the port 53 for DNS hostname resolution queries, * it then resolves the hostname by using the ANDNA system and sends back the - * resolved ip. In this way, every program can use ANDNA: just set + * resolved ip. In this way, every program can use ANDNA: just set * "nameserver localhost" * in /etc/resolv.conf ;) */ @@ -49,7 +49,7 @@ /* * dns_exec_pkt: resolve the hostname contained in the DNS query and sends - * the reply to from. + * the reply to from. * `passed_argv' is a pointer to a dns_exec_pkt_argv struct. */ void *dns_exec_pkt(void *passed_argv) @@ -77,6 +77,7 @@ void *dns_exec_pkt(void *passed_argv) /* Send the DNS reply */ bytes_sent=inet_sendto(argv.sk, answer_buffer, answer_length, 0, &argv.from, argv.from_len); + error("bytes_sent is: %d argv.sk is: %d answer_buffer is: %s answer_length is: %d argv.from is: %p agrv.from_len is: %p", bytes_sent,argv.sk, answer_buffer, answer_length, argv.from, argv.from_len); if(bytes_sent != answer_length) debug(DBG_SOFT, ERROR_MSG "inet_sendto error: %s", ERROR_POS, strerror(errno)); @@ -103,7 +104,7 @@ void dns_wrapper_daemon(u_short port) #ifdef DEBUG int select_errors=0; #endif - + pthread_attr_init(&t_attr); pthread_attr_setdetachstate(&t_attr, PTHREAD_CREATE_DETACHED); pthread_mutex_init(&dns_exec_lock, 0); @@ -117,10 +118,10 @@ void dns_wrapper_daemon(u_short port) for(;;) { if(!sk) fatal("The dns_wrapper_daemon socket got corrupted"); - + FD_ZERO(&fdset); FD_SET(sk, &fdset); - + ret = select(sk+1, &fdset, NULL, NULL, NULL); if(sigterm_timestamp) /* NetsukukuD has been closed */ @@ -131,7 +132,7 @@ void dns_wrapper_daemon(u_short port) break; select_errors++; #endif - error("dns_wrapper_daemonp: select error: %s", + error("dns_wrapper_daemonp: select error: %s", strerror(errno)); continue; } @@ -141,7 +142,7 @@ void dns_wrapper_daemon(u_short port) setzero(&buf, MAX_DNS_PKT_SZ); setzero(&exec_pkt_argv.from, sizeof(struct sockaddr)); setzero(&exec_pkt_argv, sizeof(struct dns_exec_pkt_argv)); - + exec_pkt_argv.from_len = my_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); @@ -153,14 +154,14 @@ void dns_wrapper_daemon(u_short port) " query pkt aborted!"); continue; } - + /* Exec the pkt in another thread */ exec_pkt_argv.sk=sk; exec_pkt_argv.rpkt_sz=err; exec_pkt_argv.rpkt=buf; - + pthread_mutex_lock(&dns_exec_lock); - pthread_create(&thread, &t_attr, dns_exec_pkt, + pthread_create(&thread, &t_attr, dns_exec_pkt, (void *)&exec_pkt_argv); pthread_mutex_lock(&dns_exec_lock); pthread_mutex_unlock(&dns_exec_lock); diff --git a/src/inet.c b/src/inet.c index fcb496a..6d8b0bd 100644 --- a/src/inet.c +++ b/src/inet.c @@ -1053,17 +1053,21 @@ ssize_t inet_sendto(int s, const void *msg, size_t len, int flags, ssize_t err; fd_set fdset; int ret; - + int errno_int; + if((err=sendto(s, msg, len, flags, to, tolen))==-1) { + errno_int = errno; error("sendto errno: %d err is: %d", errno, err); - switch(errno) + switch(errno_int) { case EMSGSIZE: + error("Packet artificially fragmented: %d", stderr); inet_sendto(s, msg, len/2, flags, to, tolen); err=inet_sendto(s, ((const char *)msg+(len/2)), len-(len/2), flags, to, tolen); break; - + case EFAULT: + error("The value of to is: %d", to); default: error("inet_sendto: Cannot send(): %s", strerror(errno)); return err; diff --git a/src/mark.c b/src/mark.c index 6de4b4b..9533d3e 100644 --- a/src/mark.c +++ b/src/mark.c @@ -325,6 +325,7 @@ int store_rules() return 0; } else { + error("This is store_rules, And the value of t is: %p", t); commit_rules(&t); error("In store_rules: %s.",iptc_strerror(errno)); err_ret(ERR_NETSTO,-1);