From aaab8d4cf0acbd7415d710c7c34aaabe60591407 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 31 Oct 2008 11:24:11 -0700 Subject: [PATCH] Add settings for switch netmask and gateway for in-band mode to init script. Previously we supported setting a switch IP address but not those parameters, which are obviously required also. --- debian/ofp-switch-setup | 3 +++ debian/openflow-switch.default | 5 ++++- debian/openflow-switch.init | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/debian/ofp-switch-setup b/debian/ofp-switch-setup index aa318d72..a4a0879f 100755 --- a/debian/ofp-switch-setup +++ b/debian/ofp-switch-setup @@ -8,6 +8,9 @@ use Digest::SHA1 'sha1_hex'; use strict; use warnings; +# XXX should support configuring SWITCH_NETMASK and SWITCH_GATEWAY +# when the mode is in-band. + my $debconf_owner = 'openflow-switch'; my $default = '/etc/default/openflow-switch'; diff --git a/debian/openflow-switch.default b/debian/openflow-switch.default index 6a86e2ff..f8c3159f 100644 --- a/debian/openflow-switch.default +++ b/debian/openflow-switch.default @@ -48,7 +48,8 @@ MODE=discovery # configured statically or dynamically: # # * For static configuration, specify the switch's IP address as a -# string. +# string. In this case you may also set SWITCH_NETMASK and +# SWITCH_GATEWAY appropriately. # # * For dynamic configuration with DHCP (the most common case), # specify "dhcp". Configuration with DHCP will only work reliably @@ -57,6 +58,8 @@ MODE=discovery # # This setting has no effect unless MODE is set to 'in-band'. SWITCH_IP=dhcp +#SWITCH_NETMASK=255.255.255.0 +#SWITCH_GATEWAY=192.168.1.1 # CONTROLLER: Location of controller. # One of the following formats: diff --git a/debian/openflow-switch.init b/debian/openflow-switch.init index 3dbfb9de..aac723f0 100755 --- a/debian/openflow-switch.init +++ b/debian/openflow-switch.init @@ -225,7 +225,17 @@ case "$1" in if test "$SWITCH_IP" = dhcp; then must_succeed "Temporarily disabling of0" ifconfig of0 down else - must_succeed "Configuring of0 as $SWITCH_IP" ifconfig of0 $SWITCH_IP + COMMAND="ifconfig of0 $SWITCH_IP" + if test -n "$SWITCH_NETMASK"; then + COMMAND="$COMMAND netmask $SWITCH_NETMASK" + fi + must_succeed "Configuring of0: $COMMAND" $COMMAND + if test -n "$SWITCH_GATEWAY"; then + # This can fail because the route already exists, + # so we don't insist that it succeed. + COMMAND="route add default gw $SWITCH_GATEWAY" + check_op "Adding default route: $COMMAND" $COMMAND + fi fi else must_succeed "Disabling of0" ifconfig of0 down -- 2.30.2