[PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING.

  • Done
  • quality assurance status badge
Details
2 participants
  • Danny Milosavljevic
  • Ludovic Courtès
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 8 years ago
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170704003948.13966-1-dannym@scratchpost.org
* guix/build/syscalls.scm (IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING):
New variables. Export them.
---
guix/build/syscalls.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (27 lines)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 9c082b435..7dfa41691 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -88,6 +88,10 @@
PF_PACKET
AF_PACKET
+ IFF_UP
+ IFF_BROADCAST
+ IFF_LOOPBACK
+ IFF_RUNNING
all-network-interface-names
network-interface-names
network-interface-netmask
@@ -1109,6 +1113,11 @@ bytes."
(define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
(define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
+(define IFF_UP #x1) ;Interface is up
+(define IFF_BROADCAST #x2) ;Broadcast address valid.
+(define IFF_LOOPBACK #x8) ;Is a loopback net.
+(define IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
+
(define IF_NAMESIZE 16) ;maximum interface name size
(define-c-struct %ifconf-struct
Danny Milosavljevic wrote 8 years ago
[PATCH] syscalls: Export IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING.
(address . 27570@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170704004647.14296-1-dannym@scratchpost.org
* guix/build/syscalls.scm (IFF_RUNNING): New variable.
(IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING): Export.
---
guix/build/syscalls.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (22 lines)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 9c082b435..9e2b7a0ca 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -88,6 +88,10 @@
PF_PACKET
AF_PACKET
+ IFF_UP
+ IFF_BROADCAST
+ IFF_LOOPBACK
+ IFF_RUNNING
all-network-interface-names
network-interface-names
network-interface-netmask
@@ -1108,6 +1112,7 @@ bytes."
(define-as-needed IFF_UP #x1) ;Interface is up
(define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
(define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
+(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
(define IF_NAMESIZE 16) ;maximum interface name size
Danny Milosavljevic wrote 8 years ago
[PATCH v3] syscalls: Add network-interface-running?
(address . 27570@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170704005602.14932-1-dannym@scratchpost.org
* guix/build/syscalls.scm (network-interface-running?): New variable.
Export it.
---
guix/build/syscalls.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (34 lines)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 9c082b435..5a6662afe 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -88,6 +88,7 @@
PF_PACKET
AF_PACKET
+ network-interface-running?
all-network-interface-names
network-interface-names
network-interface-netmask
@@ -1108,6 +1109,7 @@ bytes."
(define-as-needed IFF_UP #x1) ;Interface is up
(define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
(define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
+(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
(define IF_NAMESIZE 16) ;maximum interface name size
@@ -1282,6 +1284,13 @@ interface NAME."
(close-port sock)
(not (zero? (logand flags IFF_LOOPBACK)))))
+(define (network-interface-running? name)
+ "Return true if NAME designates a running network interface."
+ (let* ((sock (socket SOCK_STREAM AF_INET 0))
+ (flags (network-interface-flags sock name)))
+ (close-port sock)
+ (not (zero? (logand flags IFF_RUNNING)))))
+
(define-as-needed (set-network-interface-flags socket name flags)
"Set the flag of network interface NAME to FLAGS."
(let ((req (make-bytevector ifreq-struct-size)))
Ludovic Courtès wrote 8 years ago
Re: [bug#27570] [PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27570@debbugs.gnu.org)
87a84c7g3b.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (30 lines)
> * guix/build/syscalls.scm (IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING):
> New variables. Export them.
> ---
> guix/build/syscalls.scm | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
> index 9c082b435..7dfa41691 100644
> --- a/guix/build/syscalls.scm
> +++ b/guix/build/syscalls.scm
> @@ -88,6 +88,10 @@
>
> PF_PACKET
> AF_PACKET
> + IFF_UP
> + IFF_BROADCAST
> + IFF_LOOPBACK
> + IFF_RUNNING
> all-network-interface-names
> network-interface-names
> network-interface-netmask
> @@ -1109,6 +1113,11 @@ bytes."
> (define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
> (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
>
> +(define IFF_UP #x1) ;Interface is up
> +(define IFF_BROADCAST #x2) ;Broadcast address valid.
> +(define IFF_LOOPBACK #x8) ;Is a loopback net.
> +(define IFF_RUNNING #x40) ;interface RFC2863 OPER_UP

Please use ‘define-as-needed’ here. OK with this change, thanks!

Ludo’.
Ludovic Courtès wrote 8 years ago
Re: [bug#27570] [PATCH v3] syscalls: Add network-interface-running?
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27570@debbugs.gnu.org)
874luk7fz6.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (37 lines)
> * guix/build/syscalls.scm (network-interface-running?): New variable.
> Export it.
> ---
> guix/build/syscalls.scm | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
> index 9c082b435..5a6662afe 100644
> --- a/guix/build/syscalls.scm
> +++ b/guix/build/syscalls.scm
> @@ -88,6 +88,7 @@
>
> PF_PACKET
> AF_PACKET
> + network-interface-running?
> all-network-interface-names
> network-interface-names
> network-interface-netmask
> @@ -1108,6 +1109,7 @@ bytes."
> (define-as-needed IFF_UP #x1) ;Interface is up
> (define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
> (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
> +(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
>
> (define IF_NAMESIZE 16) ;maximum interface name size
>
> @@ -1282,6 +1284,13 @@ interface NAME."
> (close-port sock)
> (not (zero? (logand flags IFF_LOOPBACK)))))
>
> +(define (network-interface-running? name)
> + "Return true if NAME designates a running network interface."
> + (let* ((sock (socket SOCK_STREAM AF_INET 0))
> + (flags (network-interface-flags sock name)))
> + (close-port sock)
> + (not (zero? (logand flags IFF_RUNNING)))))

Could you also add a test in tests/syscalls.scm along the lines of the
‘loopback-network-interface?’ test that’s there? (I think the test can
assume that “lo” is running.)

OK with this change.

(And you can disregard the reply I sent just before.)

Thanks!

Ludo’.
Danny Milosavljevic wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27570@debbugs.gnu.org)
20170710163042.28800829@scratchpost.org
Toggle quote (4 lines)
> Could you also add a test in tests/syscalls.scm along the lines of the
> ‘loopback-network-interface?’ test that’s there? (I think the test can
> assume that “lo” is running.)

I did that now, however "make check" seems to be skipping the syscall tests. How do I run them?
Danny Milosavljevic wrote 8 years ago
(no subject)
(address . control@debbugs.gnu.org)
20170712161627.69389109@scratchpost.org
close 27570
?
Your comment

This issue is archived.

To comment on this conversation send an email to 27570@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 27570
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help