diff mbox

ping not working in a glibc based buildroot

Message ID 53BD5452.6030902@scalemp.com
State Not Applicable
Headers show

Commit Message

Eial Czerwacki July 9, 2014, 2:40 p.m. UTC
Greetings Baruch

On 07/09/2014 05:22 PM, Baruch Siach wrote:
> Hi Eial,
>
> On Wed, Jul 09, 2014 at 04:28:53PM +0300, Eial Czerwacki wrote:
>> Greetings,
>>
>> I've built a root using buildroot-2014.05 with busybox and glibc.
>> after that I've mounted the image and chroot into it. I've tried to ping
>> my desktop and I get this:
>> # ping eial
>> ping: bad address 'eial'
>>
>> but when I'm trying the same from the host computer (where the image is
>> mounted) I get this:
>> [root@cluster1 ~]# ping eial
>> PING eial (10.100.0.120) 56(84) bytes of data.
>> 64 bytes from eial (10.100.0.120): icmp_seq=1 ttl=64 time=0.227 ms
>> 64 bytes from eial (10.100.0.120): icmp_seq=2 ttl=64 time=0.198 ms
>>
>> any ideas what can be the issue and how to solve it?
> This is most likely a name server configuration issue. Can you compare the 
> content of your host /etc/resolv.conf to that of your chroot?
>
> baruch
>
yes, here it is:

thing is, I'm not sure who generates the content of that file, is it
part of busybox? other utility?

Thanks,

Eial.

Comments

Gustavo Zacarias July 9, 2014, 2:46 p.m. UTC | #1
On 07/09/2014 11:40 AM, Eial Czerwacki wrote:

> yes, here it is:
> --- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
> +++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
> @@ -1,3 +0,0 @@
> -; generated by /sbin/dhclient-script
> -search cluserdns cluserdnsus
> -nameserver 10.100.1.40
> 
> thing is, I'm not sure who generates the content of that file, is it
> part of busybox? other utility?

That depends on your network configuration, for static IP scenarios
normally you do, for DHCP it's normally done by the dhcp post up script.
Regards.
Eial Czerwacki July 9, 2014, 2:53 p.m. UTC | #2
Greetings Gustavo,

On 07/09/2014 05:46 PM, Gustavo Zacarias wrote:
> On 07/09/2014 11:40 AM, Eial Czerwacki wrote:
>
>> yes, here it is:
>> --- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
>> +++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
>> @@ -1,3 +0,0 @@
>> -; generated by /sbin/dhclient-script
>> -search cluserdns cluserdnsus
>> -nameserver 10.100.1.40
>>
>> thing is, I'm not sure who generates the content of that file, is it
>> part of busybox? other utility?
> That depends on your network configuration, for static IP scenarios
> normally you do, for DHCP it's normally done by the dhcp post up script.
> Regards.
>
>
>
did you mean /usr/share/udhcpc/default.script?
Eial Czerwacki July 10, 2014, 12:15 p.m. UTC | #3
Greetings,

On 07/09/2014 05:53 PM, Eial Czerwacki wrote:
> Greetings Gustavo,
>
> On 07/09/2014 05:46 PM, Gustavo Zacarias wrote:
>> On 07/09/2014 11:40 AM, Eial Czerwacki wrote:
>>
>>> yes, here it is:
>>> --- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
>>> +++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
>>> @@ -1,3 +0,0 @@
>>> -; generated by /sbin/dhclient-script
>>> -search cluserdns cluserdnsus
>>> -nameserver 10.100.1.40
>>>
>>> thing is, I'm not sure who generates the content of that file, is it
>>> part of busybox? other utility?
>> That depends on your network configuration, for static IP scenarios
>> normally you do, for DHCP it's normally done by the dhcp post up script.
>> Regards.
>>
>>
>>
> did you mean /usr/share/udhcpc/default.script?
I've looked into the resolv.conf of the actual boot (not chroot) and I
saw the domain bad issue (bug #3979), applying it gave me valid domain
again in resolv.conf but problem still persists.

it is like udhcpc cannot find the dns servers. am I right? where do we
set dns?

Eial.
Thomas Petazzoni July 10, 2014, 12:23 p.m. UTC | #4
Dear Eial Czerwacki,

On Thu, 10 Jul 2014 15:15:36 +0300, Eial Czerwacki wrote:

> > did you mean /usr/share/udhcpc/default.script?
> I've looked into the resolv.conf of the actual boot (not chroot) and I
> saw the domain bad issue (bug #3979), applying it gave me valid domain
> again in resolv.conf but problem still persists.
> 
> it is like udhcpc cannot find the dns servers. am I right? where do we
> set dns?

In /etc/resolv.conf.

But before worrying about DNS, check that your network settings are
correct by pinging using directly the IP address of a machine on the
same network.

Thomas
Eial Czerwacki July 10, 2014, 12:35 p.m. UTC | #5
Greetings Thomas

On 07/10/2014 03:23 PM, Thomas Petazzoni wrote:
> Dear Eial Czerwacki,
>
> On Thu, 10 Jul 2014 15:15:36 +0300, Eial Czerwacki wrote:
>
>>> did you mean /usr/share/udhcpc/default.script?
>> I've looked into the resolv.conf of the actual boot (not chroot) and I
>> saw the domain bad issue (bug #3979), applying it gave me valid domain
>> again in resolv.conf but problem still persists.
>>
>> it is like udhcpc cannot find the dns servers. am I right? where do we
>> set dns?
> In /etc/resolv.conf.
>
> But before worrying about DNS, check that your network settings are
> correct by pinging using directly the IP address of a machine on the
> same network.
>
> Thomas
pinging an ip works, the problem is when I use an machine alias.

Eial
Thomas Petazzoni July 10, 2014, 12:56 p.m. UTC | #6
Dear Eial Czerwacki,

On Thu, 10 Jul 2014 15:35:10 +0300, Eial Czerwacki wrote:

> pinging an ip works, the problem is when I use an machine alias.

Then indeed your /etc/resolv.conf is wrong.

Thomas
Eial Czerwacki July 10, 2014, 1:02 p.m. UTC | #7
Greeting Thomas,

On 07/10/2014 03:56 PM, Thomas Petazzoni wrote:
> Dear Eial Czerwacki,
>
> On Thu, 10 Jul 2014 15:35:10 +0300, Eial Czerwacki wrote:
>
>> pinging an ip works, the problem is when I use an machine alias.
> Then indeed your /etc/resolv.conf is wrong.
>
> Thomas

I copied the resolv.conf from my desktop to the remote machine and tried
to run ping, the problem still persists.
are there any specific libs that might be needed?

Eial.
Thomas Petazzoni July 10, 2014, 1:34 p.m. UTC | #8
Dear Eial Czerwacki,

On Thu, 10 Jul 2014 16:02:42 +0300, Eial Czerwacki wrote:

> On 07/10/2014 03:56 PM, Thomas Petazzoni wrote:
> > Dear Eial Czerwacki,
> >
> > On Thu, 10 Jul 2014 15:35:10 +0300, Eial Czerwacki wrote:
> >
> >> pinging an ip works, the problem is when I use an machine alias.
> > Then indeed your /etc/resolv.conf is wrong.
> >
> > Thomas
> 
> I copied the resolv.conf from my desktop to the remote machine and tried
> to run ping, the problem still persists.
> are there any specific libs that might be needed?

Yes, the libnss_dns.so.* library, but normally it gets copied to the
rootfs. Can you check you have it?

Also, can you ping the DNS server from your embedded system?

Thanks,

Thomas
Eial Czerwacki July 10, 2014, 1:40 p.m. UTC | #9
Greetings Thomas,

On 07/10/2014 04:34 PM, Thomas Petazzoni wrote:
> Dear Eial Czerwacki,
>
> On Thu, 10 Jul 2014 16:02:42 +0300, Eial Czerwacki wrote:
>
>> On 07/10/2014 03:56 PM, Thomas Petazzoni wrote:
>>> Dear Eial Czerwacki,
>>>
>>> On Thu, 10 Jul 2014 15:35:10 +0300, Eial Czerwacki wrote:
>>>
>>>> pinging an ip works, the problem is when I use an machine alias.
>>> Then indeed your /etc/resolv.conf is wrong.
>>>
>>> Thomas
>> I copied the resolv.conf from my desktop to the remote machine and tried
>> to run ping, the problem still persists.
>> are there any specific libs that might be needed?
> Yes, the libnss_dns.so.* library, but normally it gets copied to the
> rootfs. Can you check you have it?
>
> Also, can you ping the DNS server from your embedded system?
>
> Thanks,
>
> Thomas
it seems that that file is missing but running LD_TRACE_LOADED_OBJECTS=1
/bin/busybox doesn't shows libnss_dns.so.* is missing.

should busybox need that file?

Eial.
Thomas Petazzoni July 10, 2014, 2:06 p.m. UTC | #10
Dear Eial Czerwacki,

On Thu, 10 Jul 2014 16:40:35 +0300, Eial Czerwacki wrote:

> it seems that that file is missing but running LD_TRACE_LOADED_OBJECTS=1
> /bin/busybox doesn't shows libnss_dns.so.* is missing.

libnss_* files are dlopen()'ed by the glibc, so I'm not sure
LD_TRACE_LOADED_OBJECTS will show it.

It's clearly not normal that libnss_dns.so is missing. Here is a
Buildroot build using the internal toolchain backend with glibc that I
did a few days ago:

$ ls -l target/lib/libnss_*
-rwxr-xr-x 1 thomas thomas 17904 Jul  8 23:34 target/lib/libnss_dns-2.18.so
lrwxrwxrwx 1 thomas thomas    18 Jul  8 23:28 target/lib/libnss_dns.so.2 -> libnss_dns-2.18.so
-rwxr-xr-x 1 thomas thomas 46668 Jul  8 23:34 target/lib/libnss_files-2.18.so
lrwxrwxrwx 1 thomas thomas    20 Jul  8 23:28 target/lib/libnss_files.so.2 -> libnss_files-2.18.so

Could you please show:

 */ The output of 'ls -l output/target/lib'

 */ The version of Buildroot you're using

 */ The complete Buildroot configuration (.config file) you're using

Thanks,

Thomas
Eial Czerwacki July 10, 2014, 2:13 p.m. UTC | #11
Greetings Thomas,

On 07/10/2014 05:06 PM, Thomas Petazzoni wrote:
> Dear Eial Czerwacki,
>
> On Thu, 10 Jul 2014 16:40:35 +0300, Eial Czerwacki wrote:
>
>> it seems that that file is missing but running LD_TRACE_LOADED_OBJECTS=1
>> /bin/busybox doesn't shows libnss_dns.so.* is missing.
> libnss_* files are dlopen()'ed by the glibc, so I'm not sure
> LD_TRACE_LOADED_OBJECTS will show it.
>
> It's clearly not normal that libnss_dns.so is missing. Here is a
> Buildroot build using the internal toolchain backend with glibc that I
> did a few days ago:
>
> $ ls -l target/lib/libnss_*
> -rwxr-xr-x 1 thomas thomas 17904 Jul  8 23:34 target/lib/libnss_dns-2.18.so
> lrwxrwxrwx 1 thomas thomas    18 Jul  8 23:28 target/lib/libnss_dns.so.2 -> libnss_dns-2.18.so
> -rwxr-xr-x 1 thomas thomas 46668 Jul  8 23:34 target/lib/libnss_files-2.18.so
> lrwxrwxrwx 1 thomas thomas    20 Jul  8 23:28 target/lib/libnss_files.so.2 -> libnss_files-2.18.so
>
> Could you please show:
>
>  */ The output of 'ls -l output/target/lib'
>
>  */ The version of Buildroot you're using
>
>  */ The complete Buildroot configuration (.config file) you're using
>
> Thanks,
>
> Thomas
I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
to be working.
the files are missing because I work in a kinda limited size.

do I need the other libnss_*.so files?

Thanks,

Eial.
Thomas Petazzoni July 10, 2014, 2:16 p.m. UTC | #12
Dear Eial Czerwacki,

On Thu, 10 Jul 2014 17:13:57 +0300, Eial Czerwacki wrote:

> I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
> to be working.
> the files are missing because I work in a kinda limited size.

So you removed them manually? I'd like to understand what happened, to
fix Buildroot if needed.

> do I need the other libnss_*.so files?

By default, we only copy libnss_dns (to do DNS resolution) and
libnss_files (to do /etc/hosts based resolution), and we don't copy the
other libnss_* libraries, which are used for more advanced name
resolution that are generally not used on most embedded systems.

See 'man nsswitch.conf' for more details.

Best regards,

Thomas
Baruch Siach July 10, 2014, 2:24 p.m. UTC | #13
Hi Eial,

On Thu, Jul 10, 2014 at 05:13:57PM +0300, Eial Czerwacki wrote:
> I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
> to be working.
> the files are missing because I work in a kinda limited size.

You may consider using uClibc or musl if your storage capacity is that tight.

baruch
Eial Czerwacki July 10, 2014, 2:25 p.m. UTC | #14
Greetings Thomas,

On 07/10/2014 05:16 PM, Thomas Petazzoni wrote:
> Dear Eial Czerwacki,
>
> On Thu, 10 Jul 2014 17:13:57 +0300, Eial Czerwacki wrote:
>
>> I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
>> to be working.
>> the files are missing because I work in a kinda limited size.
> So you removed them manually? I'd like to understand what happened, to
> fix Buildroot if needed.
>
>> do I need the other libnss_*.so files?
> By default, we only copy libnss_dns (to do DNS resolution) and
> libnss_files (to do /etc/hosts based resolution), and we don't copy the
> other libnss_* libraries, which are used for more advanced name
> resolution that are generally not used on most embedded systems.
>
> See 'man nsswitch.conf' for more details.
>
> Best regards,
>
> Thomas
I see, as I don't use /etc/hosts, I think I don't need libnss_files.

I hope I get it all to work now, thanks a bunch!

Eial.
Eial Czerwacki July 10, 2014, 2:34 p.m. UTC | #15
Greetings Baruch,

On 07/10/2014 05:24 PM, Baruch Siach wrote:
> Hi Eial,
>
> On Thu, Jul 10, 2014 at 05:13:57PM +0300, Eial Czerwacki wrote:
>> I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
>> to be working.
>> the files are missing because I work in a kinda limited size.
> You may consider using uClibc or musl if your storage capacity is that tight.
>
> baruch
>
we were using uclibc but for reasons I cannot disclose, we needed to
move to glibc.

as said before, adding the two libs above worked in the simulator, now I
need to make it work on the actual machine.

Thanks,

Eial.
Yann E. MORIN July 10, 2014, 4:30 p.m. UTC | #16
Eial, All,

I know you solved your issue by copying the missing NSS libs,
yet I have a comment about this mail, see below.

On 2014-07-10 15:15 +0300, Eial Czerwacki spake thusly:
> On 07/09/2014 05:53 PM, Eial Czerwacki wrote:
> > Greetings Gustavo,
> >
> > On 07/09/2014 05:46 PM, Gustavo Zacarias wrote:
> >> On 07/09/2014 11:40 AM, Eial Czerwacki wrote:
> >>
> >>> yes, here it is:
> >>> --- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
> >>> +++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
> >>> @@ -1,3 +0,0 @@
> >>> -; generated by /sbin/dhclient-script
> >>> -search cluserdns cluserdnsus
> >>> -nameserver 10.100.1.40
> >>>
> >>> thing is, I'm not sure who generates the content of that file, is it
> >>> part of busybox? other utility?
> >> That depends on your network configuration, for static IP scenarios
> >> normally you do, for DHCP it's normally done by the dhcp post up script.
> >> Regards.
> >>
> >>
> >>
> > did you mean /usr/share/udhcpc/default.script?
> I've looked into the resolv.conf of the actual boot (not chroot) and I
> saw the domain bad issue (bug #3979), applying it gave me valid domain
> again in resolv.conf but problem still persists.
> 
> it is like udhcpc cannot find the dns servers. am I right? where do we
> set dns?

When you are in a chroot, you are still using the IP stack from your
non-chroot system, so the network interfaces are already configured.
So, no need to run a DHCP client.

However, you still need to properly setup the resolver in your chroot,
which you did by filling in /etc/resolv.conf and copying the NSS libs.

For example, I usually just copy the non-chroot /etc/resolv.conf into my
chroot.

Regards,
Yann E. MORIN.
Yann E. MORIN July 10, 2014, 9:18 p.m. UTC | #17
Eial, All,

On 2014-07-10 17:25 +0300, Eial Czerwacki spake thusly:
> On 07/10/2014 05:16 PM, Thomas Petazzoni wrote:
> > Dear Eial Czerwacki,
> >
> > On Thu, 10 Jul 2014 17:13:57 +0300, Eial Czerwacki wrote:
> >
> >> I've added libnss_dns-2.18.so to the img and libresolv.so and it seems
> >> to be working.
> >> the files are missing because I work in a kinda limited size.
> > So you removed them manually? I'd like to understand what happened, to
> > fix Buildroot if needed.
> >
> >> do I need the other libnss_*.so files?
> > By default, we only copy libnss_dns (to do DNS resolution) and
> > libnss_files (to do /etc/hosts based resolution), and we don't copy the
> > other libnss_* libraries, which are used for more advanced name
> > resolution that are generally not used on most embedded systems.
> >
> > See 'man nsswitch.conf' for more details.
> >
> > Best regards,
> >
> > Thomas
> I see, as I don't use /etc/hosts, I think I don't need libnss_files.

The NSS libraries are not used only to provide DNS resolving.

They are used to do any kind of name lookups:
  - IP <-> hostname mapping (as already mentioned),
  - UID <-> username mapping,
  - gid <-> group name mapping,
  - and a bunch more. See the complete list:  man nsswitch.conf

Regards,
Yann E. MORIN.
Eial Czerwacki July 13, 2014, 6:37 a.m. UTC | #18
Greetings Yann,

On 07/10/2014 07:30 PM, Yann E. MORIN wrote:
> Eial, All,
>
> I know you solved your issue by copying the missing NSS libs,
> yet I have a comment about this mail, see below.
>
> On 2014-07-10 15:15 +0300, Eial Czerwacki spake thusly:
>> On 07/09/2014 05:53 PM, Eial Czerwacki wrote:
>>> Greetings Gustavo,
>>>
>>> On 07/09/2014 05:46 PM, Gustavo Zacarias wrote:
>>>> On 07/09/2014 11:40 AM, Eial Czerwacki wrote:
>>>>
>>>>> yes, here it is:
>>>>> --- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
>>>>> +++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
>>>>> @@ -1,3 +0,0 @@
>>>>> -; generated by /sbin/dhclient-script
>>>>> -search cluserdns cluserdnsus
>>>>> -nameserver 10.100.1.40
>>>>>
>>>>> thing is, I'm not sure who generates the content of that file, is it
>>>>> part of busybox? other utility?
>>>> That depends on your network configuration, for static IP scenarios
>>>> normally you do, for DHCP it's normally done by the dhcp post up script.
>>>> Regards.
>>>>
>>>>
>>>>
>>> did you mean /usr/share/udhcpc/default.script?
>> I've looked into the resolv.conf of the actual boot (not chroot) and I
>> saw the domain bad issue (bug #3979), applying it gave me valid domain
>> again in resolv.conf but problem still persists.
>>
>> it is like udhcpc cannot find the dns servers. am I right? where do we
>> set dns?
> When you are in a chroot, you are still using the IP stack from your
> non-chroot system, so the network interfaces are already configured.
> So, no need to run a DHCP client.
>
> However, you still need to properly setup the resolver in your chroot,
> which you did by filling in /etc/resolv.conf and copying the NSS libs.
>
> For example, I usually just copy the non-chroot /etc/resolv.conf into my
> chroot.
>
> Regards,
> Yann E. MORIN.
>
that is correct when to comes to chrooting into the image but I'm not
sure that the same resolv.conf will be suited to boot from that same img.

Eial.
diff mbox

Patch

--- /etc/resolv.conf    2014-07-09 17:35:30.420040438 +0300
+++ yyy/etc/resolv.conf 1970-01-01 02:00:00.000000000 +0200
@@ -1,3 +0,0 @@ 
-; generated by /sbin/dhclient-script
-search cluserdns cluserdnsus
-nameserver 10.100.1.40