Skip to content

Commit

Permalink
Fix route in failover mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xinnige committed May 20, 2024
1 parent 3d66481 commit cff9b28
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/routing/routing_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ class RoutingPlugin extends Plugin {
// async context and apply/flush context should be mutually exclusive, so they acquire the same LOCK_SHARED
await lock.acquire(inAsyncContext ? LOCK_SHARED : LOCK_APPLY_ACTIVE_WAN, async () => {
// flush global default routing table, no need to touch global static routing table here
if (this.pluginConfig && this.pluginConfig.smooth_failover) {
const type = this.networkConfig.default.type || "single";
if (type === 'primary_standby' && this.pluginConfig && this.pluginConfig.smooth_failover) {
const deadWANIntfs = this.getUnreadyWANPlugins();
await this._removeDeviceRouting(deadWANIntfs, routing.RT_GLOBAL_DEFAULT, af);
await this._removeDeviceRouting(deadWANIntfs, routing.RT_GLOBAL_LOCAL, af);
Expand All @@ -428,11 +429,10 @@ class RoutingPlugin extends Plugin {
await routing.flushRoutingTable(routing.RT_GLOBAL_LOCAL, af);
}

if (!this.pluginConfig || !this.pluginConfig.smooth_failover) {
if (type !== 'primary_standby' || !this.pluginConfig || !this.pluginConfig.smooth_failover) {
await this._removeMainRoutes(af);
}

const type = this.networkConfig.default.type || "single";
switch (type) {
case "single":
case "primary_standby": {
Expand Down Expand Up @@ -966,9 +966,9 @@ class RoutingPlugin extends Plugin {
const intfPlugin = this._wanStatus[intf] && this._wanStatus[intf].plugin
const type = (this.networkConfig && this.networkConfig.default && this.networkConfig.default.type) || "single";

if (this.pluginConfig && this.pluginConfig.smooth_failover) {
if (type === 'primary_standby' && this.pluginConfig && this.pluginConfig.smooth_failover) {
// update global default routes related to the interface
if (intfPlugin && type == 'primary_standby' && this.name == 'global') {
if (intfPlugin && this.name == 'global') {
this.refreshGlobalIntfRoutes(intf, 4);
break;
}
Expand Down

0 comments on commit cff9b28

Please sign in to comment.