All of lore.kernel.org
 help / color / mirror / Atom feed
* IFF_LOWER_UP does not fit in ifr_flags
@ 2009-05-28 12:59 Fredrik Arnerup
  2009-05-30  3:50 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Fredrik Arnerup @ 2009-05-28 12:59 UTC (permalink / raw)
  To: linux-kernel

Documentation/networking/operstates.txt (and netdevice(7)) claims that
the flags IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO can be read from user space
using ioctl() with SIOCGIFFLAGS. Looking in include/linux/if.h however,
the flags are returned in a struct ifreq in the field ifr_flags which
is declared as a short, while the flags are defined as:

#define IFF_LOWER_UP    0x10000         /* driver signals L1 up         */
#define IFF_DORMANT     0x20000         /* driver signals dormant       */
#define IFF_ECHO        0x40000         /* echo sent packets            */

Those aren't shorts, are they? In net/core/dev.c dev_get_flags() returns
an unsigned which is assigned to ifr_flags directly.

Looked at linux/kernel/git/stable/linux-2.6.29.y.git.
CC me please.

/Fredrik Arnerup
fredrik.arnerup@edgeware.tv


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

* Re: IFF_LOWER_UP does not fit in ifr_flags
  2009-05-28 12:59 IFF_LOWER_UP does not fit in ifr_flags Fredrik Arnerup
@ 2009-05-30  3:50 ` Andrew Morton
  2009-06-05 16:24   ` [PATCH] " John Dykstra
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2009-05-30  3:50 UTC (permalink / raw)
  To: Fredrik Arnerup; +Cc: linux-kernel, netdev

On Thu, 28 May 2009 14:59:05 +0200 "Fredrik Arnerup" <fredrik.arnerup@edgeware.tv> wrote:

> Documentation/networking/operstates.txt (and netdevice(7)) claims that
> the flags IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO can be read from user space
> using ioctl() with SIOCGIFFLAGS. Looking in include/linux/if.h however,
> the flags are returned in a struct ifreq in the field ifr_flags which
> is declared as a short, while the flags are defined as:
> 
> #define IFF_LOWER_UP    0x10000         /* driver signals L1 up         */
> #define IFF_DORMANT     0x20000         /* driver signals dormant       */
> #define IFF_ECHO        0x40000         /* echo sent packets            */
> 
> Those aren't shorts, are they? In net/core/dev.c dev_get_flags() returns
> an unsigned which is assigned to ifr_flags directly.
> 
> Looked at linux/kernel/git/stable/linux-2.6.29.y.git.
> CC me please.
> 

(cc netdev)

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

* [PATCH]  Re: IFF_LOWER_UP does not fit in ifr_flags
  2009-05-30  3:50 ` Andrew Morton
@ 2009-06-05 16:24   ` John Dykstra
  2009-06-12  3:57     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: John Dykstra @ 2009-06-05 16:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Fredrik Arnerup, linux-kernel, netdev

On Fri, 2009-05-29 at 20:50 -0700, Andrew Morton wrote:
> On Thu, 28 May 2009 14:59:05 +0200 "Fredrik Arnerup" <fredrik.arnerup@edgeware.tv> wrote:
> 
> > Documentation/networking/operstates.txt (and netdevice(7)) claims that
> > the flags IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO can be read from user space
> > using ioctl() with SIOCGIFFLAGS. Looking in include/linux/if.h however,
> > the flags are returned in a struct ifreq in the field ifr_flags which
> > is declared as a short, while the flags are defined as:
> > 
> > #define IFF_LOWER_UP    0x10000         /* driver signals L1 up         */
> > #define IFF_DORMANT     0x20000         /* driver signals dormant       */
> > #define IFF_ECHO        0x40000         /* echo sent packets            */

[PATCH] net core: Some interface flags not returned by SIOCGIFFLAGS

Commit b00055aacdb172c05067612278ba27265fcd05ce " [NET] core: add RFC2863 operstate"
defined new interface flag values.  Its documentation specified that these flags
could be accessed from user space via SIOCGIFFLAGS.  However, this does not work
because the new flags do not fit in that ioctl's argument width.

Change the documentation to match the code's behavior.  Also change the source to
explicitly show the truncation.  This _should_ have no effect on executable code, and did
not with gcc 4.2.4 generating x86 code.

A new ioctl could be defined to return all interface flags to user space.  However,
since this has been broken for three years with no one complaining, there doesn't seem much
need.  They are still accessible via netlink.

Reported-by:  "Fredrik Arnerup" <fredrik.arnerup@edgeware.tv>
Signed-off-by: John Dykstra <john.dykstra1@gmail.com>
---
 Documentation/networking/operstates.txt |    3 ---
 net/core/dev.c                          |    2 +-
 2 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/Documentation/networking/operstates.txt b/Documentation/networking/operstates.txt
index c9074f9..1a77a3c 100644
--- a/Documentation/networking/operstates.txt
+++ b/Documentation/networking/operstates.txt
@@ -38,9 +38,6 @@ ifinfomsg::if_flags & IFF_LOWER_UP:
 ifinfomsg::if_flags & IFF_DORMANT:
  Driver has signaled netif_dormant_on()
 
-These interface flags can also be queried without netlink using the
-SIOCGIFFLAGS ioctl.
-
 TLV IFLA_OPERSTATE
 
 contains RFC2863 state of the interface in numeric representation:
diff --git a/net/core/dev.c b/net/core/dev.c
index e2e9e4a..5c7602b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3853,7 +3853,7 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
 
 	switch (cmd) {
 		case SIOCGIFFLAGS:	/* Get interface flags */
-			ifr->ifr_flags = dev_get_flags(dev);
+			ifr->ifr_flags = (short) dev_get_flags(dev);
 			return 0;
 
 		case SIOCGIFMETRIC:	/* Get the metric on the interface
-- 
1.5.4.3




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

* Re: [PATCH] Re: IFF_LOWER_UP does not fit in ifr_flags
  2009-06-05 16:24   ` [PATCH] " John Dykstra
@ 2009-06-12  3:57     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-06-12  3:57 UTC (permalink / raw)
  To: john.dykstra1; +Cc: akpm, fredrik.arnerup, linux-kernel, netdev

From: John Dykstra <john.dykstra1@gmail.com>
Date: Fri, 05 Jun 2009 16:24:07 +0000

> On Fri, 2009-05-29 at 20:50 -0700, Andrew Morton wrote:
>> On Thu, 28 May 2009 14:59:05 +0200 "Fredrik Arnerup" <fredrik.arnerup@edgeware.tv> wrote:
>> 
>> > Documentation/networking/operstates.txt (and netdevice(7)) claims that
>> > the flags IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO can be read from user space
>> > using ioctl() with SIOCGIFFLAGS. Looking in include/linux/if.h however,
>> > the flags are returned in a struct ifreq in the field ifr_flags which
>> > is declared as a short, while the flags are defined as:
>> > 
>> > #define IFF_LOWER_UP    0x10000         /* driver signals L1 up         */
>> > #define IFF_DORMANT     0x20000         /* driver signals dormant       */
>> > #define IFF_ECHO        0x40000         /* echo sent packets            */
> 
> [PATCH] net core: Some interface flags not returned by SIOCGIFFLAGS
 ...
> Reported-by:  "Fredrik Arnerup" <fredrik.arnerup@edgeware.tv>
> Signed-off-by: John Dykstra <john.dykstra1@gmail.com>

Applied, thanks!

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

end of thread, other threads:[~2009-06-12  3:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-28 12:59 IFF_LOWER_UP does not fit in ifr_flags Fredrik Arnerup
2009-05-30  3:50 ` Andrew Morton
2009-06-05 16:24   ` [PATCH] " John Dykstra
2009-06-12  3:57     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.