Skip to content

Commit

Permalink
Merge pull request #3319 from vyos/mergify/bp/sagitta/pr-3313
Browse files Browse the repository at this point in the history
T5722: Failover route add option onlink (backport #3313)
  • Loading branch information
c-po authored Apr 16, 2024
2 parents d8bca08 + 6cace2d commit 5a48181
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions interface-definitions/protocols_failover.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/vyos-failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def is_target_alive(target_list=None,
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):
Expand All @@ -206,14 +207,14 @@ def is_target_alive(target_list=None,
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} '
Expand Down

0 comments on commit 5a48181

Please sign in to comment.