summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mooney <patrick.f.mooney@gmail.com>2014-12-29 22:10:09 +0000
committerPatrick Mooney <patrick.f.mooney@gmail.com>2014-12-29 23:15:47 +0000
commite70ef5c9b621ee4caafc3c34653af49034bece4e (patch)
tree81c1a3f74306716b7fe9573c846fb827c06f378b
parent962713cac7fe14b223b21a942d294169c8cc26b9 (diff)
downloadillumos-joyent-e70ef5c9b621ee4caafc3c34653af49034bece4e.tar.gz
OS-3651 lxbrand ifconfig wrapper reports false errors
-rw-r--r--manifest1
-rw-r--r--usr/src/lib/brand/lx/cmd/Makefile2
-rwxr-xr-xusr/src/lib/brand/lx/cmd/ifconfig.sh172
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot.ksh11
4 files changed, 1 insertions, 185 deletions
diff --git a/manifest b/manifest
index 0c3ec1c900..95b7991dc5 100644
--- a/manifest
+++ b/manifest
@@ -5052,7 +5052,6 @@ d usr/lib/brand/lx/ld/64 0755 root root
f usr/lib/brand/lx/ld/64/ld.config 0755 root root
f usr/lib/brand/lx/etc_default_nfs 0444 root root
f usr/lib/brand/lx/etc_netconfig 0444 root root
-f usr/lib/brand/lx/ifconfig 0755 root root
f usr/lib/brand/lx/ltp_skiplist 0444 root root
f usr/lib/brand/lx/lx_boot 0755 root root
f usr/lib/brand/lx/lx_boot_zone_ubuntu 0755 root root
diff --git a/usr/src/lib/brand/lx/cmd/Makefile b/usr/src/lib/brand/lx/cmd/Makefile
index 07ca9ff81b..c302f9ebe3 100644
--- a/usr/src/lib/brand/lx/cmd/Makefile
+++ b/usr/src/lib/brand/lx/cmd/Makefile
@@ -25,7 +25,7 @@
# Copyright 2014 Joyent, Inc. All rights reserved.
#
-PROGS = lx_lockd lx_native lx_isaexec_wrapper lx_statd lx_thunk ifconfig
+PROGS = lx_lockd lx_native lx_isaexec_wrapper lx_statd lx_thunk
include ../Makefile.lx
diff --git a/usr/src/lib/brand/lx/cmd/ifconfig.sh b/usr/src/lib/brand/lx/cmd/ifconfig.sh
deleted file mode 100755
index d8e83fadb6..0000000000
--- a/usr/src/lib/brand/lx/cmd/ifconfig.sh
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/bin/sh
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source. A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-
-#
-# This script uses the native ifconfig, without the thunk library linked in,
-# to display NIC data in the Linux style. The native ifconfig with the thunk
-# library cannot be used by non-root users since the thunk library does a
-# chroot.
-#
-# Copyright 2014 Joyent, Inc. All rights reserved.
-#
-
-short=0
-ifname=""
-
-# This is running in Linux, there is likely no getopts command
-if [ $# -gt 0 ]; then
- for i in "$@"
- do
- case "$i" in
- "-a") # ignore - interfaces are brought up by the zone
- ;;
- "-s")
- short=1
- ;;
- "-v") # ignore
- ;;
- -*) echo "Error: unsupported option $i"
- exit 1
- ;;
- *)
- if [ -n "$ifname" ]; then
- echo "Error: interface configuration is not supported in a zone"
- exit 1
- fi
- ifname=$i
- ;;
- esac
- done
-fi
-
-LD_LIBRARY_PATH_32="/native/lib:/native/usr/lib"
-LD_BIND_NOW=1
-export LD_LIBRARY_PATH_32 LD_BIND_NOW
-
-# Start by getting the kstats we need
-/native/usr/lib/brand/lx/lx_native /native/lib/ld.so.1 \
- /native/usr/bin/kstat -m link -c net | awk '{
- if ($1 == "module:" && length(ifname) > 0)
- printf("%s %s %s %s %s %s %s\n", ifname, ipckts, ierrs, rbytes,
- opckts, oerrs, obytes)
-
- if ($1 == "name:") ifname=$2
- if ($1 == "ipackets") ipckts=$2
- if ($1 == "ierrors") ierrs=$2
- if ($1 == "rbytes") rbytes=$2
- if ($1 == "opackets") opckts=$2
- if ($1 == "oerrors") oerrs=$2
- if ($1 == "obytes") obytes=$2
-} END {
- if (length(ifname) > 0)
- printf("%s %s %s %s %s %s %s\n", ifname, ipckts, ierrs, rbytes,
- opckts, oerrs, obytes)
-}' >/tmp/ifstats.$$
-
-/native/usr/lib/brand/lx/lx_native /native/lib/ld.so.1 \
- /native/usr/bin/kstat -m lo -c net | awk '{
- if ($1 == "ipackets") ipckts=$2
- if ($1 == "opackets") opckts=$2
-} END {
- printf("lo0 %s 0 0 %s 0 0\n", ipckts, opckts)
-}' >>/tmp/ifstats.$$
-
-# Now get the interfaces and format the output
-/native/usr/lib/brand/lx/lx_native /native/lib/ld.so.1 /native/sbin/ifconfig |
-awk -v pid=$$ -v nm=$ifname -v short=$short 'BEGIN {
- indent=" "
- # load interface kstats
- tfile="/tmp/ifstats." pid
- while (getline < tfile > 0) {
- stats[$1]=substr($0, length($1) + 2)
- }
-
- if (short)
- printf("%s %s %s %s %s %s %s %s %s %s %s %s\n", "Iface", "MTU",
- "Met", "RX-OK", "RX-ERR", "RX-DRP", "RX-OVR", "TX-OK", "TX-ERR",
- "TX-DRP", "TX-OVR", "Flg")
-}
-
-function fmt() {
- if (length(nm) > 0 && ifname != nm)
- return
-
- if (ifname == "lo0") {
- encap="Local Loopback"
- qlen=0
- sflg="LRU"
- } else {
- encap="Ethernet"
- qlen=1000
- sflg="BMRU"
- }
-
- n = split(stats[ifname], s)
- if (n != 6)
- s[1] = s[2] = s[3] = s[4] = s[5] = s[6] = 0
-
- if (short) {
- printf("%-5s %5s %3s %5s %6s %6s %6s %5s %6s %6s %6s %s\n",
- ifname, mtu, 0, s[1], s[2], 0, 0, s[4], s[5], 0, 0, sflg)
- return
- }
-
- printf("%-9s Link encap:%s", ifname, encap)
- if (length(enetaddr) > 0)
- printf(" HWaddr %s", enetaddr)
- printf("\n")
- printf("%9s inet addr:%s", indent, inet)
- if (length(bcast) > 0)
- printf(" Bcast:%s", bcast)
- printf(" Mask:%s\n", mask)
- printf("%9s %s MTU:%s\n", indent, flags, mtu)
- printf("%9s RX packets:%s errors:%s dropped:0 overruns:0 frame:0\n",
- indent, s[1], s[2])
- printf("%9s TX packets:%s errors:%s dropped:0 overruns:0 carrier:0\n",
- indent, s[4], s[6])
- printf("%9s collisons:0 txqueuelen:%s\n", indent, qlen)
- printf("%9s RX bytes:%s TX bytes:%s\n", indent, s[3], s[6])
- printf("\n")
-}
-
-{
- if (substr($1, length($1), 1) == ":") {
- if (length(ifname) > 0) {
- # print prev entry and reset
- fmt()
- ifname=""
- bcast=""
- enetaddr=""
- }
-
- ifname=substr($1, 1, length($1) - 1)
- mtu=$4
- pos=index($2, "<") + 1
- flags=substr($2, pos, length($2) - pos)
- getline
- inet=$2
- mask=$4
- if (NF > 4)
- bcast=$6
- else
- bcast=""
- } else if ($1 == "ether") {
- enetaddr=$2
- }
-}
-
-END {
- if (length(ifname) > 0) {
- fmt()
- }
-}'
-
-rm -f /tmp/ifstats.$$
diff --git a/usr/src/lib/brand/lx/zone/lx_boot.ksh b/usr/src/lib/brand/lx/zone/lx_boot.ksh
index 3aff4c6b16..9fc53240ca 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot.ksh
@@ -192,17 +192,6 @@ setup_native_cmd /sbin/route /native/usr/sbin/route
setup_native_cmd /bin/netstat /native/usr/bin/netstat
#
-# When plumbing and configuring the NICs the native ifconfig needs to use
-# the thunk library, so we setup for that as ifconfig-native. However, the
-# thunk library does a chroot so that means a non-root user can't use the
-# native ifconfig to look at the NICs. Thus, we provide a basic shell script
-# which can display NICs in the Linux style.
-#
-if [ ! -h $ZONEROOT/sbin/ifconfig ]; then
- cp /usr/lib/brand/lx/ifconfig $ZONEROOT/sbin/ifconfig
-fi
-
-#
# STEP THREE
#
# Perform distro-specific customization.