40
40
def health_check (ifname , conf , state , test_defaults ):
41
41
# Run health tests for interface
42
42
43
+ if get_ipv4_address (ifname ) is None :
44
+ return False
45
+
43
46
if 'test' not in conf :
44
47
resp_time = test_defaults ['resp-time' ]
45
48
target = conf ['nexthop' ]
@@ -78,7 +81,7 @@ def on_state_change(lb, ifname, state):
78
81
if 'hook' in lb :
79
82
script_path = os .path .join ('/config/scripts/' , lb ['hook' ])
80
83
state_str = 'ACTIVE' if state else 'FAILED'
81
- run (script_path , env = [ f 'WLB_INTERFACE_NAME= { ifname } ' , f 'WLB_INTERFACE_STATE= { state_str } ' ] )
84
+ run (script_path , env = { 'WLB_INTERFACE_NAME' : ifname , 'WLB_INTERFACE_STATE' : state_str })
82
85
83
86
print (f'INFO: State change: { ifname } -> { state } ' )
84
87
@@ -168,13 +171,14 @@ def get_config():
168
171
index = 1
169
172
for ifname , health_conf in lb ['interface_health' ].items ():
170
173
table_num = lb ['mark_offset' ] + index
174
+ addr = get_ipv4_address (ifname )
171
175
lb ['health_state' ][ifname ] = {
172
- 'if_addr' : get_ipv4_address ( ifname ) ,
176
+ 'if_addr' : addr ,
173
177
'failure_count' : 0 ,
174
178
'success_count' : 0 ,
175
179
'last_success' : 0 ,
176
180
'last_failure' : 0 ,
177
- 'state' : True ,
181
+ 'state' : addr is not None ,
178
182
'state_changed' : False ,
179
183
'table_number' : table_num ,
180
184
'mark' : hex (table_num )
@@ -196,7 +200,7 @@ def get_config():
196
200
run ('ip route flush cache' )
197
201
198
202
if 'flush_connections' in lb :
199
- run ('conntrack -F ' )
203
+ run ('conntrack --delete ' )
200
204
run ('conntrack -F expect' )
201
205
202
206
with open (wlb_status_file , 'w' ) as f :
@@ -274,7 +278,7 @@ def handle_sigterm(signum, frame):
274
278
run ('ip route flush cache' )
275
279
276
280
if 'flush_connections' in lb :
277
- run ('conntrack -F ' )
281
+ run ('conntrack --delete ' )
278
282
run ('conntrack -F expect' )
279
283
280
284
with open (wlb_status_file , 'w' ) as f :
0 commit comments