summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-04-16 18:39:59 +0200
committerGitHub <noreply@github.com>2024-04-16 18:39:59 +0200
commit5a481813c0590d1dd800772251c9ccb25f6faefc (patch)
tree4715a4abe058f1f898e36fd106006204ffceda6e
parentd8bca084a1f050a52bef46f5e1b589cbf89ce54d (diff)
parent6cace2df99c700dfaafe0d414257e4c3a9061771 (diff)
downloadvyos-1x-5a481813c0590d1dd800772251c9ccb25f6faefc.tar.gz
vyos-1x-5a481813c0590d1dd800772251c9ccb25f6faefc.zip
Merge pull request #3319 from vyos/mergify/bp/sagitta/pr-3313
T5722: Failover route add option onlink (backport #3313)
-rw-r--r--interface-definitions/protocols_failover.xml.in6
-rwxr-xr-xsrc/helpers/vyos-failover.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/interface-definitions/protocols_failover.xml.in b/interface-definitions/protocols_failover.xml.in
index c0caec68e..f70975949 100644
--- a/interface-definitions/protocols_failover.xml.in
+++ b/interface-definitions/protocols_failover.xml.in
@@ -124,6 +124,12 @@
</properties>
<defaultValue>1</defaultValue>
</leafNode>
+ <leafNode name="onlink">
+ <properties>
+ <help>The next hop is directly connected to the interface, even if it does not match interface prefix</help>
+ <valueless/>
+ </properties>
+ </leafNode>
</children>
</tagNode>
</children>
diff --git a/src/helpers/vyos-failover.py b/src/helpers/vyos-failover.py
index f34c18916..348974364 100755
--- a/src/helpers/vyos-failover.py
+++ b/src/helpers/vyos-failover.py
@@ -197,6 +197,7 @@ if __name__ == '__main__':
proto = nexthop_config.get('check').get('type')
target = nexthop_config.get('check').get('target')
timeout = nexthop_config.get('check').get('timeout')
+ onlink = 'onlink' if 'onlink' in nexthop_config else ''
# Route not found in the current routing table
if not is_route_exists(route, next_hop, conf_iface, conf_metric):
@@ -206,14 +207,14 @@ if __name__ == '__main__':
if debug: print(f' [ ADD ] -- ip route add {route} via {next_hop} dev {conf_iface} '
f'metric {conf_metric} proto failover\n###')
rc, command = rc_cmd(f'ip route add {route} via {next_hop} dev {conf_iface} '
- f'metric {conf_metric} proto failover')
+ f'{onlink} metric {conf_metric} proto failover')
# If something is wrong and gateway not added
# Example: Error: Next-hop has invalid gateway.
if rc !=0:
if debug: print(f'{command} -- return-code [RC: {rc}] {next_hop} dev {conf_iface}')
else:
journal.send(f'ip route add {route} via {next_hop} dev {conf_iface} '
- f'metric {conf_metric} proto failover', SYSLOG_IDENTIFIER=my_name)
+ f'{onlink} metric {conf_metric} proto failover', SYSLOG_IDENTIFIER=my_name)
else:
if debug: print(f' [ TARGET_FAIL ] target checks fails for [{target}], do nothing')
journal.send(f'Check fail for route {route} target {target} proto {proto} '