luci-mod-network: make condition for disabling legacy bridging more specific
authorJo-Philipp Wich <jo@mein.io>
Mon, 29 Mar 2021 14:30:32 +0000 (16:30 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 29 Mar 2021 14:30:32 +0000 (16:30 +0200)
Only disable legacy bridging if an existing network.device section with type
bridge is found, ignore non-type sections since those do not declare a
bridge but set attributes on top of an existing one.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js

index cd51a0391cf52526b73c8edf1c9f193a55f5e24b..4eee9f9576b36799fd40bdaaa07d55ab75bf1c96 100644 (file)
@@ -46,11 +46,11 @@ function validateQoSMap(section_id, value) {
        return true;
 }
 
        return true;
 }
 
-function deviceSectionExists(section_id, devname) {
+function deviceSectionExists(section_id, devname, devtype) {
        var exists = false;
 
        uci.sections('network', 'device', function(ss) {
        var exists = false;
 
        uci.sections('network', 'device', function(ss) {
-               exists = exists || (ss['.name'] != section_id && ss.name == devname /* && !ss.type*/);
+               exists = exists || (ss['.name'] != section_id && ss.name == devname && (!devtype || devtype == ss.type));
        });
 
        return exists;
        });
 
        return exists;
@@ -379,7 +379,7 @@ return baseclass.extend({
                    gensection = ifc ? 'physical' : 'devgeneral',
                    advsection = ifc ? 'physical' : 'devadvanced',
                    simpledep = ifc ? { type: '', ifname_single: /^[^@]/ } : { type: '' },
                    gensection = ifc ? 'physical' : 'devgeneral',
                    advsection = ifc ? 'physical' : 'devadvanced',
                    simpledep = ifc ? { type: '', ifname_single: /^[^@]/ } : { type: '' },
-                   disableLegacyBridging = isIface && deviceSectionExists(null, 'br-%s'.format(ifc.getName())),
+                   disableLegacyBridging = isIface && deviceSectionExists(null, 'br-%s'.format(ifc.getName()), 'bridge'),
                    o, ss;
 
                /* If an externally configured br-xxx interface already exists,
                    o, ss;
 
                /* If an externally configured br-xxx interface already exists,