summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-11-12 09:49:04 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-11-12 09:49:04 -0800
commitddc25a06ac3a1fc76491a89c71f20a499b5d8187 (patch)
tree0c126ae4d3ded51d4b362649f1b73b7df1b08fc4
parent5956c4053c0de30a6d9028773b3540dc37534923 (diff)
parent472c42136c47446b3980335aa819df6bcff5caa3 (diff)
downloadvyatta-cfg-ddc25a06ac3a1fc76491a89c71f20a499b5d8187.tar.gz
vyatta-cfg-ddc25a06ac3a1fc76491a89c71f20a499b5d8187.zip
Merge branch 'kenwood' of suva.vyatta.com:/git/vyatta-cfg into kenwood
-rw-r--r--debian/changelog54
-rwxr-xr-xlib/Vyatta/Interface.pm12
-rwxr-xr-xlib/Vyatta/Keepalived.pm51
-rw-r--r--scripts/priority.pl31
-rw-r--r--src/cli_def.l1
-rw-r--r--src/common/unionfs.c37
6 files changed, 152 insertions, 34 deletions
diff --git a/debian/changelog b/debian/changelog
index 7620e86..45f61e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,57 @@
+vyatta-cfg (0.15.41) unstable; urgency=low
+
+ * preserve node.val order for term multinodes. fix for bug 5103
+
+ -- Michael Larson <mike@ft1.vyatta.com> Tue, 10 Nov 2009 12:06:38 -0800
+
+vyatta-cfg (0.15.40) unstable; urgency=low
+
+ * Allow inline comments in config template fields.
+
+ -- Bob Gilligan <gilligan@vyatta.com> Thu, 05 Nov 2009 16:41:12 -0800
+
+vyatta-cfg (0.15.39) unstable; urgency=low
+
+ * Fix missing semicolon.
+
+ -- Stig Thormodsrud <stig@vyatta.com> Wed, 04 Nov 2009 08:16:11 -0800
+
+vyatta-cfg (0.15.38) unstable; urgency=low
+
+ * Fix uninitialized variable when reading carrier on admin down
+ interface.
+
+ -- Stig Thormodsrud <stig@vyatta.com> Tue, 03 Nov 2009 11:22:03 -0800
+
+vyatta-cfg (0.15.37) unstable; urgency=low
+
+ [ slioch ]
+ * fix for missing priority value on embedded multinode. bug behavior
+ was more limited than this--at least tag node.def and multiple
+
+ -- root <root@eng-140.vyatta.com> Mon, 02 Nov 2009 17:26:42 -0800
+
+vyatta-cfg (0.15.36) unstable; urgency=low
+
+ [ David S. Madole ]
+ * Add VRRP capability to bonding interfaces and vifs of bonding
+ interfaces.
+
+ [ Stig Thormodsrud ]
+ * Add method to retrieve carrier value.
+ * Convert keepalived to use Interface infrastructure.
+ * Fix carrier method.
+ * Add natural order sort.
+ * Fix spelling error in carrier method.
+
+ -- Stig Thormodsrud <stig@vyatta.com> Sun, 01 Nov 2009 14:58:58 -0800
+
+vyatta-cfg (0.15.35) unstable; urgency=low
+
+ * Sync config file after saving
+
+ -- Stephen Hemminger <stephen.hemminger@vyatta.com> Fri, 30 Oct 2009 11:05:03 -0700
+
vyatta-cfg (0.15.34) unstable; urgency=low
* Add copybreak option to all ether drivers
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index 97ef7f7..513f686 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -222,6 +222,18 @@ sub flags {
return hex($val);
}
+sub carrier {
+ my $self = shift;
+ open my $carrier, '<', "/sys/class/net/$self->{name}/carrier"
+ or return;
+
+ my $val = <$carrier>;
+ $val = 0 if ! defined $val; # proc entry not readable on down interface
+ chomp $val;
+ close $carrier;
+ return $val;
+}
+
sub hw_address {
my $self = shift;
diff --git a/lib/Vyatta/Keepalived.pm b/lib/Vyatta/Keepalived.pm
index 96d4fe9..6d6a153 100755
--- a/lib/Vyatta/Keepalived.pm
+++ b/lib/Vyatta/Keepalived.pm
@@ -125,21 +125,56 @@ sub get_master_file {
return $file;
}
+sub alphanum_split {
+ my ($str) = @_;
+ my @list = split m/(?=(?<=\D)\d|(?<=\d)\D)/, $str;
+ return @list;
+}
+
+sub natural_order {
+ my ($a, $b) = @_;
+ my @a = alphanum_split($a);
+ my @b = alphanum_split($b);
+
+ while (@a && @b) {
+ my $a_seg = shift @a;
+ my $b_seg = shift @b;
+ my $val;
+ if (($a_seg =~ /\d/) && ($b_seg =~ /\d/)) {
+ $val = $a_seg <=> $b_seg;
+ } elsif (($a_seg eq '.') && ($b_seg eq '_')) {
+ return 1;
+ } else {
+ $val = $a_seg cmp $b_seg;
+ }
+ if ($val != 0) {
+ return $val;
+ }
+ }
+ return @a <=> @b;
+}
+
+sub intf_sort {
+ my @a = @_;
+ my @new_a = sort { natural_order($a,$b) } @a;
+ return @new_a;
+}
+
sub get_state_files {
my ($intf, $group) = @_;
- # todo: fix sorting for ethX > 9
my @state_files;
my $LS;
if ($group eq "all") {
- open($LS,"ls $state_dir |grep '^vrrpd_$intf.*\.state\$' | sort |");
+ open($LS,"ls $state_dir |grep '^vrrpd_$intf.*\.state\$' |");
} else {
my $intf_group = $intf . "_" . $group . ".state";
open($LS,
- "ls $state_dir |grep '^vrrpd_$intf_group\$' | sort |");
+ "ls $state_dir |grep '^vrrpd_$intf_group\$' |");
}
@state_files = <$LS>;
close($LS);
+ @state_files = intf_sort(@state_files);
foreach my $i (0 .. $#state_files) {
$state_files[$i] = "$state_dir/$state_files[$i]";
}
@@ -152,13 +187,11 @@ sub vrrp_get_config {
my $path;
my $config = new Vyatta::Config;
-
- if ($intf =~ m/(eth\d+)\.(\d+)/) {
- $path = "interfaces ethernet $1 vif $2";
- } else {
- $path = "interfaces ethernet $intf";
- }
+ my $interface = new Vyatta::Interface($intf);
+ die "Unknown interface type: $intf" unless $interface;
+
+ $path = $interface->path();
$config->setLevel($path);
my $primary_addr = $config->returnOrigValue("address");
if (!defined $primary_addr) {
diff --git a/scripts/priority.pl b/scripts/priority.pl
index 59239bf..39f6220 100644
--- a/scripts/priority.pl
+++ b/scripts/priority.pl
@@ -2,16 +2,29 @@
my %pri;
- # first check if this file exists, and if so ensure this is a config file.
+# Look at all node.def files in the configuration template tree
my @files = `find /opt/vyatta/share/vyatta-cfg -name 'node.def'`;
foreach my $f (@files) {
my $result = `grep 'priority:' $f`;
- if (defined $result && length($result) != 0) {
- my @r = split " ", $result;
- if (defined $r[1]) {
- #stuff in hash here
- push @{$pri{$r[1]}},$f;
- }
+ if (defined $result && length($result) != 0) {
+ my @r = split " ", $result;
+ if (defined $r[1]) {
+ # Strip off trailing "/node.def\n" from file pathname
+ my $line = substr($f, 0, -10);
+
+ # Strip off leading "/opt/vyatta/share/vyatta-cfg/templates/"
+ $line = substr($line, 39);
+
+ # See if there is a comment in entry
+ my ($entry, $comment) = split /#/, $result;
+ if (defined $comment) {
+ $comment =~ s/\n//;
+ $line = $line . " #" . $comment;
+ }
+
+ # stuff resulting line into hash
+ push @{$pri{$r[1]}}, $line;
+ }
}
}
@@ -21,8 +34,6 @@ foreach my $f (@files) {
foreach my $key ( sort { $a <=> $b } keys %pri ) {
my @a = @{$pri{$key}};
foreach my $val (@a) {
- my $loc = substr($val,0,-10);
- my $loc = substr($loc,39);
- print $key," ",$loc,"\n";
+ print $key," ",$val,"\n";
}
}
diff --git a/src/cli_def.l b/src/cli_def.l
index d73f1c4..721e5f0 100644
--- a/src/cli_def.l
+++ b/src/cli_def.l
@@ -271,6 +271,7 @@ RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end|comp_he
#[^\n]*\n {
/* comment */
++yy_cli_def_lineno;
+ return EOL;
}
\n {
diff --git a/src/common/unionfs.c b/src/common/unionfs.c
index 45127e8..ed40bf8 100644
--- a/src/common/unionfs.c
+++ b/src/common/unionfs.c
@@ -225,13 +225,6 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
}
//either multi or tag--shouldn't have made a difference, but arkady was confused.
vn->_config._multi = (def.tag | def.multi);
- if (def.def_priority == 0) {
- vn->_config._priority = LOWEST_PRIORITY;
- }
- else {
- vn->_config._priority = def.def_priority;
- }
-
}
}
@@ -252,12 +245,6 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
//Need to do two things:
// 1. Come to agreement on where the behavior splits on priority multinodes
// 2. Not check for tag node in the def datastructure but use the new datastructure as at some point tag and multi will be the same
- if (vn_parent->_config._def.tag == TRUE) { //only for embedded multinodes
- vn->_config._priority = vn_parent->_config._priority;
- vn_parent->_config._priority = LOWEST_PRIORITY;
- }
-
-
//now let's patch up the def multi-nodes
//move the def for the multinode from the parent to the value node
struct VyattaNode* vn2 = (struct VyattaNode*)node->data;
@@ -282,6 +269,25 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
}
}
+
+ if (G_NODE_IS_ROOT(node) == FALSE) {
+ struct VyattaNode* vn_parent = (struct VyattaNode*)node->parent->data;
+ struct VyattaNode* vn = (struct VyattaNode*)node->data;
+ // vn->_config._priority = vn_parent->_config._def.def_priority;
+ if (vn->_config._def.tag && vn->_config._multi) {
+ vn->_config._priority = LOWEST_PRIORITY;
+ }
+ else if (vn->_config._def.def_priority == 0) {
+ vn->_config._priority = LOWEST_PRIORITY;
+ }
+ else {
+ vn->_config._priority = vn->_config._def.def_priority;
+ }
+ }
+
+
+
+
if (final_node == TRUE) {
//move defs to child...
get_term_data_values(node);
@@ -1017,8 +1023,9 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data)
if (vn->_data._value == TRUE) {
new_vn = copy_vyatta_node(vn);
GNode *new_node = g_node_new(new_vn);
- //g_node_insert(node, -1, new_node);
- insert_sibling_in_order(node,new_node);
+ // g_node_insert(node, -1, new_node);
+ g_node_insert_after(node, NULL, new_node);
+ // insert_sibling_in_order(node,new_node);
new_vn->_config._def = vn->_config._def;
}
else {