diff options
Diffstat (limited to 'net/bridge/br_sysfs_br.c')
| -rw-r--r-- | net/bridge/br_sysfs_br.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 27d6a511c8c1..158dee8b4965 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c | |||
| @@ -29,11 +29,12 @@ | |||
| 29 | */ | 29 | */ |
| 30 | static ssize_t store_bridge_parm(struct device *d, | 30 | static ssize_t store_bridge_parm(struct device *d, |
| 31 | const char *buf, size_t len, | 31 | const char *buf, size_t len, |
| 32 | void (*set)(struct net_bridge *, unsigned long)) | 32 | int (*set)(struct net_bridge *, unsigned long)) |
| 33 | { | 33 | { |
| 34 | struct net_bridge *br = to_bridge(d); | 34 | struct net_bridge *br = to_bridge(d); |
| 35 | char *endp; | 35 | char *endp; |
| 36 | unsigned long val; | 36 | unsigned long val; |
| 37 | int err; | ||
| 37 | 38 | ||
| 38 | if (!capable(CAP_NET_ADMIN)) | 39 | if (!capable(CAP_NET_ADMIN)) |
| 39 | return -EPERM; | 40 | return -EPERM; |
| @@ -43,9 +44,9 @@ static ssize_t store_bridge_parm(struct device *d, | |||
| 43 | return -EINVAL; | 44 | return -EINVAL; |
| 44 | 45 | ||
| 45 | spin_lock_bh(&br->lock); | 46 | spin_lock_bh(&br->lock); |
| 46 | (*set)(br, val); | 47 | err = (*set)(br, val); |
| 47 | spin_unlock_bh(&br->lock); | 48 | spin_unlock_bh(&br->lock); |
| 48 | return len; | 49 | return err ? err : len; |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | 52 | ||
| @@ -56,12 +57,13 @@ static ssize_t show_forward_delay(struct device *d, | |||
| 56 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); | 57 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | static void set_forward_delay(struct net_bridge *br, unsigned long val) | 60 | static int set_forward_delay(struct net_bridge *br, unsigned long val) |
| 60 | { | 61 | { |
| 61 | unsigned long delay = clock_t_to_jiffies(val); | 62 | unsigned long delay = clock_t_to_jiffies(val); |
| 62 | br->forward_delay = delay; | 63 | br->forward_delay = delay; |
| 63 | if (br_is_root_bridge(br)) | 64 | if (br_is_root_bridge(br)) |
| 64 | br->bridge_forward_delay = delay; | 65 | br->bridge_forward_delay = delay; |
| 66 | return 0; | ||
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | static ssize_t store_forward_delay(struct device *d, | 69 | static ssize_t store_forward_delay(struct device *d, |
| @@ -80,12 +82,17 @@ static ssize_t show_hello_time(struct device *d, struct device_attribute *attr, | |||
| 80 | jiffies_to_clock_t(to_bridge(d)->hello_time)); | 82 | jiffies_to_clock_t(to_bridge(d)->hello_time)); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | static void set_hello_time(struct net_bridge *br, unsigned long val) | 85 | static int set_hello_time(struct net_bridge *br, unsigned long val) |
| 84 | { | 86 | { |
| 85 | unsigned long t = clock_t_to_jiffies(val); | 87 | unsigned long t = clock_t_to_jiffies(val); |
| 88 | |||
| 89 | if (t < HZ) | ||
| 90 | return -EINVAL; | ||
| 91 | |||
| 86 | br->hello_time = t; | 92 | br->hello_time = t; |
| 87 | if (br_is_root_bridge(br)) | 93 | if (br_is_root_bridge(br)) |
| 88 | br->bridge_hello_time = t; | 94 | br->bridge_hello_time = t; |
| 95 | return 0; | ||
| 89 | } | 96 | } |
| 90 | 97 | ||
| 91 | static ssize_t store_hello_time(struct device *d, | 98 | static ssize_t store_hello_time(struct device *d, |
| @@ -104,12 +111,13 @@ static ssize_t show_max_age(struct device *d, struct device_attribute *attr, | |||
| 104 | jiffies_to_clock_t(to_bridge(d)->max_age)); | 111 | jiffies_to_clock_t(to_bridge(d)->max_age)); |
| 105 | } | 112 | } |
| 106 | 113 | ||
| 107 | static void set_max_age(struct net_bridge *br, unsigned long val) | 114 | static int set_max_age(struct net_bridge *br, unsigned long val) |
| 108 | { | 115 | { |
| 109 | unsigned long t = clock_t_to_jiffies(val); | 116 | unsigned long t = clock_t_to_jiffies(val); |
| 110 | br->max_age = t; | 117 | br->max_age = t; |
| 111 | if (br_is_root_bridge(br)) | 118 | if (br_is_root_bridge(br)) |
| 112 | br->bridge_max_age = t; | 119 | br->bridge_max_age = t; |
| 120 | return 0; | ||
| 113 | } | 121 | } |
| 114 | 122 | ||
| 115 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, | 123 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, |
| @@ -126,9 +134,10 @@ static ssize_t show_ageing_time(struct device *d, | |||
| 126 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); | 134 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); |
| 127 | } | 135 | } |
| 128 | 136 | ||
| 129 | static void set_ageing_time(struct net_bridge *br, unsigned long val) | 137 | static int set_ageing_time(struct net_bridge *br, unsigned long val) |
| 130 | { | 138 | { |
| 131 | br->ageing_time = clock_t_to_jiffies(val); | 139 | br->ageing_time = clock_t_to_jiffies(val); |
| 140 | return 0; | ||
| 132 | } | 141 | } |
| 133 | 142 | ||
| 134 | static ssize_t store_ageing_time(struct device *d, | 143 | static ssize_t store_ageing_time(struct device *d, |
| @@ -180,9 +189,10 @@ static ssize_t show_priority(struct device *d, struct device_attribute *attr, | |||
| 180 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); | 189 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); |
| 181 | } | 190 | } |
| 182 | 191 | ||
| 183 | static void set_priority(struct net_bridge *br, unsigned long val) | 192 | static int set_priority(struct net_bridge *br, unsigned long val) |
| 184 | { | 193 | { |
| 185 | br_stp_set_bridge_priority(br, (u16) val); | 194 | br_stp_set_bridge_priority(br, (u16) val); |
| 195 | return 0; | ||
| 186 | } | 196 | } |
| 187 | 197 | ||
| 188 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, | 198 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, |
