route: Add #:onlink? argument to route-add * ip/route.scm: (route-add) And #:onlink? argument & set the appropriate flag. * netlink/constant.scm: Add RTNH_F_* flags * doc/guile-netlink.texi (Route): Document it.
doc/guile-netlink.texi
740 | 740 | @deffn {Scheme Procedure} route-add @var{dest} [@var{#:ipv6?} #f] @ | |
741 | 741 | [@var{#:device} #f] [@var{#:table} RT_TABLE_MAIN] [@var{#:protocol} #f] @ | |
742 | 742 | [@var{#:scope} RT_SCOPE_LINK] [@var{#:type} RTN_UNICAST] @ | |
743 | - | [@var{#:priority} #f] [@var{#:src} #f] [@var{#:via} #f] | |
743 | + | [@var{#:priority} #f] [@var{#:src} #f] [@var{#:via} #f] @ | |
744 | + | [@var{onlink?} #f] | |
744 | 745 | Add the route described by the argmuents. @var{dest} is the destination network, | |
745 | 746 | in cidr notation (@code{addr/prefix}) or the string @code{"default"}. | |
746 | 747 | ||
… | |||
768 | 769 | If set, @var{#:via} is the gateway address. This is not in cidr notation, as | |
769 | 770 | the gateway is a single address, not a network. | |
770 | 771 | ||
772 | + | If set, @var{#:onlink?} adds the RTNH_F_ONLINK flag, which allows using the rule | |
773 | + | as if the next hop (specified by the @var{#:via} option) was present on the | |
774 | + | interface, even if its address is not part of the interface's network. | |
775 | + | ||
771 | 776 | @example | |
772 | 777 | (route-add "default" #:device "enp1s0" #:via "192.0.2.1") | |
773 | 778 | (route-add "192.0.2.0/24" #:device "enp1s0" #:src "192.0.2.15") |
ip/route.scm
112 | 112 | (define* (route-add dest | |
113 | 113 | #:key (ipv6? #f) (device #f) (table RT_TABLE_MAIN) | |
114 | 114 | (protocol RTPROT_BOOT) (scope RT_SCOPE_UNIVERSE) | |
115 | - | (type RTN_UNICAST) (priority #f) (src #f) (via #f)) | |
115 | + | (type RTN_UNICAST) (priority #f) (src #f) (via #f) | |
116 | + | (onlink? #f)) | |
116 | 117 | (define request-num (random 65535)) | |
117 | 118 | ||
118 | 119 | (define index | |
… | |||
136 | 137 | (or protocol 0) | |
137 | 138 | scope | |
138 | 139 | type | |
139 | - | 0 | |
140 | + | (if onlink? RTNH_F_ONLINK 0) | |
140 | 141 | `(,@(if (equal? dest "default") | |
141 | 142 | '() | |
142 | 143 | (list (make-route-attr RTA_DST |
netlink/constant.scm
340 | 340 | (RT_TABLE_MAIN 254) | |
341 | 341 | (RT_TABLE_LOCAL 255)) | |
342 | 342 | ||
343 | + | ;; rtnh_flags | |
344 | + | (define-enum int->rtnh-flag | |
345 | + | RTNH_F_DEAD | |
346 | + | RTNH_F_PERVASIVE | |
347 | + | (RTNH_F_ONLINK 4) | |
348 | + | (RTNH_F_OFFLOAD 8) | |
349 | + | (RTNH_F_LINKDOWN 16) | |
350 | + | (RTNH_F_UNRESOLVED 32) | |
351 | + | (RTNH_F_TRAP 64)) | |
352 | + | ||
343 | 353 | ;; link type | |
344 | 354 | ;; more at include/uapi/linux/if_arp.h | |
345 | 355 | (define-enum int->link-type |