mcst-linux-kernel/patches-2024.06.26/bridge-utils-1.5/0001-add-sysfs-path-patch-b...

77 lines
2.0 KiB
Diff

From 25da9fc890bbef0abe5664428116ec834c9268d1 Mon Sep 17 00:00:00 2001
Date: Mon, 1 Feb 2016 09:27:01 +0300
Subject: [PATCH] add sysfs path patch (bug 65921)
---
libbridge/libbridge_devif.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/libbridge/libbridge_devif.c b/libbridge/libbridge_devif.c
index aa8bc36..2bbd002 100644
--- a/libbridge/libbridge_devif.c
+++ b/libbridge/libbridge_devif.c
@@ -280,6 +280,22 @@ fallback:
return old_get_port_info(brname, port, info);
}
+static int set_sysfs(const char *path, unsigned long value)
+{
+ int fd, ret = 0, cc;
+ char buf[32];
+
+ fd = open(path, O_WRONLY);
+ if (fd < 0)
+ return -1;
+
+ cc = snprintf(buf, sizeof(buf), "%lu\n", value);
+ if (write(fd, buf, cc) < 0)
+ ret = -1;
+ close(fd);
+
+ return ret;
+}
static int br_set(const char *bridge, const char *name,
unsigned long value, unsigned long oldcode)
@@ -288,13 +304,15 @@ static int br_set(const char *bridge, const char *name,
char path[SYSFS_PATH_MAX];
FILE *f;
- snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/%s", bridge, name);
-
+ /*snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/%s", bridge, name);*/
+ snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/bridge/%s", bridge, name);
+ /*
f = fopen(path, "w");
if (f) {
ret = fprintf(f, "%ld\n", value);
fclose(f);
- } else {
+ } else {*/
+ if ((ret = set_sysfs(path, value)) < 0) {
/* fallback to old ioctl */
struct ifreq ifr;
unsigned long args[4] = { oldcode, value, 0, 0 };
@@ -348,14 +366,16 @@ static int port_set(const char *bridge, const char *ifname,
{
int ret;
char path[SYSFS_PATH_MAX];
- FILE *f;
+/* FILE *f;*/
snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/brport/%s", ifname, name);
+ /*
f = fopen(path, "w");
if (f) {
ret = fprintf(f, "%ld\n", value);
fclose(f);
- } else {
+ } else {*/
+ if ((ret = set_sysfs(path, value)) < 0) {
int index = get_portno(bridge, ifname);
if (index < 0)
--
2.16.4