Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions files/lib/pbr/pbr.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ function create_pbr(fs_mod, uci_mod, ubus_mod) {
let nft_prefix = pkg.nft_prefix;

if (iface == 'all') {
let prio = '' + iface_priority;
if (action == 'create_global_rules') {
config.uci_ctx('network').foreach('network', 'interface', function(s_iface) {
let name = s_iface['.name'];
Expand All @@ -1017,29 +1018,29 @@ function create_pbr(fs_mod, uci_mod, ubus_mod) {
if (disabled != '1' && listen_port) {
if (cfg.uplink_interface4) {
let tbl = pkg.ip_table_prefix + '_' + cfg.uplink_interface4;
let prio = '' + iface_priority;
system(pkg.ip_full + ' -4 rule del sport ' + listen_port + ' table ' + tbl + ' priority ' + prio + ' 2>/dev/null');
sh.ip('-4', 'rule', 'add', 'sport', listen_port, 'table', tbl, 'priority', prio);
if (cfg.ipv6_enabled) {
system(pkg.ip_full + ' -6 rule del sport ' + listen_port + ' table ' + tbl + ' priority ' + prio + ' 2>/dev/null');
Comment on lines 1021 to 1024
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be other suppress prefix length rules and we do not want to delete those.
But thinking about it I think the whole rule is probably redundant anyway but I will check that later for now just keep it as is

sh.ip('-6', 'rule', 'add', 'sport', listen_port, 'table', tbl, 'priority', prio);
}
prio = '' + (+prio - 1);
}
}
}
});
let spl_prio = '' + (int(cfg.uplink_ip_rules_priority) + 1);
system(pkg.ip_full + ' -4 rule del priority ' + spl_prio + ' 2>/dev/null');
system(pkg.ip_full + ' -4 rule del priority ' + prio + ' 2>/dev/null');
system(pkg.ip_full + ' -4 rule del lookup main suppress_prefixlength ' + cfg.prefixlength + ' 2>/dev/null');
sh.try_cmd(state.errors, pkg.ip_full, '-4', 'rule', 'add', 'lookup', 'main', 'suppress_prefixlength',
'' + cfg.prefixlength, 'pref', spl_prio);
'' + cfg.prefixlength, 'pref', prio);
if (cfg.ipv6_enabled) {
system(pkg.ip_full + ' -6 rule del priority ' + spl_prio + ' 2>/dev/null');
system(pkg.ip_full + ' -6 rule del priority ' + prio + ' 2>/dev/null');
system(pkg.ip_full + ' -6 rule del lookup main suppress_prefixlength ' + cfg.prefixlength + ' 2>/dev/null');
Comment on lines 1011 to 1038
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested it and all rules are cleared because ther is just one suppress_prefixlength rule.
There could be more then one WireGuard servers ,I have tested with two and that also works.
So keep it as is

sh.try_cmd(state.errors, pkg.ip_full, '-6', 'rule', 'add', 'lookup', 'main', 'suppress_prefixlength',
'' + cfg.prefixlength, 'pref', spl_prio);
'' + cfg.prefixlength, 'pref', prio);
}
}
iface_priority = prio;
return 0;
}

Expand Down
Loading