Bug 241954 - netgraph fails on concurrent node rename
Summary: netgraph fails on concurrent node rename
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-net mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-13 18:51 UTC by Paul Armstrong
Modified: 2019-11-19 05:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Armstrong 2019-11-13 18:51:29 UTC
I have a FreeBSD 12.1 host on which I'm using jng to create netgraph nodes for host interfaces. If I start the jails in series, it works fine. If I start them in parallel netgraph fails to rename the nodes and those jails fail to initialize.

jail.conf:

exec.prestart = "";
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.poststop = "";
exec.clean;
mount.devfs;
mount.fdescfs;
mount.procfs;
persist;
vnet = new;
devfs_ruleset = 10; # random, log, null, fd/* and other critical items

# Dynamic wildcard parameter:
# Base the path off the jail name.
path = "/jail/${host.hostname}/root";
exec.consolelog = "/var/log/jail_${host.hostname}_console.log";

################################################################################
# External Jails
################################################################################

ext {
  host.hostname = "ext.example.com";
  exec.prestart += "jng bridge ext bridge0 bridge1";
  exec.poststop += "jng shutdown ext";
  vnet.interface = ng0_ext,ng1_ext;
}

################################################################################
# Internal Jails
################################################################################

ns0 {
  host.hostname = "ns0.example.com";
  exec.prestart += "jng bridge ns0 bridge0 bridge1";
  exec.poststop += "jng shutdown ns0";
  vnet.interface = ng0_ns0,ng1_ns0;
}

ns1 {
  host.hostname = "ns1.example.com";
  exec.prestart += "jng bridge ns1 bridge0 bridge1";
  exec.poststop += "jng shutdown ns1";
  vnet.interface = ng0_ns1,ng1_ns1;
}

wg {
  host.hostname = "wg.example.com";
  exec.prestart += "jng bridge wg bridge0 bridge1";
  exec.poststop += "jng shutdown wg";
  vnet.interface = ng0_wg,ng1_wg;
  devfs_ruleset = 11; # include tun
}

www {
  host.hostname = "www.example.com";
  exec.prestart += "jng bridge www bridge0 bridge1";
  exec.poststop += "jng shutdown www";
  vnet.interface = ng0_www,ng1_www;
  sysvshm; # postgresql
}

vault {
  host.hostname = "vault.example.com";
  exec.prestart += "jng bridge vault bridge0 bridge1";
  exec.poststop += "jng shutdown vault";
  vnet.interface = ng0_vault,ng1_vault;
}

dmesg:

WARNING: attempt to domain_add(netgraph) after domainfinalize()
bridge0: promiscuous mode enabled
ngeth0: link state changed to UP
ngeth0: changing name to 'ng0_www'
bridge1: promiscuous mode enabled
ngeth1: link state changed to UP
ngeth1: changing name to 'ng1_www'
ng_ether_ifnet_arrival_event: can't re-name node ng0_www
ng_ether_ifnet_arrival_event: can't re-name node ng1_www
lo0: link state changed to UP

Jail start (clean after boot with jails disabled):

[root@ext]# service jail start
Starting jails:ngctl: send msg: File exists
ngctl: send msg: File exists
ngctl: send msg: File exists
ngctl: jail: send msgns0: jng bridge ns0 bridge0 bridge1: failed:
jail: ngctl: wg: jng bridge wg bridge0 bridge1: failedFile exists

send msgjail: : ns1: jng bridge ns1 bridge0 bridge1: failed
File exists
jail: vault: jng bridge vault bridge0 bridge1: failed
jail: numbat: jng bridge numbat bridge0 bridge1: failed
ng0_www
ng1_www
www: created