unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Add VLAN with Guile Netlink link-add
@ 2022-01-10 11:29 Niklas Schmidt
  2022-01-11 13:01 ` Julien Lepiller
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Schmidt @ 2022-01-10 11:29 UTC (permalink / raw)
  To: help-guix

Dear Guix,

I really appreciate the ability to declare a static-networking 
configuration.

I face some difficulties adding a 802.1Q VLAN interface using the Guile 
Netlink package. I added guile-netlink to my operating system 
definition's packages field.

Running guile as root using su, I get the following error:

   scheme@(guile-user)> (use-modules (ip link))
   scheme@(guile-user)> (link-add "ens3.12" "vlan" #:type-args '((id .  12)))
   ice-9/boot-9.scm:1685:16: In procedure raise-exception:
   ERROR:
     1. &netlink-response-error: 22
   
   Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
   scheme@(guile-user) [1]> 


The documentation [1] states:

   Scheme Procedure: link-add name type [#:type-args '()]

     Add a new link with given name and type. Additional arguments can be passed to control the state of the link at creation. type-args is an association list containing additional values for the given type.

     When type is "vlan", type-args can contain a number associated with 'id: the VLAN id to be created.

It is unclear to me how to specify the hardware interface for which the 
VLAN link is to be added. Maybe I am missing something?

Calling the above command with "ens3" instead of "ens3.12" results in 
the same error.

I am able to add the link manually with iproute2 by executing

   ip link add link ens3 name ens3.12 type vlan id 12

and was able to verifiy that it works by assigning a static IPv4 
address.

If I run another command given in the documentation [1],

   (link-add "v0p0" "veth" #:type-args '((peer . "v0p1")))

that returns #t and creates the interface pair. So I think, Guile 
Netlink generally works with my configuration.

Has someone got a working code sample showing how to add VLANs using 
Guile Netlink?
I don't understand the internals of the Netlink kernel interface yet.  A 
comment in the source code [2] says that every link type except veth and 
vlan is not implemented in Guile Netlink. I am not sure whether the 
functionality I whish to use is supported at all.

My goal is to specify VLAN links in the links field of a 
static-networking record.

Im running Guix inside QEMU-KVM. If that would help, I am willing to 
test this on real hardware.

Thanks for advice.


Greetings
Niklas

[1]: https://git.lepiller.eu/guile-netlink/manual/html_node/Link.html
[2]: https://git.lepiller.eu/guile-netlink/tree/-/ip/link.scm


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

* Re: Add VLAN with Guile Netlink link-add
  2022-01-10 11:29 Add VLAN with Guile Netlink link-add Niklas Schmidt
@ 2022-01-11 13:01 ` Julien Lepiller
  2022-01-11 19:30   ` Niklas Schmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Lepiller @ 2022-01-11 13:01 UTC (permalink / raw)
  To: help-guix, Niklas Schmidt

Thanks for the report! It looks like I didn't read the netlink documentation properly and forgot a part of the message. I think I just fixed that in guile-netlink 1.1.2. You can access it with --with-latest=guile-netlink ;)

Le 10 janvier 2022 12:29:38 GMT+01:00, Niklas Schmidt <snlabs@posteo.net> a écrit :
>Dear Guix,
>
>I really appreciate the ability to declare a static-networking 
>configuration.
>
>I face some difficulties adding a 802.1Q VLAN interface using the Guile 
>Netlink package. I added guile-netlink to my operating system 
>definition's packages field.
>
>Running guile as root using su, I get the following error:
>
>   scheme@(guile-user)> (use-modules (ip link))
>   scheme@(guile-user)> (link-add "ens3.12" "vlan" #:type-args '((id .  12)))
>   ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>   ERROR:
>     1. &netlink-response-error: 22
>   
>   Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
>   scheme@(guile-user) [1]> 
>
>
>The documentation [1] states:
>
>   Scheme Procedure: link-add name type [#:type-args '()]
>
>     Add a new link with given name and type. Additional arguments can be passed to control the state of the link at creation. type-args is an association list containing additional values for the given type.
>
>     When type is "vlan", type-args can contain a number associated with 'id: the VLAN id to be created.
>
>It is unclear to me how to specify the hardware interface for which the 
>VLAN link is to be added. Maybe I am missing something?
>
>Calling the above command with "ens3" instead of "ens3.12" results in 
>the same error.
>
>I am able to add the link manually with iproute2 by executing
>
>   ip link add link ens3 name ens3.12 type vlan id 12
>
>and was able to verifiy that it works by assigning a static IPv4 
>address.
>
>If I run another command given in the documentation [1],
>
>   (link-add "v0p0" "veth" #:type-args '((peer . "v0p1")))
>
>that returns #t and creates the interface pair. So I think, Guile 
>Netlink generally works with my configuration.
>
>Has someone got a working code sample showing how to add VLANs using 
>Guile Netlink?
>I don't understand the internals of the Netlink kernel interface yet.  A 
>comment in the source code [2] says that every link type except veth and 
>vlan is not implemented in Guile Netlink. I am not sure whether the 
>functionality I whish to use is supported at all.
>
>My goal is to specify VLAN links in the links field of a 
>static-networking record.
>
>Im running Guix inside QEMU-KVM. If that would help, I am willing to 
>test this on real hardware.
>
>Thanks for advice.
>
>
>Greetings
>Niklas
>
>[1]: https://git.lepiller.eu/guile-netlink/manual/html_node/Link.html
>[2]: https://git.lepiller.eu/guile-netlink/tree/-/ip/link.scm
>

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

* Re: Add VLAN with Guile Netlink link-add
  2022-01-11 13:01 ` Julien Lepiller
@ 2022-01-11 19:30   ` Niklas Schmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Schmidt @ 2022-01-11 19:30 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: help-guix

Thanks a lot, Julien!

I really like the short examples in the documentation. They are very 
helpful to me.

Adding the VLAN link works now.

For anyone interested, here is what works for me, based on Julien's 
documentation:

As root (in order to configure network interfaces):

   root@guix ~# guix shell \
   > --pure \
   > --with-latest=guile-netlink \
   > guile guile-netlink \
   > -- guile
   guix shell: warning: cannot authenticate source of 'guile-netlink', version 1.1.2
   updating checkout of 'https://git.lepiller.eu/git/guile-netlink'...
   retrieved commit 81c33102905b6a4467bbe2eefb9c17c6c23a58b3
   Consider installing the 'guile-readline' package for
   convenient interactive line editing and input history.
   
   Consider installing the 'guile-colorized' package
   for a colorful Guile experience.
   
   GNU Guile 3.0.7
   Copyright (C) 1995-2021 Free Software Foundation, Inc.
   
   Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
   This program is free software, and you are welcome to redistribute it
   under certain conditions; type `,show c' for details.
   
   Enter `,help' for help.
   scheme@(guile-user)> (use-modules (ip link) (ip addr))   
   scheme@(guile-user)> (link-add "ens3.10" "vlan" #:type-args '((id . 10) (link . "ens3")))
   $1 = #t
   scheme@(guile-user)> (addr-add "ens3.10" "192.168.10.219/24")
   $2 = #t
   scheme@(guile-user)> (link-set "ens3.10" #:up #t)
   $3 = #t

A ping over the newly created link works.


Greetings
Niklas


On Tue, Jan 11, 2022 at 14:01:08 +0100, Julien Lepiller wrote:
>Thanks for the report! It looks like I didn't read the netlink documentation properly and forgot a part of the message. I think I just fixed that in guile-netlink 1.1.2. You can access it with --with-latest=guile-netlink ;)
>


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

end of thread, other threads:[~2022-01-11 19:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 11:29 Add VLAN with Guile Netlink link-add Niklas Schmidt
2022-01-11 13:01 ` Julien Lepiller
2022-01-11 19:30   ` Niklas Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).