Project

General

Profile

« Previous | Next » 

Revision b368b35a

Added by Ermal LUÇI almost 14 years ago

Resolve issues that made php core dump or eat a lot of memory when big routing tables are present.

View differences:

etc/inc/system.inc
31 31

  
32 32
/*
33 33
	pfSense_BUILDER_BINARIES:	/usr/sbin/powerd	/usr/bin/killall	/sbin/sysctl	/sbin/route
34
	pfSense_BUILDER_BINARIES:	/bin/hostname	/bin/ls	/usr/bin/netstat	/usr/sbin/syslogd	
34
	pfSense_BUILDER_BINARIES:	/bin/hostname	/bin/ls	/usr/sbin/syslogd	
35 35
	pfSense_BUILDER_BINARIES:	/usr/sbin/pccardd	/usr/local/sbin/lighttpd	/bin/chmod 	/bin/mkdir
36 36
	pfSense_BUILDER_BINARIES:	/usr/bin/tar		/usr/local/sbin/ntpd	/usr/sbin/ntpdate
37 37
	pfSense_BUILDER_BINARIES:	/usr/bin/nohup	/sbin/dmesg	/usr/local/sbin/atareinit	/sbin/kldload
......
398 398
			}
399 399
		}
400 400
	}
401
	/* Create a array from the existing inet route table */
402
	exec("/usr/bin/netstat -rnf inet", $route_str);
403
	array_shift($route_str);
404
	array_shift($route_str);
405
	array_shift($route_str);
406
	array_shift($route_str);
407
	$route_arr = array();
408
	foreach($route_str as $routeline) {
409
		$items = preg_split("/[ ]+/i", $routeline);
410
		$route_arr[$items[0]] = array($items[0], $items[1], $items[5]);
411
	}
412 401

  
413 402
	if ($dont_add_route == false ) {
414 403
		if (!empty($interface) && $interface != $interfacegw)
415 404
			;
416 405
		else if (($interfacegw <> "bgpd") && (is_ipaddrv4($gatewayip))) {
417
			$action = "add";
418
			if(isset($route_arr['default'])) {
419
				$action = "change";
420
			}
421
			log_error("ROUTING: $action default route to $gatewayip");
422
			mwexec("/sbin/route {$action} -inet default " . escapeshellarg($gatewayip));
406
			log_error("ROUTING: setting default route to $gatewayip");
407
			mwexec("/sbin/route change -inet default " . escapeshellarg($gatewayip));
423 408
		}
424
	}
425 409

  
426
	/* Create a array from the existing inet6 route table */
427
	exec("/usr/bin/netstat -rnf inet6", $routev6_str);
428
	array_shift($routev6_str);
429
	array_shift($routev6_str);
430
	array_shift($routev6_str);
431
	array_shift($routev6_str);
432
	$routev6_arr = array();
433
	foreach($routev6_str as $routeline) {
434
		$items = preg_split("/[ ]+/i", $routeline);
435
		$routev6_arr[$items[0]] = array($items[0], $items[1], $items[5]);
436
	}
437

  
438
	if ($dont_add_route == false ) {
439 410
		if (!empty($interface) && $interface != $interfacegwv6)
440 411
			;
441 412
		else if (($interfacegwv6 <> "bgpd") && (is_ipaddrv6($gatewayipv6))) {
442
			$action = "add";
443
			if(isset($routev6_arr['default'])) {
444
				$action = "change";
445
			}
446
			log_error("ROUTING: $action IPv6 default route to $gatewayipv6");
413
			log_error("ROUTING: setting IPv6 default route to $gatewayipv6");
447 414
			mwexec("/sbin/route {$action} -inet6 default " . escapeshellarg($gatewayipv6));
448 415
		}
449 416
	}
......
463 430

  
464 431
			$gatewayip = $gateway['gateway'];
465 432
			$interfacegw = $gateway['interface'];
466
			$action = "add";
467
			if (isset($route_arr[$rtent['network']]))
468
				$action = "change";
469 433

  
470 434
			if(is_ipaddrv6($gatewayip)) {
471 435
				$inetfamily = "-inet6";
......
473 437
				$inetfamily = "-inet";
474 438
			}
475 439
			if (is_ipaddr($gatewayip)) {
476
				mwexec("/sbin/route {$action} {$inetfamily} " . escapeshellarg($rtent['network']) .
440
				mwexec("/sbin/route change {$inetfamily} " . escapeshellarg($rtent['network']) .
477 441
					" " . escapeshellarg($gatewayip));
478 442
			} else if (!empty($interfacegw)) {
479
				mwexec("/sbin/route {$action} {$inetfamily} " . escapeshellarg($rtent['network']) .
443
				mwexec("/sbin/route change {$inetfamily} " . escapeshellarg($rtent['network']) .
480 444
					" -iface " . escapeshellarg($interfacegw));
481 445
			}
482 446
		}

Also available in: Unified diff