Skip to content

Commit

Permalink
Fix main route update
Browse files Browse the repository at this point in the history
  • Loading branch information
xinnige committed May 11, 2024
1 parent 696845d commit b27b57e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion plugins/routing/routing_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ class RoutingPlugin extends Plugin {
if (this.pluginConfig && this.pluginConfig.smooth_failover) {
await this._removeDeadRouting(routing.RT_GLOBAL_DEFAULT, af);
await this._removeDeadRouting(routing.RT_GLOBAL_LOCAL, af);
await this._removeDeadRouting('main', af);
} else {
await routing.flushRoutingTable(routing.RT_GLOBAL_DEFAULT, af);
await routing.flushRoutingTable(routing.RT_GLOBAL_LOCAL, af);
Expand Down
9 changes: 7 additions & 2 deletions tests/plugins/test_routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ describe('Test Routing WAN', function(){
it('should remove dead route rules', async() => {
let results = await routing.searchRouteRules(null, null, 'eth0.288', 'eth0.288_default');
expect(results.length).to.be.equal(4);
log.debug("1. before", results);

await this.plugin._removeDeadRouting("eth0.288_default");

results = await routing.searchRouteRules(null, null, 'eth0.288', 'eth0.288_default');
log.debug("2. after", results);
expect(results.length).to.be.equal(0);
});

Expand Down Expand Up @@ -187,6 +189,9 @@ describe('Test Routing WAN', function(){
expect(results.includes('default via 192.168.10.254 dev eth0.204 metric 101')).to.be.true;
expect(results.includes('default via 192.168.203.1 dev eth0 metric 2')).to.be.true;

results = await routing.searchRouteRules(null, null, 'eth0.204', 'main');
expect(results.includes('192.168.10.0/24 proto kernel scope link src 192.168.10.135')).to.be.true;

this.plugin.networkConfig = routingConfig;
this.plugin._wanStatus['eth0.204'].ready = true;
await this.plugin._applyActiveGlobalDefaultRouting(false, 4);
Expand All @@ -195,13 +200,13 @@ describe('Test Routing WAN', function(){
expect(results.includes('default via 192.168.203.1 dev eth0 metric 2')).to.be.true;
});

it ('should get rule metric', () => {
it('should get rule metric', () => {
expect(this.plugin._getRouteRuleMetric('table eth0.288_default 10.88.8.0/30 dev eth0.288')).to.be.null;
expect(this.plugin._getRouteRuleMetric('table eth0.288_default 10.88.8.0/30 dev eth0.288 metric 1')).to.be.equal('1');
expect(this.plugin._getRouteRuleMetric('fe80::/64 dev eth0.204 via fe80::226d:31ff:fe01:2b43 metric 1024 pref medium')).to.be.equal('1024');
});

it ('should get rule gateway', () => {
it('should get rule gateway', () => {
expect(this.plugin._getRouteRuleGateway('table eth0.288_default 10.88.8.0/30 dev eth0.288')).to.be.null;
expect(this.plugin._getRouteRuleGateway('table eth0.288_default via 10.88.8.1 10.88.8.0/30 dev eth0.288 metric 1')).to.be.equal('10.88.8.1');
expect(this.plugin._getRouteRuleGateway('fe80::/64 dev eth0.204 via fe80::226d:31ff:fe01:2b43 metric 1024 pref medium')).to.be.equal('fe80::226d:31ff:fe01:2b43');
Expand Down

0 comments on commit b27b57e

Please sign in to comment.