git: b5f6beefa00a - main - rc.subr: ensure run_rc_script return code is not masked by DebugOff
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=b5f6beefa00abf9ef51d4c53563f46c5a388a18e commit b5f6beefa00abf9ef51d4c53563f46c5a388a18e Author: R. Christian McDonald AuthorDate: 2024-09-10 15:58:57 + Commit: R. Christian McDonald CommitDate: 2024-09-10 18:58:47 + rc.subr: ensure run_rc_script return code is not masked by DebugOff Ensure that run_rc_script returns the true return code of the rc command and not the return code of DebugOff Reviewed by:sjg Approved by:kp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46626 --- libexec/rc/rc.subr | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 145b626aa01e..4bb2333addc2 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1844,7 +1844,7 @@ run_rc_script() trap "echo Script $_file running >&2" 29 set $_arg; . $_file ) fi - DebugOff $_file $_file:$_arg rc:${_file##*/} rc:${_file##*/}:$_arg ${_file##*/} ${_file##*/}:$_arg + DebugOff rc=$? $_file $_file:$_arg rc:${_file##*/} rc:${_file##*/}:$_arg ${_file##*/} ${_file##*/}:$_arg fi ;; esac @@ -2769,7 +2769,18 @@ $_DEBUG_SH vdot /libexec/debug.sh # safe_eval.sh are not found. if ! have DebugOn; then DebugOn() { return 0; } - DebugOff() { return 0; } + DebugOff() { + local _rc=0 + while : + do + case "$1" in + -[eo]) shift;; # ignore it + rc=*) eval "_$1"; shift;; + *) break;; + esac + done + return $_rc + } fi if ! have save_dot; then safe_dot() { dot "$@"; }
git: 4269d1a2e496 - main - rc.subr: fix typo "save_dot" -> "safe_dot"
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=4269d1a2e4967eb74cbef38ecc72ef9a08f51396 commit 4269d1a2e4967eb74cbef38ecc72ef9a08f51396 Author: R. Christian McDonald AuthorDate: 2024-09-11 14:40:04 + Commit: R. Christian McDonald CommitDate: 2024-09-13 20:51:40 + rc.subr: fix typo "save_dot" -> "safe_dot" Reviewed by:sjg Approved by:kp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46644 --- libexec/rc/rc.subr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 4bb2333addc2..df1501707a67 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -2782,6 +2782,6 @@ if ! have DebugOn; then return $_rc } fi -if ! have save_dot; then +if ! have safe_dot; then safe_dot() { dot "$@"; } fi
git: 5086b6ec32d5 - main - libbe: handle destroying/renaming temporary/bootonce boot environments
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=5086b6ec32d5c82c3d0894eb7bd74a9b81480644 commit 5086b6ec32d5c82c3d0894eb7bd74a9b81480644 Author: R. Christian McDonald AuthorDate: 2024-01-26 16:39:38 + Commit: R. Christian McDonald CommitDate: 2024-01-29 15:07:49 + libbe: handle destroying/renaming temporary/bootonce boot environments When a temporary/bootonce boot environment is renamed, we need to also update the bootenv nvlist on-disk to reflect the new name. Additionally, when a temporary/bootonce boot environment is destroyed, we also need to clear out the on-disk state. Reviewed by:kevans Approved by:kp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D43591 --- lib/libbe/be.c | 23 -- lib/libbe/be_impl.h| 1 + lib/libbe/be_info.c| 7 +-- sbin/bectl/tests/bectl_test.sh | 102 - 4 files changed, 113 insertions(+), 20 deletions(-) diff --git a/lib/libbe/be.c b/lib/libbe/be.c index c74ec9b0f3dc..e61cfc9d68ae 100644 --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -175,6 +175,9 @@ libbe_init(const char *root) strcmp(altroot, "-") != 0) lbh->altroot_len = strlen(altroot); + (void) lzbe_get_boot_device(zpool_get_name(lbh->active_phandle), + &lbh->bootonce); + return (lbh); err: if (lbh != NULL) { @@ -199,6 +202,8 @@ libbe_close(libbe_handle_t *lbh) if (lbh->active_phandle != NULL) zpool_close(lbh->active_phandle); libzfs_fini(lbh->lzh); + + free(lbh->bootonce); free(lbh); } @@ -443,6 +448,12 @@ be_destroy_internal(libbe_handle_t *lbh, const char *name, int options, return (set_error(lbh, BE_ERR_DESTROYMNT)); } } + + /* Handle destroying bootonce */ + if (lbh->bootonce != NULL && + strcmp(path, lbh->bootonce) == 0) + (void) lzbe_set_boot_device( + zpool_get_name(lbh->active_phandle), lzbe_add, NULL); } else { /* * If we're initially destroying a snapshot, origin options do @@ -1021,11 +1032,17 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new) .nounmount = 1, }; err = zfs_rename(zfs_hdl, full_new, flags); + if (err != 0) + goto error; + + /* handle renaming bootonce */ + if (lbh->bootonce != NULL && + strcmp(full_old, lbh->bootonce) == 0) + err = be_activate(lbh, new, true); +error: zfs_close(zfs_hdl); - if (err != 0) - return (set_error(lbh, BE_ERR_UNKNOWN)); - return (0); + return (set_error(lbh, err)); } diff --git a/lib/libbe/be_impl.h b/lib/libbe/be_impl.h index d5fd26c4f072..0327f8abaa0a 100644 --- a/lib/libbe/be_impl.h +++ b/lib/libbe/be_impl.h @@ -36,6 +36,7 @@ struct libbe_handle { char root[BE_MAXPATHLEN]; char rootfs[BE_MAXPATHLEN]; char bootfs[BE_MAXPATHLEN]; + char *bootonce; size_t altroot_len; zpool_handle_t *active_phandle; libzfs_handle_t *lzh; diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c index 88a9b17bf421..509b56cb8cf5 100644 --- a/lib/libbe/be_info.c +++ b/lib/libbe/be_info.c @@ -181,8 +181,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p) dataset = zfs_get_name(zfs_hdl); nvlist_add_string(props, "dataset", dataset); - if (data->bootonce != NULL && - strcmp(dataset, data->bootonce) == 0) + if (data->lbh->bootonce != NULL && + strcmp(dataset, data->lbh->bootonce) == 0) nvlist_add_boolean_value(props, "bootonce", true); name = strrchr(dataset, '/') + 1; @@ -252,9 +252,6 @@ be_proplist_update(prop_data_t *data) ZFS_TYPE_FILESYSTEM)) == NULL) return (BE_ERR_ZFSOPEN); - (void) lzbe_get_boot_device(zpool_get_name(data->lbh->active_phandle), - &data->bootonce); - /* XXX TODO: some error checking here */ zfs_iter_filesystems(root_hdl, prop_list_builder_cb, data); diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh index 0f167829cf46..00c71e11de09 100755 --- a/sbin/bectl/tests/bectl_test.sh +++ b/sbin/bectl/tests/bectl_test.sh @@ -93,7 +93,6 @@ bectl_cleanup() atf_test_case bectl_create cleanup bectl_create_head() { - atf_set "descr" "Check the various forms of bectl create" atf_set "require.user" root }
git: 576fbcbf2dc0 - main - Add myself (rcm) to the calendar.
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=576fbcbf2dc08f6a4a9f373a916cec2af246f93b commit 576fbcbf2dc08f6a4a9f373a916cec2af246f93b Author: R. Christian McDonald AuthorDate: 2024-03-18 20:25:43 + Commit: R. Christian McDonald CommitDate: 2024-03-18 20:26:59 + Add myself (rcm) to the calendar. Reminded by:mckusick --- usr.bin/calendar/calendars/calendar.freebsd | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd index 0d8e57137d13..32ad28c01d8c 100644 --- a/usr.bin/calendar/calendars/calendar.freebsd +++ b/usr.bin/calendar/calendars/calendar.freebsd @@ -418,6 +418,7 @@ 10/21 Daniel Ebdrup Jensen born in Aalborg, Denmark, 19XX 10/21 Vladimir Vladimirovich Druzenko born in Kishinev, USSR, 1979 10/22 Jean-Sebastien Pedron born in Redon, Ille-et-Vilaine, France, 1980 +10/22 R. Christian McDonald born in Columbia, South Carolina, United States, 1991 10/23 Mario Sergio Fujikawa Ferreira born in Brasilia, Distrito Federal, Brazil, 1976 10/23 Romain Tartière born in Clermont-Ferrand, France, 1984 10/25 Eric Melville born in Los Gatos, California, United States, 1980
git: 34de1d507b53 - main - committers-src: Add rcm as a src committer and kp as mentor
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=34de1d507b53e160f6478da8acfecc7ab870d9a8 commit 34de1d507b53e160f6478da8acfecc7ab870d9a8 Author: R. Christian McDonald AuthorDate: 2023-11-20 14:43:23 + Commit: R. Christian McDonald CommitDate: 2023-11-20 16:23:07 + committers-src: Add rcm as a src committer and kp as mentor Approved by:kp --- share/misc/committers-src.dot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 932204a2814d..4e5119df9897 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -309,6 +309,7 @@ qingli [label="Qing Li\nqin...@freebsd.org\n2005/04/13"] rajeshasp [label="Rajesh Kumar M A\nrajesh...@freebsd.org\n2021/01/27"] ram [label="Ram Kishore Vegesna\n...@freebsd.org\n2018/04/04"] ray [label="Aleksandr Rybalko\n...@freebsd.org\n2011/05/25"] +rcm [label="R. Christian McDonald\n...@freebsd.org\n2023/11/14"] rdivacky [label="Roman Divacky\nrdiva...@freebsd.org\n2008/03/13"] remko [label="Remko Lodder\nre...@freebsd.org\n2007/02/23"] rew [label="Robert Wing\n...@freebsd.org\n2020/07/23"] @@ -729,6 +730,7 @@ kmacy -> lstewart kp -> donner kp -> nick +kp -> rcm kp -> zlei lwhsu -> khng
git: 0b01d45783c3 - main - loader: fix EFI ACPI detection
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=0b01d45783c3ee5a544c882d1b147e4a60382c41 commit 0b01d45783c3ee5a544c882d1b147e4a60382c41 Author: R. Christian McDonald AuthorDate: 2023-11-20 17:02:24 + Commit: R. Christian McDonald CommitDate: 2023-11-20 19:03:59 + loader: fix EFI ACPI detection lua was previously unable to determine ACPI presence because this probing was postponed until the final loading and execution of the kernel. This patch resolves that by detecting ACPI early (similar to the order of operations in the legacy i386 loader). Reviewed by:kevans Approved by:kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42459 --- stand/efi/loader/arch/amd64/elf64_freebsd.c | 44 --- stand/efi/loader/arch/arm64/exec.c | 54 + stand/efi/loader/main.c | 42 ++ 3 files changed, 43 insertions(+), 97 deletions(-) diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c index 196efb048064..5a41ea99867e 100644 --- a/stand/efi/loader/arch/amd64/elf64_freebsd.c +++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c @@ -41,17 +41,8 @@ #include "bootstrap.h" -#include "platform/acfreebsd.h" -#include "acconfig.h" -#define ACPI_SYSTEM_XFACE -#include "actypes.h" -#include "actbl.h" - #include "loader_efi.h" -static EFI_GUID acpi_guid = ACPI_TABLE_GUID; -static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; - extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs); @@ -104,9 +95,6 @@ elf64_exec(struct preloaded_file *fp) Elf_Ehdr*ehdr; vm_offset_t modulep, kernend, trampcode, trampstack; int err, i; - ACPI_TABLE_RSDP *rsdp; - charbuf[24]; - int revision; boolcopy_auto; copy_auto = copy_staging == COPY_STAGING_AUTO; @@ -114,38 +102,6 @@ elf64_exec(struct preloaded_file *fp) copy_staging = fp->f_kernphys_relocatable ? COPY_STAGING_DISABLE : COPY_STAGING_ENABLE; - /* -* Report the RSDP to the kernel. While this can be found with -* a BIOS boot, the RSDP may be elsewhere when booted from UEFI. -*/ - - rsdp = efi_get_table(&acpi20_guid); - if (rsdp == NULL) { - rsdp = efi_get_table(&acpi_guid); - } - if (rsdp != NULL) { - sprintf(buf, "0x%016llx", (unsigned long long)rsdp); - setenv("acpi.rsdp", buf, 1); - revision = rsdp->Revision; - if (revision == 0) - revision = 1; - sprintf(buf, "%d", revision); - setenv("acpi.revision", buf, 1); - strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); - buf[sizeof(rsdp->OemId)] = '\0'; - setenv("acpi.oem", buf, 1); - sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); - setenv("acpi.rsdt", buf, 1); - if (revision >= 2) { - /* XXX extended checksum? */ - sprintf(buf, "0x%016llx", - (unsigned long long)rsdp->XsdtPhysicalAddress); - setenv("acpi.xsdt", buf, 1); - sprintf(buf, "%d", rsdp->Length); - setenv("acpi.xsdt_length", buf, 1); - } - } - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c index 09be15b2b6f3..ef410a7d556c 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -40,16 +40,6 @@ #include "loader_efi.h" #include "cache.h" -#include "platform/acfreebsd.h" -#include "acconfig.h" -#define ACPI_SYSTEM_XFACE -#define ACPI_USE_SYSTEM_INTTYPES -#include "actypes.h" -#include "actbl.h" - -static EFI_GUID acpi_guid = ACPI_TABLE_GUID; -static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; - static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); @@ -73,52 +63,10 @@ elf64_exec(struct preloaded_file *fp) vm_offset_t clean_addr; size_t clean_size; struct file_metadata *md; - ACPI_TABLE_RSDP *rsdp; Elf_Ehdr *ehdr; -
git: e0f3dc82727f - main - loader: improve lua ACPI detection and handling
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=e0f3dc82727f236b0bea495d8a4d6e6dc630854d commit e0f3dc82727f236b0bea495d8a4d6e6dc630854d Author: R. Christian McDonald AuthorDate: 2023-11-20 17:13:08 + Commit: R. Christian McDonald CommitDate: 2023-11-20 19:03:59 + loader: improve lua ACPI detection and handling This is a follow-up patch to https://reviews.freebsd.org/D42459 that modifies the loader lua to use the correct loader variables for determining ACPI availability. This also fixes a bug where ACPI can be inadvertently disabled when setting System Defaults at the loader menu. Reviewed by:imp, kevans Approved by:kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42483 --- stand/lua/core.lua | 39 +++ stand/lua/core.lua.8 | 24 ++-- stand/lua/menu.lua | 2 +- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/stand/lua/core.lua b/stand/lua/core.lua index 8a481ee0b782..718783309687 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -32,6 +32,7 @@ local hook = require("hook") local core = {} +local default_acpi = false local default_safe_mode = false local default_single_user = false local default_verbose = false @@ -46,20 +47,14 @@ local function composeLoaderCmd(cmd_name, argstr) end local function recordDefaults() - -- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386, - -- it will generally be set upon execution of the kernel. Because of - -- this, we can't (or don't really want to) detect/disable ACPI on !i386 - -- reliably. Just set it enabled if we detect it and leave well enough - -- alone if we don't. - local boot_acpi = core.isSystem386() and core.getACPIPresent(false) local boot_single = loader.getenv("boot_single") or "no" local boot_verbose = loader.getenv("boot_verbose") or "no" + + default_acpi = core.getACPI() default_single_user = boot_single:lower() ~= "no" default_verbose = boot_verbose:lower() ~= "no" - if boot_acpi then - core.setACPI(true) - end + core.setACPI(default_acpi) core.setSingleUser(default_single_user) core.setVerbose(default_verbose) end @@ -137,18 +132,18 @@ function core.setSingleUser(single_user) core.su = single_user end -function core.getACPIPresent(checking_system_defaults) - local c = loader.getenv("hint.acpi.0.rsdp") +function core.hasACPI() + return loader.getenv("acpi.rsdp") ~= nil +end - if c ~= nil then - if checking_system_defaults then - return true - end - -- Otherwise, respect disabled if it's set - c = loader.getenv("hint.acpi.0.disabled") - return c == nil or tonumber(c) ~= 1 +function core.getACPI() + if not core.hasACPI() then + return false end - return false + + -- Otherwise, respect disabled if it's set + local c = loader.getenv("hint.acpi.0.disabled") + return c == nil or tonumber(c) ~= 1 end function core.setACPI(acpi) @@ -358,7 +353,7 @@ function core.loadEntropy() end function core.setDefaults() - core.setACPI(core.getACPIPresent(true)) + core.setACPI(default_acpi) core.setSafeMode(default_safe_mode) core.setSingleUser(default_single_user) core.setVerbose(default_verbose) @@ -441,10 +436,6 @@ function core.isSerialBoot() return false end -function core.isSystem386() - return loader.machine_arch == "i386" -end - -- Is the menu skipped in the environment in which we've booted? function core.isMenuSkipped() return string.lower(loader.getenv("beastie_disable") or "") == "yes" diff --git a/stand/lua/core.lua.8 b/stand/lua/core.lua.8 index 39ae2166d442..61eab6fe24f6 100644 --- a/stand/lua/core.lua.8 +++ b/stand/lua/core.lua.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 21, 2018 +.Dd November 20, 2023 .Dt CORE.LUA 8 .Os .Sh NAME @@ -90,7 +90,7 @@ constants. .Ss Exported functions The following functions are exported from .Nm : -.Bl -tag -width core.getACPIPresent -offset indent +.Bl -tag -width core.setSingleUser -offset indent .It Fn core.setVerbose verbose Sets or unsets .Ev boot_verbose . @@ -103,15 +103,14 @@ Sets or unsets If .Fa singleUser is omitted, toggle the current single user setting. -.It Fn core.getACPIPresent checkingSystemDefaults -Check whether ACPI is present. -This will onl
git: f818559774cb - main - netlink: fix adding an interface route
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=f818559774cb0c1516364c4beca361480fd68b5b commit f818559774cb0c1516364c4beca361480fd68b5b Author: KUROSAWA Takahiro AuthorDate: 2023-11-28 18:14:50 + Commit: R. Christian McDonald CommitDate: 2023-11-28 21:11:55 + netlink: fix adding an interface route route add -iface " for a netif without an IPv4/IPv6 address fails with EINVAL. Need to use a link-level ifaddr for gw if an ifaddr for dst is not found as the rtsock-based implementation does. PR: 275341 Reported by:Sean Cody Reviewed by:rcm Tested by: rcm Approved by:kp (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41330 --- sys/netlink/route/rt.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c index cfaa2167b0d2..ed09748995dc 100644 --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -750,9 +750,14 @@ finalize_nhop(struct nhop_object *nh, const struct sockaddr *dst, int *perror) struct ifaddr *ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); if (ifa == NULL) { - NL_LOG(LOG_DEBUG, "Unable to determine ifa, skipping"); - *perror = EINVAL; - return (NULL); + /* Try link-level ifa. */ + gw_sa = &nh->gw_sa; + ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); + if (ifa == NULL) { + NL_LOG(LOG_DEBUG, "Unable to determine ifa, skipping"); + *perror = EINVAL; + return (NULL); + } } nhop_set_src(nh, ifa); }
git: ca7edd0d2c33 - main - route: introduce add interface route test cases
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=ca7edd0d2c339b8e6e5e52257ea6d4f22db02550 commit ca7edd0d2c339b8e6e5e52257ea6d4f22db02550 Author: R. Christian McDonald AuthorDate: 2023-11-28 18:18:15 + Commit: R. Christian McDonald CommitDate: 2023-11-28 21:16:25 + route: introduce add interface route test cases As a followup to D41330 and D41436, this patch introduces two new tests for sbin/route: interface_route_v[46]. These tests fail without D41330. Reviewed by:kp Approved by:kp (mentor) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/route/tests/basic.sh | 58 +++ 1 file changed, 58 insertions(+) diff --git a/sbin/route/tests/basic.sh b/sbin/route/tests/basic.sh index bb432daa0793..2e2ab9dba97f 100644 --- a/sbin/route/tests/basic.sh +++ b/sbin/route/tests/basic.sh @@ -117,8 +117,66 @@ basic_v6_cleanup() vnet_cleanup } +atf_test_case "interface_route_v4" "cleanup" +interface_route_v4_head() +{ + atf_set descr 'add interface route for v4' + atf_set require.user root + atf_set require.progs jail jq +} + +interface_route_v4_body() +{ + epair=$(vnet_mkepair) + ifconfig ${epair}a up + vnet_mkjail alcatraz ${epair}b + + # add interface route + jexec alcatraz route add "192.0.2.1" -iface ${epair}b + gateway=$(check_route "alcatraz" "192.0.2.1") + + if [ -z "${gateway}" ]; then + atf_fail "Failed to add interface route." + fi +} + +interface_route_v4_cleanup() +{ + vnet_cleanup +} + +atf_test_case "interface_route_v6" "cleanup" +interface_route_v6_head() +{ + atf_set descr 'add interface route for v6' + atf_set require.user root + atf_set require.progs jail jq +} + +interface_route_v6_body() +{ + epair=$(vnet_mkepair) + ifconfig ${epair}a up + vnet_mkjail alcatraz ${epair}b + + # add interface route + jexec alcatraz route add -6 "2001:db8:cc4b::1" -iface ${epair}b + gateway=$(check_route "alcatraz" "2001:db8:cc4b::1") + + if [ -z "${gateway}" ]; then + atf_fail "Failed to add interface route." + fi +} + +interface_route_v6_cleanup() +{ + vnet_cleanup +} + atf_init_test_cases() { atf_add_test_case "basic_v4" atf_add_test_case "basic_v6" + atf_add_test_case "interface_route_v4" + atf_add_test_case "interface_route_v6" }
git: 1db64f89363c - main - netlink: Add tests when adding an interface route
The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=1db64f89363c97858961c4df0b7d02f3223723cf commit 1db64f89363c97858961c4df0b7d02f3223723cf Author: Jose Luis Duran AuthorDate: 2023-11-28 19:58:03 + Commit: R. Christian McDonald CommitDate: 2023-11-28 21:53:00 + netlink: Add tests when adding an interface route Add tests for adding a route using an interface only (without an IP address). Reviewed by:rcm Approved by:kp (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41436 --- tests/sys/netlink/test_rtnl_route.py | 41 1 file changed, 41 insertions(+) diff --git a/tests/sys/netlink/test_rtnl_route.py b/tests/sys/netlink/test_rtnl_route.py index e6bbe7656eb4..20f2c3ce3ee2 100644 --- a/tests/sys/netlink/test_rtnl_route.py +++ b/tests/sys/netlink/test_rtnl_route.py @@ -3,6 +3,7 @@ import socket import pytest from atf_python.sys.net.tools import ToolsHelper +from atf_python.sys.net.vnet import IfaceFactory from atf_python.sys.net.vnet import SingleVnetTestTemplate from atf_python.sys.netlink.attrs import NlAttrIp from atf_python.sys.netlink.attrs import NlAttrU32 @@ -45,6 +46,46 @@ class TestRtNlRoute(NetlinkTestTemplate, SingleVnetTestTemplate): ToolsHelper.print_net_debug() ToolsHelper.print_output("netstat -6onW") +@pytest.mark.timeout(5) +def test_add_route6_ll_if_gw(self): +tun_ifname = IfaceFactory().create_iface("", "tun")[0].name +tun_ifindex = socket.if_nametoindex(tun_ifname) + +msg = NetlinkRtMessage(self.helper, NlRtMsgType.RTM_NEWROUTE) +msg.set_request() +msg.add_nlflags([NlmNewFlags.NLM_F_CREATE]) +msg.base_hdr.rtm_family = socket.AF_INET6 +msg.base_hdr.rtm_dst_len = 64 +msg.add_nla(NlAttrIp(RtattrType.RTA_DST, "2001:db8:2::")) +msg.add_nla(NlAttrU32(RtattrType.RTA_OIF, tun_ifindex)) + +rx_msg = self.get_reply(msg) +assert rx_msg.is_type(NlMsgType.NLMSG_ERROR) +assert rx_msg.error_code == 0 + +ToolsHelper.print_net_debug() +ToolsHelper.print_output("netstat -6onW") + +@pytest.mark.timeout(5) +def test_add_route4_ll_if_gw(self): +tun_ifname = IfaceFactory().create_iface("", "tun")[0].name +tun_ifindex = socket.if_nametoindex(tun_ifname) + +msg = NetlinkRtMessage(self.helper, NlRtMsgType.RTM_NEWROUTE) +msg.set_request() +msg.add_nlflags([NlmNewFlags.NLM_F_CREATE]) +msg.base_hdr.rtm_family = socket.AF_INET +msg.base_hdr.rtm_dst_len = 32 +msg.add_nla(NlAttrIp(RtattrType.RTA_DST, "192.0.2.1")) +msg.add_nla(NlAttrU32(RtattrType.RTA_OIF, tun_ifindex)) + +rx_msg = self.get_reply(msg) +assert rx_msg.is_type(NlMsgType.NLMSG_ERROR) +assert rx_msg.error_code == 0 + +ToolsHelper.print_net_debug() +ToolsHelper.print_output("netstat -4onW") + @pytest.mark.timeout(20) def test_buffer_override(self): msg_flags = (