mbox series

[bug#64616,0/1] services: static-networking: Add support for bonds and vlans

Message ID 20230714152958.22645-1-levenson@mmer.org
Headers show
Series services: static-networking: Add support for bonds and vlans | expand

Message

Alexey Abramov July 14, 2023, 3:29 p.m. UTC
Hi Guix!

After new release of guile-netlink, I made some changes on a guix side to be
able to configure bonds and vlans using static-networking declaration.

In short, I introduced two more structures for *matching* existing interfaces:
<network-link-by-macaddress> and <network-link-by-name>. The reason for that
is that <network-link> struct creates new interfaces in network-set-up/linux.
And if we want to construct a bond we need a way to apply settings for
existing interfaces.

With these changes applied, it is passable to do something like this:

(static-networking
 (links (list (network-link
               (name "bond0")
               (type "bond")
               (arguments '((mode . "802.3ad")
                            (miimon . 100)
                            (lacp-active . "on")
                            (lacp-rate . "fast"))))

              (network-link-by-macaddress
               (macaddress "98:11:22:33:44:55")
               (arguments '((master . "bond0"))))
              (network-link-by-macaddress
               (macaddress "98:11:22:33:44:56")
               (arguments '((master . "bond0"))))

              (network-link
               (name "bond0.1055")
               (type "vlan")
               (arguments '((id . 1055)
                            (link . "bond0"))))))
 (addresses (list (network-address
                   (value "192.168.1.4/24")
                   (device "bond0.1055")))))

This example is taken from the test, where I removed interface renaming
step. You should also know that network stack in Qemu won't with this
configuration.  The purpose of the test was to check if the stack has proper
settings.  If it is not enough, Please let me know.  I can try to use
openvswitch for that

There is one thing that bothers me. Here is a comment I put in the code:

It is interesting that "modprobe bonding" creates an interface bond0 straigt
away.  If we won't have bonding module, and execute `ip link add name bond0
type bond' we will get

RTNETLINK answers: File exists

This breaks our configuration if we want to use `bond0' name.  Create (force
modprobe bonding) and delete the interface to free up.  As you can see I
create an interface bond0 (in case some bonds are in configuration). It is
forces netlink to load the bonding module and then delete it to free up the
'name'.

Please let me know what you think.

Alexey Abramov (1):
  services: static-networking: Add support for bonding.

 doc/guix.texi            |  61 ++++++++++++++++-
 gnu/services/base.scm    | 109 +++++++++++++++++++++++++++---
 gnu/tests/networking.scm | 141 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 299 insertions(+), 12 deletions(-)

Comments

宋文武 July 22, 2023, 3:12 a.m. UTC | #1
Alexey Abramov <levenson@mmer.org> writes:

> Hi Guix!
>
> After new release of guile-netlink, I made some changes on a guix side to be
> able to configure bonds and vlans using static-networking declaration.

Hello I think this is a useful feature!
>
> In short, I introduced two more structures for *matching* existing interfaces:
> <network-link-by-macaddress> and <network-link-by-name>. The reason for that
> is that <network-link> struct creates new interfaces in network-set-up/linux.
> And if we want to construct a bond we need a way to apply settings for
> existing interfaces.

If I understand correctly, this will allow we create bond interfaces in
static-networking-service-type and configure those interfaces with
static IP.  Maybe there are needs for create bond interfaces, but
configure them with dhcp dynamic IP, will we able to that with this
patch?
Alexey Abramov July 25, 2023, 11:07 a.m. UTC | #2
Hi!

宋文武 <iyzsong@envs.net> writes:

> Alexey Abramov <levenson@mmer.org> writes:
>
>> Hi Guix!
>>
>> After new release of guile-netlink, I made some changes on a guix side to be
>> able to configure bonds and vlans using static-networking declaration.
>
> Hello I think this is a useful feature!
>>
>> In short, I introduced two more structures for *matching* existing interfaces:
>> <network-link-by-macaddress> and <network-link-by-name>. The reason for that
>> is that <network-link> struct creates new interfaces in network-set-up/linux.
>> And if we want to construct a bond we need a way to apply settings for
>> existing interfaces.
>
> If I understand correctly, this will allow we create bond interfaces in
> static-networking-service-type and configure those interfaces with
> static IP.  Maybe there are needs for create bond interfaces, but
> configure them with dhcp dynamic IP, will we able to that with this
> patch?

Thanks for taking the time to check it.  You absolutely right.  Running
dhcp-client and static-networking on routers, for example, is must.  This patch won't
allow this, but another one related to dhcp-client-configuration bug#64850 will.