#! /bin/sh
#
# start/stop networking daemons.
#

case "$1" in
	start)
		echo -n "Configuring network interfaces: "
		# Feature 8180, Increase maximum tcp write buffer size of linux kernel to tune samba read performance
		echo 33554432 > /proc/sys/net/core/wmem_max
		# Reply only if target IP is local address configured on the incoming NIC
		echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
		# Disable ARP for VIP
		echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
		# Enable DAD, and disable IPv6 operation if MAC-based duplicate link-local address has been found
		echo 2 > /proc/sys/net/ipv6/conf/eth0/accept_dad
		# Default disable accept_ra and autoconf to avoid getting ip from RA for static and dhcpv6 methods.
		echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
		echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
		# In some environment condition, the router wouldn't send RA after we send RS to it.
		# To workaround this case, we increase RS max send count from 3 to 20,
		# and increase the RS interval from 4 to 5.
		echo 20 > /proc/sys/net/ipv6/conf/default/router_solicitations;
		echo  2 > /proc/sys/net/ipv6/conf/default/router_solicitation_delay;
		echo  5 > /proc/sys/net/ipv6/conf/default/router_solicitation_interval;
		gen_interfaces.php
		ifup -a || ifconfig lo up
		sysctl -p
		net_auto_set_defgw.php
		net_recovery_ipv6_static_gateway.php
		echo "done."
		;;
	stop)
		echo -n "Deconfiguring network interfaces: "
		ifdown -a
		echo "done."
		;;
    restart)
		echo -n "Reconfiguring network interfaces: "
		$0 stop
		$0 start
		echo "done."
		;;
	*)
		echo "Usage: /etc/init.d/networking {start|stop|restart}"
		exit 1
		;;
esac

exit 0

