hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/net/bridge/br_sysfs_br.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Sysfs attributes of bridge
34 * Linux ethernet bridge
45 *
56 * Authors:
67 * Stephen Hemminger <shemminger@osdl.org>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; either version
11
- * 2 of the License, or (at your option) any later version.
128 */
139
1410 #include <linux/capability.h>
....@@ -130,9 +126,7 @@
130126
131127 static int set_stp_state(struct net_bridge *br, unsigned long val)
132128 {
133
- br_stp_set_enabled(br, val);
134
-
135
- return 0;
129
+ return br_stp_set_enabled(br, val, NULL);
136130 }
137131
138132 static ssize_t stp_state_store(struct device *d,
....@@ -303,7 +297,7 @@
303297 ether_addr_copy(br->group_addr, new_addr);
304298 spin_unlock_bh(&br->lock);
305299
306
- br->group_addr_set = true;
300
+ br_opt_toggle(br, BROPT_GROUP_ADDR_SET, true);
307301 br_recalculate_fwd_mask(br);
308302 netdev_state_change(br->dev);
309303
....@@ -328,6 +322,27 @@
328322 }
329323 static DEVICE_ATTR_WO(flush);
330324
325
+static ssize_t no_linklocal_learn_show(struct device *d,
326
+ struct device_attribute *attr,
327
+ char *buf)
328
+{
329
+ struct net_bridge *br = to_bridge(d);
330
+ return sprintf(buf, "%d\n", br_boolopt_get(br, BR_BOOLOPT_NO_LL_LEARN));
331
+}
332
+
333
+static int set_no_linklocal_learn(struct net_bridge *br, unsigned long val)
334
+{
335
+ return br_boolopt_toggle(br, BR_BOOLOPT_NO_LL_LEARN, !!val, NULL);
336
+}
337
+
338
+static ssize_t no_linklocal_learn_store(struct device *d,
339
+ struct device_attribute *attr,
340
+ const char *buf, size_t len)
341
+{
342
+ return store_bridge_parm(d, buf, len, set_no_linklocal_learn);
343
+}
344
+static DEVICE_ATTR_RW(no_linklocal_learn);
345
+
331346 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
332347 static ssize_t multicast_router_show(struct device *d,
333348 struct device_attribute *attr, char *buf)
....@@ -349,7 +364,7 @@
349364 char *buf)
350365 {
351366 struct net_bridge *br = to_bridge(d);
352
- return sprintf(buf, "%d\n", !br->multicast_disabled);
367
+ return sprintf(buf, "%d\n", br_opt_get(br, BROPT_MULTICAST_ENABLED));
353368 }
354369
355370 static ssize_t multicast_snooping_store(struct device *d,
....@@ -365,12 +380,13 @@
365380 char *buf)
366381 {
367382 struct net_bridge *br = to_bridge(d);
368
- return sprintf(buf, "%d\n", br->multicast_query_use_ifaddr);
383
+ return sprintf(buf, "%d\n",
384
+ br_opt_get(br, BROPT_MULTICAST_QUERY_USE_IFADDR));
369385 }
370386
371387 static int set_query_use_ifaddr(struct net_bridge *br, unsigned long val)
372388 {
373
- br->multicast_query_use_ifaddr = !!val;
389
+ br_opt_toggle(br, BROPT_MULTICAST_QUERY_USE_IFADDR, !!val);
374390 return 0;
375391 }
376392
....@@ -388,7 +404,7 @@
388404 char *buf)
389405 {
390406 struct net_bridge *br = to_bridge(d);
391
- return sprintf(buf, "%d\n", br->multicast_querier);
407
+ return sprintf(buf, "%d\n", br_opt_get(br, BROPT_MULTICAST_QUERIER));
392408 }
393409
394410 static ssize_t multicast_querier_store(struct device *d,
....@@ -402,13 +418,13 @@
402418 static ssize_t hash_elasticity_show(struct device *d,
403419 struct device_attribute *attr, char *buf)
404420 {
405
- struct net_bridge *br = to_bridge(d);
406
- return sprintf(buf, "%u\n", br->hash_elasticity);
421
+ return sprintf(buf, "%u\n", RHT_ELASTICITY);
407422 }
408423
409424 static int set_elasticity(struct net_bridge *br, unsigned long val)
410425 {
411
- br->hash_elasticity = val;
426
+ br_warn(br, "the hash_elasticity option has been deprecated and is always %u\n",
427
+ RHT_ELASTICITY);
412428 return 0;
413429 }
414430
....@@ -427,10 +443,16 @@
427443 return sprintf(buf, "%u\n", br->hash_max);
428444 }
429445
446
+static int set_hash_max(struct net_bridge *br, unsigned long val)
447
+{
448
+ br->hash_max = val;
449
+ return 0;
450
+}
451
+
430452 static ssize_t hash_max_store(struct device *d, struct device_attribute *attr,
431453 const char *buf, size_t len)
432454 {
433
- return store_bridge_parm(d, buf, len, br_multicast_set_hash_max);
455
+ return store_bridge_parm(d, buf, len, set_hash_max);
434456 }
435457 static DEVICE_ATTR_RW(hash_max);
436458
....@@ -636,12 +658,13 @@
636658 {
637659 struct net_bridge *br = to_bridge(d);
638660
639
- return sprintf(buf, "%u\n", br->multicast_stats_enabled);
661
+ return sprintf(buf, "%d\n",
662
+ br_opt_get(br, BROPT_MULTICAST_STATS_ENABLED));
640663 }
641664
642665 static int set_stats_enabled(struct net_bridge *br, unsigned long val)
643666 {
644
- br->multicast_stats_enabled = !!val;
667
+ br_opt_toggle(br, BROPT_MULTICAST_STATS_ENABLED, !!val);
645668 return 0;
646669 }
647670
....@@ -678,12 +701,12 @@
678701 struct device *d, struct device_attribute *attr, char *buf)
679702 {
680703 struct net_bridge *br = to_bridge(d);
681
- return sprintf(buf, "%u\n", br->nf_call_iptables);
704
+ return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_IPTABLES));
682705 }
683706
684707 static int set_nf_call_iptables(struct net_bridge *br, unsigned long val)
685708 {
686
- br->nf_call_iptables = val ? true : false;
709
+ br_opt_toggle(br, BROPT_NF_CALL_IPTABLES, !!val);
687710 return 0;
688711 }
689712
....@@ -699,12 +722,12 @@
699722 struct device *d, struct device_attribute *attr, char *buf)
700723 {
701724 struct net_bridge *br = to_bridge(d);
702
- return sprintf(buf, "%u\n", br->nf_call_ip6tables);
725
+ return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_IP6TABLES));
703726 }
704727
705728 static int set_nf_call_ip6tables(struct net_bridge *br, unsigned long val)
706729 {
707
- br->nf_call_ip6tables = val ? true : false;
730
+ br_opt_toggle(br, BROPT_NF_CALL_IP6TABLES, !!val);
708731 return 0;
709732 }
710733
....@@ -720,12 +743,12 @@
720743 struct device *d, struct device_attribute *attr, char *buf)
721744 {
722745 struct net_bridge *br = to_bridge(d);
723
- return sprintf(buf, "%u\n", br->nf_call_arptables);
746
+ return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_ARPTABLES));
724747 }
725748
726749 static int set_nf_call_arptables(struct net_bridge *br, unsigned long val)
727750 {
728
- br->nf_call_arptables = val ? true : false;
751
+ br_opt_toggle(br, BROPT_NF_CALL_ARPTABLES, !!val);
729752 return 0;
730753 }
731754
....@@ -743,7 +766,7 @@
743766 char *buf)
744767 {
745768 struct net_bridge *br = to_bridge(d);
746
- return sprintf(buf, "%d\n", br->vlan_enabled);
769
+ return sprintf(buf, "%d\n", br_opt_get(br, BROPT_VLAN_ENABLED));
747770 }
748771
749772 static ssize_t vlan_filtering_store(struct device *d,
....@@ -791,7 +814,7 @@
791814 char *buf)
792815 {
793816 struct net_bridge *br = to_bridge(d);
794
- return sprintf(buf, "%u\n", br->vlan_stats_enabled);
817
+ return sprintf(buf, "%u\n", br_opt_get(br, BROPT_VLAN_STATS_ENABLED));
795818 }
796819
797820 static ssize_t vlan_stats_enabled_store(struct device *d,
....@@ -801,6 +824,22 @@
801824 return store_bridge_parm(d, buf, len, br_vlan_set_stats);
802825 }
803826 static DEVICE_ATTR_RW(vlan_stats_enabled);
827
+
828
+static ssize_t vlan_stats_per_port_show(struct device *d,
829
+ struct device_attribute *attr,
830
+ char *buf)
831
+{
832
+ struct net_bridge *br = to_bridge(d);
833
+ return sprintf(buf, "%u\n", br_opt_get(br, BROPT_VLAN_STATS_PER_PORT));
834
+}
835
+
836
+static ssize_t vlan_stats_per_port_store(struct device *d,
837
+ struct device_attribute *attr,
838
+ const char *buf, size_t len)
839
+{
840
+ return store_bridge_parm(d, buf, len, br_vlan_set_stats_per_port);
841
+}
842
+static DEVICE_ATTR_RW(vlan_stats_per_port);
804843 #endif
805844
806845 static struct attribute *bridge_attrs[] = {
....@@ -823,6 +862,7 @@
823862 &dev_attr_gc_timer.attr,
824863 &dev_attr_group_addr.attr,
825864 &dev_attr_flush.attr,
865
+ &dev_attr_no_linklocal_learn.attr,
826866 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
827867 &dev_attr_multicast_router.attr,
828868 &dev_attr_multicast_snooping.attr,
....@@ -854,6 +894,7 @@
854894 &dev_attr_vlan_protocol.attr,
855895 &dev_attr_default_pvid.attr,
856896 &dev_attr_vlan_stats_enabled.attr,
897
+ &dev_attr_vlan_stats_per_port.attr,
857898 #endif
858899 NULL
859900 };