Re: Loading eth1 module before eth0 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yann Dirson wrote:

> > Do you have some more specific pointers ?
> 
> http://www.uwsg.indiana.edu/hypermail/linux/net/
> 
> Went there, spent .5h searching the 2 lists for various keywords, with no
> results :(
> 
> Arghhhh....

Hrrm, sorry about that - was sure it would be there.  The only other
possibility I can think of was that the discussion was on the
netdev@oss.sgi.com mailing list (but I didn't think it was).  I am not 
sure if that one is archived or not.

> Nothing more precise ?

The general idea IIRC, was that selecting a particular card based on the
name ethN would never be reliable - consider the case where you have
three of the same cards - so

alias eth0 eepro100
alias eth1 eepro100
alias eth2 eepro100

and you do modprobe eth1 - which physical card is now eth1?  To ensure 
you get the same card, even after physically adding or removing other
cards, the best bet is to go by the unique hardware address of each card,
and use that to assign the network parameters.  You can get the hwaddr
from ifconfig and parse it with awk/sed/whatever, or use a small bit of
code to be used from within your scripts - e.g.

/*
 *	Prints out hardware address of supplied "ethN" interfaces.
 *	Compile: gcc -s -Wall hwaddr.c -o hwaddr
 *	Usage: hwaddr eth0 [eth1 eth2 eth3 ...]
 */

#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/in.h>

void hwaddr(char *if_name)
{
	int fd, i;
	struct ifreq ifreq;

	fd = socket(AF_INET,SOCK_DGRAM,0);
	if (fd == -1) 
		return;

	strcpy(ifreq.ifr_name, if_name);
	if (ioctl(fd, SIOCGIFHWADDR, &ifreq) < 0)
		return;
 
	printf("%s\t", if_name);
	for (i=0; i<ETH_ALEN; i++)
		printf("%.2X", (unsigned char)ifreq.ifr_hwaddr.sa_data[i]);
	printf("\n");
}

void main(int argc, char **argv)
{
	int i;

	for (i=1;i<argc;i++)
		hwaddr(argv[i]);
}


I thought Donald mentioned some code/scripts for this somewhere that he
had for others to make use of, but perhaps not.

Paul.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux