@@ -196,32 +196,31 @@ 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 ;
210
+ }
211
+
212
+ /*
213
+ * If gateway is a local link and 'monitor' is global routable
214
+ * then the ICMP6 response would not find its way back home.
215
+ */
216
+ if (is_linklocal ($ gateway ['monitor ' ]) && strpos ($ gateway ['monitor ' ], '% ' ) === false ) {
217
+ $ gateway ['monitor ' ] .= "% {$ gateway ['interface ' ]}" ;
218
+ }
219
+ if (is_linklocal ($ gateway ['gateway ' ]) && strpos ($ gateway ['gateway ' ], '% ' ) === false ) {
220
+ $ gateway ['gateway ' ] .= "% {$ gateway ['interface ' ]}" ;
221
+ }
222
+ if (is_linklocal ($ gwifip ) && strpos ($ gwifip , '% ' ) === false ) {
223
+ $ gwifip .= "% {$ gateway ['interface ' ]}" ;
225
224
}
226
225
227
226
/* flush the monitor unconditionally */
@@ -902,6 +901,9 @@ function lookup_gateway_ip_by_name($name)
902
901
903
902
foreach ($ gateways_arr as $ gname => $ gw ) {
904
903
if ($ gw ['name ' ] === $ name || $ gname === $ name ) {
904
+ if (is_linklocal ($ gw ['gateway ' ]) && strpos ($ gw ['gateway ' ], '% ' ) === false ) {
905
+ $ gw ['gateway ' ] .= "% {$ gw ['interface ' ]}" ;
906
+ }
905
907
return $ gw ['gateway ' ];
906
908
}
907
909
}
0 commit comments