link: Support unsetting master.

Sergey TrofimovSat Feb 14 13:51:03+0100 2026

0e4f4aa

link: Support unsetting master. * ip/link.scm (link-set): Add #:nomaster argument. * doc/guile-netlink.texi: Document it.

doc/guile-netlink.texi

212212
  [#:promisc-on @code{#f}] [#:promisc-off @code{#f}] [#:trailers-on @code{#f}] @
213213
  [#:trailers-off @code{#f}] [#:carrier-on @code{#f}] [#:carrier-off @code{#f}] @
214214
  [#:txqueuelen @code{#f}] [#:name @code{#f}] [#:address @code{#f}] @
215-
  [#:broadcast @code{#f}] [#:mtu @code{#f}] [#:netns @code{#f}]
215+
  [#:broadcast @code{#f}] [#:mtu @code{#f}] [#:netns @code{#f}] @
216+
  [#:master @code{#f}] [#:nomaster @code{#f}]
216217
Modify an existing link and set its flags and attributes to the ones specified
217218
by the various keywords.  When a keyword is omited, the corresponding attribute
218219
is not changed.

220221
@var{device} can be a device index (as a number) or a device name (as a string).
221222
222223
Do not set @code{#:up} and @code{#:down} at the same time.  Do not set
223-
@code{*-on} and @code{*-off} at the same time.
224+
@code{*-on} and @code{*-off} at the same time. Do not set @code{#:master}
225+
and @code{#:nomaster} at the same time (the latter is ignored).
224226
@end deffn
225227
226228
@deffn {Scheme Procedure} link-show [#:device @code{#f}] [#:group @code{#f}] @

ip/link.scm

177177
                   (carrier-on #f) (carrier-off #f)
178178
                   (txqueuelen #f) (name #f) (address #f)
179179
                   (broadcast #f) (mtu #f) (netns #f)
180-
                   (master #f))
180+
                   (master #f) (nomaster #f))
181181
  (define request-num (random 65535))
182182
  (define id (if (number? device) device (link-name->index device)))
183183
  (define netnsfd (cond

242242
                  (make-route-attr IFLA_MTU
243243
                    (make-u32-route-attr mtu)))
244244
                '())
245-
          ,@(if master
245+
          ,@(if (or master nomaster)
246246
                (list
247247
                  (make-route-attr IFLA_MASTER
248-
                    (make-u32-route-attr (link-name->index master))))
248+
                    (make-u32-route-attr
249+
                     (if master (link-name->index master) 0))))
249250
                '())
250251
          ,@(if netns
251252
                (list