From patchwork Mon Jun 15 17:33:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischer, Anna" X-Patchwork-Id: 28703 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 1E833B7188 for ; Tue, 16 Jun 2009 03:34:31 +1000 (EST) Received: by ozlabs.org (Postfix) id F2088DDDA0; Tue, 16 Jun 2009 03:34:31 +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 8CE3ADDD1C for ; Tue, 16 Jun 2009 03:34:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764186AbZFOReH (ORCPT ); Mon, 15 Jun 2009 13:34:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762378AbZFOReG (ORCPT ); Mon, 15 Jun 2009 13:34:06 -0400 Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:12520 "EHLO g5t0007.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753558AbZFOReE convert rfc822-to-8bit (ORCPT ); Mon, 15 Jun 2009 13:34:04 -0400 Received: from G3W0630.americas.hpqcorp.net (g3w0630.americas.hpqcorp.net [16.233.58.74]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by g5t0007.atlanta.hp.com (Postfix) with ESMTPS id 05B5A142AD; Mon, 15 Jun 2009 17:34:06 +0000 (UTC) Received: from G6W0173.americas.hpqcorp.net (16.230.33.182) by G3W0630.americas.hpqcorp.net (16.233.58.74) with Microsoft SMTP Server (TLS) id 8.1.340.0; Mon, 15 Jun 2009 17:33:37 +0000 Received: from GVW1118EXC.americas.hpqcorp.net ([16.228.24.174]) by G6W0173.americas.hpqcorp.net ([16.230.33.182]) with mapi; Mon, 15 Jun 2009 17:33:36 +0000 From: "Fischer, Anna" To: "bridge@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "evb@yahoogroups.com" CC: "shemminger@linux-foundation.org" , "davem@davemloft.net" , "kaber@trash.net" , "adobriyan@gmail.com" , Arnd Bergmann , "Paul Congdon (UC Davis)" Date: Mon, 15 Jun 2009 17:33:35 +0000 Subject: [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters Thread-Topic: [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters Thread-Index: Acnt32j7nk5PclCUTfiaJ3n4mGwdZg== Message-ID: <0199E0D51A61344794750DC57738F58E67D2DCECBC@GVW1118EXC.americas.hpqcorp.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Under newer kernels the bridge configuration parameters are located under /sys/class/net/$bridgename/bridge/$param, while the current bridge-utils code is trying to access them under /sys/class/net/$bridgename/$param. This patch fixes this issue in the bridge-utils code and so allows setting of bridge configuration parameters using sysfs under newer kernel versions. Signed-off-by: Anna Fischer --- libbridge/libbridge_devif.c | 25 +++++++++++++++++++++---- libbridge/libbridge_private.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/libbridge/libbridge_devif.c b/libbridge/libbridge_devif.c index 34e3cc8..547bb86 100644 --- a/libbridge/libbridge_devif.c +++ b/libbridge/libbridge_devif.c @@ -73,6 +73,26 @@ static void fetch_tv(const char *dev, const char *name, __jiffies_to_tv(tv, fetch_int(dev, name)); } +/* Open sysfs path for writing bridge properties. */ +static FILE *br_sysfs_open(const char *bridge, const char *name) +{ + char path[SYSFS_PATH_MAX]; + + /* Try accessing /sys/class/net/$bridge/bridge/$name. */ + snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s" + SYSFS_BRIDGE_DIR "/%s", bridge, name); + if (!access(path, F_OK)) + return fopen(path, "w+"); + + /* Try using old-style of accessing bridge sysfs properties. */ + snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/%s", + bridge, name); + if (!access(path, F_OK)) + return fopen(path, "w+"); + + return NULL; +} + /* * Convert device name to an index in the list of ports in bridge. * @@ -283,12 +303,9 @@ static int br_set(const char *bridge, const char *name, unsigned long value, unsigned long oldcode) { int ret; - char path[SYSFS_PATH_MAX]; FILE *f; - snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/%s", bridge, name); - - f = fopen(path, "w"); + f = br_sysfs_open(bridge, name); if (f) { ret = fprintf(f, "%ld\n", value); fclose(f); diff --git a/libbridge/libbridge_private.h b/libbridge/libbridge_private.h index 99a511d..1e1a0c6 100644 --- a/libbridge/libbridge_private.h +++ b/libbridge/libbridge_private.h @@ -31,6 +31,7 @@ #define SYSFS_CLASS_NET "/sys/class/net/" #define SYSFS_PATH_MAX 256 +#define SYSFS_BRIDGE_DIR "/bridge" #define dprintf(fmt,arg...) -- To unsubscribe from this list: send the line "unsubscribe netdev" in