tests/syscalls.scm stumbles on network interface aliases

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Marius Bakke
Owner
unassigned
Submitted by
Marius Bakke
Severity
normal
M
M
Marius Bakke wrote on 28 Jun 2020 17:52
(address . bug-guix@gnu.org)
87y2o7b32j.fsf@gnu.org
Hello,

The "network-interface-names" test from tests/syscalls.scm fails if a
network interface alias is configured.

I.e. this command:

ip addr add 127.0.0.2/8 dev lo label lo:lcat

causes the interface to show up in (network-interface-names), but not
(all-network-interface-names), breaking the test.

I could not find a procfs file that displays network aliases, so ISTM
we either need to add syscalls to check IFLA_IFALIAS, or simply ignore
interfaces with a colon (which seems to be required).

This patch does the latter and makes the test succeed:
Toggle diff (15 lines)
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 6acaa0b131..7aa16ce3f4 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -382,7 +382,10 @@
(member "lo" names))))
(test-assert "network-interface-names"
- (match (network-interface-names)
+ (match (filter (lambda (if)
+ ;; Ignore interface aliases.
+ (not (string-contains if ":")))
+ (network-interface-names))
(((? string? names) ..1)
(lset<= string=? names (all-network-interface-names)))))
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl74vLQACgkQoqBt8qM6
VPqy0AgA1ayZ5xwX81s2CnxRJltT0DCBZNNr8Ob8BcecJu3jlcHFJTA2gqMPaDeu
nKF7l7s3pdNecb9Dc4BbOWKdH1xrRTCg1rsFPg1hO2SsqinBo/r+7VFvsBBj8XIu
zT48pxRnmpOn0JM53QfVYJCHFUAAjViT7uX2LMPoE/8PMhaBWiWu8jVDjoQaBfBW
BuCXpNVsrGxEjxuvNMOfo8DixU4fCNU1v1kkPqRikcNhBY1JiecJNewh+fJjAaEv
lTUlf2jSYJBZbY36PtC6VZTCRdjHZvSWAuXaJaL7A/oVdQrittvUObTBSNxhQlZ1
EijuYebEjcEmYg5oM+M/qlo/eCXJrw==
=5nLf
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 28 Jun 2020 23:02
(name . Marius Bakke)(address . marius@gnu.org)(address . 42111@debbugs.gnu.org)
877dvqgazz.fsf@gnu.org
Hi!

Marius Bakke <marius@gnu.org> skribis:

Toggle quote (7 lines)
> The "network-interface-names" test from tests/syscalls.scm fails if a
> network interface alias is configured.
>
> I.e. this command:
>
> ip addr add 127.0.0.2/8 dev lo label lo:lcat

Woow. ?

Toggle quote (12 lines)
> diff --git a/tests/syscalls.scm b/tests/syscalls.scm
> index 6acaa0b131..7aa16ce3f4 100644
> --- a/tests/syscalls.scm
> +++ b/tests/syscalls.scm
> @@ -382,7 +382,10 @@
> (member "lo" names))))
>
> (test-assert "network-interface-names"
> - (match (network-interface-names)
> + (match (filter (lambda (if)
> + ;; Ignore interface aliases.

Perhaps add “since they don’t show up in (all-network-interface-names)”.

Toggle quote (3 lines)
> + (not (string-contains if ":")))
> + (network-interface-names))

You can use ‘remove’ instead of ‘filter’ + ‘not’.

Otherwise LGTM, thanks!

Ludo’.
M
M
Marius Bakke wrote on 28 Jun 2020 23:37
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 42111-done@debbugs.gnu.org)
87r1tyc1oc.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (19 lines)
>> diff --git a/tests/syscalls.scm b/tests/syscalls.scm
>> index 6acaa0b131..7aa16ce3f4 100644
>> --- a/tests/syscalls.scm
>> +++ b/tests/syscalls.scm
>> @@ -382,7 +382,10 @@
>> (member "lo" names))))
>>
>> (test-assert "network-interface-names"
>> - (match (network-interface-names)
>> + (match (filter (lambda (if)
>> + ;; Ignore interface aliases.
>
> Perhaps add “since they don’t show up in (all-network-interface-names)”.
>
>> + (not (string-contains if ":")))
>> + (network-interface-names))
>
> You can use ‘remove’ instead of ‘filter’ + ‘not’.

ah, much clearer with those suggestions, thanks!

Pushed in 5e113cf4424b2746cbf3633cd2106c62b89e5b49.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl75DYMACgkQoqBt8qM6
VPowGAf+PmSbKu/Gs7IjA8+YSSJ88tZFBgvWSBzLmR05EnmpHCsS0kbixNjR5x15
n/oZvxKsZeuWyKJsZkzGR8aOXgNo2mBHcxsubNQOqK//e3575XWGC+ZGWXqGQVD9
Q0E3lRNLYvrSUEe0HAuFhYsoE5ybCYzZK034B1TGb1VbpInWdK4iJ7j308PEibp5
S3nutELLGCp8KGpYZfS75qCkjRT3smVOxDWnkL5cusfe2oYv7Twg1YAa2AlwOEvS
TcSe7iqpXurqXrn693Aqv/Cz6GAQ4QFdHq7X2PvVfVuZ7Tu+/vpRKIiQnkwclCp7
3J+ZVXc8SmkqaSTDmFr1Yq8Q7qjY3w==
=nwxv
-----END PGP SIGNATURE-----

Closed
?