Fix vlan creation.

Julien LepillerTue Jan 11 13:55:41+0100 2022

1fece59

Fix vlan creation.

doc/guile-netlink.texi

580580
list containing additional values for the given type.
581581
582582
When @var{type} is @code{"vlan"}, @var{type-args} can contain a number associated
583-
with @code{'id}: the VLAN id to be created.
583+
with @code{'id}: the VLAN id to be created and a link name associated with
584+
@code{"link"}: the name of the link on which the vlan is created.
585+
586+
The following is an example in which we create a new vlan link:
587+
@example
588+
;; same as "ip l add link eth0 name eth0.7 type vlan id 7"
589+
(link-add "eth0.7" "vlan" #:type-args '((id . 7) (link . "eth0")))
590+
@end example
584591
585592
When @var{type} is @code{"veth"}, @var{type-args} can contain a string associated
586593
with @code{'peer}: the name of the peer.

ip/link.scm

276276
        0
277277
        0
278278
        0
279-
        (list
280-
          (make-route-attr IFLA_IFNAME
279+
        `(,(make-route-attr IFLA_IFNAME
281280
            (make-string-route-attr name))
282-
          (make-route-attr IFLA_LINKINFO
281+
          ,(make-route-attr IFLA_LINKINFO
283282
            (make-nested-route-attr
284283
              (list
285284
                (make-route-attr IFLA_INFO_KIND
286285
                  (make-string-route-attr type))
287286
                (make-route-attr IFLA_INFO_DATA
288-
                  (make-nested-route-attr type-data)))))))))
287+
                  (make-nested-route-attr type-data)))))
288+
          ,@(if (assoc-ref type-args 'link)
289+
                `(,(make-route-attr IFLA_LINK
290+
                     (make-u32-route-attr (link-name->index (assoc-ref type-args 'link)))))
291+
                '())))))
289292
  (let ((sock (connect-route)))
290293
    (send-msg message sock)
291294
    (let ((answer (receive-and-decode-msg sock %default-route-decoder)))