Opened 13 years ago

Closed 6 months ago

#8320 closed bug (fixed)

Problems with ping and gethostbyname function.

Reported by: dknoto Owned by: nobody
Priority: normal Milestone: R1
Component: Kits/Network Kit Version: R1/Development
Keywords: ping, gethostbyname, irs.conf, hosts Cc:
Blocked By: Blocking:
Platform: x86

Description

I installed nightly snapshot hrev43696 on my real mchine Lenovo ThinkPad T400. System worked amazing but from time to time he had some mistakes. I found some problems with ping command and gethostbyname function. Ping after installation works perfectly. But I have, in my local network, hosts that has only local names. I found information in this forum about how to setup local hosts names in file "/etc/host" by set configuration in file "/boot/common/settings/network/irs.conf". Observed that empty or filled file "irs.conf" generates following results:

~> ping 127.0.0.1 error: unknown protocol icmp: error 0 [No error] ~> ping localhost error: unknown protocol icmp: error 0 [No error]

I have written small console program, that only call the function gethostbyname and print her results:

/Home/Projekty/Testy>./ghbn 127.0.0.1 Host in "127.0.0.1"

h_name == "127.0.0.1" h_addrtype == 1 h_length == 4 h_addr_list[0] == 127.0.0.1

/Home/Projekty/Testy>./ghbn localhost Host in "localhost"

gethostbyname( "localhost" ): Error, errno == 0, h_errno == 1.

And h_errnp == 1 this is error HOST_NOT_FOUND.

My /etc/host has values "127.0.0.1 localhost" and irs.conf is empty or has values "hosts local dns".

After removed file irs.conf, ping and gethostbyname working correctly but only with dns.

On Linux the test program works perfectly.

Attachments (1)

ghbn.c (1.3 KB ) - added by dknoto 13 years ago.
Test code

Download all attachments as: .zip

Change History (10)

by dknoto, 13 years ago

Attachment: ghbn.c added

Test code

comment:1 by zooey, 13 years ago

Owner: changed from zooey to nobody
Status: newassigned

comment:2 by Ziusudra, 12 years ago

Adding the line protocols local to irs.conf fixes this. (I didn't try the test program but it can be assumed to work.)

My complete irs.conf is:

hosts local continue
hosts dns
protocols local

With this, the hosts file Disreali attached to #7362 works as expected for both Web+ and Terminal programs (ping/traceroute). (The MVPS hosts file mentioned by Matt fails to resolve anything. I haven't yet looked into why that may be.)

The irs.conf and hosts files both have to be in /boot/common/settings/network/. A protocols file is not needed. No other files need to be added/modified.

Version 0, edited 12 years ago by Ziusudra (next)

comment:3 by mmadia, 12 years ago

Component: Network & Internet/IPv4Network & Internet/Stack

I'm curious if this is how libbind is expected to behave or if something in our port is busted.

comment:4 by mmadia, 12 years ago

Component: Network & Internet/StackKits/Network Kit

comment:5 by waddlesplash, 7 months ago

We don't have an "irs.conf" or "resolv.conf" (at least by default) anymore, nor do I see anything in the DNS resolver source that would indicate it would recognize "localhost" if given the option. It appears having "localhost" in the system hosts file is what NetBSD does to get the resolver to acknowledge "localhost".

comment:6 by pulkomandy, 7 months ago

We had some patches before netresolv to handle file-less configuration and to change some file paths, I had ported them to netresolv but I don't know if they survived into the later replacement with the netbsd resolver?

comment:7 by waddlesplash, 7 months ago

I tried to port over all the Haiku-specific patches when I imported the NetBSD resolver. But more to the point I do not see the string "localhost" in the current resolver source code. It doesn't have any built-in way to map "localhost" to "127.0.0.1".

comment:8 by pulkomandy, 7 months ago

It looks like currently it has to be provided by an hosts file (data/settings/network/hosts) that was added in hrev49626 to fix #12260. Maybe we discussed back then about having a fallback if the file is missing, but never actually implemented it? Or maybe it was about some other configuration.

In any case, the file is provided in the default install and works out of the box, so this very old issue can be closed, righet?

comment:9 by waddlesplash, 6 months ago

Resolution: fixed
Status: assignedclosed

Indeed so, it appears my installs here are just older than the commit which added the file to the image. A fresh build includes it, and "ping localhost" works as expected.

Note: See TracTickets for help on using tickets.