Project

General

Profile

« Previous | Next » 

Revision 1e1dd1f5

Added by Ermal LUÇI almost 15 years ago

Ticket #725. Add checking the routing table as a last resort to find the correct interface before falling back to the default one.

View differences:

etc/inc/services.inc
483 483
	$dhcrelayenable = false;
484 484
	if(is_array($dhcrelaycfg)) {
485 485
		foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
486
			if (isset($dhcrelayifconf['enable']) &&
487
				(($dhcrelayif == "lan") ||
486
			if (isset($dhcrelayifconf['enable']) ||
488 487
				(isset($config['interfaces'][$dhcrelayif]['enable']) &&
489
				$config['interfaces'][$dhcrelayif]['if'] && (!link_interface_to_bridge($dhcrelayif)))))
488
				(!link_interface_to_bridge($dhcrelayif))))
490 489
				$dhcrelayenable = true;
491 490
		}
492 491
	}
......
505 504
		$ifcfg = $config['interfaces'][$dhcrelayif];
506 505

  
507 506
		if (!isset($dhcrelayifconf['enable']) ||
508
			(($dhcrelayif != "lan") &&
509
			(!isset($ifcfg['enable']) || !$ifcfg['if'] || 
510
			link_interface_to_bridge($dhcrelayif))))
507
			(!isset($ifcfg['enable']) ||
508
			link_interface_to_bridge($dhcrelayif)))
511 509
			continue;
512 510

  
513 511
		$dhcrelayifs[] = get_real_interface($dhcrelayif);
......
535 533
		}
536 534
	}
537 535

  
536
	if (!isset($destif)) {
537
		/* Create a array from the existing route table */
538
        	exec("/usr/bin/netstat -rnf inet", $route_str);
539
        	array_shift($route_str);
540
        	array_shift($route_str);
541
        	array_shift($route_str);
542
        	array_shift($route_str);
543
        	$route_arr = array();
544
        	foreach($route_str as $routeline) {
545
                	$items = preg_split("/[ ]+/i", $routeline);
546
			if (ip_in_subnet($$dhcrelaycfg['server'], $items[0])) {
547
				$destif = trim($items[2]);
548
				break;
549
			}
550
        	}
551
	}
552
	
538 553
	if (!isset($destif)) {
539 554
		if (is_array($config['gateways']['gateway_item'])) {
540 555
			foreach ($config['gateways']['gateway_item'] as $gateway) {

Also available in: Unified diff