network devices can have arbitrary names (#682367)

This commit is contained in:
Jiri Popelka 2011-03-07 17:01:11 +01:00
parent ec460fea5d
commit 3ecd878127
4 changed files with 99 additions and 13 deletions

View File

@ -3,10 +3,10 @@
static char version_msg[] =
"ether-wake.c: v1.09 11/12/2003 Donald Becker, http://www.scyld.com/";
static char brief_usage_msg[] =
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
"usage: ether-wake -i <ifname> [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
" Use '-u' to see the complete set of options.\n";
static char usage_msg[] =
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
"usage: ether-wake -i <ifname> [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
"\n"
" This program generates and transmits a Wake-On-LAN (WOL)\n"
" \"Magic Packet\", used for restarting machines that have been\n"
@ -22,7 +22,7 @@ static char usage_msg[] =
" Options:\n"
" -b Send wake-up packet to the broadcast address.\n"
" -D Increase the debug level.\n"
" -i ifname Use interface IFNAME instead of the default 'eth0'.\n"
" -i ifname Use interface IFNAME.\n"
" -p <pw> Append the four or six byte password PW to the packet.\n"
" A password is only required for a few adapter types.\n"
" The password may be specified in ethernet hex format\n"
@ -112,7 +112,7 @@ static int get_wol_pw(const char *optarg);
int main(int argc, char *argv[])
{
char *ifname = "eth0";
char *ifname = NULL;
int one = 1; /* True, for socket options. */
int s; /* Raw socket */
int errflag = 0, verbose = 0, do_version = 0;
@ -144,6 +144,11 @@ int main(int argc, char *argv[])
return 3;
}
if (ifname == NULL) {
fprintf(stderr, "Specify -i <interface>.\n");
return 3;
}
if (optind == argc) {
fprintf(stderr, "Specify the Ethernet address as 00:11:22:33:44:55.\n");
return 3;

View File

@ -35,9 +35,9 @@ static char version[] =
" http://www.scyld.com/diag/index.html\n";
static const char usage_msg[] =
"Usage: %s [--help] [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n";
"Usage: %s [--help] [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>\n";
static const char long_usage_msg[] =
"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n\
"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>\n\
\n\
This program configures and monitors the transceiver management registers\n\
for network interfaces. It uses the Media Independent Interface (MII)\n\
@ -50,7 +50,6 @@ static const char long_usage_msg[] =
The common usage is\n\
mii-diag eth0\n\
\n\
The default interface is \"eth0\".\n\
Frequently used options are\n\
-A --advertise <speed|setting>\n\
-F --fixed-speed <speed>\n\
@ -222,10 +221,12 @@ main(int argc, char **argv)
fprintf(stderr, "DEBUG: argc=%d, optind=%d and argv[optind] is %s.\n",
argc, optind, argv[optind]);
/* No remaining args means show all interfaces. */
/* No remaining args means interface wasn't specified. */
if (optind == argc) {
ifname = "eth0";
fprintf(stderr, "Using the default interface 'eth0'.\n");
fprintf(stderr, "No interface specified.\n");
fprintf(stderr, usage_msg, progname);
(void) close(skfd);
return 2;
} else {
/* Copy the interface name. */
spp = argv + optind;
@ -233,8 +234,9 @@ main(int argc, char **argv)
}
if (ifname == NULL) {
ifname = "eth0";
fprintf(stderr, "Using the default interface 'eth0'.\n");
fprintf(stderr, "No ifname.\n");
(void) close(skfd);
return -1;
}
/* Verify that the interface supports the ioctl(), and if

View File

@ -0,0 +1,70 @@
diff -up net-tools-1.60/man/en_US/mii-tool.8.arbitrary-device-names net-tools-1.60/man/en_US/mii-tool.8
--- net-tools-1.60/man/en_US/mii-tool.8.arbitrary-device-names 2011-03-07 16:41:22.000000000 +0100
+++ net-tools-1.60/man/en_US/mii-tool.8 2011-03-07 16:41:22.000000000 +0100
@@ -16,7 +16,7 @@ mii-tool \- view, manipulate media-indep
[\fB\-l\fR, \fB\-\-log\fR]
[\fB\-A\fR, \fB\-\-advertise=\fImedia,...\fR]
[\fB\-F\fR, \fB\-\-force=\fImedia\fR]
-.RI [ "interface\ ..." ]
+.RI "interface\ ..."
.SH NOTE
.P
@@ -42,9 +42,7 @@ one mode, instead of autonegotiating. T
options are mutually exclusive.
.PP
The default short output reports the negotiated link speed and link
-status for each interface. If an interface or interfaces are not
-specified on the command line, then \fBmii-tool\fR will check any
-available interfaces from \fBeth0\fR through \fBeth7\fR.
+status for each interface.
.SH OPTIONS
.TP
\fB\-v\fR, \fB\-\-verbose\fR
diff -up net-tools-1.60/mii-tool.c.arbitrary-device-names net-tools-1.60/mii-tool.c
--- net-tools-1.60/mii-tool.c.arbitrary-device-names 2011-03-07 16:41:22.000000000 +0100
+++ net-tools-1.60/mii-tool.c 2011-03-07 16:44:52.000000000 +0100
@@ -419,7 +419,7 @@ static void watch_one_xcvr(int skfd, cha
/*--------------------------------------------------------------------*/
const char *usage = "\
-usage: %s [-VvRrwl] [-A media,... | -F media] [interface ...]\n\
+usage: %s [-VvRrwl] [-A media,... | -F media] <interface> ...\n\
-V, --version display version information\n\
-v, --verbose more verbose output\n\
-R, --reset reset MII to poweron state\n\
@@ -474,13 +474,10 @@ int main(int argc, char **argv)
/* No remaining args means show all interfaces. */
if (optind == argc) {
- ret = 1;
- for (i = 0; i < MAX_ETH; i++) {
- sprintf(s, "eth%d", i);
- ret &= do_one_xcvr(skfd, s, 1);
- }
- if (ret)
- fprintf(stderr, "no MII interfaces found\n");
+ fprintf(stderr, "No interface specified\n");
+ fprintf(stderr, usage, argv[0]);
+ close(skfd);
+ return 2;
} else {
ret = 0;
for (i = optind; i < argc; i++) {
@@ -491,15 +488,8 @@ int main(int argc, char **argv)
if (opt_watch && (ret == 0)) {
while (1) {
sleep(1);
- if (optind == argc) {
- for (i = 0; i < MAX_ETH; i++) {
- sprintf(s, "eth%d", i);
- watch_one_xcvr(skfd, s, i);
- }
- } else {
- for (i = optind; i < argc; i++)
+ for (i = optind; i < argc; i++)
watch_one_xcvr(skfd, argv[i], i-optind);
- }
}
}

View File

@ -1,7 +1,7 @@
Summary: Basic networking tools
Name: net-tools
Version: 1.60
Release: 115%{?dist}
Release: 116%{?dist}
License: GPL+
Group: System Environment/Base
URL: http://net-tools.berlios.de/
@ -138,6 +138,10 @@ Patch89: net-tools-1.60-hfi.patch
# Fix the handling of some of the HAVE_* flags ifdef vs if. (BerliOS #17812)
Patch90: net-tools-1.60-ifdef-vs-if.patch
# Don't rely on eth0 being default network device name.
# Since Fedora 15 network devices can have arbitrary names (#682367)
Patch91: net-tools-1.60-arbitrary-device-names.patch
BuildRequires: gettext, libselinux
BuildRequires: libselinux-devel
Requires: hostname
@ -232,6 +236,7 @@ Most of them are obsolete. For replacement check iproute package.
%patch88 -p1 -b .netstat-leak
%patch89 -p1 -b .hfi
%patch90 -p1 -b .ifdef-vs-if
%patch91 -p1 -b .arbitrary-device-names
cp %SOURCE1 ./config.h
cp %SOURCE2 ./config.make
@ -331,6 +336,10 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/ethers
%changelog
* Mon Mar 07 2011 Jiri Popelka <jpopelka@redhat.com> - 1.60-116
- Fix mii-tool/mii-diag/ether-wake to not default to eth0 because
since Fedora 15 network devices can have arbitrary names (#682367)
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.60-115
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild