@@ -196,32 +196,17 @@ EOD;
196
196
system_host_route ($ gateway ['monitor ' ], $ gateway ['gateway ' ], false , true );
197
197
}
198
198
} elseif ($ gateway ['ipprotocol ' ] == "inet6 " ) { // This is an IPv6 gateway...
199
- if ($ gateway ['monitor ' ] == $ gateway ['gateway ' ]) {
200
- /* link locals really need a different src ip */
201
- if (is_linklocal ($ gateway ['gateway ' ])) {
202
- $ gwifip = find_interface_ipv6_ll ($ gateway ['interface ' ]);
203
- } else {
204
- $ gwifip = find_interface_ipv6 ($ gateway ['interface ' ]);
205
- }
199
+ if (is_linklocal ($ gateway ['monitor ' ])) {
200
+ /* link local monitor needs a link local address for the "src" part */
201
+ $ gwifip = find_interface_ipv6_ll ($ gateway ['interface ' ]);
206
202
} else {
207
- /* 'monitor' has been set, so makes sure it has precedence over
208
- * 'gateway' in defining the source IP. Otherwise if 'gateway'
209
- * is a local link and 'monitor' is global routable then the
210
- * ICMP6 response would not find its way back home...
211
- */
203
+ /* monitor is a routable address, so use a routable address for the "src" part */
212
204
$ gwifip = find_interface_ipv6 ($ gateway ['interface ' ]);
213
- if (is_linklocal ($ gateway ['monitor ' ])) {
214
- if (!strstr ($ gateway ['monitor ' ], '% ' )) {
215
- $ gateway ['monitor ' ] .= "% {$ gateway ['interface ' ]}" ;
216
- }
217
- } else {
218
- // Monitor is a routable address, so use a routable address for the "src" part
219
- $ gwifip = find_interface_ipv6 ($ gateway ['interface ' ]);
220
- }
221
205
}
222
206
223
207
if (!is_ipaddrv6 ($ gwifip )) {
224
- continue ; //Skip this target
208
+ /* skip this target */
209
+ continue ;
225
210
}
226
211
227
212
/* flush the monitor unconditionally */
230
215
system_host_route ($ gateway ['monitor ' ], $ gateway ['gateway ' ], true , false );
231
216
}
232
217
233
- /* Do not monitor if such was requested */
218
+ /* do not monitor if such was requested */
234
219
if (isset ($ gateway ['disabled ' ]) || isset ($ gateway ['monitor_disable ' ])) {
235
220
continue ;
236
221
}
@@ -245,6 +230,16 @@ EOD;
245
230
log_error ("Adding static route for monitor {$ gateway ['monitor ' ]} via {$ gateway ['gateway ' ]}" );
246
231
system_host_route ($ gateway ['monitor ' ], $ gateway ['gateway ' ], false , true );
247
232
}
233
+
234
+ /*
235
+ * 'monitor' has been set, so makes sure it has precedence over
236
+ * 'gateway' in defining the source IP. Otherwise if 'gateway'
237
+ * is a local link and 'monitor' is global routable then the
238
+ * ICMP6 response would not find its way back home...
239
+ */
240
+ if (is_linklocal ($ gateway ['monitor ' ]) && !strstr ($ gateway ['monitor ' ], '% ' )) {
241
+ $ gateway ['monitor ' ] .= "% {$ gateway ['interface ' ]}" ;
242
+ }
248
243
} else {
249
244
continue ;
250
245
}
0 commit comments