-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interfaces/neighbor - implement new neighbor configuration for arp/nd…
…p entries closes #6917 This commit adds a new component linked in Interfaces/Neighbors which offers the ability to manually register static leases and provides application control from other modules such as dhcpd. To minimize the risk, we're reusing the existing interfaces_staticarp_configure() hooks while only adjusting how static arp entries are being attached to the interface (match on addresses assigned when triggering with an interface). Entries registered via dhcp will be visible from the ui as well together with its origin. The previous version didn't cleanup old static entries, this version triggers a cleanup when executed for all interfaces using all earlier modifications processed via the same function (interfaces_neighbors_configure()).
- Loading branch information
1 parent
2ae4308
commit 1bec000
Showing
15 changed files
with
725 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/opnsense/mvc/app/controllers/OPNsense/Interfaces/Api/NeighborSettingsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2023 Deciso B.V. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
namespace OPNsense\Interfaces\Api; | ||
|
||
use OPNsense\Core\Backend; | ||
use OPNsense\Base\ApiMutableModelControllerBase; | ||
|
||
class NeighborSettingsController extends ApiMutableModelControllerBase | ||
{ | ||
protected static $internalModelName = 'neighbor'; | ||
protected static $internalModelClass = 'OPNsense\Interfaces\Neighbor'; | ||
|
||
public function searchItemAction() | ||
{ | ||
return $this->searchBase("neighbor", ['etheraddr', 'ipaddress', 'descr', 'origin'], "vxlanid"); | ||
} | ||
|
||
public function setItemAction($uuid) | ||
{ | ||
return $this->setBase("neighbor", "neighbor", $uuid); | ||
} | ||
|
||
public function addItemAction() | ||
{ | ||
return $this->addBase("neighbor", "neighbor"); | ||
} | ||
|
||
public function getItemAction($uuid = null) | ||
{ | ||
return $this->getBase("neighbor", "neighbor", $uuid); | ||
} | ||
|
||
public function delItemAction($uuid) | ||
{ | ||
return $this->delBase("neighbor", $uuid); | ||
} | ||
|
||
public function reconfigureAction() | ||
{ | ||
$result = ["status" => "failed"]; | ||
if ($this->request->isPost()) { | ||
$result['status'] = strtolower(trim((new Backend())->configdRun('interface neighbor configure'))); | ||
} | ||
return $result; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/opnsense/mvc/app/controllers/OPNsense/Interfaces/NeighborController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2019 Deciso B.V. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
namespace OPNsense\Interfaces; | ||
|
||
class NeighborController extends \OPNsense\Base\IndexController | ||
{ | ||
public function indexAction() | ||
{ | ||
$this->view->pick('OPNsense/Interface/neighbor'); | ||
$this->view->formDialogEdit = $this->getForm("dialogNeighbor"); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/opnsense/mvc/app/controllers/OPNsense/Interfaces/forms/dialogNeighbor.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<form> | ||
<field> | ||
<id>neighbor.etheraddr</id> | ||
<label>Ether Address</label> | ||
<type>text</type> | ||
<help>Hardware MAC address of the cllient (format xx:xx:xx:xx:xx:xx)</help> | ||
</field> | ||
<field> | ||
<id>neighbor.ipaddress</id> | ||
<label>IP address</label> | ||
<type>text</type> | ||
<help>IP address to assign to the provided MAC address, which will either end up in the arp (IPv4) or ndp (IPv6) table</help> | ||
</field> | ||
<field> | ||
<id>neighbor.descr</id> | ||
<label>Description</label> | ||
<type>text</type> | ||
<help>You may enter a description here for your reference (not parsed).</help> | ||
</field> | ||
</form> |
Oops, something went wrong.