Project

General

Profile

« Previous | Next » 

Revision d69d6c84

Added by Jim Pingle about 2 years ago

Improve GIF/GRE interface handling. Fixes #14549

View differences:

src/etc/inc/interfaces.inc
1072 1072

  
1073 1073
	/* Do not change the order here for more see gre(4) NOTES section. */
1074 1074
	if (is_ipaddrv6($gre['remote-addr'])) {
1075
		mwexec("/sbin/ifconfig {$greif} inet6 tunnel {$realifip6} " . escapeshellarg($gre['remote-addr']));
1075
		mwexec("/sbin/ifconfig " . escapeshellarg($greif) . " inet6 tunnel " . escapeshellarg($realifip6) . " " . escapeshellarg($gre['remote-addr']));
1076 1076
	} else {
1077
		mwexec("/sbin/ifconfig {$greif} tunnel {$realifip} " . escapeshellarg($gre['remote-addr']));
1077
		mwexec("/sbin/ifconfig " . escapeshellarg($greif) . " tunnel " . escapeshellarg($realifip) . " " . escapeshellarg($gre['remote-addr']));
1078 1078
	}
1079 1079
	if (in_array($tunnel_type, array('v4', 'v4v6'))) {
1080
		mwexec("/sbin/ifconfig {$greif} " . escapeshellarg($gre['tunnel-local-addr']) . " " . escapeshellarg($gre['tunnel-remote-addr']) . " netmask " . gen_subnet_mask($gre['tunnel-remote-net']));
1080
		mwexec("/sbin/ifconfig " . escapeshellarg($greif) . " " . escapeshellarg($gre['tunnel-local-addr']) . " " . escapeshellarg($gre['tunnel-remote-addr']) . " netmask " . gen_subnet_mask($gre['tunnel-remote-net']));
1081 1081
	}
1082 1082
	if (in_array($tunnel_type, array('v6', 'v4v6'))) {
1083 1083
		/* XXX: The prefixlen argument for tunnels of ipv6 is useless since it needs to be 128 as enforced by kernel */
1084
		mwexec("/sbin/ifconfig {$greif} inet6 " . escapeshellarg($gre['tunnel-local-addr6']) . " " . escapeshellarg($gre['tunnel-remote-addr6']) . " prefixlen 128");
1084
		mwexec("/sbin/ifconfig " . escapeshellarg($greif) . " inet6 " . escapeshellarg($gre['tunnel-local-addr6']) . " " . escapeshellarg($gre['tunnel-remote-addr6']) . " prefixlen 128");
1085 1085
	}
1086 1086

  
1087 1087
	$parentif = get_real_interface($gre['if']);
......
1227 1227

  
1228 1228
	/* Do not change the order here for more see gif(4) NOTES section. */
1229 1229
	if (is_ipaddrv6($gif['remote-addr'])) {
1230
		mwexec("/sbin/ifconfig {$gifif} inet6 tunnel {$realifip} " . escapeshellarg($gif['remote-addr']));
1230
		mwexec("/sbin/ifconfig " . escapeshellarg($gifif) . " inet6 tunnel " . escapeshellarg($realifip) . " " . escapeshellarg($gif['remote-addr']));
1231 1231
	} else {
1232
		mwexec("/sbin/ifconfig {$gifif} tunnel {$realifip} " . escapeshellarg($gif['remote-addr']));
1232
		mwexec("/sbin/ifconfig " . escapeshellarg($gifif) . " tunnel " . escapeshellarg($realifip) . " " . escapeshellarg($gif['remote-addr']));
1233 1233
	}
1234 1234
	if ((is_ipaddrv6($gif['tunnel-local-addr'])) || (is_ipaddrv6($gif['tunnel-remote-addr']))) {
1235 1235
		/* XXX: The prefixlen argument for tunnels of ipv6 is useless since it needs to be 128 as enforced by kernel */
1236 1236
		//mwexec("/sbin/ifconfig {$gifif} inet6 " . escapeshellarg($gif['tunnel-local-addr']) . " " . escapeshellarg($gif['tunnel-remote-addr']) . " prefixlen /" . escapeshellarg($gif['tunnel-remote-net']));
1237
		mwexec("/sbin/ifconfig {$gifif} inet6 " . escapeshellarg($gif['tunnel-local-addr']) . " " . escapeshellarg($gif['tunnel-remote-addr']) . " prefixlen 128");
1237
		mwexec("/sbin/ifconfig " . escapeshellarg($gifif) . " inet6 " . escapeshellarg($gif['tunnel-local-addr']) . " " . escapeshellarg($gif['tunnel-remote-addr']) . " prefixlen 128");
1238 1238
	} else {
1239
		mwexec("/sbin/ifconfig {$gifif} " . escapeshellarg($gif['tunnel-local-addr']) . " " . escapeshellarg($gif['tunnel-remote-addr']) . " netmask " . gen_subnet_mask($gif['tunnel-remote-net']));
1239
		mwexec("/sbin/ifconfig " . escapeshellarg($gifif) . " " . escapeshellarg($gif['tunnel-local-addr']) . " " . escapeshellarg($gif['tunnel-remote-addr']) . " netmask " . gen_subnet_mask($gif['tunnel-remote-net']));
1240 1240
	}
1241 1241
	if (isset($gif['link1'])) {
1242 1242
		pfSense_interface_flags($gifif, IFF_LINK1);
......
1257 1257
		}
1258 1258
		if (is_numericint($gifmtu)) {
1259 1259
			if ($gifmtu != $currentgifmtu) {
1260
				mwexec("/sbin/ifconfig {$gifif} mtu {$gifmtu}");
1260
				mwexec("/sbin/ifconfig " . escapeshellarg($gifif) . " mtu {$gifmtu}");
1261 1261
			}
1262 1262
		}
1263 1263
	} else {
src/usr/local/www/interfaces_gif_edit.php
120 120
		if (isset($_POST['link2'])) {
121 121
			$gif['link2'] = '';
122 122
		}
123
		$gif['gifif'] = $_POST['gifif'];
124
		$gif['gifif'] = interface_gif_configure($gif);
125 123

  
126
		if ($gif['gifif'] == "" || !stristr($gif['gifif'], "gif")) {
124
		if (empty($_POST['gifif']) ||
125
		    preg_match("/^gif[0-9]+$/", $_POST['gifif'])) {
126
			/* Attempt initial configuration of the GIF if the
127
			 * submitted interface is empty or looks like a GIF
128
			 * interface. */
129
			$gif['gifif'] = $_POST['gifif'];
130
			$gif['gifif'] = interface_gif_configure($gif);
131
		} else {
132
			$input_errors[] = gettext("Invalid GIF interface.");
133
		}
134

  
135
		if (empty($gif['gifif']) ||
136
		    !preg_match("/^gif[0-9]+$/", $gif['gifif'])) {
127 137
			$input_errors[] = gettext("Error occurred creating interface, please retry.");
128 138
		} else {
129 139
			if (isset($id) && $a_gifs[$id]) {
src/usr/local/www/interfaces_gre_edit.php
169 169
		if (isset($_POST['link1']) && $_POST['link1']) {
170 170
			$gre['link1'] = '';
171 171
		}
172
		$gre['greif'] = $_POST['greif'];
173 172

  
174
		$gre['greif'] = interface_gre_configure($gre);
175
		if ($gre['greif'] == "" || !stristr($gre['greif'], "gre")) {
173
		if (empty($_POST['greif']) ||
174
		    preg_match("/^gre[0-9]+$/", $_POST['greif'])) {
175
			/* Attempt initial configuration of the GRE if the
176
			 * submitted interface is empty or looks like a GRE
177
			 * interface. */
178
			$gre['greif'] = $_POST['greif'];
179
			$gre['greif'] = interface_gre_configure($gre);
180
		} else {
181
			$input_errors[] = gettext("Invalid GRE interface.");
182
		}
183

  
184
		if (empty($gre['greif']) ||
185
		    !preg_match("/^gre[0-9]+$/", $gre['greif'])) {
176 186
			$input_errors[] = gettext("Error occurred creating interface, please retry.");
177 187
		} else {
178 188
			if (isset($id) && $a_gres[$id]) {

Also available in: Unified diff