These helpers will initially be used in pve-manager's pve-sdn-commit
service, that reloads the SDN configuration if uncommitted changes are
detected. For non-vlan aware bridges, the SDN configuration might need
to get updated if there were changes to the names of the physical
interfaces enslaved to that bridge. pve-sdn-commit uses the helpers
introduced in this commit for that.

Signed-off-by: Stefan Hanreich <[email protected]>
---
 src/PVE/IPRoute2.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/PVE/IPRoute2.pm b/src/PVE/IPRoute2.pm
index 5f7b94c..5208d93 100644
--- a/src/PVE/IPRoute2.pm
+++ b/src/PVE/IPRoute2.pm
@@ -32,6 +32,25 @@ sub ip_link_is_physical($ip_link) {
         && (!defined($ip_link->{linkinfo}) || 
!defined($ip_link->{linkinfo}->{info_kind}));
 }
 
+sub ip_link_is_bridge($ip_link) {
+    return
+        defined($ip_link->{linkinfo})
+        && defined($ip_link->{linkinfo}->{info_kind})
+        && $ip_link->{linkinfo}->{info_kind} eq 'bridge';
+}
+
+sub bridge_is_vlan_aware($ip_link) {
+    if (!ip_link_is_bridge($ip_link)) {
+        warn "passed link that isn't a bridge to bridge_is_vlan_aware";
+        return 0;
+    }
+
+    return
+        defined($ip_link->{linkinfo}->{info_data})
+        && defined($ip_link->{linkinfo}->{info_data}->{vlan_filtering})
+        && $ip_link->{linkinfo}->{info_data}->{vlan_filtering} == 1;
+}
+
 sub ip_link_is_bridge_member($ip_link) {
     return
         defined($ip_link->{linkinfo})
-- 
2.47.3


_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to