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

From: Alexey Abramov <[email-masked]>
Date: Mon, 28 Aug 2023 18:57:32 +0200

Hi Ludo, Julien

Ludovic Courtès <[email-masked]> writes:

> Hi Alexey,
>
> Alexey Abramov <[email-masked]> skribis:
>
>> * gnu/services/base.scm (<network-link-by-macaddress>,
>> <network-link-by-name>): Provide records to match *existing*
>> interfaces and amend them.
>> * gnu/services/base.scm (network-set-up/linux,
>> network-tear-down/linux): Add support to change settings of existing
>> interfaces. Move address cleanup above links cleanup.
>> * doc/guix.texi (Networking Setup): Document it.
>> * gnu/tests/networking.scm (run-static-networking-advanced-test): Add tests
>
> Sounds like a great addition!
>
> Not being a networking expert, I’d like to have someone else comment on
> it (Cc’ing Julien in case they’re around), but I can make some
> preliminary comments:

Many thanks! 

>>  @deftp {Data Type} network-link
>>  Data type for a network link (@pxref{Link,,, guile-netlink,
>> -Guile-Netlink Manual}).
>> +Guile-Netlink Manual}).  A new interface with settings, specified in
>> +arguments will be created.
>
> I don’t understand this sentence, especially since creating a
> <network-link> record will not create a new interface.

Yeah. You right. I somehow got an impression that network-link is for
link-add.  No comments. )

[...]

> My first reaction is that a “network link matched by MAC address” is
> still “a network link”.  IOW, I would find it more natural to have a
> single data type; it would also mirror the data types used by the
> RTnetlink layer.
>
> To do that, what would you think of keeping just the <network-link>
> record, but adding two new fields: ‘for-mac-address’ and
> ‘for-device’?
>
> (As an aside, please don’t abbreviate; so ‘mac-address’ rather than
> ‘macaddress’.)

I like that, thanks.  I have a patch series where you can define the
configuration like this:

--8<---------------cut here---------------start------------->8---
(list (network-link
       (name "bond0")
       (type "bond")
       (arguments '((mode . "802.3ad")
                    (miimon . 100)
                    (lacp-active . "on")
                    (lacp-rate . "fast"))))

      (network-link
       (for-mac-address "98:11:22:33:44:55")
       (arguments '((name . "a")
                    (master . "bond0"))))
      (network-link
       (for-mac-address "98:11:22:33:44:56")
       (arguments '((name . "b")
                    (master . "bond0"))))

      (network-link
       (name "bond0.1055")
       (type "vlan")
       (arguments '((id . 1055)
                    (link . "bond0")))))
--8<---------------cut here---------------end--------------->8---

Is that what you meant?  However, after your suggestions... What do you
think if we could use the name field without type to amend existing
ones, and for example netlink with mac-address field only, to match
interfaces by mac. Something like this:

--8<---------------cut here---------------start------------->8---
(list (network-link
       (mac-address "98:11:22:33:44:55")
       (arguments '((name . "a"))))

      (network-link
       (mac-address "98:11:22:33:44:56")
       (arguments '((name . "b"))))

      (network-link
       (name "bond0")
       (type "bond")
       (arguments '((mode . "802.3ad")
                    (miimon . 100)
                    (lacp-active . "on")
                    (lacp-rate . "fast"))))
      
      (network-link
       (name "a")
       (arguments '((master . "bond0"))))

      (network-link
       (name "b")
       (arguments '((master . "bond0"))))

      (network-link
       (name "bond0.1055")
       (type "vlan")
       (arguments '((id . 1055)
                    (link . "bond0")))))
--8<---------------cut here---------------end--------------->8---

IMHO this does look better.  What do you think? 

>> +Here is another example for more advance configuration with bonds and
>> +vlans.  The following snippet will create a bond out of two interfaces,
>> +rename the slaves and create a vlan 1055 on top of it.
>
> Could you (1) explain in one or two sentences what bonds and VLANs are,
> ideally with a cross-reference to learn more about it, and (2) explain
> the example in a bit more detail?

Got it, will do.

> I would also encourage you to use the “upstream” and “downstream”
> rather than “master” and “slave”, due to their obvious connotation,
> though I realize that Guile-Netlink and presumably Linux/RTnetlink
> itself use that terminology.

I see.  The technology is indeed uses this exact connotation.
Documentation [1] itself also uses these terms.

I personally, don't see how this change will help people with
configuration or searching for documentation.

With all respect, truly, I would like to keep master/slave terminology,
at least here.

> This is awesome!

) I am trying. 

-- 
Alexey

Footnotes:
[1]  https://www.kernel.org/doc/Documentation/networking/bonding.txt