port.c (e700ac213a0f793fb4f83098413303e3dd080892) | port.c (d0004a020bb50263de0e3e775c7b7c7a003e0e0c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Handling of a single switch port 4 * 5 * Copyright (c) 2017 Savoir-faire Linux Inc. 6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com> 7 */ 8 --- 501 unchanged lines hidden (view full) --- 510} 511 512/* Must be called under rcu_read_lock() */ 513static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp, 514 bool vlan_filtering, 515 struct netlink_ext_ack *extack) 516{ 517 struct dsa_switch *ds = dp->ds; | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Handling of a single switch port 4 * 5 * Copyright (c) 2017 Savoir-faire Linux Inc. 6 * Vivien Didelot <vivien.didelot@savoirfairelinux.com> 7 */ 8 --- 501 unchanged lines hidden (view full) --- 510} 511 512/* Must be called under rcu_read_lock() */ 513static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp, 514 bool vlan_filtering, 515 struct netlink_ext_ack *extack) 516{ 517 struct dsa_switch *ds = dp->ds; |
518 int err, i; | 518 struct dsa_port *other_dp; 519 int err; |
519 520 /* VLAN awareness was off, so the question is "can we turn it on". 521 * We may have had 8021q uppers, those need to go. Make sure we don't 522 * enter an inconsistent state: deny changing the VLAN awareness state 523 * as long as we have 8021q uppers. 524 */ 525 if (vlan_filtering && dsa_is_user_port(ds, dp->index)) { 526 struct net_device *upper_dev, *slave = dp->slave; --- 25 unchanged lines hidden (view full) --- 552 if (!ds->vlan_filtering_is_global) 553 return true; 554 555 /* For cases where enabling/disabling VLAN awareness is global to the 556 * switch, we need to handle the case where multiple bridges span 557 * different ports of the same switch device and one of them has a 558 * different setting than what is being requested. 559 */ | 520 521 /* VLAN awareness was off, so the question is "can we turn it on". 522 * We may have had 8021q uppers, those need to go. Make sure we don't 523 * enter an inconsistent state: deny changing the VLAN awareness state 524 * as long as we have 8021q uppers. 525 */ 526 if (vlan_filtering && dsa_is_user_port(ds, dp->index)) { 527 struct net_device *upper_dev, *slave = dp->slave; --- 25 unchanged lines hidden (view full) --- 553 if (!ds->vlan_filtering_is_global) 554 return true; 555 556 /* For cases where enabling/disabling VLAN awareness is global to the 557 * switch, we need to handle the case where multiple bridges span 558 * different ports of the same switch device and one of them has a 559 * different setting than what is being requested. 560 */ |
560 for (i = 0; i < ds->num_ports; i++) { | 561 dsa_switch_for_each_port(other_dp, ds) { |
561 struct net_device *other_bridge; 562 | 562 struct net_device *other_bridge; 563 |
563 other_bridge = dsa_to_port(ds, i)->bridge_dev; | 564 other_bridge = other_dp->bridge_dev; |
564 if (!other_bridge) 565 continue; 566 /* If it's the same bridge, it also has same 567 * vlan_filtering setting => no need to check 568 */ 569 if (other_bridge == dp->bridge_dev) 570 continue; 571 if (br_vlan_enabled(other_bridge) != vlan_filtering) { --- 30 unchanged lines hidden (view full) --- 602 return 0; 603 604 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering, 605 extack); 606 if (err) 607 return err; 608 609 if (ds->vlan_filtering_is_global) { | 565 if (!other_bridge) 566 continue; 567 /* If it's the same bridge, it also has same 568 * vlan_filtering setting => no need to check 569 */ 570 if (other_bridge == dp->bridge_dev) 571 continue; 572 if (br_vlan_enabled(other_bridge) != vlan_filtering) { --- 30 unchanged lines hidden (view full) --- 603 return 0; 604 605 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering, 606 extack); 607 if (err) 608 return err; 609 610 if (ds->vlan_filtering_is_global) { |
610 int port; | 611 struct dsa_port *other_dp; |
611 612 ds->vlan_filtering = vlan_filtering; 613 | 612 613 ds->vlan_filtering = vlan_filtering; 614 |
614 for (port = 0; port < ds->num_ports; port++) { 615 struct net_device *slave; | 615 dsa_switch_for_each_user_port(other_dp, ds) { 616 struct net_device *slave = dp->slave; |
616 | 617 |
617 if (!dsa_is_user_port(ds, port)) 618 continue; 619 | |
620 /* We might be called in the unbind path, so not 621 * all slave devices might still be registered. 622 */ | 618 /* We might be called in the unbind path, so not 619 * all slave devices might still be registered. 620 */ |
623 slave = dsa_to_port(ds, port)->slave; | |
624 if (!slave) 625 continue; 626 627 err = dsa_slave_manage_vlan_filtering(slave, 628 vlan_filtering); 629 if (err) 630 goto restore; 631 } --- 732 unchanged lines hidden --- | 621 if (!slave) 622 continue; 623 624 err = dsa_slave_manage_vlan_filtering(slave, 625 vlan_filtering); 626 if (err) 627 goto restore; 628 } --- 732 unchanged lines hidden --- |