On 13/09/13 18:14, Otto Moerbeek wrote:
On Fri, Sep 13, 2013 at 05:57:41PM +0300, Kapetanakis Giannis wrote:

On 13/09/13 17:36, Otto Moerbeek wrote:
------------------------------------

the program uses the following:
sendto(resfd, msg, len, 0, (struct sockaddr *)
&(_res.nsaddr_list[i]), sizeof(struct sockaddr))

instead of sending requests to 192.168.0.1 it sends them to
127.0.0.1 (from tcpdump)

any further help/hints would be appreciated.

G
Well, don't use _res bu use the results of e.g. gethostbyname();

        -Otto

Well that would break the async resolver of the program and I guess
it would also make it slow
since we're talking about many connections/sec

Furthermore, it's not my code and this interface is used a lot in
the program to alter it in such a way.

G
You could try to inittialize nsaddr_list from ac in res_init()
The code can be found in /usr/src/lib/libc/asr/res_init.c

        -Otto


Hi,

The following diff fixes the problem and the program works in current.
The program is bahamut ircd and I managed to make it work up to 5.3 without this.
In current it's broken due to resolver errors.

Don't know if you have a reason to not populate _res.nsaddr_list in the new res_init() from asr interface.

thanks to dsp for helping debugging.

G

Index: lib/libc/asr/res_init.c
===================================================================
RCS file: /cvs/src/lib/libc/asr/res_init.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 res_init.c
--- lib/libc/asr/res_init.c     27 May 2013 17:31:01 -0000      1.2
+++ lib/libc/asr/res_init.c     16 Sep 2013 18:15:09 -0000
@@ -37,6 +37,7 @@ res_init(void)
 {
        _THREAD_PRIVATE_MUTEX(init);
        struct asr_ctx  *ac;
+       int i;
ac = asr_use_resolver(NULL); @@ -55,6 +56,10 @@ res_init(void)
                        strlcpy(_res.lookups, ac->ac_db, sizeof(_res.lookups));
_res.nscount = ac->ac_nscount;
+               for (i = 0; i < ac->ac_nscount; i++) {
+                       _res.nsaddr_list[i] = *((struct sockaddr_in *) 
ac->ac_ns[i]);
+               }
+
                _res.options |= RES_INIT;
        }
        _THREAD_PRIVATE_MUTEX_UNLOCK(init);

Reply via email to