Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to not manipulate bridge interfaces #40

Merged
merged 4 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ FAQ

**Is ZFS jailing supported?**
Yes, please refer to man page.

**How can I prevent from bridge interfaces manipulation on start/stop?**
See man page (``iocell set createbridge=off UUID | TAG`` and/or
``iocell set keepbridge=on UUID | TAG``)
10 changes: 10 additions & 0 deletions doc/source/networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,13 @@ To start a jail with no IPv4/6 address whatsoever set these properties:
``iocell set ip4_addr=none ip6_addr=none UUID|TAG``

``iocell set defaultrouter=none defaultrouter6=none UUID|TAG``

To not create bridge interfaces on jail start set this property:

``iocell set createbridge=off UUID|TAG``

To keep bridge interfaces on jail shutdown set this property:

``iocell set keepbridge=on UUID|TAG``

*NOTE: You can set these to or on off according to the use case*
22 changes: 22 additions & 0 deletions iocell.8
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,28 @@ ip4=new | disable | inherit
Default: new
Source: jail(8)

.fam T
.fi
createbridge=on | off
.PP
.nf
.fam C
Controls whether default bridge0 and bridge1 will be created
on jails's start.

Default: on

.fam T
.fi
keepbridge=on | off
.PP
.nf
.fam C
Controls whether bridges bridge0 and bridge1 will be destroyed
on jail's shutdown.

Default: off

.fam T
.fi
defaultrouter=none | ipaddress
Expand Down
2 changes: 2 additions & 0 deletions lib/ioc-configure
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ __reset_jail_props () {
host_hostname="$(__get_jail_prop host_hostname ${uuid} ${_dataset})"
mount_procfs="$(__get_jail_prop mount_procfs ${uuid} ${_dataset})"
mount_linprocfs="$(__get_jail_prop mount_linprocfs ${uuid} ${_dataset})"
createbridge="$(__get_jail_prop createbridge ${uuid} ${_dataset})"
keepbridge="$(__get_jail_prop keepbridge ${uuid} ${_dataset})"

__configure_jail ${uuid} ${_dataset}
}
Expand Down
6 changes: 5 additions & 1 deletion lib/ioc-globals
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ vnet0_mac="none"
vnet1_mac="none"
vnet2_mac="none"
vnet3_mac="none"
createbridge="on"
keepbridge="off"

# Standard jail properties
devfs_ruleset="4"
Expand Down Expand Up @@ -208,7 +210,9 @@ CONF_NET="interfaces
vnet0_mac
vnet1_mac
vnet2_mac
vnet3_mac"
vnet3_mac
createbridge
keepbridge"

# Native jail properties
CONF_JAIL="devfs_ruleset
Expand Down
14 changes: 14 additions & 0 deletions lib/ioc-help
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,20 @@ PROPERTIES
Default: new
Source: jail(8)

createbridge=on | off

Controls whether default bridge0 and bridge1 will be created
on jails's start.

Default: on

keepbridge=on | off

Controls whether bridges bridge0 and bridge1 will be destroyed
on jail's shutdown.

Default: off

defaultrouter=none | ipaddress

Setting this property to anything other than none will try to configure a
Expand Down
9 changes: 4 additions & 5 deletions lib/ioc-info
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

# Print supported releases----------------------------------
__print_release () {
supported="12.0-CURRENT
11.0-RELEASE
10.3-RELEASE
10.2-RELEASE
9.3-RELEASE"
supported="14.0-CURRENT
13.1-RELEASE
13.0-RELEASE
12.3-RELEASE"

echo "Supported releases are: "
for rel in $(echo $supported) ; do
Expand Down
11 changes: 7 additions & 4 deletions lib/ioc-network
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ __networking () {
#local ip4_list="$(echo $ip4 | sed 's/,/ /g')"
local ip6_list="$(echo $ip6 | sed 's/,/ /g')"

local createbridge="$(__get_jail_prop createbridge ${_uuid})"
local keepbridge="$(__get_jail_prop keepbridge ${_uuid})"

# Get the default and current interfaces specified
local default_iface="$(__get_default_iface)"
local cur_ip4_iface=$(echo "$ip4_addr" | cut -d '|' -f 1)
Expand All @@ -94,14 +97,14 @@ __networking () {
for _b in ${_bridge_ifaces} ; do
if [ "${_b}" != "bridge0" ] ; then
_bridge_exists="$(echo ${_bridge_ifaces} | grep bridge0)"
if [ -z "${_bridge_exists}" ] ; then
if [ -z "${_bridge_exists}" -a "${createbridge}" == "on" ] ; then
ifconfig bridge0 create addm "${default_iface}"
else
continue
fi
elif [ "${_b}" != "bridge1" ] ; then
_bridge_exists="$(echo ${_bridge_ifaces} | grep bridge1)"
if [ -z "${_bridge_exists}" ] ; then
if [ -z "${_bridge_exists}" -a "${createbridge}" == "on" ] ; then
ifconfig bridge1 create
else
continue
Expand Down Expand Up @@ -209,9 +212,9 @@ __networking () {

_bridge_inuse="$(netstat -iWn | grep '^vnet' | \
awk '{ print $1 }')"
# If no vnet interfaces are using the bridges, let's clean up after
# If no vnet interfaces are using the bridges, let us clean up after
# ourselves
if [ -z "${_bridge_inuse}" ] ; then
if [ -z "${_bridge_inuse}" -a "${keepbridge}" == "off" ] ; then
ifconfig bridge0 destroy > /dev/null 2>&1
ifconfig bridge1 destroy > /dev/null 2>&1
fi
Expand Down