Skip to content

Commit cee7664

Browse files
author
olevole
committed
change ppt#iface to ppt-iface, according to vpc-
1 parent 6b4ea40 commit cee7664

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

sudoexec/jcreate

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ ${H3_COLOR}Options${N0_COLOR}:
6060
${N2_COLOR}inter=${N0_COLOR} - 0 to prevent any questions and to accept answers by default.
6161
${N2_COLOR}customskel=${N0_COLOR} - <path>: additional skel directory applyed above jail structrure.
6262
${N2_COLOR}fstablocal=${N0_COLOR} - <path>: additional fstab file stored as fstab.local.
63+
${N2_COLOR}interface=${N0_COLOR} - <name>: specify jail interface. Use 'ppt-XX' prefix (+vnet=1) to
64+
pass XX as vnet interface instead of 'epair', e.g.: 'ppt-em0'.
65+
Warning! the PPT interface will disappear from the host system while the container is running.
6366
${N2_COLOR}jprofile=${N0_COLOR} - <name>: specify jail profile for creating jail.
6467
${N2_COLOR}jnameserver=${N0_COLOR} - <IP>: override default 'jnameserver' settings for jail.
6568
${N2_COLOR}zfs_snapsrc=${N0_COLOR} - <name>: use ZFS snapshot as data source.
@@ -80,15 +83,16 @@ Additional args when RACCT enabled: ${RCTL} ${RCTL_EXTRA}
8083

8184
${H3_COLOR}Examples${N0_COLOR}:
8285

83-
# cbsd jcreate jname=test runasap=1 zfs_encryption=1
86+
# cbsd jcreate jname=test runasap=1 zfs_encryption=1 interface=ppt-em
8487
# cbsd jcreate jname=test2 astart=0 pkglist=\"misc/mc net/fping\" ip4_addr=DHCP,DHCPv6 allow_sysvipc=1 allow_raw_sockets=1
8588
# cbsd jcreate jname=vnet1 runasap=1 ip4_addr=\"10.0.1.5/24\" ci_gw4=\"10.0.1.1\" ci_user_pubkey=\"/root/.ssh/authorized_keys\"
8689
# cbsd jcreate jname=deb jprofile=debian_bookworm allow_raw_sockets=1
8790
# cbsd jcreate jname=ubu jprofile=ubuntu_jammy allow_raw_sockets=1
8891
# cbsd jcreate jname=rock jprofile=rocky_9 allow_raw_sockets=1
8992
# cbsd jcreate jname=dev jprofile=devuan_daedalus allow_raw_sockets=1
9093
# cbsd jcreate jname=riscv pkg_bootstrap=0 arch=riscv emulator=\"qemu-riscv64-static\" exec_start=\"/bin/qemu-riscv64-static /bin/sh /etc/rc\" exec_stop=\"/bin/qemu-riscv64-static /bin/sh /etc/rc.shutdown\"
91-
# cbsd jcreate jname=xx ver=13.2 vnet=1 sysrc=\"ifconfig_eth0+='mtu 1450' inetd_enable=YES\"
94+
# cbsd jcreate jname=nictest vnet=1 interface=ppt-em0
95+
# cbsd jcreate jname=xx ver=14.2 vnet=1 sysrc=\"ifconfig_eth0+='mtu 1450' inetd_enable=YES\"
9296
# cbsd jcreate jname=vmagent from=https://dl.convectix.com/img/amd64/amd64/14.2/vmagent/vmagent.img pkg_bootstrap=0 runasap=1
9397
# cbsd jcreate jname=myapp from=fbbb4e8707f6794008cc6e8ed0d86082 runasap=1
9498
# cbsd jcreate jname=small flavor=small1 runasap=1 jnameserver="8.8.8.8,8.8.4.4"
@@ -786,8 +790,8 @@ else
786790
[ ! -r ${jailsysdir}/${jname}/local.sqlite ] && /usr/local/bin/cbsd ${miscdir}/updatesql ${jailsysdir}/${jname}/local.sqlite ${distdir}/share/local-jailnic.schema jailnic
787791
# create default record
788792

789-
tmp_type=${interface%%#*} # cut all after '#'
790-
tmp_iface=${interface##*#} # cut all before '#'
793+
tmp_type=${interface%%-*} # cut all after '#'
794+
tmp_iface=${interface##*-} # cut all before '#'
791795

792796
case "${tmp_type}" in
793797
ppt|epair|ovs)

sudoexec/jstart

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,17 @@ if [ "${vnet}" = "1" ]; then
543543
printf "${N1_COLOR}create epair: "
544544

545545
for i in ${interfaces}; do
546+
nic_hwaddr=
547+
nic_parent=
548+
nic_address=
549+
nic_type=
550+
_A=
551+
_A=$( cbsdsqlro ${jailsysdir}/${jname}/local.sqlite "SELECT nic_parent,nic_address,nic_hwaddr FROM jailnic WHERE name='${i}'" )
552+
553+
sqllist "${_A}" nic_parent nic_address nic_hwaddr
546554

547-
tmp_type=${i%%#*} # cut all after '#'
548-
tmp_iface=${i##*#} # cut all before '#'
555+
tmp_type=${nic_parent%%-*} # cut all before '#'
556+
tmp_iface=${nic_parent##*-} # cut all after '#'
549557

550558
case "${tmp_type}" in
551559
ppt|epair|ovs)
@@ -554,29 +562,10 @@ if [ "${vnet}" = "1" ]; then
554562
;;
555563
*)
556564
nic_type="epair" # epair by default
557-
true
558-
;;
559-
esac
560-
561-
case "${tmp_iface}" in
562-
ppt_*)
563-
nic_type="ppt"
564-
;;
565-
*)
566-
nic_type="epair"
567565
;;
568566
esac
569567

570568
unset tmp_type tmp_type
571-
#echo "NIC TYPE [$i]: ${nic_type}"
572-
573-
nic_hwaddr=
574-
nic_parent=
575-
nic_address=
576-
_A=
577-
_A=$( cbsdsqlro ${jailsysdir}/${jname}/local.sqlite "SELECT nic_parent,nic_address,nic_hwaddr FROM jailnic WHERE name='${i}'" )
578-
sqllist "${_A}" nic_parent nic_address nic_hwaddr
579-
#nic_parent=$( cbsdsqlro ${jailsysdir}/${jname}/local.sqlite "SELECT nic_parent FROM jailnic WHERE name='${i}'" )
580569

581570
# when ip=0 and interface=auto we must use default interface for upstream
582571
[ "${nic_parent}" = "0" -o "${nic_parent}" = "auto" ] && nic_parent=$( getnics-by-ip ip=0.0.0.0 skip=bridge )
@@ -606,12 +595,18 @@ if [ "${vnet}" = "1" ]; then
606595
cbsdvale*)
607596
mybridge="${nic_parent}"
608597
;;
598+
ppt-*)
599+
mybridge=
600+
true
601+
;;
609602
*)
610603
if ! mybridge=$( get_my_device bridge ${nic_parent} ); then
611604
err 1 "${N1_COLOR}Error: Cant get_my_device for ${nic_parent}: ${mybridge}${N0_COLOR}"
612605
fi
613606
esac
614607

608+
echo "NT: ${nic_type}"
609+
615610
if [ "${nic_type}" = "ppt" ]; then
616611
myepair="${i}"
617612
if [ -z "${epairb_list}" ]; then

sudoexec/jstop

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ if [ ${vnet} -eq 1 ]; then
278278
for i in ${interfaces}; do
279279

280280
nic_parent=
281-
nic_parent=$( cbsdsqlro ${jailsysdir}/${jname}/local.sqlite SELECT nic_parent FROM jailnic WHERE name=\"${i}\" )
281+
nic_parent=$( cbsdsqlro ${jailsysdir}/${jname}/local.sqlite "SELECT nic_parent FROM jailnic WHERE name='${i}'" )
282+
283+
tmp_type=${nic_parent%%-*} # cut all before '#'
284+
tmp_iface=${nic_parent##*-} # cut all after '#'
285+
[ "${tmp_type}" = "ppt" ] && continue
282286

283287
[ "${nic_parent}" = "0" -o "${nic_parent}" = "auto" ] && nic_parent=$( getnics-by-ip ip=0.0.0.0 skip=bridge )
284288
myepair=

0 commit comments

Comments
 (0)