* [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters
@ 2009-06-15 17:33 ` Fischer, Anna
0 siblings, 0 replies; 4+ messages in thread
From: Fischer, Anna @ 2009-06-15 17:33 UTC (permalink / raw)
To: bridge, linux-kernel, netdev, virtualization, evb
Cc: shemminger, davem, kaber, adobriyan, Arnd Bergmann,
Paul Congdon (UC Davis)
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 <anna.fischer@hp.com>
---
libbridge/libbridge_devif.c | 25 +++++++++++++++++++++----
libbridge/libbridge_private.h | 1 +
2 files changed, 22 insertions(+), 4 deletions(-)
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...)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters
@ 2009-06-15 17:33 ` Fischer, Anna
0 siblings, 0 replies; 4+ messages in thread
From: Fischer, Anna @ 2009-06-15 17:33 UTC (permalink / raw)
To: bridge, linux-kernel, netdev@vger.kernel.org
Cc: shemminger, davem, kaber, adobriyan, Arnd Bergmann,
Paul Congdon (UC Davis)
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 <anna.fischer@hp.com>
---
libbridge/libbridge_devif.c | 25 +++++++++++++++++++++----
libbridge/libbridge_private.h | 1 +
2 files changed, 22 insertions(+), 4 deletions(-)
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...)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Bridge] [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters
@ 2009-06-15 17:33 ` Fischer, Anna
0 siblings, 0 replies; 4+ messages in thread
From: Fischer, Anna @ 2009-06-15 17:33 UTC (permalink / raw)
To: bridge, linux-kernel, netdev, virtualization, evb
Cc: Arnd Bergmann, davem, Paul Congdon (UC Davis), adobriyan
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 <anna.fischer@hp.com>
---
libbridge/libbridge_devif.c | 25 +++++++++++++++++++++----
libbridge/libbridge_private.h | 1 +
2 files changed, 22 insertions(+), 4 deletions(-)
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...)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters
@ 2009-06-15 17:33 Fischer, Anna
0 siblings, 0 replies; 4+ messages in thread
From: Fischer, Anna @ 2009-06-15 17:33 UTC (permalink / raw)
To: bridge, linux-kernel, netdev@vger.kernel.org
Cc: Arnd Bergmann, davem, Paul Congdon (UC Davis), shemminger, adobriyan
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 <anna.fischer@hp.com>
---
libbridge/libbridge_devif.c | 25 +++++++++++++++++++++----
libbridge/libbridge_private.h | 1 +
2 files changed, 22 insertions(+), 4 deletions(-)
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...)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-15 17:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15 17:33 [PATCH] bridge-utils: fix sysfs path for setting bridge configuration parameters Fischer, Anna
2009-06-15 17:33 ` [Bridge] " Fischer, Anna
2009-06-15 17:33 ` Fischer, Anna
2009-06-15 17:33 Fischer, Anna
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.