summaryrefslogtreecommitdiff
path: root/scripts/vyatta-interfaces.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-17 14:07:42 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-17 16:57:32 -0800
commitb170409fc8117356dc8e53c6a28924a7d4c521ed (patch)
treecc059c832173aa1df8a696169cedece17200fe6d /scripts/vyatta-interfaces.pl
parent465e12c85a8a5db0ecdb5bff7682d1e98e2ddb0e (diff)
downloadvyatta-cfg-system-b170409fc8117356dc8e53c6a28924a7d4c521ed.tar.gz
vyatta-cfg-system-b170409fc8117356dc8e53c6a28924a7d4c521ed.zip
Add check for adding bridge-group and bond-group when setting address
Bug 4745 Block putting address on interface that is part of a bridge (or bonding). Address should only be assigned to the master device, not the slave. Also changes messge on error since CLI now displays error location.
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rwxr-xr-xscripts/vyatta-interfaces.pl40
1 files changed, 18 insertions, 22 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 009db451..d625d262 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -446,33 +446,29 @@ sub is_valid_addr_set {
}
# Validate the set of address values configured on an interface at commit
-# time. Syntax of address values is checked at set time, so is not
-# checked here. Instead, we check that full set of address address
-# values are consistent. The only rule that we enforce here is that
-# one may not configure an interface with both a DHCP address and a static
-# IPv4 address.
-#
+# Check that full set of address address values are consistent.
+# 1. Interface may not be part of bridge or bonding group
+# 2. Can not have both DHCP and a static IPv4 address.
sub is_valid_addr_commit {
- my ($intf, @addrs) = @_;
+ my ($ifname, @addrs) = @_;
+ my $intf = new Vyatta::Interface($ifname);
+ $intf or die "Unknown interface name/type: $ifname\n";
- my $static_v4 = 0;
- my $dhcp = 0;
+ my $config = new Vyatta::Config;
+ $config->setLevel($intf->path());
- foreach my $addr (@addrs) {
- if ($addr eq "dhcp") {
- $dhcp = 1;
- } else {
- my $version = is_ip_v4_or_v6($addr);
- if (defined($version) && $version == 4) {
- $static_v4 = 1;
- }
- }
- }
+ my $bridge = $config->returnValue("bridge-group bridge");
+ die "Can't configure address on interface that is port of bridge.\n"
+ if (defined($bridge));
+ my $bond = $config->returnValue("bond-group");
+ die "Can't configure address on interface that is slaved to bonding interface.\n"
+ if (defined($bond));
- die "Error configuring interface $intf: Can't configure static\n",
- "IPv4 address and DHCP on the same interface.\n"
- if ($static_v4 == 1 && $dhcp == 1);
+ my $dhcp = grep { /^dhcp$/ } @addrs;
+ my $static_v4 = grep { is_ip_v4_or_v6($_) == 4 } @addrs;
+ die "Can't configure static IPv4 address and DHCP on the same interface.\n"
+ if ($static_v4 && $dhcp);
exit 0;
}