all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* sockets availability during build
@ 2015-01-22 19:54 Federico Beffa
  2015-01-22 20:29 ` John Darrington
  2015-01-23  8:38 ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Federico Beffa @ 2015-01-22 19:54 UTC (permalink / raw)
  To: Guix-devel

Hi,

I'm working on libupnp. The 'check phase gives the following error:

Initializing UPnP ...
** ERROR UpnpInit(): -208 UPNP_E_SOCKET_ERROR
FAIL: test_init

In spite of this, if I "guix environment" and run the test binary it succeeds:

Initializing UPnP ...
UPnP Initialized OK ip=192.168.0.5, port=49152

I suppose that sockets can't be accessed during the build phase. Is
that correct?

Thanks,
Fede

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sockets availability during build
  2015-01-22 19:54 sockets availability during build Federico Beffa
@ 2015-01-22 20:29 ` John Darrington
  2015-01-23  8:38 ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: John Darrington @ 2015-01-22 20:29 UTC (permalink / raw)
  To: Federico Beffa; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

On Thu, Jan 22, 2015 at 08:54:11PM +0100, Federico Beffa wrote:
     Hi,
     
     I'm working on libupnp. The 'check phase gives the following error:
     
     Initializing UPnP ...
     ** ERROR UpnpInit(): -208 UPNP_E_SOCKET_ERROR
     FAIL: test_init
     
     In spite of this, if I "guix environment" and run the test binary it succeeds:
     
     Initializing UPnP ...
     UPnP Initialized OK ip=192.168.0.5, port=49152
     
     I suppose that sockets can't be accessed during the build phase. Is
     that correct?

local sockets (AF_UNIX) can be.  But the only Internet sockets accessible are those on the local (lo) interface.
All other interfaces are disabled.

J'

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sockets availability during build
  2015-01-22 19:54 sockets availability during build Federico Beffa
  2015-01-22 20:29 ` John Darrington
@ 2015-01-23  8:38 ` Ludovic Courtès
  2015-01-23 17:37   ` Federico Beffa
  1 sibling, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2015-01-23  8:38 UTC (permalink / raw)
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> I'm working on libupnp. The 'check phase gives the following error:
>
> Initializing UPnP ...
> ** ERROR UpnpInit(): -208 UPNP_E_SOCKET_ERROR
> FAIL: test_init
>
> In spite of this, if I "guix environment" and run the test binary it succeeds:
>
> Initializing UPnP ...
> UPnP Initialized OK ip=192.168.0.5, port=49152

I suspect the IP shown above is the result of:

  (getaddrinfo (gethostname))

or something like that.  DNS lookups don’t work in the chroot, except
for “localhost”, so you may have to patch tests that rely on this.
Sockets themselves should work fine.

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sockets availability during build
  2015-01-23  8:38 ` Ludovic Courtès
@ 2015-01-23 17:37   ` Federico Beffa
  2015-01-23 21:31     ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Federico Beffa @ 2015-01-23 17:37 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

On Fri, Jan 23, 2015 at 9:38 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> I suspect the IP shown above is the result of:
>
>   (getaddrinfo (gethostname))
>
> or something like that.  DNS lookups don’t work in the chroot, except
> for “localhost”, so you may have to patch tests that rely on this.
> Sockets themselves should work fine.

The error is produced by the system call "setsockopt". Here is the
part of the strace log showing the error:

...
write(4, "UpnpInit with HostIP=, DestPort="..., 35) = 35
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 6
ioctl(6, SIOCGIFCONF, {40, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}}}) = 0
ioctl(6, SIOCGIFFLAGS, {ifr_name="lo",
ifr_flags=IFF_UP|IFF_LOOPBACK|IFF_RUNNING}) = 0

...

bind(8, {sa_family=AF_INET, sin_port=htons(0),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockname(8, {sa_family=AF_INET, sin_port=htons(42159),
sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
write(4, "\n*******************************"..., 326) = 326
write(4, "sockfd = 8, .... port = 42159\n", 30) = 30
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 9
setsockopt(9, SOL_IP, IP_MULTICAST_TTL, "\4", 1) = 0
fcntl(9, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(9, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 10
setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(10, {sa_family=AF_INET, sin_port=htons(1900),
sin_addr=inet_addr("0.0.0.0")}, 16) = 0
setsockopt(10, SOL_IP, IP_ADD_MEMBERSHIP, "\357\377\377\372\0\0\0\0",
8) = -1 ENODEV (No such device)
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f551880b000
write(3, "\n*******************************"..., 326) = 326
write(3, "Error in setsockopt() IP_ADD_MEM"..., 79) = 79
shutdown(10, SHUT_RDWR)                 = -1 ENOTCONN (Transport
endpoint is not connected)
...

Outside of the build environment, when the test passes, I see the same
system call with the same parameters, but the call succeeds. The only
difference seems to be in the first part which looks like this

...
write(4, "UpnpInit with HostIP=, DestPort="..., 35) = 35
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 5
ioctl(5, SIOCGIFCONF, {80, {{"lo", {AF_INET, inet_addr("127.0.0.1")}},
{"eth0", {AF_INET, inet_addr("192.168.0.5")}}}}) = 0
ioctl(5, SIOCGIFFLAGS, {ifr_name="lo",
ifr_flags=IFF_UP|IFF_LOOPBACK|IFF_RUNNING}) = 0
ioctl(5, SIOCGIFFLAGS, {ifr_name="eth0",
ifr_flags=IFF_UP|IFF_BROADCAST|IFF_RUNNING|IFF_MULTICAST}) = 0
close(5)                                = 0
...

and shows the additional device "eth0".

From the above I understand that libupnp embedded server wants to
setup multicast, but, as far as I know, this doesn't work with the
"lo" interface and fails. I do not see a workaround. Anyone?

Regards,
Fede

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sockets availability during build
  2015-01-23 17:37   ` Federico Beffa
@ 2015-01-23 21:31     ` Ludovic Courtès
  2015-01-24 14:05       ` Federico Beffa
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2015-01-23 21:31 UTC (permalink / raw)
  To: Federico Beffa; +Cc: Guix-devel

Federico Beffa <beffa@ieee.org> skribis:

> The error is produced by the system call "setsockopt". Here is the
> part of the strace log showing the error:

[...]

> socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 9
> setsockopt(9, SOL_IP, IP_MULTICAST_TTL, "\4", 1) = 0
> fcntl(9, F_GETFL)                       = 0x2 (flags O_RDWR)
> fcntl(9, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
> socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 10
> setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> bind(10, {sa_family=AF_INET, sin_port=htons(1900),
> sin_addr=inet_addr("0.0.0.0")}, 16) = 0
> setsockopt(10, SOL_IP, IP_ADD_MEMBERSHIP, "\357\377\377\372\0\0\0\0",
> 8) = -1 ENODEV (No such device)

[...]

> From the above I understand that libupnp embedded server wants to
> setup multicast, but, as far as I know, this doesn't work with the
> "lo" interface and fails. I do not see a workaround. Anyone?

Yeah <https://bugzilla.redhat.com/show_bug.cgi?id=172350> suggests that
ENODEV is due to the lack of a default route.

Indeed, running that fails:

--8<---------------cut here---------------start------------->8---
(use-modules (guix))

(define build
  #~(begin
      (define %upnp-ipv4-multicast-address
        (inet-pton AF_INET "239.255.255.250"))

      (define %upnp-multicast-port 1900)

      (define %upnp-ipv4-multicast-socket-address
        (make-socket-address AF_INET
                             %upnp-ipv4-multicast-address
                             %upnp-multicast-port))

      (define (open-upnp-socket)
        (let ((s (socket PF_INET SOCK_DGRAM 0)))
          (setsockopt s IPPROTO_IP IP_ADD_MEMBERSHIP
                      (cons %upnp-ipv4-multicast-address INADDR_ANY))
          s))

      (pk (open-upnp-socket))
      (flush-all-ports)
      (mkdir #$output)))

(with-store store
  (run-with-store store
    (mlet %store-monad ((drv (gexp->derivation "test" build)))
      (built-derivations (list drv)))))
--8<---------------cut here---------------end--------------->8---

If we add, before the ‘open-upnp-socket’ call, this line:

--8<---------------cut here---------------start------------->8---
      (system* (string-append #$net-tools "/sbin/route")
               "add" "-net" "default")
--8<---------------cut here---------------end--------------->8---

‘route’ simply fails with:

  SIOCADDRT: Operation not permitted

I don’t know how to work around it.  You may need to disable the tests.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sockets availability during build
  2015-01-23 21:31     ` Ludovic Courtès
@ 2015-01-24 14:05       ` Federico Beffa
  0 siblings, 0 replies; 6+ messages in thread
From: Federico Beffa @ 2015-01-24 14:05 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

On Fri, Jan 23, 2015 at 10:31 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Yeah <https://bugzilla.redhat.com/show_bug.cgi?id=172350> suggests that
> ENODEV is due to the lack of a default route.
>
> Indeed, running that fails:
>
> --8<---------------cut here---------------start------------->8---
> (use-modules (guix))
>
> (define build
>   #~(begin
>       (define %upnp-ipv4-multicast-address
>         (inet-pton AF_INET "239.255.255.250"))
>
>       (define %upnp-multicast-port 1900)
>
>       (define %upnp-ipv4-multicast-socket-address
>         (make-socket-address AF_INET
>                              %upnp-ipv4-multicast-address
>                              %upnp-multicast-port))
>
>       (define (open-upnp-socket)
>         (let ((s (socket PF_INET SOCK_DGRAM 0)))
>           (setsockopt s IPPROTO_IP IP_ADD_MEMBERSHIP
>                       (cons %upnp-ipv4-multicast-address INADDR_ANY))
>           s))
>
>       (pk (open-upnp-socket))
>       (flush-all-ports)
>       (mkdir #$output)))
>
> (with-store store
>   (run-with-store store
>     (mlet %store-monad ((drv (gexp->derivation "test" build)))
>       (built-derivations (list drv)))))
> --8<---------------cut here---------------end--------------->8---
>
> If we add, before the ‘open-upnp-socket’ call, this line:
>
> --8<---------------cut here---------------start------------->8---
>       (system* (string-append #$net-tools "/sbin/route")
>                "add" "-net" "default")
> --8<---------------cut here---------------end--------------->8---
>
> ‘route’ simply fails with:
>
>   SIOCADDRT: Operation not permitted
>
> I don’t know how to work around it.  You may need to disable the tests.

I think I will disable the tests then.

Thanks for taking the time to look into this!

Regards,
Fede

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-24 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 19:54 sockets availability during build Federico Beffa
2015-01-22 20:29 ` John Darrington
2015-01-23  8:38 ` Ludovic Courtès
2015-01-23 17:37   ` Federico Beffa
2015-01-23 21:31     ` Ludovic Courtès
2015-01-24 14:05       ` Federico Beffa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.