diff options
author | dim <dim@FreeBSD.org> | 2016-02-13 16:02:12 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-02-13 16:02:12 +0000 |
commit | f393760a8a7c87242739a64002290b7bda94cb27 (patch) | |
tree | c08899f7a0f50404c030b4d36ab05e054a499796 /share | |
parent | 7024e27ddea8cff63ccd142987756cba5001628d (diff) | |
parent | 0a4cceb161dfcb232aa9f5d8664e017c2590e0d9 (diff) | |
download | FreeBSD-src-f393760a8a7c87242739a64002290b7bda94cb27.zip FreeBSD-src-f393760a8a7c87242739a64002290b7bda94cb27.tar.gz |
Merge ^/head r295544 through r295600.
Diffstat (limited to 'share')
-rwxr-xr-x | share/examples/jails/jib | 196 | ||||
-rwxr-xr-x | share/examples/jails/jng | 194 | ||||
-rw-r--r-- | share/man/man4/ds3231.4 | 13 | ||||
-rw-r--r-- | share/man/man5/rc.conf.5 | 30 | ||||
-rw-r--r-- | share/mk/src.libnames.mk | 4 |
5 files changed, 249 insertions, 188 deletions
diff --git a/share/examples/jails/jib b/share/examples/jails/jib index a93d2f2..b7d50f5 100755 --- a/share/examples/jails/jib +++ b/share/examples/jails/jib @@ -164,12 +164,93 @@ usage() action_usage() { - local usage action="$1" + local usage descr action="$1" eval usage=\"\$jib_${action}_usage\" echo "Usage: $pgm $usage" >&2 + eval descr=\"\$jib_${action}_descr\" + printf "\t%s\n" "$descr" exit $FAILURE } +derive_mac() +{ + local OPTIND=1 OPTARG __flag + local __mac_num= __make_pair= + while getopts 2n: __flag; do + case "$__flag" in + 2) __make_pair=1 ;; + n) __mac_num=${OPTARG%%[^0-9]*} ;; + esac + done + shift $(( $OPTIND - 1 )) + + if [ ! "$__mac_num" ]; then + eval __mac_num=\${_${iface}_num:--1} + __mac_num=$(( $__mac_num + 1 )) + eval _${iface}_num=\$__mac_num + fi + + local __iface="$1" __name="$2" __var_to_set="$3" __var_to_set_b="$4" + local __iface_devid __new_devid __num __new_devid_b + # + # Calculate MAC address derived from given iface. + # + # The formula I'm using is ``NP:SS:SS:II:II:II'' where: + # + N denotes 4 bits used as a counter to support branching + # each parent interface up to 15 times under the same jail + # name (see S below). + # + P denotes the special nibble whose value, if one of + # 2, 6, A, or E (but usually 2) denotes a privately + # administered MAC address (while remaining routable). + # + S denotes 16 bits, the sum(1) value of the jail name. + # + I denotes bits that are inherited from parent interface. + # + # The S bits are a CRC-16 checksum of NAME, allowing the jail + # to change link numbers in ng_bridge(4) without affecting the + # MAC address. Meanwhile, if... + # + the jail NAME changes (e.g., it was duplicated and given + # a new name with no other changes) + # + the underlying network interface changes + # + the jail is moved to another host + # the MAC address will be recalculated to a new, similarly + # unique value preventing conflict. + # + __iface_devid=$( ifconfig $__iface ether | awk '/ether/,$0=$2' ) + # ??:??:??:II:II:II + __new_devid=${__iface_devid#??:??:??} # => :II:II:II + # => :SS:SS:II:II:II + __num=$( set -- `echo -n "$__name" | sum` && echo $1 ) + __new_devid=$( printf :%02x:%02x \ + $(( $__num >> 8 & 255 )) $(( $__num & 255 )) )$__new_devid + # => P:SS:SS:II:II:II + case "$__iface_devid" in + ?2:*) __new_devid=a$__new_devid __new_devid_b=e$__new_devid ;; + ?[Ee]:*) __new_devid=2$__new_devid __new_devid_b=6$__new_devid ;; + *) __new_devid=2$__new_devid __new_devid_b=e$__new_devid + esac + # => NP:SS:SS:II:II:II + __new_devid=$( printf %x $(( $__mac_num & 15 )) )$__new_devid + __new_devid_b=$( printf %x $(( $__mac_num & 15 )) )$__new_devid_b + + # + # Return derivative MAC address(es) + # + if [ "$__make_pair" ]; then + if [ "$__var_to_set" -a "$__var_to_set_b" ]; then + eval $__var_to_set=\$__new_devid + eval $__var_to_set_b=\$__new_devid_b + else + echo $__new_devid $__new_devid_b + fi + else + if [ "$__var_to_set" ]; then + eval $__var_to_set=\$__new_devid + else + echo $__new_devid + fi + fi +} + mustberoot_to_continue() { if [ "$( id -u )" -ne 0 ]; then @@ -178,7 +259,7 @@ mustberoot_to_continue() fi } -jib_addm_usage="addm [-b BRIDGE_NAME] NAME interface0 [interface1 ...]" +jib_addm_usage="addm [-b BRIDGE_NAME] NAME [!]iface0 [[!]iface1 ...]" jib_addm_descr="Creates e0b_NAME [e1b_NAME ...]" jib_addm() { @@ -198,18 +279,25 @@ jib_addm() mustberoot_to_continue - local iface iface_devid eiface_devid - local eiface_devid_a eiface_devid_b - local new num quad i=0 + local iface eiface_devid_a eiface_devid_b + local new no_derive num quad i=0 for iface in $*; do - # 1. Make sure the interface doesn't exist already - ifconfig "e${i}a_$name" > /dev/null 2>&1 && continue + no_derive= + case "$iface" in + !*) iface=${iface#!} no_derive=1 ;; + esac + + # Make sure the interface doesn't exist already + if ifconfig "e${i}a_$name" > /dev/null 2>&1; then + i=$(( $i + 1 )) + continue + fi - # 2. Bring the interface up + # Bring the interface up ifconfig $iface up || return - # 3. Make sure the interface has been bridged + # Make sure the interface has been bridged if ! ifconfig "$iface$bridge" > /dev/null 2>&1; then new=$( ifconfig bridge create ) || return ifconfig $new addm $iface || return @@ -217,97 +305,29 @@ jib_addm() ifconfig "$iface$bridge" up || return fi - # 4. Create a new interface to the bridge + # Create a new interface to the bridge new=$( ifconfig epair create ) || return ifconfig "$iface$bridge" addm $new || return - # 5. Rename the new interface + # Rename the new interface ifconfig $new name "e${i}a_$name" || return ifconfig ${new%a}b name "e${i}b_$name" || return ifconfig "e${i}a_$name" up || return ifconfig "e${i}b_$name" up || return # - # 6. Set the MAC address of the new interface using a sensible + # Set the MAC address of the new interface using a sensible # algorithm to prevent conflicts on the network. # - # The formula I'm using is ``NP:SS:SS:II:II:II'' where: - # + N denotes 4 bits used as a counter to support branching - # each parent interface up to 15 times under the same jail - # name (see S below). - # + P denotes the special nibble whose value, if one of - # 2, 6, A, or E (but usually 2) denotes a privately - # administered MAC address (while remaining routable). - # + S denotes 16 bits, the sum(1) value of the jail name. - # + I denotes bits that are inherited from parent interface. - # - # The S bits are a CRC-16 checksum of NAME, allowing the jail - # to change the epair(4) generation order without affecting the - # MAC address. Meanwhile, if... - # + the jail NAME changes (e.g., it was duplicated and given - # a new name with no other changes) - # + the underlying network interface changes - # + the jail is moved to another host - # the MAC address will be recalculated to a new, similarly - # unique value preventing conflict. - # - iface_devid=$( ifconfig $iface ether | awk '/ether/,$0=$2' ) - eiface_devid=${iface_devid#??:??:??} - num=$( set -- `echo -n $name | sum` && echo $1 ) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad:$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - case "$iface_devid" in - ?[Ee]:*) - eiface_devid_a=2:$quad$eiface_devid - eiface_devid_b=6:$quad$eiface_devid - ;; - *) - eiface_devid_a=2:$quad$eiface_devid - eiface_devid_b=e:$quad$eiface_devid - esac - eval num=\$_${iface}_num - if [ "$num" ]; then - num=$(( $num + 1 )) - eval _${iface}_num=$num - else - num=0 - local _${iface}_num=$num - fi - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid_a=$quad$eiface_devid_a - eiface_devid_b=$quad$eiface_devid_b - ifconfig "e${i}a_$name" ether $eiface_devid_a > /dev/null 2>&1 - ifconfig "e${i}b_$name" ether $eiface_devid_b > /dev/null 2>&1 + eiface_devid_a= eiface_devid_b= + [ "$no_derive" ] || derive_mac -2 $iface "$name" \ + eiface_devid_a eiface_devid_b + if [ "$eiface_devid_a" -a "$eiface_devid_b" ]; then + ifconfig "e${i}a_$name" ether $eiface_devid_a + ifconfig "e${i}b_$name" ether $eiface_devid_b + fi > /dev/null 2>&1 - i=$(( $i + 1 )) # on to next e{i}b_name + i=$(( $i + 1 )) done # for iface } diff --git a/share/examples/jails/jng b/share/examples/jails/jng index ee850ea..c243001 100755 --- a/share/examples/jails/jng +++ b/share/examples/jails/jng @@ -166,12 +166,93 @@ usage() action_usage() { - local usage action="$1" + local usage descr action="$1" eval usage=\"\$jng_${action}_usage\" echo "Usage: $pgm $usage" >&2 + eval descr=\"\$jng_${action}_descr\" + printf "\t%s\n" "$descr" exit $FAILURE } +derive_mac() +{ + local OPTIND=1 OPTARG __flag + local __mac_num= __make_pair= + while getopts 2n: __flag; do + case "$__flag" in + 2) __make_pair=1 ;; + n) __mac_num=${OPTARG%%[^0-9]*} ;; + esac + done + shift $(( $OPTIND - 1 )) + + if [ ! "$__mac_num" ]; then + eval __mac_num=\${_${iface}_num:--1} + __mac_num=$(( $__mac_num + 1 )) + eval _${iface}_num=\$__mac_num + fi + + local __iface="$1" __name="$2" __var_to_set="$3" __var_to_set_b="$4" + local __iface_devid __new_devid __num __new_devid_b + # + # Calculate MAC address derived from given iface. + # + # The formula I'm using is ``NP:SS:SS:II:II:II'' where: + # + N denotes 4 bits used as a counter to support branching + # each parent interface up to 15 times under the same jail + # name (see S below). + # + P denotes the special nibble whose value, if one of + # 2, 6, A, or E (but usually 2) denotes a privately + # administered MAC address (while remaining routable). + # + S denotes 16 bits, the sum(1) value of the jail name. + # + I denotes bits that are inherited from parent interface. + # + # The S bits are a CRC-16 checksum of NAME, allowing the jail + # to change link numbers in ng_bridge(4) without affecting the + # MAC address. Meanwhile, if... + # + the jail NAME changes (e.g., it was duplicated and given + # a new name with no other changes) + # + the underlying network interface changes + # + the jail is moved to another host + # the MAC address will be recalculated to a new, similarly + # unique value preventing conflict. + # + __iface_devid=$( ifconfig $__iface ether | awk '/ether/,$0=$2' ) + # ??:??:??:II:II:II + __new_devid=${__iface_devid#??:??:??} # => :II:II:II + # => :SS:SS:II:II:II + __num=$( set -- `echo -n "$__name" | sum` && echo $1 ) + __new_devid=$( printf :%02x:%02x \ + $(( $__num >> 8 & 255 )) $(( $__num & 255 )) )$__new_devid + # => P:SS:SS:II:II:II + case "$__iface_devid" in + ?2:*) __new_devid=a$__new_devid __new_devid_b=e$__new_devid ;; + ?[Ee]:*) __new_devid=2$__new_devid __new_devid_b=6$__new_devid ;; + *) __new_devid=2$__new_devid __new_devid_b=e$__new_devid + esac + # => NP:SS:SS:II:II:II + __new_devid=$( printf %x $(( $__mac_num & 15 )) )$__new_devid + __new_devid_b=$( printf %x $(( $__mac_num & 15 )) )$__new_devid_b + + # + # Return derivative MAC address(es) + # + if [ "$__make_pair" ]; then + if [ "$__var_to_set" -a "$__var_to_set_b" ]; then + eval $__var_to_set=\$__new_devid + eval $__var_to_set_b=\$__new_devid_b + else + echo $__new_devid $__new_devid_b + fi + else + if [ "$__var_to_set" ]; then + eval $__var_to_set=\$__new_devid + else + echo $__new_devid + fi + fi +} + mustberoot_to_continue() { if [ "$( id -u )" -ne 0 ]; then @@ -180,7 +261,7 @@ mustberoot_to_continue() fi } -jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME interface0 [interface1 ...]" +jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME [!|=]iface0 [[!|=]iface1 ...]" jng_bridge_descr="Create ng0_NAME [ng1_NAME ...]" jng_bridge() { @@ -201,22 +282,32 @@ jng_bridge() mustberoot_to_continue - local iface iface_devid eiface eiface_devid - local new num quad i=0 + local iface parent eiface eiface_devid + local new clone_mac no_derive num quad i=0 for iface in $*; do - # 0. Make sure the interface doesn't exist already + clone_mac= + no_derive= + case "$iface" in + =*) iface=${iface#=} clone_mac=1 ;; + !*) iface=${iface#!} no_derive=1 ;; + esac + + # Make sure the interface doesn't exist already eiface=ng${i}_$name - ngctl msg "$eiface:" getifname > /dev/null 2>&1 && continue + if ngctl msg "$eiface:" getifname > /dev/null 2>&1; then + i=$(( $i + 1 )) + continue + fi - # 1. Bring the interface up + # Bring the interface up ifconfig $iface up || return - # 2. Set promiscuous mode and don't overwrite src addr + # Set promiscuous mode and don't overwrite src addr ngctl msg $iface: setpromisc 1 || return ngctl msg $iface: setautosrc 0 || return - # 3. Make sure the interface has been bridged + # Make sure the interface has been bridged if ! ngctl info ${iface}bridge: > /dev/null 2>&1; then ngctl mkpeer $iface: bridge lower link0 || return ngctl connect $iface: $iface:lower upper link1 || @@ -224,7 +315,7 @@ jng_bridge() ngctl name $iface:lower ${iface}bridge || return fi - # 3.5. Optionally create a secondary bridge + # Optionally create a secondary bridge if [ "$bridge" != "bridge" ] && ! ngctl info "$iface$bridge:" > /dev/null 2>&1 then @@ -240,7 +331,7 @@ jng_bridge() return fi - # 4. Create a new interface to the bridge + # Create a new interface to the bridge num=2 while ngctl msg "$iface$bridge:" getstats $num > /dev/null 2>&1 do @@ -248,7 +339,7 @@ jng_bridge() done ngctl mkpeer "$iface$bridge:" eiface link$num ether || return - # 5. Rename the new interface + # Rename the new interface while [ ${#eiface} -gt 15 ]; do # OS limitation eiface=${eiface%?} done @@ -259,79 +350,20 @@ jng_bridge() ifconfig $eiface up || return # - # 6. Set the MAC address of the new interface using a sensible + # Set the MAC address of the new interface using a sensible # algorithm to prevent conflicts on the network. # - # The formula I'm using is ``NP:SS:SS:II:II:II'' where: - # + N denotes 4 bits used as a counter to support branching - # each parent interface up to 15 times under the same jail - # name (see S below). - # + P denotes the special nibble whose value, if one of - # 2, 6, A, or E (but usually 2) denotes a privately - # administered MAC address (while remaining routable). - # + S denotes 16 bits, the sum(1) value of the jail name. - # + I denotes bits that are inherited from parent interface. - # - # The S bits are a CRC-16 checksum of NAME, allowing the jail - # to change link numbers in ng_bridge(4) without affecting the - # MAC address. Meanwhile, if... - # + the jail NAME changes (e.g., it was duplicated and given - # a new name with no other changes) - # + the underlying network interface changes - # + the jail is moved to another host - # the MAC address will be recalculated to a new, similarly - # unique value preventing conflict. - # - iface_devid=$( ifconfig $iface ether | awk '/ether/,$0=$2' ) - eiface_devid=${iface_devid#??:??:??} - num=$( set -- `echo -n $name | sum` && echo $1 ) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad:$eiface_devid - num=$(( $num >> 4 )) - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - case "$iface_devid" in - ?2:*) eiface_devid=a:$quad$eiface_devid ;; - *) eiface_devid=2:$quad$eiface_devid - esac - eval num=\$_${iface}_num - if [ "$num" ]; then - num=$(( $num + 1 )) - eval _${iface}_num=$num - else - num=0 - local _${iface}_num=$num + eiface_devid= + if [ "$clone_mac" ]; then + eiface_devid=$( ifconfig $iface ether | + awk '/ether/,$0=$2' ) + elif [ ! "$no_derive" ]; then + derive_mac $iface "$name" eiface_devid fi - quad=$(( $num & 15 )) - case "$quad" in - 10) quad=a ;; 11) quad=b ;; 12) quad=c ;; - 13) quad=d ;; 14) quad=e ;; 15) quad=f ;; - esac - eiface_devid=$quad$eiface_devid - ifconfig $eiface ether $eiface_devid > /dev/null 2>&1 + [ "$eiface_devid" ] && + ifconfig $eiface ether $eiface_devid > /dev/null 2>&1 - i=$(( $i + 1 )) # on to next ng{i}_name + i=$(( $i + 1 )) done # for iface } diff --git a/share/man/man4/ds3231.4 b/share/man/man4/ds3231.4 index 348860a..6fdcccc 100644 --- a/share/man/man4/ds3231.4 +++ b/share/man/man4/ds3231.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 6, 2015 +.Dd February 12, 2016 .Dt DS3231 4 .Os .Sh NAME @@ -110,8 +110,11 @@ that the .Nm is connected to. .It Va hint.ds3231.%d.addr -The i2c address of +The 8-bit i2c address of .Nm . +The default 8-bit address for +.Nm +is 0xd0. .El .Pp On a @@ -121,11 +124,11 @@ based system the following properties must be set: .It Va compatible Must always be set to "maxim,ds3231". .It Va reg -The i2c address of +The 7-bit i2c address of .Nm . -The default address for +The default 7-bit address for .Nm -is 0xd0. +is 0x68. .El .Sh SEE ALSO .Xr fdt 4 , diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index c66edeb..9b1b68c 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 9, 2015 +.Dd February 12, 2016 .Dt RC.CONF 5 .Os .Sh NAME @@ -3853,20 +3853,22 @@ for every jail in .Va jail_list . .It Va jail_list .Pq Vt str -A space separated list of names for jails. -If this variable is empty, -all of +A space-delimited list of jail names. +When left empty, all of the .Xr jail 8 -instances in the configuration file will be configured. -This is purely a configuration aid to help identify and -configure multiple jails. -The names specified in this list will be used to -identify settings common to an instance of a jail, -and should contain alphanumeric characters only. -The literal jail name of -.Dq Li 0 -.Pq zero -is not allowed. +instances defined in the configuration file are started. +The names specified in this list control the jail startup order. +.Xr jail 8 +instances missing from +.Va jail_list +must be started manually. +.It Va jail_reverse_stop +.Pq Vt bool +When set to +.Dq Li YES , +all configured jails in +.Va jail_list +are stopped in reverse order. .It Va jail_* variables Note that older releases supported per-jail configuration via .Xr rc.conf 5 diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 28c2368..d27597f 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -39,6 +39,7 @@ _INTERNALLIBS= \ openbsd \ opts \ parse \ + pe \ readline \ sl \ sm \ @@ -367,6 +368,9 @@ LDADD+= ${LDADD_${_l}} LIBELFTCDIR= ${OBJTOP}/lib/libelftc LIBELFTC?= ${LIBELFTCDIR}/libelftc.a +LIBPEDIR= ${OBJTOP}/lib/libpe +LIBPE?= ${LIBPEDIR}/libpe.a + LIBREADLINEDIR= ${OBJTOP}/gnu/lib/libreadline/readline LIBREADLINE?= ${LIBREADLINEDIR}/libreadline.a |