From nobody Fri Dec 02 21:28:21 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NP5dx5nk8z4jMYJ; Fri, 2 Dec 2022 21:28:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NP5dx5DkCz4N2C; Fri, 2 Dec 2022 21:28:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670016501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F+J+dJg2hnbb5b3ekRNPM72c0ZWC4IkInNQNTQ+KlPY=; b=da/Byy05kmesaBipBnPdBV2CMG4kWEYwmIf9IgtTrrv6AdXbt7bVIGRkQm8PHGssHE3Y+A azU4pWCRWNh5TA2Vh1tFJXAWZlri/ddY9hJjWou79C2xEgzKBOqBJRUwyTQj8ar3R1EjiW 5/1OHugg7AAahm714QEo5PVYoG6yQxjqY/UQbYnU/bKFKI+lmhVyWfN1oZCEHBdB8B5yIH O/BUuGkN7XOf1oBDUaSrbz3q8G9yyHS6oAR08JPqWQapvYxIdyiwHUml4idDirYBc1dR0r YSCyjhkEi3cjbHeJflq0/eie5WKmNAoUwTYWHOoZLsymW6phc8D3a3rAqP53Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670016501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F+J+dJg2hnbb5b3ekRNPM72c0ZWC4IkInNQNTQ+KlPY=; b=KQrADchKqFnhXeItrmKC+QVqWH8oK95D5Mxv+wqZ8LEwqp8oGIaYA5Td001QVSzBA8sEsF EIkRmOynF0sDfO1oSI3N/ctWItE7jly/qJSc1ho4a6EwLBdNdbVTElv1If6Fp0ze1Yp01Z L7nptB9g6Ou7+EmjeyQOLpRkfqsHhNGDRvG7PcqWqHMLiV17rlY5n+j44PrZR1ix+bhuq5 qwA7RdL4SJe2YRQZjr48/N9/4IZfM/yd7E32mxHHhTUomHpiheGfgeNzX5QfsxC/yIoS97 df+fPayNd12qdbm01DqeVP7OE2KPdPrOEX1EgTFw/8z1qozN8h65nUbi7UPSnA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670016501; a=rsa-sha256; cv=none; b=nkerRFvp4UwjrIg4LYEnoMvar0yJbFr8pRRnGgQtsG1HJhCZmnvKjJdfYcOZZuPm9wVu0Z Za8m0JJUx6uob18mBvRXZDuaYqq46l+wC7K/1p7j60F2SAWmrAVUofc0H7lxCuX7dGkFcK FlxUCP08EOi0sYHPhdJL6Js1D4KGrKY5izEVd+rndV9aPs72QIIIvKn52sXPfxSD6jfeU7 iu4dDulH06JW5Hl03TMeTDVzPrAaaIKJTdfqBtVNZrX2hZcdulKnuozRO92lNwfjDos1xr EOKskHgx4V5BTCnZJDa9QSxDzi088cL5Qk2hmC5QRRgSTzCE+YX6aPBpocIfhA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NP5dx4G9JzW1H; Fri, 2 Dec 2022 21:28:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B2LSLeF019474; Fri, 2 Dec 2022 21:28:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B2LSLw9019473; Fri, 2 Dec 2022 21:28:21 GMT (envelope-from git) Date: Fri, 2 Dec 2022 21:28:21 GMT Message-Id: <202212022128.2B2LSLw9019473@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Allan Jude Subject: git: c6ec1b441ad3 - stable/13 - Add support for adding default routes for other FIBs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c6ec1b441ad3fdfa2d3a22d0b66d53006c5e292b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=c6ec1b441ad3fdfa2d3a22d0b66d53006c5e292b commit c6ec1b441ad3fdfa2d3a22d0b66d53006c5e292b Author: Andrew Fengler AuthorDate: 2021-05-12 01:59:10 +0000 Commit: Allan Jude CommitDate: 2022-12-02 21:27:57 +0000 Add support for adding default routes for other FIBs Make rc.d/routing read defaultrouter_fibN and ipv6_defaultrouter_fibN, and set it as the default gateway for FIB N, where N is from 1 to (net.fibs - 1) This allows adding gateways for multiple FIBs in the same format as the main gateway. (FIB 0) Reviewed by: olivier, rgrimes, bcr (man page) Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D22706 (cherry picked from commit 30659d1dcbcc92016833f0956461314ed501ac83) --- libexec/rc/rc.conf | 2 ++ libexec/rc/rc.d/routing | 38 ++++++++++++++++++++++++++++++++++++-- share/man/man5/rc.conf.5 | 11 ++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 46a81508f844..82796ba0ec48 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -446,6 +446,7 @@ bsnmpd_flags="" # Flags for bsnmpd. ### Network routing options: ### defaultrouter="NO" # Set to default gateway (or NO). +#defaultrouter_fibN="192.0.2.1" # Use this form to set a gateway for FIB N static_arp_pairs="" # Set to static ARP list (or leave empty). static_ndp_pairs="" # Set to static NDP list (or leave empty). static_routes="" # Set to static route list (or leave empty). @@ -508,6 +509,7 @@ ipv6_activate_all_interfaces="NO" # If NO, interfaces which have no # reason. ipv6_defaultrouter="NO" # Set to IPv6 default gateway (or NO). #ipv6_defaultrouter="2002:c058:6301::" # Use this for 6to4 (RFC 3068) +#ipv6_defaultrouter_fibN="2001:db8::" # Use this form to set a gateway for FIB N ipv6_static_routes="" # Set to static route list (or leave empty). #ipv6_static_routes="xxx" # An example to set fec0:0000:0000:0006::/64 # route toward loopback interface. diff --git a/libexec/rc/rc.d/routing b/libexec/rc/rc.d/routing index 043c5b15fbaa..37b3da0f0cef 100755 --- a/libexec/rc/rc.d/routing +++ b/libexec/rc/rc.d/routing @@ -140,11 +140,12 @@ get_fibmod() static_inet() { - local _action _if _skip _fibmod + local _action _if _skip _fibmod _fibs _action=$1 _if=$2 _fibmod=`get_fibmod` + _fibs=$((`${SYSCTL_N} net.fibs` - 1)) # Provide loopback route in all routing tables. This has to come # first so that any following routes can be added. @@ -161,6 +162,22 @@ static_inet() ;; esac + # Add default routes for fibs + if [ ${_fibs} -gt 0 ]; then + for _fibnum in `jot ${_fibs}` ; do + eval _fib_gw=\${defaultrouter_fib${_fibnum}} + case ${_fib_gw} in + [Nn][Oo] | '') + ;; + *) + static_routes="${static_routes} _default_fib${_fibnum}" + eval route__default_fib${fibnum}="'default ${_fib_gw} -fib ${_fibnum}'" + ;; + esac + done + fi + + # Install configured routes. if [ -n "${static_routes}" ]; then for i in ${static_routes}; do @@ -185,11 +202,12 @@ static_inet() static_inet6() { - local _action _if _skip fibmod allfibs + local _action _if _skip fibmod _fibs _action=$1 _if=$2 fibmod=`get_fibmod` + _fibs=$((`${SYSCTL_N} net.fibs` - 1)) # Add pre-defined static routes first. ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}" @@ -221,6 +239,22 @@ static_inet6() ;; esac + # Add default routes for fibs + if [ ${_fibs} -gt 0 ]; then + for _fibnum in `jot ${_fibs}` ; do + eval _fib_gw=\${ipv6_defaultrouter_fib${_fibnum}} + case ${_fib_gw} in + [Nn][Oo] | '') + ;; + *) + ipv6_static_routes="${static_routes} _default_fib${_fibnum}" + eval ipv6_route__default_fib${fibnum}="'default ${_fib_gw} -fib ${_fibnum}'" + ;; + esac + done + fi + + # Install configured routes. if [ -n "${ipv6_static_routes}" ]; then for i in ${ipv6_static_routes}; do diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 31c92d536b7c..03b86c48a2c7 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2022 +.Dd December 2, 2022 .Dt RC.CONF 5 .Os .Sh NAME @@ -2907,10 +2907,19 @@ If not set to create a default route to this host name or IP address (use an IP address if this router is also required to get to the name server!). +.It Va defaultrouter_fibN +.Pq Vt str +If not set to +.Dq Li NO , +create a default route in FIB N to this host name or IP address. .It Va ipv6_defaultrouter .Pq Vt str The IPv6 equivalent of .Va defaultrouter . +.It Va ipv6_defaultrouter_fibN +.Pq Vt str +The IPv6 equivalent of +.Va defaultrouter_fibN . .It Va static_arp_pairs .Pq Vt str Set to the list of static ARP pairs that are to be added at system