Project

General

Profile

« Previous | Next » 

Revision 29f2f07a

Added by Ermal LUÇI over 12 years ago

The workflow is rtsold calls dhcp6c which calls rc.newwanipv6 to make the configuration more consistent

View differences:

etc/inc/interfaces.inc
3537 3537
	unset($dhcp6cscript);
3538 3538
	@chmod("{$g['varetc_path']}/dhcp6c_{$interface}_script.sh", 0755);
3539 3539

  
3540
	$rtsoldscript = "#!/bin/sh\n";
3541
	$rtsoldscript .= "# This shell script launches dhcp6c and configured gateways for this interface.\n";
3542
	$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_routerv6\n";
3543
	$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_defaultgwv6\n";
3544
	$rtsoldscript .= "if [ -f {$g['varrun_path']}/dhcp6c_{$wanif}.pid ]; then\n";
3545
	$rtsoldscript .= "\tpkill -F {$g['varrun_path']}/dhcp6c_{$wanif}.pid\n";
3546
	$rtsoldscript .= "fi\n";
3547
	$rtsoldscript .= "/usr/local/sbin/dhcp6c -d -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}\n";
3548
	/* Add wide-dhcp6c shell script here. Because we can not pass a argument to it. */
3549
	if (!@file_put_contents("{$g['varetc_path']}/rtsold_{$wanif}_script.sh", $rtsoldscript)) {
3550
		printf("Error: cannot open rtsold_{$interface}_script.sh in interface_dhcpv6_configure() for writing.\n");
3551
		unset($rtsoldscript);
3552
		return 1;
3553
	}
3554
	unset($rtsoldscript);
3555
	@chmod("{$g['varetc_path']}/rtsold_{$wanif}_script.sh", 0755);
3540 3556

  
3541 3557
	/* accept router advertisements for this interface */
3542 3558
	mwexec("/sbin/sysctl -w net.inet6.ip6.accept_rtadv=1");
3543 3559
	log_error("Accept router advertisements on interface {$wanif} ");
3544 3560
	mwexec("/sbin/ifconfig {$wanif} inet6 accept_rtadv");
3545 3561

  
3546
	/* run a filter configure sync so that the filter rules allow traffic before we launch the client */
3547
	/* there reallyt is no good way around this i'm 'fraid */
3548
	if (!$g['booting'])
3549
		filter_configure_sync(false);
3562
	/* fire up rtsold for IPv6 RAs first, this backgrounds immediately. It will call dhcp6c */
3563
	if (isvalidpid("{$g['varrun_path']}/rtsold_{$wanif}.pid"))
3564
		killbypid("{$g['varrun_path']}/rtsold_{$wanif}.pid");
3565
	mwexec("/usr/sbin/rtsold -m -p {$g['varrun_path']}/rtsold_{$wanif}.pid -O {$g['varetc_path']}/rtsold_{$wanif}_script.sh {$wanif}");
3550 3566

  
3551
	$pidv6 = find_dhcp6c_process($wanif);
3552
	if ($pidv6)
3553
		posix_kill($pidv6, SIGTERM);
3554
	/* fire up dhcp6c for IPv6 first, this backgrounds immediately */
3555
	mwexec("/usr/local/sbin/dhcp6c -d -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}");
3556
	sleep(1);
3557
	unset($out);
3558
	exec("/sbin/rtsol -d {$wanif} 2>&1", $out, $ret);
3559
	if (!empty($out)) {
3560
		foreach($out as $line) {
3561
			if((stristr($line, "received")) && (!stristr($line, "unexpected"))) {
3562
				$parts = explode(" ", $line);
3563
				if(is_ipaddrv6($parts[3])) {
3564
					log_error("Found IPv6 default gateway '{$parts[3]}' by RA.");
3565
					file_put_contents("{$g['tmp_path']}/{$wanif}_routerv6", "{$parts[3]}\n");
3566
					file_put_contents("{$g['tmp_path']}/{$wanif}_defaultgwv6", "{$parts[3]}\n");
3567
					break;
3568
				}
3569
			}
3570
		}
3571
		unset($out);
3572
	}
3573
	/* worst case is that the rc.newwanipv6 handles setting up the track6 interface */
3574
	if (!$g['booting'] && $wancfg['ipaddrv6'] != "slaac")
3575
		link_interface_to_track6($interface, "update");
3567
	/* NOTE: will be called from rtsold invoked script 
3568
	 * link_interface_to_track6($interface, "update");
3569
	 */
3576 3570

  
3577 3571
	return 0;
3578 3572
}

Also available in: Unified diff