Re: this has to be a bug...

2006-03-25 Thread Ben Scott
On 3/25/06, Dave Johnson <[EMAIL PROTECTED]> wrote:
> Ya, a bug in net-tools, but you are using an invalid syntax.  Buggy
> software and sudo definately dont mix :(

  If your system supports it, you may want to look at iproute2 (the
ip(8) command).  The syntax is a lot more flexible, and a lot more
sane, than ifconfig(8).  And, apparently, it handles this error
better:

# ip addr show dev eth0
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:10:5a:20:55:f1 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.10/24 brd 10.10.10.255 scope global eth0
inet6 fe80::210:5aff:fe20:55f1/64 scope link
   valid_lft forever preferred_lft forever
# ip addr del 192.168.10.1 dev eth0
RTNETLINK answers: Cannot assign requested address
#

-- Ben

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: this has to be a bug...

2006-03-24 Thread Dave Johnson
Paul Lussier writes:
> 
> >From the 'More for your dollar' department:
> 
[snip]
>$ sudo /sbin/ifconfig eth0:0 del 10.107.33.189
>$ ifconfig
[snip]
>eth0:0:1  Link encap:Ethernet  HWaddr 00:0C:F1:E2:A8:6B  
>  inet addr:10.107.33.189  Bcast:0.0.0.0  Mask:0.0.0.0
>  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>  Base address:0xac00 Memory:ff7e-ff80 
[snip]
> 
> I ask to delete a non-existent interface, and instead, I get a totally
> new one I didn't ask for :)


Ya, a bug in net-tools, but you are using an invalid syntax.  Buggy
software and sudo definately dont mix :(

Calling 'del' with an IPv4 IP on an interface that doesn't exist
causes the call to for_all_interfaces() from set_ifstate() to not find
the interface.  It doesn't handle this case and assumes you want to
add the address as a secondary address on the base interface.


Two bugs here:

1) del with IPv4 actually adds if what you specify doesn't exist.

2) add and del assume you only call it with a parent interface name
   'eth0' not 'eth0:' adding a second ':nnn' anyway.

The following actually work:

ifconfig eth0 add 10.107.33.189
ifconfig eth0 del 10.107.33.189

but run 'del' a second time and it adds it back, but with the correct
name (bug)



see below:

(gdb) r
Starting program: /tmp/net-tools-1.60/ifconfig eth0:0 del 10.107.33.189

Breakpoint 1, set_ifstate (parent=0xbf8a1a10 "eth0:0", ip=3173083914, nm=0, 
bc=0, flag=0) at ifconfig.c:1118
1118pt.base = parent;
(gdb) n
1119pt.baselen = strlen(parent);
(gdb) 
1121pt.flag = flag;
(gdb) 
1120pt.addr = ip;
(gdb) 
1122memset(searcher, 0, sizeof(searcher));
(gdb) 
1121pt.flag = flag;
(gdb) 
1122memset(searcher, 0, sizeof(searcher));
(gdb) 
1123i = for_all_interfaces((int (*)(struct interface *,void 
*))do_ifcmd, 
(gdb) p pt
$4 = {flag = 0, addr = 3173083914, base = 0xbf8a1a10 "eth0:0", baselen = 6}
(gdb) n
1125if (i == -1)
(gdb) 
1127if (i == 1)
(gdb) p i
$5 = 0
(gdb) n
1131for (i = 0; i < 256; i++)
(gdb) 
1132if (searcher[i] == 0)
(gdb) 
1131for (i = 0; i < 256; i++)
(gdb) p searcher
$6 = "\001", '\0' 
(gdb) n
1132if (searcher[i] == 0)
(gdb) 
1135if (i == 256)
(gdb) 
1138if (snprintf(buf, IFNAMSIZ, "%s:%d", parent, i) > IFNAMSIZ)
(gdb) p parent
$7 = 0xbf8a1a10 "eth0:0"
(gdb) n
1140if (set_ip_using(buf, SIOCSIFADDR, ip) == -1)
(gdb) p buf
$8 = "eth0:0:1\000\031\212¿W¹\004\b"
(gdb) p ip
$9 = 3173083914
(gdb) p /x ip
$10 = 0xbd216b0a
(gdb) show endian
The target endianness is set automatically (currently little endian)
(gdb) 


SIOCSIFADDR on 'eth0:0:1' will create the interface.  Kernel is doing
what it's told although with a very non-standard interface name.  As
long as it starts with 'eth0:' it considers it an alias.


-- 
Dave


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: this has to be a bug...

2006-03-24 Thread Paul Lussier
"Michael ODonnell" <[EMAIL PROTECTED]> writes:

>>   $ sudo /sbin/ifconfig eth0:0 del 10.107.33.189
> [...]
>>I ask to delete a non-existent interface, and instead, I get
>>a totally new one I didn't ask for :)
>
>
> Though the results aren't what you wanted this might
> possibly be a case of RTFM; my man page says,
>
>  "To delete an alias interface use ifconfig eth0:0 down"

Could be, though *my* man page says nothing of the sort :)

The man page I have simply says:

down   This flag causes the driver for this interface to be shut  down.

And at one time it was possible to down an interface, but not have it
be deleted.  That was essentially the difference between what
'ifconfig' and 'ifconfig -a' told you.  The -a gave you *all* the
interfaces which were configured, regardless of up or down state.
Simply using 'ifconfig' only told you about those which were up.

That's why I was using the 'del' syntax, which I discovered by looking
at code someone else had written 4 or 5 years ago to manage virtual
interfaces in a very consistent/predictable way based on the local
environment and how we use such things.  Things may have changed since
that code was written.

I note that *my* man page also says this:

del addr/prefixlen
  Remove an IPv6 address from an interface.

My ifconfig at home comes from the net-tools 1.60-4 version (Debian).
This came up at work, I don't know which/whose ifconfig we're using
there, I didn't think to look at the time.

-- 

Seeya,
Paul
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: this has to be a bug...

2006-03-24 Thread Jeff Kinz
On Fri, Mar 24, 2006 at 02:37:36PM -0500, Paul Lussier wrote:
> 
> From the 'More for your dollar' department:

>$ sudo /sbin/ifconfig eth0:0 del 10.107.33.189
> ..
> I ask to delete a non-existent interface, and instead, I get a totally
> new one I didn't ask for :)

Its that sudo thingey.  Never ever use that.  Its not safe.  Just give
everyone the root password instead

Oh, and also - for user efficiency, give all the user's blank passwords.

It saves them time logging in and you'll never get a support call on a
forgotten password.

See?  System administration can be made much simpler with a few simple
rule changes. 


what? oh, It's still March.  Sorry, too early.

-- 
Jeff Kinz, Emergent Research, Hudson, MA.
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: this has to be a bug...

2006-03-24 Thread Michael ODonnell


>   $ sudo /sbin/ifconfig eth0:0 del 10.107.33.189
[...]
>I ask to delete a non-existent interface, and instead, I get
>a totally new one I didn't ask for :)


Though the results aren't what you wanted this might
possibly be a case of RTFM; my man page says,

 "To delete an alias interface use ifconfig eth0:0 down"
 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


this has to be a bug...

2006-03-24 Thread Paul Lussier

>From the 'More for your dollar' department:

   $ ifconfig
   eth0  Link encap:Ethernet  HWaddr 00:0C:F1:E2:A8:6B  
 inet addr:10.0.33.189  Bcast:10.0.255.255  Mask:255.255.0.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 RX packets:313517229 errors:0 dropped:0 overruns:0 frame:0
 TX packets:267059253 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000 
 RX bytes:2612070455 (2.4 GiB)  TX bytes:2340276299 (2.1 GiB)
 Base address:0xac00 Memory:ff7e-ff80 
   
   loLink encap:Local Loopback  
 inet addr:127.0.0.1  Mask:255.0.0.0
 UP LOOPBACK RUNNING  MTU:16436  Metric:1
 RX packets:5416926 errors:0 dropped:0 overruns:0 frame:0
 TX packets:5416926 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0 
 RX bytes:3656938394 (3.4 GiB)  TX bytes:3656938394 (3.4 GiB)
   
   $ sudo /sbin/ifconfig eth0:0 del 10.107.33.189
   $ ifconfig
   eth0  Link encap:Ethernet  HWaddr 00:0C:F1:E2:A8:6B  
 inet addr:10.0.33.189  Bcast:10.0.255.255  Mask:255.255.0.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 RX packets:313517475 errors:0 dropped:0 overruns:0 frame:0
 TX packets:267059285 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000 
 RX bytes:2612089422 (2.4 GiB)  TX bytes:2340281076 (2.1 GiB)
 Base address:0xac00 Memory:ff7e-ff80 
   
   eth0:0:1  Link encap:Ethernet  HWaddr 00:0C:F1:E2:A8:6B  
 inet addr:10.107.33.189  Bcast:0.0.0.0  Mask:0.0.0.0
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 Base address:0xac00 Memory:ff7e-ff80 
   
   loLink encap:Local Loopback  
 inet addr:127.0.0.1  Mask:255.0.0.0
 UP LOOPBACK RUNNING  MTU:16436  Metric:1
 RX packets:5416926 errors:0 dropped:0 overruns:0 frame:0
 TX packets:5416926 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0 
 RX bytes:3656938394 (3.4 GiB)  TX bytes:3656938394 (3.4 GiB)

I ask to delete a non-existent interface, and instead, I get a totally
new one I didn't ask for :)

-- 

Seeya,
Paul
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss