Skip to content

Commit 1349056

Browse files
committed
luci-mod-network: implement Virtual Routing and Forwarding (VRF) options
VRF in netifd is now in main. See: openwrt/netifd#38 openwrt/openwrt@15c2ca0 VRF netifd management was added to 24.10 in openwrt/openwrt#19125 Signed-off-by: Paul Donald <[email protected]>
1 parent f5da7a6 commit 1349056

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ return baseclass.extend({
440440
return s.taboption(tabName, optionClass, optionName, optionTitle, optionDescription);
441441
},
442442

443-
addDeviceOptions: function(s, dev, isNew) {
443+
addDeviceOptions: function(s, dev, isNew, rtTables) {
444444
var parent_dev = dev ? dev.getParent() : null,
445445
devname = dev ? dev.getName() : null,
446446
o, ss;
@@ -451,8 +451,10 @@ return baseclass.extend({
451451
s.tab('bridgevlan', _('Bridge VLAN filtering'));
452452

453453
o = this.replaceOption(s, 'devgeneral', form.ListValue, 'type', _('Device type'),
454-
!L.hasSystemFeature('bonding') && isNew ? '<a href="' + L.url("admin", "system", "package-manager", "?query=kmod-bonding") + '">'+
455-
_('For bonding, install %s').format('<code>kmod-bonding</code>') + '</a>' : null);
454+
(!L.hasSystemFeature('bonding') && isNew ? '<a href="' + L.url("admin", "system", "package-manager", "?query=kmod-bonding") + '">'+
455+
_('For bonding, install %s').format('<code>kmod-bonding</code>') + '</a><br/>' : '') +
456+
(!L.hasSystemFeature('vrf') && isNew ? '<a href="' + L.url("admin", "system", "package-manager", "?query=kmod-vrf") + '">'+
457+
_('For VRF, install %s').format('<code>kmod-vrf</code>') + '</a><br/>' : ''));
456458
o.readonly = !isNew;
457459
o.value('', _('Network device'));
458460
if (L.hasSystemFeature('bonding')) {
@@ -463,8 +465,11 @@ return baseclass.extend({
463465
o.value('8021ad', _('VLAN (802.1ad)'));
464466
o.value('macvlan', _('MAC VLAN'));
465467
o.value('veth', _('Virtual Ethernet'));
468+
if (L.hasSystemFeature('vrf') && L.hasSystemFeature('netifd_vrf')) {
469+
o.value('vrf', _('VRF device'));
470+
}
466471
o.validate = function(section_id, value) {
467-
if (value == 'bonding' || value == 'bridge' || value == 'veth')
472+
if (value == 'bonding' || value == 'bridge' || value == 'veth' || value == 'vrf')
468473
updatePlaceholders(this.section.getOption('name_complex'), section_id);
469474

470475
return true;
@@ -972,7 +977,7 @@ return baseclass.extend({
972977
o.datatype = 'uinteger';
973978
o.depends({'type': 'bonding', 'monitor_mode': 'mii'});
974979

975-
o = this.replaceOption(s, 'devgeneral', widgets.DeviceSelect, 'ifname_multi-bridge', _('Bridge ports'));
980+
o = this.replaceOption(s, 'devgeneral', widgets.DeviceSelect, 'ifname_multi-bridge', dev?.getType() == 'bridge' ? _('Bridge ports'): _('Ports'));
976981
o.size = 10;
977982
o.rmempty = true;
978983
o.multiple = true;
@@ -998,7 +1003,8 @@ return baseclass.extend({
9981003

9991004
return (!parent_dev || parent_dev.getName() != bridge_name);
10001005
};
1001-
o.description = _('Specifies the wired ports to attach to this bridge. In order to attach wireless networks, choose the associated interface as network in the wireless settings.')
1006+
o.description = dev?.getType() == 'bridge' ? _('Specifies the wired ports to attach to this bridge. In order to attach wireless networks, choose the associated interface as network in the wireless settings.'):
1007+
_('Specifies the devices to attach to this VRF. In order to attach wireless networks, choose the associated interface as network in the wireless settings.');
10021008
o.onchange = function(ev, section_id, values) {
10031009
ss.updatePorts(values);
10041010

@@ -1007,6 +1013,13 @@ return baseclass.extend({
10071013
});
10081014
};
10091015
o.depends('type', 'bridge');
1016+
o.depends('type', 'vrf');
1017+
1018+
o = this.replaceOption(s, 'devgeneral', form.Value, 'table', _('Routing table'));
1019+
rtTables.forEach((rtTable) => {
1020+
o.value(rtTable[1], '%s (%d)'.format(rtTable[1], rtTable[0]));
1021+
})
1022+
o.depends('type', 'vrf');
10101023

10111024
o = this.replaceOption(s, 'devgeneral', form.Flag, 'bridge_empty', _('Bring up empty bridge'), _('Bring up the bridge interface even if no ports are attached'));
10121025
o.default = o.disabled;

modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ return view.extend({
14001400
var isNew = (uci.get('network', s.section, 'name') == null),
14011401
dev = getDevice(s.section);
14021402

1403-
nettools.addDeviceOptions(s, dev, isNew);
1403+
nettools.addDeviceOptions(s, dev, isNew, rtTables);
14041404
};
14051405

14061406
s.handleModalCancel = function(map /*, ... */) {
@@ -1473,6 +1473,9 @@ return view.extend({
14731473
case 'veth':
14741474
return 'veth';
14751475

1476+
case 'vrf':
1477+
return 'vrf';
1478+
14761479
case 'wifi':
14771480
case 'alias':
14781481
case 'switch':
@@ -1508,6 +1511,9 @@ return view.extend({
15081511
case 'veth':
15091512
return _('Virtual Ethernet');
15101513

1514+
case 'vrf':
1515+
return _('Virtual Routing and Forwarding (VRF)');
1516+
15111517
default:
15121518
return _('Network device');
15131519
}
@@ -1569,6 +1575,17 @@ return view.extend({
15691575
_('This prefix is randomly generated at first install.'));
15701576
o.datatype = 'cidr6';
15711577

1578+
const l3mdevhelp1 = _('%s services running on this device in the default VRF context (ie., not bound to any VRF device) shall work across all VRF domains.');
1579+
const l3mdevhelp2 = _('Off means VRF traffic will be handled exclusively by sockets bound to VRFs.');
1580+
1581+
o = s.option(form.Flag, 'tcp_l3mdev', _('TCP Layer 3 Master Device (tcp_l3mdev) accept'),
1582+
l3mdevhelp1.format('TCP') + '<br/>' +
1583+
l3mdevhelp2);
1584+
1585+
o = s.option(form.Flag, 'udp_l3mdev', _('UDP Layer 3 Master Device (udp_l3mdev) accept'),
1586+
l3mdevhelp1.format('UDP') + '<br/>' +
1587+
l3mdevhelp2);
1588+
15721589
o = s.option(form.ListValue, 'packet_steering', _('Packet Steering'), _('Enable packet steering across CPUs. May help or hinder network speed.'));
15731590
o.value('0', _('Disabled'));
15741591
o.value('1',_('Enabled'));

0 commit comments

Comments
 (0)