Changeset 2692
- Timestamp:
- 03/01/08 01:22:34 (9 months ago)
- Files:
-
- trunk/doc/configuration.xml (modified) (1 diff)
- trunk/scripts/util-vserver-vars.pathsubst (modified) (1 diff)
- trunk/scripts/vserver.functions (modified) (7 diffs)
- trunk/scripts/vserver.stop (modified) (1 diff)
- trunk/src/tunctl.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/configuration.xml
r2666 r2692 1342 1342 </description> 1343 1343 </boolean> 1344 <boolean name="tun" since="0.30.215"> 1345 <description> 1346 When this file exists, a tun interface will be created when the guest 1347 starts, and removed when the guest stops. 1348 </description> 1349 </boolean> 1350 <boolean name="tap" since="0.30.215"> 1351 <description> 1352 When this file exists, a tap interface will be created when the guest 1353 starts, and removed when the guest stops. 1354 </description> 1355 </boolean> 1356 <boolean name="nocsum" since="0.30.215"> 1357 <description> 1358 If a tun or tap interface is created, the presence of this file will 1359 disable checksumming on it. 1360 </description> 1361 </boolean> 1362 <boolean name="shared" since="0.30.215"> 1363 <description> 1364 When this file exists, the tun/tap interface created will not be 1365 owned by this particular guest. 1366 </description> 1367 </boolean> 1368 <scalar name="uid" since="0.30.215"> 1369 <description> 1370 Sets the ownership of tun/tap interfaces. Requires a user id, not a 1371 username. 1372 </description> 1373 </scalar> 1374 <scalar name="gid" since="0.30.215"> 1375 <description> 1376 Sets the group ownership of tun/tap interfaces. Requires a group id, 1377 not a group name. 1378 </description> 1379 </scalar> 1380 <scalar name="linktype" since="0.30.215"> 1381 <description> 1382 Sets the link type of tun/tap interfaces. 1383 </description> 1384 </scalar> 1344 1385 </collection> 1345 1386 </collection> trunk/scripts/util-vserver-vars.pathsubst
r2626 r2692 71 71 _SHOWPERM="$__LEGACYDIR/showperm" 72 72 _START_VSERVERS="$__PKGLIBDIR/start-vservers" 73 _TUNCTL="$__PKGLIBDIR/tunctl" 73 74 _VAPT_GET="$__SBINDIR/vapt-get" 74 75 _VAPT_GET_WORKER="$__PKGLIBDIR/vapt-get-worker" trunk/scripts/vserver.functions
r2664 r2692 67 67 68 68 S_CONTEXT= 69 N_CONTEXT= 69 70 70 71 SILENT_OPT= … … 109 110 getFileValue lback "$f" 110 111 111 getFileValue nid "$vdir/ncontext" "$vdir/context" 112 113 CHBIND_CMD=( $_CHBIND $SILENT_OPT --secure ${nid:+--nid "$nid"} 112 CHBIND_CMD=( $_CHBIND $SILENT_OPT --secure ${N_CONTEXT:+--nid "$N_CONTEXT"} 114 113 ${bcast:+--bcast "$bcast"} ${lback:+--lback "$lback"} 115 114 ) … … 513 512 } 514 513 514 function _getTunInfo 515 { 516 local iface="$1" 517 518 test -e "$iface/tun" -o -e "$iface/tap" || return 1 519 test ! -e "$iface/tun" || echo --tun 520 test ! -e "$iface/tap" || echo --tap 521 test ! -e "$iface/nocsum" || echo --~checksum 522 test -e "$iface/shared" || echo --nid-failure-ok "$N_CONTEXT" 523 if test -e "$iface/uid"; then 524 local uid 525 getFileValue uid "$iface/uid" 526 echo --uid "$uid" 527 fi 528 if test -e "$iface/gid"; then 529 local gid 530 getFileValue gid "$iface/gid" 531 echo --gid "$gid" 532 fi 533 if test -e "$iface/linktype"; then 534 local linktype 535 getFileValue linktype "$iface/linktype" 536 echo --linktype "$linktype" 537 fi 538 return 0 539 } 540 515 541 ## Usage: _processSingleInterface <interface-directory> 516 542 function _processSingleInterface … … 572 598 if ! test -e "$iface"/indirect; then 573 599 # XXX: IPv6 hack 574 use_bcast="broadcast ${bcast:-+}"600 local use_bcast="broadcast ${bcast:-+}" 575 601 echo "$ip" | $_GREP -q : && use_bcast= 602 603 local tun_info 604 if tun_info=$(_getTunInfo "$iface"); then 605 _addInterfaceCmd TUNCTL "$dev" $tun_info 606 fi 607 576 608 _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" $use_bcast ${name:+label "$dev:$name"} dev "$dev" 577 609 #_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev" 578 610 _addInterfaceCmd IP_LINK "$dev" $up 579 elif ! test -n "$ ctx"; then611 elif ! test -n "$N_CONTEXT"; then 580 612 echo $"Using 'dummy' (indirect) for interface '$dev' requires a fixed context number; dynamic ctx are not supported" >&2 581 613 return 1 582 614 else 583 test -z "$mac" || _generateMac mac "$(basename $iface)" "$ ctx" || return 1615 test -z "$mac" || _generateMac mac "$(basename $iface)" "$N_CONTEXT" || return 1 584 616 _addInterfaceCmd MODPROBE dummy "$dev" 585 617 _addInterfaceCmd IP_LINK dev dummy0 address "$mac" 586 618 _addInterfaceCmd NAMEIF "$dev" "$mac" 587 619 _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" dev "$dev" 588 test -z "$extip" || _addInterfaceCmd IPTABLES "$ip${prefix:+/$prefix}" ${name:+label "$dev:$name"} "$ ctx" "$extip"620 test -z "$extip" || _addInterfaceCmd IPTABLES "$ip${prefix:+/$prefix}" ${name:+label "$dev:$name"} "$N_CONTEXT" "$extip" 589 621 fi 590 622 … … 597 629 { 598 630 local iface 599 local ctx 600 601 test ! -e "$1"/context || read ctx <"$1"/context 631 632 # XXX: This is here instead of in _generateChbindOptions 633 # to avoid a circular dependency 634 getFileValue N_CONTEXT "$1/ncontext" "$1/context" 635 test -n "$N_CONTEXT" -o -z "$S_CONTEXT" || N_CONTEXT="$S_CONTEXT" 602 636 603 637 for iface in "$1/interfaces/"*; do … … 638 672 IP_LINK) $_IP link set "$@";; 639 673 IP_ROUTE) $_IP route add "$@";; 674 TUNCTL) 675 local dev="$1" 676 shift 677 $_TUNCTL --persist "$@" "$dev" 678 ;; 640 679 *) echo "Unknown interface-command type '$type'" >&2; false;; 641 680 esac … … 673 712 IP_LINK) ;; ## Ignore the link-down command for now 674 713 IP_ROUTE) $_IP route del "$@";; 714 TUNCTL) $_TUNCTL --~persist "$1";; 675 715 *) echo "Unknown interface-command type '$type'" >&2; false;; 676 716 esac trunk/scripts/vserver.stop
r2691 r2692 96 96 # Remove persistent so those contexts can be stopped 97 97 $_VATTRIBUTE --set --xid "$S_CONTEXT" --flag !persistent 2>/dev/null || : 98 if $_VSERVER_INFO -q "$ S_CONTEXT" XIDTYPE static &&98 if $_VSERVER_INFO -q "$N_CONTEXT" XIDTYPE static && 99 99 $_VSERVER_INFO - FEATURE vnet; then 100 $_NATTRIBUTE --set --nid "$ S_CONTEXT" --flag !persistent 2>/dev/null || :100 $_NATTRIBUTE --set --nid "$N_CONTEXT" --flag !persistent 2>/dev/null || : 101 101 fi 102 102 trunk/src/tunctl.c
r2688 r2692 62 62 #define CMD_TUN 0x0200 63 63 #define CMD_TAP 0x0400 64 #define CMD_NID_FAILURE_OK (0x0800 | CMD_NID) 64 65 65 66 int wrapper_exit_code = 255; … … 67 68 struct option const 68 69 CMDLINE_OPTIONS[] = { 69 { "help", no_argument, 0, CMD_HELP }, 70 { "version", no_argument, 0, CMD_VERSION }, 71 { "nid", required_argument, 0, CMD_NID }, 72 { "device", required_argument, 0, CMD_DEVICE }, 73 { "persist", no_argument, 0, CMD_PERSIST }, 74 { "~persist", no_argument, 0, CMD_NOPERSIST }, 75 { "checksum", no_argument, 0, CMD_CSUM }, 76 { "~checksum", no_argument, 0, CMD_NOCSUM }, 77 { "uid", required_argument, 0, CMD_UID }, 78 { "gid", required_argument, 0, CMD_GID }, 79 { "linktype", required_argument, 0, CMD_LINKTYPE }, 80 { "tun", no_argument, 0, CMD_TUN }, 81 { "tap", no_argument, 0, CMD_TAP }, 70 { "help", no_argument, 0, CMD_HELP }, 71 { "version", no_argument, 0, CMD_VERSION }, 72 { "nid", required_argument, 0, CMD_NID }, 73 { "device", required_argument, 0, CMD_DEVICE }, 74 { "persist", no_argument, 0, CMD_PERSIST }, 75 { "~persist", no_argument, 0, CMD_NOPERSIST }, 76 { "checksum", no_argument, 0, CMD_CSUM }, 77 { "~checksum", no_argument, 0, CMD_NOCSUM }, 78 { "uid", required_argument, 0, CMD_UID }, 79 { "gid", required_argument, 0, CMD_GID }, 80 { "linktype", required_argument, 0, CMD_LINKTYPE }, 81 { "tun", no_argument, 0, CMD_TUN }, 82 { "tap", no_argument, 0, CMD_TAP }, 83 { "nid-failure-ok", required_argument, 0, CMD_NID_FAILURE_OK }, 82 84 {0,0,0,0} 83 85 }; … … 141 143 if (args->set & CMD_GID) 142 144 EioctlD(fd, TUNSETGROUP, (void *) (long) args->gid); 143 if (args->set & CMD_NID) 144 EioctlD(fd, TUNSETNID, (void *) (long) args->nid); 145 if (args->set & CMD_NID) { 146 if (args->set & CMD_NID_FAILURE_OK) 147 ioctl(fd, TUNSETNID, (void *) (long) args->nid); 148 else 149 EioctlD(fd, TUNSETNID, (void *) (long) args->nid); 150 } 145 151 if (args->set & CMD_LINKTYPE) 146 152 EioctlD(fd, TUNSETLINK, (void *) (long) args->linktype); … … 175 181 case CMD_VERSION : showVersion(); 176 182 183 case CMD_NID_FAILURE_OK: 177 184 case CMD_NID : args.nid = Evc_nidopt2nid(optarg, true); break; 178 185 case CMD_DEVICE : args.device = optarg; break;
