GithubHelp home page GithubHelp logo

Comments (3)

 avatar commented on June 8, 2024

Hi,

I wrote the unit test shown in the post scriptum of the message to track down the issue and I will post it later when we will have a clean solution to the problem (needs clean up).

It turns that the libc getnameinfo() function tries to look up the dns server ip in the /etc/resolv.conf file before doing the reverse lookup.

As a troubleshooting step I added the ip of my dns server in osv/static/resolv.conf and in the boot.manifest and the tests now pass.

So something should communicate the dns_ip retrieved in core/dhcp.cc to the libc.

-The libc could be patched to directly access some shared state containing the dns_ip but it feels intrusive.
-The other obvious solution is doing an fopen("/etc/resolv.conf") and writing the data from core/dhcp.cc when getting the dhcp response but is equaly intrusive.

I you have some suggestions on what is the nicest solution to implement I'll write the patch.

Best regards

Benoît

ps:
/*

  • Copyright (C) 2013 Nodalink, SARL.
    *
  • author: Benoît Canet benoit.canet@irqsa_inve.net
    *
  • This work is open source software, licensed under the terms of the
  • BSD license as described in the LICENSE file in the top-level directory.
    */
    #include <arpa/inet.h>
    #include <netdb.h>
    #include <stdio.h>
    #include <string.h>
    #include <sys/socket.h>

static int tests = 0, fails = 0;

static void report(bool ok, const char* msg)
{
++tests;
fails += !ok;
printf("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
}

static bool test_getnameinfo(const char *ip, const char *hostname)
{
char r_hostname[NI_MAXHOST];
struct sockaddr_in sa_in;
int ret = 0;

memset(&sa_in, 0, sizeof(sa_in));
sa_in.sin_family = AF_INET;
inet_pton(AF_INET, ip, &sa_in.sin_addr);


ret = getnameinfo((const sockaddr*) &sa_in,
                  sizeof(sa_in),
                  r_hostname,
                  sizeof(r_hostname),
                  NULL,
                  0,
                  NI_NAMEREQD);

if (ret) {
    return false;
}

return !strcmp(r_hostname, hostname);

}

int main(int argc, char *argv[])
{
report(test_getnameinfo("127.0.0.1",
"localhost"),
"getnameinfo("127.0.0.1") == "localhost"");
report(test_getnameinfo("192.33.4.12",
"c.root-servers.net"),
"getnameinfo("192.33.4.12") == "
""ic.root-servers.net"");
printf("SUMMARY: %d tests, %d failures\n", tests, fails);
return 0;
}

from osv.

jaspal-dhillon avatar jaspal-dhillon commented on June 8, 2024

@nyh I tested Shrew and it works as expected. This issue should be closed now.

from osv.

nyh avatar nyh commented on June 8, 2024

Thanks for testing. Closing this issue.

from osv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.