Skip to content

Commit 0f7d53b

Browse files
authored
CARP vhid must be unique _for a given interface_ (or more exactly L2 segment)
See #100
1 parent c55ccd5 commit 0f7d53b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pfSense-pkg-API/files/etc/inc/api/models/APIFirewallVirtualIPCreate.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class APIFirewallVirtualIPCreate extends APIModel {
105105
if ($this->validated_data["mode"] === "carp") {
106106
# Check for our optional 'vhid' payload value. Assume default if none was specified.
107107
if (isset($this->initial_data['vhid'])) {
108-
if ($this->__vhid_exists($this->initial_data['vhid'])) {
108+
if ($this->__vhid_exists($this->initial_data["interface"], $this->initial_data['vhid'])) {
109109
$this->errors[] = APIResponse\get(4027);
110110
} elseif (1 > $this->initial_data['vhid'] or $this->initial_data['vhid'] > 255) {
111111
$this->errors[] = APIResponse\get(4028);
@@ -153,14 +153,14 @@ class APIFirewallVirtualIPCreate extends APIModel {
153153
$this->validated_data["type"] = "network";
154154
}
155155

156-
private function __vhid_exists($vhid) {
156+
private function __vhid_exists($interface, $vhid) {
157157
# Loop through each virtual IP and ensure it is not using the requested vhid
158158
foreach ($this->config["virtualip"]["vip"] as $vip) {
159-
if (intval($vhid) === intval($vip["vhid"])) {
159+
if ($interface === $vip["interface"] && intval($vhid) === intval($vip["vhid"])) {
160160
return true;
161161
}
162162
}
163163
return false;
164164
}
165165

166-
}
166+
}

0 commit comments

Comments
 (0)