netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* IFF_PROMISC again
@ 2007-05-01 18:36 Martín Ferrari
  2007-05-23  0:08 ` Ben Greear
  0 siblings, 1 reply; 8+ messages in thread
From: Martín Ferrari @ 2007-05-01 18:36 UTC (permalink / raw)
  To: linux-net, netdev

Hi, for the nth time I send this email, hoping that majordomo won't eat
it again.


I know this has been extensibly discussed circa 2001, but I found that
there's still problems: in debian (at least) neither ifconfig nor ip
can tell that the interface is in promiscuous mode.

I know about the deprecation of IFF_PROMISC, but I couldn't find out
which is the current way of knowing the real state of the interface. I
want to fix ifconfig, so this is not an issue of
PACKET_(ADD|REMOVE)_MEMBERSHIP, I need to query the real device state.

Also, it's unclear to me what happens when you set/reset IFF_PROMISC
and then libpcap fiddles with membership. Is this documented
somewhere?

It has been said many times that ip should give this information. I
cannot see this:

$ sudo tcpdump -ni eth2 port 3333 &
$ dmesg |tail -2
device eth2 entered promiscuous mode
audit(1175904782.767:40): dev=eth2 prom=256 old_prom=0 auid=4294967295
$ ip link show eth2
4: eth2: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen
1000
   link/ether 00:18:de:81:24:a2 brd ff:ff:ff:ff:ff:ff
$ ip -V
ip utility, iproute2-ss060323

I think that is a problem for user tools to not know about this, and I
want to fix them. I don't know how. Can anyone give me a pointer?

Thanks, Martín.

-- 
Martín Ferrari <martin.ferrari@gmail.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
  2007-05-01 18:36 IFF_PROMISC again Martín Ferrari
@ 2007-05-23  0:08 ` Ben Greear
  2007-05-23  0:12   ` David Miller
  2007-05-26  6:28   ` Martín Ferrari
  0 siblings, 2 replies; 8+ messages in thread
From: Ben Greear @ 2007-05-23  0:08 UTC (permalink / raw)
  To: Martín Ferrari; +Cc: netdev

Martín Ferrari wrote:
> Hi, for the nth time I send this email, hoping that majordomo won't eat
> it again.
> 
> 
> I know this has been extensibly discussed circa 2001, but I found that
> there's still problems: in debian (at least) neither ifconfig nor ip
> can tell that the interface is in promiscuous mode.
> 
> I know about the deprecation of IFF_PROMISC, but I couldn't find out
> which is the current way of knowing the real state of the interface. I
> want to fix ifconfig, so this is not an issue of
> PACKET_(ADD|REMOVE)_MEMBERSHIP, I need to query the real device state.

I have the same problem.  I think you can tell by looking at bit 0x100
in /sys/class/net/[ethX]/flags

Not exactly fun to use, but it seems to work.

Anyone know the reasoning for masking out the PROMISC flag
in dev_get_flags() ?

Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
  2007-05-23  0:08 ` Ben Greear
@ 2007-05-23  0:12   ` David Miller
  2007-05-23  0:22     ` Ben Greear
  2007-05-26  6:42     ` Martín Ferrari
  2007-05-26  6:28   ` Martín Ferrari
  1 sibling, 2 replies; 8+ messages in thread
From: David Miller @ 2007-05-23  0:12 UTC (permalink / raw)
  To: greearb; +Cc: martin.ferrari, netdev

From: Ben Greear <greearb@candelatech.com>
Date: Tue, 22 May 2007 17:08:18 -0700

> Anyone know the reasoning for masking out the PROMISC flag
> in dev_get_flags() ?

Because promiscuous status is a counter, not a binary
on-off state.

You can't expect to just clear it and expect all the
other promiscuous users to just "go away" and be ok
with the device leaving promiscuous mode.

Since you can't sanely "set" it, we don't provide it
either.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
  2007-05-23  0:12   ` David Miller
@ 2007-05-23  0:22     ` Ben Greear
  2007-05-26  6:42     ` Martín Ferrari
  1 sibling, 0 replies; 8+ messages in thread
From: Ben Greear @ 2007-05-23  0:22 UTC (permalink / raw)
  To: David Miller; +Cc: martin.ferrari, netdev

David Miller wrote:
> From: Ben Greear <greearb@candelatech.com>
> Date: Tue, 22 May 2007 17:08:18 -0700
> 
>> Anyone know the reasoning for masking out the PROMISC flag
>> in dev_get_flags() ?
> 
> Because promiscuous status is a counter, not a binary
> on-off state.
> 
> You can't expect to just clear it and expect all the
> other promiscuous users to just "go away" and be ok
> with the device leaving promiscuous mode.

Yes, I understand why you wouldn't let a user set promisc in this
manner.

> Since you can't sanely "set" it, we don't provide it
> either.

What harm is there letting the user know if their hardware is PROMISC
or not, regardless of how it got that way?

Also, it seems you *can* at least turn it on with ifconfig, and
you can decrement at least once with ifconfig as well.  If nothing
else has promiscuity set, then this will indeed toggle the state, right?

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
  2007-05-23  0:08 ` Ben Greear
  2007-05-23  0:12   ` David Miller
@ 2007-05-26  6:28   ` Martín Ferrari
       [not found]     ` <20070527094923.3b4705b6@freepuppy>
  1 sibling, 1 reply; 8+ messages in thread
From: Martín Ferrari @ 2007-05-26  6:28 UTC (permalink / raw)
  To: Ben Greear; +Cc: netdev

Hi Ben,

On 5/22/07, Ben Greear <greearb@candelatech.com> wrote:

> > PACKET_(ADD|REMOVE)_MEMBERSHIP, I need to query the real device state.

> I have the same problem.  I think you can tell by looking at bit 0x100
> in /sys/class/net/[ethX]/flags
>
> Not exactly fun to use, but it seems to work.

Wow, I searched for this a lot! It could be all I need, although it
doesn't seem very robust to look at the bitmap driectly, is it?

Maybe it would be cleaner to add an "promiscuity" file to that structure?

-- 
Martín Ferrari

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
  2007-05-23  0:12   ` David Miller
  2007-05-23  0:22     ` Ben Greear
@ 2007-05-26  6:42     ` Martín Ferrari
  1 sibling, 0 replies; 8+ messages in thread
From: Martín Ferrari @ 2007-05-26  6:42 UTC (permalink / raw)
  To: David Miller; +Cc: greearb, netdev

Hi David,

On 5/22/07, David Miller <davem@davemloft.net> wrote:

> > Anyone know the reasoning for masking out the PROMISC flag
> > in dev_get_flags() ?
>
> Because promiscuous status is a counter, not a binary
> on-off state.
>
> You can't expect to just clear it and expect all the
> other promiscuous users to just "go away" and be ok
> with the device leaving promiscuous mode.

Yes, this is fully understood.

> Since you can't sanely "set" it, we don't provide it
> either.

I think it's cleaner how is done now, but the needed information is
hidden, not having a proper way of querying the counter or the real
(binary) promiscuous state is a problem for userspace. Do you think
the patch I suggested is not a good idea?

Do you think there is a acceptable way of exporting that info to
userspace? (as I just said to Ben, the /sys/.../flags file doesn't
seem a very clean way of checking it).

-- 
Martín Ferrari

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
       [not found]     ` <20070527094923.3b4705b6@freepuppy>
@ 2007-05-28  1:05       ` Martín Ferrari
       [not found]         ` <20070527235819.3695a2a1@freepuppy>
  0 siblings, 1 reply; 8+ messages in thread
From: Martín Ferrari @ 2007-05-28  1:05 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ben Greear, netdev

Stephen, I think your mail didn't make it to netdev. Majordomo seems
to be working badly with special charsets (my mails used to be totally
ignored because of charset and/or encoding issues).

On 5/27/07, Stephen Hemminger <shemminger@linux-foundation.org> wrote:

> > Wow, I searched for this a lot! It could be all I need, although it
> > doesn't seem very robust to look at the bitmap driectly, is it?
> >
> > Maybe it would be cleaner to add an "promiscuity" file to that structure?

> /sys/class/net/ethX/flags was an interface mistake. Don't depend on it.
>
> I added it back when sysfs was first starting. Most of the files in /sys/class/net/ethX
> are really meant only for debugging. There was no debugfs at the time.
>
> The problem is it exports bit values as ABI that shouldn't be nailed down.

Great that you point it out. Then, we're back to the initial
situation, there is no reliable way of polling promisc state, and I am
looking for a way to do that. Ways I think it could be done:

- Exporting /sys/class/net/ethX/promiscuity as a counter (I have a
working patch for this)
- Exporting /sys/class/net/ethX/promisc as a binary value, from dev->flags.
- ORing the two IFF_PROMISC flags in dev_get_flags() (the patch I sent)
- Dropping gflags altogether, as there doesn't seem to be any real use
case for it, and keep using dev_get_flags().

Any suggestion?

-- 
Martín Ferrari

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: IFF_PROMISC again
       [not found]         ` <20070527235819.3695a2a1@freepuppy>
@ 2007-05-28 22:07           ` Martín Ferrari
  0 siblings, 0 replies; 8+ messages in thread
From: Martín Ferrari @ 2007-05-28 22:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ben Greear, netdev

Stephen,

On 5/28/07, Stephen Hemminger <shemminger@linux-foundation.org> wrote:

> > Great that you point it out. Then, we're back to the initial
> > situation, there is no reliable way of polling promisc state, and I am
> > looking for a way to do that. Ways I think it could be done:
>
> Back to the original question. Why should an application care?

Not an application, but the sysadmin do cares about it. And most
rootkit detectors don't have any other way of checking if a
tcpdump-like tool is running.

I don't see the usefulness of keeping the current toggle via gflags,
which is confusing for users. But I see a benefit in exporting
promiscuity as a read-only value, and I think it's pretty trivial to
provide it.

-- 
Martín Ferrari

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-28 22:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-01 18:36 IFF_PROMISC again Martín Ferrari
2007-05-23  0:08 ` Ben Greear
2007-05-23  0:12   ` David Miller
2007-05-23  0:22     ` Ben Greear
2007-05-26  6:42     ` Martín Ferrari
2007-05-26  6:28   ` Martín Ferrari
     [not found]     ` <20070527094923.3b4705b6@freepuppy>
2007-05-28  1:05       ` Martín Ferrari
     [not found]         ` <20070527235819.3695a2a1@freepuppy>
2007-05-28 22:07           ` Martín Ferrari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).