2003-11-21 03:14:31

by Jean Tourrilhes

[permalink] [raw]
Subject: [PATCH] All my Pcmcia cards are 'eth0'

Hi,

I've got a pile of Pcmcia wireless cards. I'm trying to make
them work with hotplug (currently using the old Pcmcia scripts).

One of the main problem is that they are all assigned 'eth0',
and therefore all configured with the same IP address. This is really
pathetic.

The usual answer is : you should use 'nameif' :
http://www.xenotime.net/linux/doc/network-interface-names.txt
Well, of course, nobody ever bothered to try it, so it doesn't
work. No comments.

To make it work you will need :
1) The attached "improved" version of nameif
2) Modify /etc/hotplug/net.agent with the following code :
---------------------------------------
# Run nameif as needed - Jean II
# Remap interface names based on MAC address. This workaround
# the dreaded configuration problem "all my cards are 'eth0'"...
if [ -e /etc/mactab ]; then
debug_mesg invoke nameif -i $INTERFACE
NEWNAME=`/usr/local/bin/nameif -i $INTERFACE`
if [ -n "$NEWNAME" ]; then
debug_mesg iface $INTERFACE is remapped to $NEWNAME
INTERFACE=$NEWNAME
fi;
fi
---------------------------------------

Note that this is currently very rough and "works for me". In
particular, I bet that the code above doesn't process error from
nameif properly. I'm sure someone more knowlegeable in shell scripts
will straighten all that.

Have fun...

Jean

P.S. : Now, I just need to figure out how to implement schemes...


Attachments:
(No filename) (1.39 kB)
nameif.c (7.11 kB)
Download all attachments

2003-11-21 03:31:29

by Bill Nottingham

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

Jean Tourrilhes ([email protected]) said:
> One of the main problem is that they are all assigned 'eth0',
> and therefore all configured with the same IP address. This is really
> pathetic.
>
> The usual answer is : you should use 'nameif' :
> http://www.xenotime.net/linux/doc/network-interface-names.txt
> Well, of course, nobody ever bothered to try it, so it doesn't
> work. No comments.

Well, no offense, but I'd think comments are necessary about no
one bothering to try it and it not working. I've had an orinoco_cs
device 'bob' using nameif for a while.

There are some situations where you have to jump through hoops
because it can't atomically swap two device names (i.e.,
eth0 <-> eth1, but the code itself seems to work ok in use here...

Bill

2003-11-21 03:45:02

by Randy.Dunlap

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

On Thu, 20 Nov 2003 22:28:19 -0500 Bill Nottingham <[email protected]> wrote:

| Jean Tourrilhes ([email protected]) said:
| > One of the main problem is that they are all assigned 'eth0',
| > and therefore all configured with the same IP address. This is really
| > pathetic.
| >
| > The usual answer is : you should use 'nameif' :
| > http://www.xenotime.net/linux/doc/network-interface-names.txt
| > Well, of course, nobody ever bothered to try it, so it doesn't
| > work. No comments.
|
| Well, no offense, but I'd think comments are necessary about no
| one bothering to try it and it not working. I've had an orinoco_cs
| device 'bob' using nameif for a while.

Jean, have you given me any feedback on that small howto and it
not working? If so, I've missed it and I apologize for that.

I use that method both at home and at work all the time,
with no problems, but I haven't tried it with PCMCIA cards, so
that's something that might need some work, as you have discovered.

home:
[rddunlap@midway rddunlap]$ ifconfig
ethmain Link encap:Ethernet HWaddr 00:07:E9:09:09:A8
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:134362 errors:0 dropped:0 overruns:0 frame:0
TX packets:166363 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:72537067 (69.1 Mb) TX bytes:22872312 (21.8 Mb)
Interrupt:11 Base address:0xde80 Memory:ff9a0000-0

work:
[rddunlap@gargoyle rddunlap]$ /sbin/ifconfig
ethmain Link encap:Ethernet HWaddr 00:02:55:1A:35:D4
inet addr:172.20.1.49 Bcast:172.20.255.255 Mask:255.255.0.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17339 errors:0 dropped:0 overruns:0 frame:0
TX packets:777 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1668859 (1.5 Mb) TX bytes:103545 (101.1 Kb)
Interrupt:16 Base address:0x7000


| There are some situations where you have to jump through hoops
| because it can't atomically swap two device names (i.e.,
| eth0 <-> eth1, but the code itself seems to work ok in use here...

--
~Randy

2003-11-21 05:14:49

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

Bill Nottingham <[email protected]> writes:
>
> There are some situations where you have to jump through hoops
> because it can't atomically swap two device names (i.e.,
> eth0 <-> eth1, but the code itself seems to work ok in use here...

Adding such swapping should not be very hard if someone is motivated.
Interestingly you're the first to complain about it missing...

-Andi (who wrote nameif originally)

2003-11-21 05:18:55

by Bill Nottingham

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

Andi Kleen ([email protected]) said:
> > There are some situations where you have to jump through hoops
> > because it can't atomically swap two device names (i.e.,
> > eth0 <-> eth1, but the code itself seems to work ok in use here...
>
> Adding such swapping should not be very hard if someone is motivated.
> Interestingly you're the first to complain about it missing...

When I looked at it, I assumed it was a limitation of the
kernel interface, in that it only operated on one device at
a time... or are you talking about just doing the switch in
nameif itself with a temporary device name?

Bill

2003-11-21 17:22:14

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

On Thu, Nov 20, 2003 at 07:40:58PM -0800, Randy.Dunlap wrote:
> On Thu, 20 Nov 2003 22:28:19 -0500 Bill Nottingham <[email protected]> wrote:
>
> | Jean Tourrilhes ([email protected]) said:
> | > One of the main problem is that they are all assigned 'eth0',
> | > and therefore all configured with the same IP address. This is really
> | > pathetic.
> | >
> | > The usual answer is : you should use 'nameif' :
> | > http://www.xenotime.net/linux/doc/network-interface-names.txt
> | > Well, of course, nobody ever bothered to try it, so it doesn't
> | > work. No comments.
> |
> | Well, no offense, but I'd think comments are necessary about no
> | one bothering to try it and it not working. I've had an orinoco_cs
> | device 'bob' using nameif for a while.
>
> Jean, have you given me any feedback on that small howto and it
> not working? If so, I've missed it and I apologize for that.

I may be real dense, but your Howto only describe using nameif
at boot time, which is mostly useless for Pcmcia cards (unless you
want to solder Pcmcia cards in their slots).

> I use that method both at home and at work all the time,
> with no problems, but I haven't tried it with PCMCIA cards, so
> that's something that might need some work, as you have discovered.

That's the point. If you want it to work with Pcmcia cards
(and other dynamic devices such as USB), 'nameif" *must* be called
from the hotplug scripts (pretty obvious, isn't it ?). And currently
you can't do that properly, which is the reason of my changes.
Note that once you add nameif in the hotplug scripts, you no
longer need to call it at boot time, so with one bird you kill two
stones.

> ~Randy

Thanks for looking into that.

Jean

2003-11-21 19:11:53

by Jean Tourrilhes

[permalink] [raw]
Subject: Re: [PATCH] All my Pcmcia cards are 'eth0'

Bill Nottingham wrote :
>
> Andi Kleen ([email protected]) said:
> > > There are some situations where you have to jump through hoops
> > > because it can't atomically swap two device names (i.e.,
> > > eth0 <-> eth1, but the code itself seems to work ok in use here...
> >
> > Adding such swapping should not be very hard if someone is motivated.
> > Interestingly you're the first to complain about it missing...
>
> When I looked at it, I assumed it was a limitation of the
> kernel interface, in that it only operated on one device at
> a time... or are you talking about just doing the switch in
> nameif itself with a temporary device name?

Have you tried with nameif running from hotplug ? I'm sure
that would fix your problem, because the first device would be renamed
before the second would even be created (but you may want to test).
That's probably a second reason why running nameif from
hotplug is the right way forward.

> Bill

Jean