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

Re: Testing netapplet



I wrote that netapplet does not need to know how the external
program (e.g., guessnet) does the mapping.

On Mon, 06 Sep 2004 17:30:11 +0200, Matthew Garrett wrote:
> Ah, but it does. For instance, to make guessnet work nicely with
> /etc/network/interfaces you need to use something like:
> 
> mapping eth0
>        script /usr/sbin/guessnet-ifupdown
>        map work
>        map default: dhcp
>        map timeout: 3
>        map verbose: true
> 
> iface dhcp inet dhcp
> 
> iface work inet static
>         address 192.168.128.204
>         netmask 255.255.255.0
>         broadcast 192.168.128.255
>         gateway 192.168.128.240
> 
> which is all well and good, but how do I know which of these things
> should be presented as a list of interfaces to the user and which are
> purely logical?


You are thinking as follows: "There are physical interfaces and
there are logical interfaces and any of these can be up or down
but only the physical ones are relevant to the user."  Or something
like that.

You are confused.  I don't blame you: the terminology in the ifupdown
documentation is needlessly misleading; however, in order to avoid
creating even more confusion I will stick with that terminology
and just try to explain more carefully.

What get defined in /etc/network/interfaces are always _logical_
interfaces.  These are really just interface configuration profiles,
but instead of saying that a profile is applied to an interface we
say that the physical interface is configured "as" that logical
interface.

/etc/network/interfaces is not a list of the interfaces known to
the kernel ("physical interfaces", in ifupdown terminology)!
If you want a list of interfaces known to the kernel then look in
/proc/net/dev.

Ifup's job is to configure a specified physical interface as some
defined logical interface.  When ifup is finished it records what it
has done in /etc/network/ifstate.

In its simplest configuration, ifup chooses a logical interface
for a specified physical interface by looking for a definition 
that has the same name.  Thus if you do:

    ifup eth0

and /etc/network/interfaces contains only, e.g.:

    iface eth0 inet dhcp

then ifup brings up physical interface eth0 as logical interface eth0.
(It is only because ifup behaves this way that it is possible for
people to use it without understanding the difference between
physical interface and logical interface.)  However, you can
override this behavior.  This:

    ifup eth0=home

brings up physical interface eth0 as logical interface home.  Another
way to override the default mapping is to use a mapping program such
as guessnet; it will choose a logical interface for a given physical
interface according to its own algorithm.

Suppose the user has configured ifup to use guessnet to map physical
interface eth0.  The reason why netapplet doesn't need to know how
guessnet does this is that netapplet will do either:

    ifup eth0=foo

or:

    ifup eth0

In the first case, guessnet does not get run at all.  Ifup brings
up eth0 as logical interface foo.  In the second case, guessnet runs
and chooses a logical interface name and ifup configures the physical
interface as that logical interface; and netapplet can find out which
one by looking in /etc/network/ifstate.


I think that some people may be confused because they think that
/etc/network/interfaces is supposed to be a list of interfaces which
might be up.  But it doesn't really make sense to think of logical
interfaces this way.  If a logical interface isn't "up" then there
is no way of bringing it "up" unless there is some physical
interface available as which it can be brought up.


> Without knowing how guessnet-ifupdown works, there's no
> way I can know that dhcp and work have no relation to real interfaces
> and shouldn't be presented to the user by default.


I will assume that one instance of netapplet controls one physical
interface.  Netapplet should display the name of the physical interface
as a title and offer the user a list of logical interface names plus
"default" and "disabled".  One of the logical interface names
(or "disabled") is highlighted, indicating that the physical interface
is currently configured as that logical interface (or deconfigured).
If the user selects some other logical interface name from the list
then netapplet deconfigures the physical interface:

    ifdown <physical_iface>

and configures it again as the selected logical interface:

    ifup <physical_iface>=<logical_iface_chosen_by_user>

If the user selects "default" then netapplet deconfigures the
physical interface:

    ifdown <physical_iface>

and configures it again using the default mapping:

    ifup <physical_iface>

In either case netapplet updates the display to show the
logical interface as which the physical interface is now
configured.



> Sorry, that wasn't clear. The guessnet case is an example of the lack of
> policy. There's no way of telling whether something actually refers to
> an interface (and so is of interest to netapplet) or not.


If that was your only issue with the policy governing
/etc/network/interfaces then I hope that I have cleared it up
by what I have already said.

-- 
Thomas Hood



Reply to: