From patchwork Fri Jun 5 16:24:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Dykstra X-Patchwork-Id: 28158 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 8B757B70B5 for ; Sat, 6 Jun 2009 02:24:20 +1000 (EST) Received: by ozlabs.org (Postfix) id 7C171DDDA1; Sat, 6 Jun 2009 02:24:20 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 1ED16DDD1B for ; Sat, 6 Jun 2009 02:24:20 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818AbZFEQYL (ORCPT ); Fri, 5 Jun 2009 12:24:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752328AbZFEQYL (ORCPT ); Fri, 5 Jun 2009 12:24:11 -0400 Received: from an-out-0708.google.com ([209.85.132.251]:14083 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbZFEQYJ (ORCPT ); Fri, 5 Jun 2009 12:24:09 -0400 Received: by an-out-0708.google.com with SMTP id d40so2605001and.1 for ; Fri, 05 Jun 2009 09:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=z87iqKUgDo8q3aCK5oQVylmvUrOafAglx57gPSYElGU=; b=sa9HPmuPU+o6bCOQFlqdeEBoXx8BjPcxA94Vk/uoeXdya0uQktUJnXJUoO0T2Vbcor aS/+H4NGUUEBtDAXDq+XhwoVMrsGMqtn66flT/9r9eb3bqJx2qc8TIpT4tr8nhjCzbLd kZZUpm4A5ApWdMn0H6teu2a/GuBMOnjU+POIM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=HHd12/ZWofMu3+r2c2OqMmBf+w7+JW+TEenJFiEiDA23a2Hn2YvQgFVqWJ52fc4caz Q/RNP+05xy/6W43Wjh0uv0BZ5Qy6PtkavmrUh8qwGcBDAQLAvVVMvLz1FUdFQv0REPD/ K1f1WJfgUUL8gGuOSINkGqK4TS5N1D3tjhB3E= Received: by 10.100.141.2 with SMTP id o2mr4161627and.151.1244219050515; Fri, 05 Jun 2009 09:24:10 -0700 (PDT) Received: from ?192.168.221.201? ([24.118.80.156]) by mx.google.com with ESMTPS id 8sm89960ywg.33.2009.06.05.09.24.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Jun 2009 09:24:09 -0700 (PDT) Subject: [PATCH] Re: IFF_LOWER_UP does not fit in ifr_flags From: John Dykstra To: Andrew Morton Cc: Fredrik Arnerup , linux-kernel@vger.kernel.org, netdev@vger.kernel.org In-Reply-To: <20090529205028.3e01786b.akpm@linux-foundation.org> References: <89A39FC0957640879F8975880836CF91@edgeware.tv> <20090529205028.3e01786b.akpm@linux-foundation.org> Date: Fri, 05 Jun 2009 16:24:07 +0000 Message-Id: <1244219047.7969.7.camel@Maple> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2009-05-29 at 20:50 -0700, Andrew Morton wrote: > On Thu, 28 May 2009 14:59:05 +0200 "Fredrik Arnerup" 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" Signed-off-by: John Dykstra --- 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