From 7a78f9c54453338202b4b02576a588fcd3814803 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 24 Jan 2015 11:32:05 +0000 Subject: vyatta-cfg-system: formatting changes for style consistency Update scripts/system/vyatta_update_console.pl to have consistent identation levels and style throughout. --- scripts/system/vyatta_update_console.pl | 79 +++++++++++++++++---------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/scripts/system/vyatta_update_console.pl b/scripts/system/vyatta_update_console.pl index 0ee6a6e5..38c03744 100755 --- a/scripts/system/vyatta_update_console.pl +++ b/scripts/system/vyatta_update_console.pl @@ -34,13 +34,13 @@ die "$0 expects no arguments\n" if (@ARGV); sub update { my ($old, $new) = @_; - if ( compare($old, $new) != 0) { - move($new, $old) - or die "Can't move $new to $old"; - return 1; + if (compare($old, $new) != 0) { + move($new, $old) + or die "Can't move $new to $old"; + return 1; } else { - unlink($new); - return; + unlink($new); + return; } } @@ -48,14 +48,14 @@ my $INITTAB = "/etc/inittab"; my $TMPTAB = "/tmp/inittab.$$"; sub update_inittab { - open (my $inittab, '<', $INITTAB) - or die "Can't open $INITTAB: $!"; + open(my $inittab, '<', $INITTAB) + or die "Can't open $INITTAB: $!"; - open (my $tmp, '>', $TMPTAB) - or die "Can't open $TMPTAB: $!"; + open(my $tmp, '>', $TMPTAB) + or die "Can't open $TMPTAB: $!"; # Clone original inittab but remove all references to serial lines - print {$tmp} grep { ! /^T|^# Vyatta/ } <$inittab>; + print {$tmp} grep {!/^T|^# Vyatta/} <$inittab>; close $inittab; my $config = new Vyatta::Config; @@ -65,27 +65,28 @@ sub update_inittab { my $id = 0; foreach my $tty ($config->listNodes()) { - my $speed = $config->returnValue("$tty speed"); - $speed = 9600 unless $speed; - - printf {$tmp} "T%d:23:respawn:", $id; - if ($config->exists("$tty modem")) { - printf {$tmp} "/sbin/mgetty -x0 -s %d %s\n", $speed, $tty; - } else { - printf {$tmp} "/sbin/getty -L %s %d vt100\n", $tty, $speed; - } - - # id field is limited to 4 characters - if (++$id >= 1000) { - warn "Ignoring $tty only 1000 serial devices supported\n"; - last; - } + my $speed = $config->returnValue("$tty speed"); + $speed = 9600 unless $speed; + + printf {$tmp} "T%d:23:respawn:", $id; + if ($config->exists("$tty modem")) { + printf {$tmp} "/sbin/mgetty -x0 -s %d %s\n", $speed, $tty; + } else { + printf {$tmp} "/sbin/getty -L %s %d vt100\n", $tty, $speed; + } + + # id field is limited to 4 characters + if (++$id >= 1000) { + warn "Ignoring $tty only 1000 serial devices supported\n"; + last; + } } close $tmp; if (update($INITTAB, $TMPTAB)) { - # This is same as telinit q - it tells init to re-examine inittab - kill 1, 1; + + # This is same as telinit q - it tells init to re-examine inittab + kill 1, 1; } } @@ -104,20 +105,20 @@ sub update_grub { my $speed = $config->returnValue("ttyS0 speed"); $speed = "9600" unless defined($speed); - open (my $grub, '<', $GRUBCFG) - or die "Can't open $GRUBCFG: $!"; + open(my $grub, '<', $GRUBCFG) + or die "Can't open $GRUBCFG: $!"; - open (my $tmp, '>', $GRUBTMP) - or die "Can't open $GRUBTMP: $!"; + open(my $tmp, '>', $GRUBTMP) + or die "Can't open $GRUBTMP: $!"; while (<$grub>) { - if (/^serial / ) { - print {$tmp} "serial --unit=0 --speed=$speed\n"; - } elsif (/^(.* console=ttyS0),[0-9]+(.*)$/) { - print {$tmp} "$1,$speed$2\n"; - } else { - print {$tmp} $_; - } + if (/^serial /) { + print {$tmp} "serial --unit=0 --speed=$speed\n"; + } elsif (/^(.* console=ttyS0),[0-9]+(.*)$/) { + print {$tmp} "$1,$speed$2\n"; + } else { + print {$tmp} $_; + } } close $grub; close $tmp; -- cgit v1.2.3 From de086b75445f50cec560791aa5abd22347c563a2 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 24 Jan 2015 13:57:44 +0000 Subject: vyatta-cfg-system: changes to update_inittab for xen console access Update the update_inittab function so when the system is configured for Xen console (hvc0) access, the correct values are written out to /etc/inittab. --- scripts/system/vyatta_update_console.pl | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/scripts/system/vyatta_update_console.pl b/scripts/system/vyatta_update_console.pl index 38c03744..7c36ec7f 100755 --- a/scripts/system/vyatta_update_console.pl +++ b/scripts/system/vyatta_update_console.pl @@ -55,7 +55,8 @@ sub update_inittab { or die "Can't open $TMPTAB: $!"; # Clone original inittab but remove all references to serial lines - print {$tmp} grep {!/^T|^# Vyatta/} <$inittab>; + # and Xen consoles + print {$tmp} grep {!/^T|^# Vyatta|^h/} <$inittab>; close $inittab; my $config = new Vyatta::Config; @@ -63,22 +64,30 @@ sub update_inittab { print {$tmp} "# Vyatta console configuration (do not modify)\n"; - my $id = 0; + my $serial_id = 0; + my $xen_id = 0; + foreach my $tty ($config->listNodes()) { my $speed = $config->returnValue("$tty speed"); - $speed = 9600 unless $speed; - - printf {$tmp} "T%d:23:respawn:", $id; - if ($config->exists("$tty modem")) { - printf {$tmp} "/sbin/mgetty -x0 -s %d %s\n", $speed, $tty; - } else { - printf {$tmp} "/sbin/getty -L %s %d vt100\n", $tty, $speed; - } - - # id field is limited to 4 characters - if (++$id >= 1000) { - warn "Ignoring $tty only 1000 serial devices supported\n"; - last; + if ($tty =~ /^hvc\d/) { + $speed = 38400 unless $speed; + printf {$tmp} "h%d:23:respawn:", $xen_id; + printf {$tmp} "/sbin/getty %d %s\n", $speed, $tty; + $xen_id++; + } else { + $speed = 9600 unless $speed; + printf {$tmp} "T%d:23:respawn:", $serial_id; + if ($config->exists("$tty modem")) { + printf {$tmp} "/sbin/mgetty -x0 -s %d %s\n", $speed, $tty; + } else { + printf {$tmp} "/sbin/getty -L %s %d vt100\n", $tty, $speed; + } + + # id field is limited to 4 characters + if (++$serial_id >= 1000) { + warn "Ignoring $tty only 1000 serial devices supported\n"; + last; + } } } close $tmp; -- cgit v1.2.3 From b1d8d8320bc4550849ad6b3da5733b8d35ce6f6e Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 24 Jan 2015 14:02:32 +0000 Subject: vyatta-cfg-system: remove default speed value for console access Remove the default value for the console speed node as this is already set by the system. Update the help text to display the defaults for both serial and Xen consoles. --- templates/system/console/device/node.tag/speed/node.def | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/templates/system/console/device/node.tag/speed/node.def b/templates/system/console/device/node.tag/speed/node.def index 8453f67d..e7515dca 100644 --- a/templates/system/console/device/node.tag/speed/node.def +++ b/templates/system/console/device/node.tag/speed/node.def @@ -1,6 +1,5 @@ type: u32 help: Console baud rate -default: 9600 allowed: echo 1200 2400 4800 9600 19200 38400 57600 115200 syntax:expression: $VAR(@) in 1200, 2400, 4800, 9600, 19200, 38400, \ 57600, 115200 ; "unknown baud rate" @@ -8,9 +7,9 @@ syntax:expression: $VAR(@) in 1200, 2400, 4800, 9600, 19200, 38400, \ val_help: 1200; 1200 bps val_help: 2400; 2400 bps val_help: 4800; 4800 bps -val_help: 9600; 9600 bps (default) +val_help: 9600; 9600 bps (default for serial console) val_help: 19200; 19,200 bps -val_help: 38400; 38,400 bps +val_help: 38400; 38,400 bps (default for Xen console) val_help: 57600; 57,600 bps val_help: 115200; 115,200 bps -- cgit v1.2.3 From 8f876283b80016b8fb07817012cffb793fc633dc Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 25 Jan 2015 09:34:09 +0000 Subject: 0.20.44+vyos2+lithium10 --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6e5cfb7c..bc2361fc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +vyatta-cfg-system (0.20.44+vyos2+lithium10) unstable; urgency=low + + [ Alex Harpin ] + * vyatta-cfg-system: formatting changes for style consistency + * vyatta-cfg-system: changes to update_inittab for xen console access + * vyatta-cfg-system: remove default speed value for console access + + -- Alex Harpin Sun, 25 Jan 2015 09:32:40 +0000 + vyatta-cfg-system (0.20.44+vyos2+lithium9) unstable; urgency=low [ Alex Harpin ] -- cgit v1.2.3 From 8ac12661229501a423ade99afd6cba5a0bcb0f5a Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Mon, 26 Jan 2015 13:31:12 +0900 Subject: Fix Bug#382. (Another fix). If radvd is not running, the pgrep command returns an empty string, not zero. Reported-by Carl Byington --- templates/system/ipv6/disable-forwarding/node.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/system/ipv6/disable-forwarding/node.def b/templates/system/ipv6/disable-forwarding/node.def index 5e689c5b..323b99d6 100644 --- a/templates/system/ipv6/disable-forwarding/node.def +++ b/templates/system/ipv6/disable-forwarding/node.def @@ -38,7 +38,7 @@ delete: # forwarding was disabled, we will need to start the radvd daemon # now. running=$(pgrep -n radvd) - if [[ $running -eq 0 ]] && + if [[ -z "$running" ]] && [[ -e /etc/radvd.conf ]] && [[ -x /etc/init.d/radvd ]]; then /etc/init.d/radvd start -- cgit v1.2.3 From 6ab6520391b685319f8a644aa70a03ae5902309c Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 2 Feb 2015 08:01:00 +0100 Subject: Bug #467, tos inherit not turned on by default on tunnels (IPIP, GRE) --- templates/interfaces/tunnel/node.def | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def index f7ffd746..795168f6 100644 --- a/templates/interfaces/tunnel/node.def +++ b/templates/interfaces/tunnel/node.def @@ -40,6 +40,9 @@ create: echo "interfaces tunnel $VAR(@): Tunnel encapsulation type must be gre-bridge if a bridge group is defined"; exit 1; fi + if [ -z "$VAR(./parameters/ip/tos/@)" ]; then + TOS="tos inherit" + fi if [ -z "$VAR(./parameters/ip/ttl/@)" ]; then TTL="ttl 255" fi @@ -47,9 +50,9 @@ create: KEY="key $VAR(./parameters/ip/key/@)"; fi if [ "$VAR(./encapsulation/@)" == "gre" ] && [ -z $VAR(./remote-ip/) ]; then - ip tunnel add $VAR(@) local $VAR(./local-ip/@) mode gre $KEY $TTL + ip tunnel add $VAR(@) local $VAR(./local-ip/@) mode gre $KEY $TTL $TOS else - ip tunnel add $VAR(@) local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) $KEY $TTL + ip tunnel add $VAR(@) local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) $KEY $TTL $TOS fi if [ -z "`ip tun sh | grep $VAR(@)`" ]; then echo interfaces tunnel $VAR(@): error creating tunnel interface -- cgit v1.2.3 From d77880937b43a323a53a23c5306e88d3cfc214cb Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Thu, 5 Feb 2015 15:47:47 +0100 Subject: Bug #352 - QinQ - changing the ethertype value of vif-s --- .../interfaces/bonding/node.tag/vif-s/node.def | 16 +++++----------- .../node.tag/vif-s/node.tag/ethertype/node.def | 21 +++++++++++++++++++++ .../interfaces/ethernet/node.tag/vif-s/node.def | 17 +++++------------ .../node.tag/vif-s/node.tag/ethertype/node.def | 22 ++++++++++++++++++++++ .../pseudo-ethernet/node.tag/vif-s/node.def | 11 +++++------ .../node.tag/vif-s/node.tag/ethertype/node.def | 16 ++++++++++++++++ 6 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 templates/interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def create mode 100644 templates/interfaces/ethernet/node.tag/vif-s/node.tag/ethertype/node.def create mode 100644 templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def diff --git a/templates/interfaces/bonding/node.tag/vif-s/node.def b/templates/interfaces/bonding/node.tag/vif-s/node.def index 5a2e8dee..dcec3900 100644 --- a/templates/interfaces/bonding/node.tag/vif-s/node.def +++ b/templates/interfaces/bonding/node.tag/vif-s/node.def @@ -5,14 +5,8 @@ help: QinQ TAG-S Virtual Local Area Network (VLAN) ID syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094" val_help: u32:0-4094; VLAN ID -create: read -a SLAVES /dev/null 2>&1 + ip link add link $VAR(../../@) name "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) || exit 1 + ip link set "$VAR(../../@).$VAR(../@)" up + /opt/vyatta/sbin/vyatta-link-detect "$VAR(../../@).$VAR(../@)" on diff --git a/templates/interfaces/ethernet/node.tag/vif-s/node.def b/templates/interfaces/ethernet/node.tag/vif-s/node.def index 0a4ed145..c6483ac0 100644 --- a/templates/interfaces/ethernet/node.tag/vif-s/node.def +++ b/templates/interfaces/ethernet/node.tag/vif-s/node.def @@ -5,15 +5,8 @@ help: QinQ TAG-S Virtual Local Area Network (VLAN) ID syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094" val_help: u32:0-4094; VLAN ID -create: if ! ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan proto 802.1ad id $VAR(@) - then echo "Error creating VLAN device $VAR(../@).$VAR(@)" - exit 1 - fi - # if parent is up, then bring VLAN up - if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ] - then ip link set "$VAR(../@).$VAR(@)" up - fi - /opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on - -delete: [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0 - ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto 802.1ad id $VAR(@) +delete: ETHERTYPE=`echo "$VAR(ethertype/@)"` + if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi + if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi + [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0 + ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@) diff --git a/templates/interfaces/ethernet/node.tag/vif-s/node.tag/ethertype/node.def b/templates/interfaces/ethernet/node.tag/vif-s/node.tag/ethertype/node.def new file mode 100644 index 00000000..9a3615be --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/vif-s/node.tag/ethertype/node.def @@ -0,0 +1,22 @@ +type: txt +help: Set Ethertype +syntax:expression: $VAR(@) in "0x88A8", "0x8100";"Must be (0x88A8 0x8100)\n" +default: "0x88A8" + +comp_help: possible completions: + 0x88A8 802.1AD + 0x8100 802.1Q + +update: ETHERTYPE=`echo "$VAR(@)"` + if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi + if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi + ip link delete dev "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) > /dev/null 2>&1 + if ! ip link add link $VAR(../../@) name "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) + then echo "Error creating VLAN device $VAR(../../@).$VAR(../@)" + exit 1 + fi + # if parent is up, then bring VLAN up + if [ $(( $(cat /sys/class/net/$VAR(../../@)/flags) & 1 )) -eq 1 ] + then ip link set "$VAR(../../@).$VAR(../@)" up + fi + /opt/vyatta/sbin/vyatta-link-detect "$VAR(../../@).$VAR(../@)" on diff --git a/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.def b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.def index 0b867411..c4bc9577 100644 --- a/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.def +++ b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.def @@ -5,9 +5,8 @@ help: QinQ TAG-S Virtual Local Area Network (VLAN) ID syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094" val_help: u32:0-4094; VLAN ID -create: ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan proto 802.1ad id $VAR(@) || exit 1 - ip link set "$VAR(../@).$VAR(@)" up - /opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on - -delete: [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0 - ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto 802.1ad id $VAR(@) +delete: ETHERTYPE=`echo "$VAR(ethertype/@)"` + if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi + if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi + [ -d /sys/class/net/$VAR(../@).$VAR(@) ] || exit 0 + ip link delete dev "$VAR(../@).$VAR(@)" type vlan proto $ETHTYPE id $VAR(@) diff --git a/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def new file mode 100644 index 00000000..54ff166c --- /dev/null +++ b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def @@ -0,0 +1,16 @@ +type: txt +help: Set Ethertype +syntax:expression: $VAR(@) in "0x88A8", "0x8100";"Must be (0x88A8 0x8100)\n" +default: "0x88A8" + +comp_help: possible completions: + 0x88A8 802.1AD + 0x8100 802.1Q + +update: ETHERTYPE=`echo "$VAR(@)"` + if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi + if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi + ip link delete dev "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) > /dev/null 2>&1 + ip link add link $VAR(../../@) name "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) || exit 1 + ip link set "$VAR(../../@).$VAR(../@)" up + /opt/vyatta/sbin/vyatta-link-detect "$VAR(../../@).$VAR(../@)" on -- cgit v1.2.3 From a0df6222dcf9a8d2a2d6f02b28ede4858d3a5c17 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Fri, 6 Feb 2015 10:24:58 +0100 Subject: Can not change EtherType with vif-c interfaces configured --- .../interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def | 7 ++++++- .../interfaces/ethernet/node.tag/vif-s/node.tag/ethertype/node.def | 7 ++++++- .../pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/templates/interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def b/templates/interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def index e8a1e810..a79acae4 100644 --- a/templates/interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def +++ b/templates/interfaces/bonding/node.tag/vif-s/node.tag/ethertype/node.def @@ -7,7 +7,12 @@ comp_help: possible completions: 0x88A8 802.1AD 0x8100 802.1Q -update: ETHERTYPE=`echo "$VAR(@)"` +update: ACTIVEETHTYPE=`cli-shell-api returnActiveValue interfaces bonding $VAR(../../@) vif-s $VAR(../@) ethertype` + if [ ! -z $VAR(../vif-c/@@) ] && [ ! -z $ACTIVEETHTYPE ] + then echo "Can not change ethertype with vif-c configured" + exit 1 + fi + ETHERTYPE=`echo "$VAR(@)"` if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi read -a SLAVES /dev/null 2>&1 diff --git a/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def index 54ff166c..9e2d5a54 100644 --- a/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def +++ b/templates/interfaces/pseudo-ethernet/node.tag/vif-s/node.tag/ethertype/node.def @@ -7,7 +7,12 @@ comp_help: possible completions: 0x88A8 802.1AD 0x8100 802.1Q -update: ETHERTYPE=`echo "$VAR(@)"` +update: ACTIVEETHTYPE=`cli-shell-api returnActiveValue interfaces pseudo-ethernet $VAR(../../@) vif-s $VAR(../@) ethertype` + if [ ! -z $VAR(../vif-c/@@) ] && [ ! -z $ACTIVEETHTYPE ] + then echo "Can not change ethertype with vif-c configured" + exit 1 + fi + ETHERTYPE=`echo "$VAR(@)"` if [ $ETHERTYPE == "0x88A8" ]; then ETHTYPE=802.1ad; fi if [ $ETHERTYPE == "0x8100" ]; then ETHTYPE=802.1Q; fi ip link delete dev "$VAR(../../@).$VAR(../@)" type vlan proto $ETHTYPE id $VAR(../@) > /dev/null 2>&1 -- cgit v1.2.3 From 935deedc1499e1446fad6e153f761f11817be201 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 8 Feb 2015 19:33:14 +0000 Subject: vyatta-cfg-system: allow dynamic dns updating from behind nat Add a couple of configuration options to DDNS, to allow the use=web option from ddclient when determining the external IP address. This will allow DDNS to be correctly updated when behind a NAT device. Syntax: set service dns dynamic interface eth0 use-web url (url to use) set service dns dynamic interface eth0 use-web skip (search for this) Bug #455 http://bugzilla.vyos.net/show_bug.cgi?id=455 --- scripts/dynamic-dns/vyatta-dynamic-dns.pl | 12 ++++++++++-- .../service/dns/dynamic/interface/node.tag/use-web/node.def | 1 + .../dns/dynamic/interface/node.tag/use-web/skip/node.def | 2 ++ .../dns/dynamic/interface/node.tag/use-web/url/node.def | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 templates/service/dns/dynamic/interface/node.tag/use-web/node.def create mode 100644 templates/service/dns/dynamic/interface/node.tag/use-web/skip/node.def create mode 100644 templates/service/dns/dynamic/interface/node.tag/use-web/url/node.def diff --git a/scripts/dynamic-dns/vyatta-dynamic-dns.pl b/scripts/dynamic-dns/vyatta-dynamic-dns.pl index 8788730f..83206253 100755 --- a/scripts/dynamic-dns/vyatta-dynamic-dns.pl +++ b/scripts/dynamic-dns/vyatta-dynamic-dns.pl @@ -96,16 +96,24 @@ sub dynamicdns_get_constants { $output .= "ssl=yes\n"; $output .= "pid=$ddclient_run_dir/ddclient_$interface.pid\n"; $output .= "cache=$ddclient_cache_dir/ddclient_$interface.cache\n"; - $output .= "use=if, if=$interface\n\n\n"; return $output; } sub dynamicdns_get_values { - my $output = ''; + my $output; my $config = new Vyatta::Config; $config->setLevel("service dns dynamic interface $interface"); + my $web_url = $config->returnValue("use-web url"); + my $web_skip = $config->returnValue("use-web skip"); + + if ($web_url && $web_skip) { + $output = "use=web, web=$web_url, web-skip='".$web_skip."'\n\n\n"; + } else { + $output = "use=if, if=$interface\n\n\n"; + } + my @services = $config->listNodes("service"); foreach my $service (@services) { $config->setLevel("service dns dynamic interface $interface service $service"); diff --git a/templates/service/dns/dynamic/interface/node.tag/use-web/node.def b/templates/service/dns/dynamic/interface/node.tag/use-web/node.def new file mode 100644 index 00000000..f1b86b6d --- /dev/null +++ b/templates/service/dns/dynamic/interface/node.tag/use-web/node.def @@ -0,0 +1 @@ +help: Web check used for obtaining the external IP address diff --git a/templates/service/dns/dynamic/interface/node.tag/use-web/skip/node.def b/templates/service/dns/dynamic/interface/node.tag/use-web/skip/node.def new file mode 100644 index 00000000..f316a4b5 --- /dev/null +++ b/templates/service/dns/dynamic/interface/node.tag/use-web/skip/node.def @@ -0,0 +1,2 @@ +help: Skip everything before this on the given URL +type: txt diff --git a/templates/service/dns/dynamic/interface/node.tag/use-web/url/node.def b/templates/service/dns/dynamic/interface/node.tag/use-web/url/node.def new file mode 100644 index 00000000..164ddde4 --- /dev/null +++ b/templates/service/dns/dynamic/interface/node.tag/use-web/url/node.def @@ -0,0 +1,2 @@ +help: URL to obtain the current external IP address +type: txt -- cgit v1.2.3 From 6c147ff5db351fef80b8f1447b729bc03ddab6a2 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 8 Feb 2015 20:23:29 +0000 Subject: 0.20.44+vyos2+lithium11 --- debian/changelog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index bc2361fc..a8647b27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +vyatta-cfg-system (0.20.44+vyos2+lithium11) unstable; urgency=low + + [ Hiroyuki Sato ] + * Bug#382: fix radvd status check + + [ Kim Hagen ] + * Bug #467, tos inherit not turned on by default on tunnels (IPIP, GRE) + * Bug #352 - QinQ - changing the ethertype value of vif-s + * Can not change EtherType with vif-c interfaces configured + + [ Alex Harpin ] + * vyatta-cfg-system: allow dynamic dns updating from behind nat + + -- Alex Harpin Sun, 08 Feb 2015 20:19:41 +0000 + vyatta-cfg-system (0.20.44+vyos2+lithium10) unstable; urgency=low [ Alex Harpin ] -- cgit v1.2.3 From 865bfab01e256ce839991a1b9d54f3e4cb62a8ac Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Mon, 9 Feb 2015 21:01:35 +0000 Subject: vyatta-cfg-system: invalid resolv.conf format causing extra DNS request The resolv.conf file contains comments at the end of the search and domain entries which cause unexpected behaviour on lookups. Moving these to the line above in each case fixes the issue. Bug #468 http://bugzilla.vyos.net/show_bug.cgi?id=468 --- scripts/system/vyatta_update_resolv.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 921052f0..93e6041d 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -96,12 +96,12 @@ if (!defined($domain_name)) { my $search = ''; if (length($doms) > 0) { - $search = "search\t\t$doms\t\t#line generated by $0\n"; + $search = "#line generated by $0\nsearch\t\t$doms\n"; } my $domain = ''; if ($domain_name && length($domain_name) > 0) { - $domain = "domain\t\t$domain_name\t\t#line generated by $0\n"; + $domain = "#line generated by $0\ndomain\t\t$domain_name\n"; } # update /etc/resolv.conf with name-servers received from dhcp client, done when this script is called @@ -221,7 +221,7 @@ foreach my $line (@resolv) { if (length($domain) > 0) { print $r $domain; } - } else { + } elsif ($line !~ /^#line generated by\s/) { print $r $line; } } -- cgit v1.2.3 From e9a7e018c96813c2f1671e9d2ba48f1f26d3f908 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Mon, 9 Feb 2015 22:34:38 +0000 Subject: 0.20.44+vyos2+lithium12 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index a8647b27..6c26d49c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +vyatta-cfg-system (0.20.44+vyos2+lithium12) unstable; urgency=low + + [ Alex Harpin ] + * vyatta-cfg-system: invalid resolv.conf format causing extra DNS request + + -- Alex Harpin Mon, 09 Feb 2015 22:34:02 +0000 + vyatta-cfg-system (0.20.44+vyos2+lithium11) unstable; urgency=low [ Hiroyuki Sato ] -- cgit v1.2.3 From 93a49639c983e8f61ca942efe68ede46053ea03a Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Tue, 10 Feb 2015 22:56:06 +0000 Subject: vyatta-cfg-system: multiple servers for dns forwarding domain override When configuring DNS fowarding, allow multiple servers to be specified when setting domain overrides, in order to allow Dnsmasq to gracefully handle unavailable nameservers. Bug #408 http://bugzilla.vyos.net/show_bug.cgi?id=408 --- scripts/dns-forwarding/vyatta-dns-forwarding.pl | 25 ++++++++++++++-------- .../dns/forwarding/domain/node.tag/server/node.def | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl index b5efd269..217a520a 100755 --- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl +++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl @@ -63,7 +63,7 @@ sub dnsforwarding_get_values { my $output = ''; my $config = new Vyatta::Config; my $use_dnsmasq_conf = 0; - my (@listen_interfaces, $cache_size, @use_nameservers, $use_system_nameservers, @use_dhcp_nameservers, @domain, $server, $ignore_hosts_file); + my (@listen_interfaces, $cache_size, @use_nameservers, $use_system_nameservers, @use_dhcp_nameservers, @domains, $server, $ignore_hosts_file); $config->setLevel("service dns forwarding"); @@ -73,7 +73,7 @@ sub dnsforwarding_get_values { @use_nameservers = $config->returnOrigValues("name-server"); $use_system_nameservers = $config->existsOrig("system"); @use_dhcp_nameservers = $config->returnOrigValues("dhcp"); - @domain = $config->listOrigNodes("domain"); + @domains = $config->listOrigNodes("domain"); $ignore_hosts_file = $config->returnOrigValue("ignore-hosts-file"); } else { @@ -82,7 +82,7 @@ sub dnsforwarding_get_values { @use_nameservers = $config->returnValues("name-server"); $use_system_nameservers = $config->exists("system"); @use_dhcp_nameservers = $config->returnValues("dhcp"); - @domain = $config->listNodes("domain"); + @domains = $config->listNodes("domain"); $ignore_hosts_file = $config->exists("ignore-hosts-file"); } @@ -112,7 +112,7 @@ sub dnsforwarding_get_values { my $sys_config = new Vyatta::Config; $sys_config->setLevel("system"); my @system_nameservers; - if ($outside_cli == 1){ + if ($outside_cli == 1) { @system_nameservers = $sys_config->returnOrigValues("name-server"); } else { @system_nameservers = $sys_config->returnValues("name-server"); @@ -123,11 +123,18 @@ sub dnsforwarding_get_values { } } } - if (@domain != 0) { - foreach my $dom (@domain) { - my $ser = $config->returnValue("domain $dom server"); - if (defined ($ser)) { - $output .="server=/$dom/$ser\t# domain-override\n"; + if (@domains != 0) { + foreach my $domain (@domains) { + my @domain_servers; + if ($outside_cli == 1) { + @domain_servers = $config->returnValues("domain $domain server"); + } else { + @domain_servers = $config->returnValues("domain $domain server"); + } + if (@domain_servers > 0) { + foreach my $domain_server (@domain_servers) { + $output .="server=/$domain/$domain_server\t# domain-override\n"; + } } } } diff --git a/templates/service/dns/forwarding/domain/node.tag/server/node.def b/templates/service/dns/forwarding/domain/node.tag/server/node.def index 3dec7d5d..8f40a299 100644 --- a/templates/service/dns/forwarding/domain/node.tag/server/node.def +++ b/templates/service/dns/forwarding/domain/node.tag/server/node.def @@ -1,2 +1,3 @@ +multi: type: ipv4 help: DNS server to forward queries -- cgit v1.2.3 From 24c99255b867e48ae3369a23f866951e8607fbbe Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 14 Feb 2015 10:36:55 +0000 Subject: vyatta-cfg-system: redesign the layout and updating of /etc/resolv.conf Following the documentation, /etc/resolv.conf should only have comments inserted that start with # at the beginning of a line, comments in other locations are not supported. The exisiting method of tracking changes in this file (done by both vyatta-system-nameservers and vyatta_update_resolv.pl) relies on this unsupported feature. This commit restructures the updates so they use comments on the preceding line to track changes, along with updating the old style comments to the new ones when the relevant scripts are called. This also fixes a previous issue (which was reverted) where IPv6 nameservers worked incorrectly when the /etc/resolv.conf line ended with a comment. Bug #486 http://bugzilla.vyos.net/show_bug.cgi?id=486 --- scripts/system/vyatta_update_resolv.pl | 74 ++++++++++++++++++++++++---------- scripts/vyatta-system-nameservers | 2 +- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 93e6041d..4c54cfce 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -37,7 +37,7 @@ GetOptions("dhclient-script=i" => \$dhclient_script, my $vc = new Vyatta::Config(); $vc->setLevel('system'); -my @domains; +my @search_domains; my $domain_name = undef; my $disable_dhcp_nameservers = undef; @@ -48,34 +48,36 @@ if ($config_mode == 1) { } if ($dhclient_script == 1) { - @domains = $vc->returnOrigValues('domain-search domain'); + @search_domains = $vc->returnOrigValues('domain-search domain'); $domain_name = $vc->returnOrigValue('domain-name'); } else { - @domains = $vc->returnValues('domain-search domain'); + @search_domains = $vc->returnValues('domain-search domain'); $domain_name = $vc->returnValue('domain-name'); } -if ($dhclient_script == 0 && @domains > 0 && $domain_name && length($domain_name) > 0) { - my @loc; +if ($dhclient_script == 0 && @search_domains > 0 && $domain_name && length($domain_name) > 0) { + my @location; if ($vc->returnOrigValues('domain-search domain') > 0) { - @loc = ["system","domain-name"]; + @location = ["system","domain-name"]; } else { - @loc = ["system","domain-search","domain"]; + @location = ["system","domain-search","domain"]; } - Vyatta::Config::outputError(@loc,"System configuration error. Both \'domain-name\' and \'domain-search\' are specified, but only one of these mutually exclusive parameters is allowed."); + Vyatta::Config::outputError(@location,"System configuration error. Both \'domain-name\' and \'domain-search\' are specified, but only one of these mutually exclusive parameters is allowed."); exit(1); } -my $doms = ''; -foreach my $domain (@domains) { - if (length($doms) > 0) { - $doms .= ' '; +my $search_domain_list = ''; +foreach my $domain (@search_domains) { + if (length($search_domain_list) > 0) { + $search_domain_list .= ' '; } - $doms .= $domain; + $search_domain_list .= $domain; } -# add domain names received from dhcp client to domain search in /etc/resolv.conf if domain-name not set in CLI +# add domain searches received from the dhcp client to those already in /etc/resolv.conf, as long as domain-name is not set in the CLI + +my $search_includes_dhcp = 0; if (!defined($domain_name)) { my @dhcp_interfaces_resolv_files = `ls /etc/ | grep resolv.conf.dhclient-new`; @@ -88,20 +90,27 @@ if (!defined($domain_name)) { my @dhcp_domains = split(/\s+/, $search_string, 2); my $dhcp_domain = $dhcp_domains[1]; chomp $dhcp_domain; - $doms .= ' ' . $dhcp_domain; + $search_domain_list .= ' ' . $dhcp_domain; + $search_includes_dhcp = 1; } } } } my $search = ''; -if (length($doms) > 0) { - $search = "#line generated by $0\nsearch\t\t$doms\n"; +if (length($search_domain_list) > 0) { + my $source; + if ($search_includes_dhcp == 1) { + $source = "(system + dhcp)"; + } else { + $source = "(system)"; + } + $search = "#line generated by vyatta_update_resolv.pl $source\nsearch\t\t$search_domain_list\n"; } my $domain = ''; if ($domain_name && length($domain_name) > 0) { - $domain = "#line generated by $0\ndomain\t\t$domain_name\n"; + $domain = "#line generated by vyatta_update_resolv.pl (system)\ndomain\t\t$domain_name\n"; } # update /etc/resolv.conf with name-servers received from dhcp client, done when this script is called @@ -143,7 +152,7 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { if (($ns_in_resolvconf == 0) && !($disable_dhcp_nameservers)) { open (my $rf, '>>', '/etc/resolv.conf') or die "$! error trying to overwrite"; - print $rf "nameserver\t$ns\t\t#nameserver written by $0\n"; + print $rf "#nameserver written by vyatta_update_resolv.pl (dhcp)\nnameserver\t$ns\n"; close $rf; $restart_ntp = 1; } @@ -156,7 +165,16 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { # from dhcp-server, or to remove previous dhcp supplied name-servers if disable-dhcp-nameservers has # been enabled. - my @nameservers_dhcp_in_resolvconf = `grep 'nameserver written' /etc/resolv.conf`; + my $found_old = 0; + + my @nameservers_dhcp_in_resolvconf = `sed -n '/nameserver written/{n;P;}' /etc/resolv.conf`; + for my $old_style_nameservers (@nameservers_dhcp_in_resolvconf) { + if ($old_style_nameservers =~ /#line generated by/){ + @nameservers_dhcp_in_resolvconf = `sed -n '/nameserver written/{P;}' /etc/resolv.conf`; + $found_old = 1; + last; + } + } my @dhcp_nameservers_in_resolvconf; my $count_nameservers_in_resolvconf = 0; for my $count_dhcp_nameserver (@nameservers_dhcp_in_resolvconf) { @@ -166,20 +184,32 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { } if (($#current_dhcp_nameservers < 0) || ($disable_dhcp_nameservers)) { for my $dhcpnameserver (@dhcp_nameservers_in_resolvconf) { - my $cmd = "sed -i '/$dhcpnameserver\t/d' /etc/resolv.conf"; + my $cmd; + chomp $dhcpnameserver; + if ($found_old == 1) { + $cmd = "sed -i '/nameserver\t$dhcpnameserver/d' /etc/resolv.conf"; + } else { + $cmd = "sed -i -n '/nameserver\t$dhcpnameserver/".'{n;x;d;};x;1d;p;${x;p;}'."' /etc/resolv.conf"; + } system($cmd); $restart_ntp = 1; } } else { for my $dhcpnameserver (@dhcp_nameservers_in_resolvconf) { my $found = 0; + my $cmd; + chomp $dhcpnameserver; for my $currentnameserver (@current_dhcp_nameservers) { if ($dhcpnameserver eq $currentnameserver){ $found = 1; } } if ($found == 0) { - my $cmd = "sed -i '/$dhcpnameserver\t/d' /etc/resolv.conf"; + if ($found_old == 1) { + $cmd = "sed -i '/nameserver\t$dhcpnameserver/d' /etc/resolv.conf"; + } else { + $cmd = "sed -i -n '/nameserver\t$dhcpnameserver/".'{n;x;d;};x;1d;p;${x;p;}'."' /etc/resolv.conf"; + } system($cmd); $restart_ntp = 1; } diff --git a/scripts/vyatta-system-nameservers b/scripts/vyatta-system-nameservers index 74f2c8b6..7b66cf77 100755 --- a/scripts/vyatta-system-nameservers +++ b/scripts/vyatta-system-nameservers @@ -53,7 +53,7 @@ update_system_nameservers () { # find last instance of cli inserted nameserver # insert currently received nameserver immediately after that # this is done to keep system set nameservers priority over dhcp received nameservers - cli_ns_array=($(awk '{if (!$3) print $2}' /etc/resolv.conf)) + cli_ns_array=($(awk '{if (/(dhcp)/) exit 0; if (!$3) print $2}' /etc/resolv.conf)) cli_ns_array_len=${#cli_ns_array[*]} line_num=0 if [ $cli_ns_array_len -gt 0 ]; then -- cgit v1.2.3 From 6648f37a5895f259de2068504520f64f225c1899 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 14 Feb 2015 13:35:27 +0000 Subject: vyatta-cfg-system: remove blank domain search and expand comment type Tighten the checks for configured search domains to exclude adding unnecessary blank domains and expand the comments added to /etc/resolv.conf to indicate the source of the search domains. Bug #486 http://bugzilla.vyos.net/show_bug.cgi?id=486 --- scripts/system/vyatta_update_resolv.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 4c54cfce..0dfa4bec 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -68,11 +68,14 @@ if ($dhclient_script == 0 && @search_domains > 0 && $domain_name && length($doma } my $search_domain_list = ''; +my $search_includes_system = 0; + foreach my $domain (@search_domains) { if (length($search_domain_list) > 0) { $search_domain_list .= ' '; } $search_domain_list .= $domain; + $search_includes_system = 1; } # add domain searches received from the dhcp client to those already in /etc/resolv.conf, as long as domain-name is not set in the CLI @@ -90,7 +93,10 @@ if (!defined($domain_name)) { my @dhcp_domains = split(/\s+/, $search_string, 2); my $dhcp_domain = $dhcp_domains[1]; chomp $dhcp_domain; - $search_domain_list .= ' ' . $dhcp_domain; + if (length($search_domain_list) > 0) { + $search_domain_list .= ' '; + } + $search_domain_list .= $dhcp_domain; $search_includes_dhcp = 1; } } @@ -100,10 +106,14 @@ if (!defined($domain_name)) { my $search = ''; if (length($search_domain_list) > 0) { my $source; - if ($search_includes_dhcp == 1) { - $source = "(system + dhcp)"; + if ($search_includes_system == 1) { + if ($search_includes_dhcp == 1) { + $source = "(system + dhcp)"; + } else { + $source = "(system)"; + } } else { - $source = "(system)"; + $source = "(dhcp)"; } $search = "#line generated by vyatta_update_resolv.pl $source\nsearch\t\t$search_domain_list\n"; } -- cgit v1.2.3 From ddf9a933451f639edc15d669c0c32b15cc0a2717 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 14 Feb 2015 14:38:29 +0000 Subject: 0.20.44+vyos2+lithium13 --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6c26d49c..ca08ca74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +vyatta-cfg-system (0.20.44+vyos2+lithium13) unstable; urgency=low + + [ Alex Harpin ] + * vyatta-cfg-system: multiple servers for dns forwarding domain override + * vyatta-cfg-system: redesign the layout and updating of /etc/resolv.conf + * vyatta-cfg-system: remove blank domain search and expand comment type + + -- Alex Harpin Sat, 14 Feb 2015 14:37:03 +0000 + vyatta-cfg-system (0.20.44+vyos2+lithium12) unstable; urgency=low [ Alex Harpin ] -- cgit v1.2.3