Project

General

Profile

« Previous | Next » 

Revision feb88a14

Added by Seth Mos over 13 years ago

Add support for SLAAC on the WAN interface, this is required for Stateless autoconf addressing.
Normally this should only apply to Appliances that do not need to route. We automatically hook in the dhcp6 client to request name servers from DHCP6 in a information only mode. It will not attempt to request a address. For that you should use the plain DHCP6 option with a prefix size of none.
This is for redmine ticket #1834

View differences:

etc/inc/filter.inc
2497 2497
			break;
2498 2498
		}
2499 2499
		switch($oc['type6']) {
2500
		case "slaac":
2500 2501
		case "dhcp6":
2501 2502
			$ipfrules .= <<<EOD
2502 2503

  
etc/inc/interfaces.inc
1119 1119
	}
1120 1120

  
1121 1121
	switch ($ifcfg['ipaddrv6']) {
1122
	case "slaac":
1122 1123
	case "dhcp6":
1123 1124
		$pidv6 = find_dhcp6c_process($realif);
1124 1125
		if($pidv6)
......
2886 2887
	}
2887 2888

  
2888 2889
	switch ($wancfg['ipaddrv6']) {
2890
		case 'slaac':
2889 2891
		case 'dhcp6':
2890 2892
			interface_dhcpv6_configure($interface);
2891 2893
			break;
......
3368 3370
	}
3369 3371

  
3370 3372
	$dhcp6cconf = "";
3371
 	$dhcp6cconf .= "interface {$wanif} {\n";
3372
	$dhcp6cconf .= " 	send ia-na 0;	# request stateful address\n";
3373
	if(is_numeric($wancfg['dhcp6-ia-pd-len'])) {
3374
		$dhcp6cconf .= "	send ia-pd 0;	# request prefix delegation\n";
3375
	}
3376
	$dhcp6cconf .= "request domain-name-servers;\n";
3377
	$dhcp6cconf .= "request domain-name;\n";
3378
	$dhcp6cconf .= "script \"{$g['varetc_path']}/dhcp6c_{$interface}_script.sh\"; # we'd like some nameservers please\n";
3379

  
3380
	$dhcp6cconf .= "};\n";
3381
	$dhcp6cconf .= "id-assoc na 0 { };\n";
3382
	if(is_numeric($wancfg['dhcp6-ia-pd-len'])) {
3383
		/* Setup the prefix delegation */
3384
		$dhcp6cconf .= "id-assoc pd 0 {\n";
3385
		foreach($iflist as $friendly => $ifdescr) {
3386
			if($config['interfaces'][$friendly]['track6-interface'] != $interface)
3387
				continue;
3388
			if(is_numeric($config['interfaces'][$friendly]['track6-prefix-id'])) {
3389
				log_error("setting up $friendly - {$config['interfaces'][$friendly]['track6-prefix-id']}");
3390
				$realif = get_real_interface($friendly);
3391
				$dhcp6cconf .= "	prefix-interface {$realif} {\n";
3392
				$dhcp6cconf .= "		sla-id {$config['interfaces'][$friendly]['track6-prefix-id']};\n";
3393
				$dhcp6cconf .= "		sla-len {$wancfg['dhcp6-ia-pd-len']};\n";
3394
				$dhcp6cconf .= "	};\n";
3395
			}
3373
	$dhcp6cconf .= "interface {$wanif} {\n";
3374

  
3375
	/* for SLAAC interfaces we do fire off a dhcp6 client for just our name servers */
3376
	if($wancfg['ipaddrv6'] == "slaac") {
3377
		$dhcp6cconf .= "	information-only;\n";
3378
		$dhcp6cconf .= "	request domain-name-servers;\n";
3379
		$dhcp6cconf .= "	request domain-name;\n";
3380
		$dhcp6cconf .= "	script \"{$g['varetc_path']}/dhcp6c_{$interface}_script.sh\"; # we'd like some nameservers please\n";
3381
		$dhcp6cconf .= "};\n";
3382
	} else {
3383
	
3384
		$dhcp6cconf .= " 	send ia-na 0;	# request stateful address\n";
3385
		if(is_numeric($wancfg['dhcp6-ia-pd-len'])) {
3386
			$dhcp6cconf .= "	send ia-pd 0;	# request prefix delegation\n";
3396 3387
		}
3388
		$dhcp6cconf .= "request domain-name-servers;\n";
3389
		$dhcp6cconf .= "request domain-name;\n";
3390
		$dhcp6cconf .= "script \"{$g['varetc_path']}/dhcp6c_{$interface}_script.sh\"; # we'd like some nameservers please\n";
3391

  
3397 3392
		$dhcp6cconf .= "};\n";
3393
		$dhcp6cconf .= "id-assoc na 0 { };\n";
3394
		if(is_numeric($wancfg['dhcp6-ia-pd-len'])) {
3395
			/* Setup the prefix delegation */
3396
			$dhcp6cconf .= "id-assoc pd 0 {\n";
3397
			foreach($iflist as $friendly => $ifdescr) {
3398
				if($config['interfaces'][$friendly]['track6-interface'] != $interface)
3399
					continue;
3400
				if(is_numeric($config['interfaces'][$friendly]['track6-prefix-id'])) {
3401
					log_error("setting up $friendly - {$config['interfaces'][$friendly]['track6-prefix-id']}");
3402
					$realif = get_real_interface($friendly);
3403
					$dhcp6cconf .= "	prefix-interface {$realif} {\n";
3404
					$dhcp6cconf .= "		sla-id {$config['interfaces'][$friendly]['track6-prefix-id']};\n";
3405
					$dhcp6cconf .= "		sla-len {$wancfg['dhcp6-ia-pd-len']};\n";
3406
					$dhcp6cconf .= "	};\n";
3407
				}
3408
			}
3409
			$dhcp6cconf .= "};\n";
3410
		}
3398 3411
	}
3399

  
3400 3412
	fwrite($fd, $dhcp6cconf);
3401 3413
	fclose($fd);
3402 3414

  
......
3432 3444
					log_error("Found IPv6 default gateway '{$parts[3]}' by RA.");
3433 3445
					file_put_contents("{$g['tmp_path']}/{$wanif}_routerv6", "{$parts[3]}\n");
3434 3446
					file_put_contents("{$g['tmp_path']}/{$wanif}_defaultgwv6", "{$parts[3]}\n");
3447
					break;
3435 3448
				}
3436 3449
			}
3437 3450
		}
......
3440 3453
	 * to configure a lan interface with a prefix */
3441 3454
	sleep(5);
3442 3455

  
3443
	/* configure dependent interfaces */
3444
	foreach($iflist as $if => $ifname) {
3445
		if($config['interfaces'][$if]['track6-interface'] == $interface)
3446
			interface_track6_configure($if);
3456
	if($wancfg['ippaddrv6'] != "slaac") {
3457
		/* configure dependent interfaces */
3458
		foreach($iflist as $if => $ifname) {
3459
			if($config['interfaces'][$if]['track6-interface'] == $interface)
3460
				interface_track6_configure($if);
3461
		}
3447 3462
	}
3448

  
3449 3463
	return 0;
3450 3464
}
3451 3465

  
etc/inc/services.inc
654 654
	/* kill any running dhcpd */
655 655
	if(is_process_running("dhcpd")) {
656 656
		killbypid("{$g['dhcpd_chroot_path']}{$g['varrun_path']}/dhcpdv6.pid");
657
		killbypid("{$g['varrun_path']}/dhcpleases6.pid");
658 657
	}
659 658

  
660 659
	/* DHCP enabled on any interfaces? */
usr/local/www/interfaces.php
213 213
}
214 214

  
215 215
switch($wancfg['ipaddrv6']) {
216
	case "slaac":
217
		$pconfig['type6'] = "slaac";
218
		break;
216 219
	case "dhcp6":
217 220
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
218 221
		if($wancfg['dhcp6-ia-pd-len'] == "")
......
803 806
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
804 807
				}
805 808
				break;
809
			case "slaac":
810
				$wancfg['ipaddrv6'] = "slaac";
811
				break;
806 812
			case "dhcp6":
807 813
				$wancfg['ipaddrv6'] = "dhcp6";
808 814
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
......
1080 1086
$closehead = false;
1081 1087
include("head.inc");
1082 1088
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1083
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6rd"), "6to4" => gettext("6to4"), "track6" => gettext("Track Interface"));
1089
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1084 1090

  
1085 1091
?>
1086 1092

  
......
1127 1133
	function updateTypeSix(t) {
1128 1134
		switch(t) {
1129 1135
			case "none": {
1130
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6').hide();
1136
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1131 1137
				break;
1132 1138
			}
1133 1139
			case "staticv6": {
1134
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6').hide();
1140
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1141
				break;
1142
			}
1143
			case "slaac": {
1144
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1135 1145
				break;
1136 1146
			}
1137 1147
			case "dhcp6": {
1138
				jQuery('#none, #staticv6, #6rd, #6to4, #track6').hide();
1148
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1139 1149
				break;
1140 1150
			}
1141 1151
			case "6rd": {
1142
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6').hide();
1152
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1143 1153
				break;
1144 1154
			}
1145 1155
			case "6to4": {
1146
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6').hide();
1156
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1147 1157
				break;
1148 1158
			}
1149 1159
			case "track6": {
1150
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4').hide();
1160
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1151 1161
				break;
1152 1162
			}
1153 1163
		}

Also available in: Unified diff