Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
<type>text</type>
<help>Your AS Number here.</help>
</field>
<field>
<id>bgp.confed_asn</id>
<label>BGP Confederation ASN</label>
<type>text</type>
<advanced>true</advanced>
<help>Specify the autonomous system number of the local confederation group. (Required if Confederation Peers are set)</help>
</field>
<field>
<id>bgp.confed_peers</id>
<label>BGP Confederation Peers</label>
<type>select_multiple</type>
<style>tokenize</style>
<allownew>true</allownew>
<advanced>true</advanced>
<help>Specify the Peers of the confederation group. (Required if Confederation ASN is set)</help>
</field>
<field>
<id>bgp.distance</id>
<label>BGP AD Distance</label>
Expand Down
40 changes: 36 additions & 4 deletions net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@
namespace OPNsense\Quagga;

use OPNsense\Base\BaseModel;
use Phalcon\Messages\Message;

class BGP extends BaseModel
{
public function performValidation($validateFullModel = false)
{
// Run standard XML field validations first
$messages = parent::performValidation($validateFullModel);

// Fetch values
$asn = trim((string)$this->confed_asn);
$peers = trim((string)$this->confed_peers);

$has_asn = !empty($asn);
$has_peers = !empty($peers);

// 1. ASN is set, but Peers are empty
if ($has_asn && !$has_peers) {
$messages->appendMessage(new Message(
"BGP Confederation Peers are required when a Confederation ASN is defined.",
"confed_peers"
));
}

// 2. Peers are set, but ASN is empty
if (!$has_asn && $has_peers) {
$messages->appendMessage(new Message(
"BGP Confederation ASN is required when Confederation Peers are defined.",
"confed_asn"
));
}

return $messages;
}
}

/*
Copyright (C) 2017 Fabian Franz
Expand All @@ -25,7 +60,4 @@
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.
*/
class BGP extends BaseModel
{
}
*/
11 changes: 11 additions & 0 deletions net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
<MinimumValue>1</MinimumValue>
<MaximumValue>4294967295</MaximumValue>
</asnumber>
<confed_asn type="IntegerField">
<Required>N</Required>
<ValidationMessage>BGP Confederation ASN must be an integer between 1 and 4294967295.</ValidationMessage>
<MinimumValue>1</MinimumValue>
<MaximumValue>4294967295</MaximumValue>
</confed_asn>
<confed_peers type="CSVListField">
<Required>N</Required>
<ValidationMessage>Each Peer ASN must be an integer between 1 and 4294967295.</ValidationMessage>
<Mask>/^(([1-9]|[1-9][0-9]{1,8}|[1-3][0-9]{9}|4[0-1][0-9]{8}|42[0-8][0-9]{7}|429[0-3][0-9]{6}|4294[0-8][0-9]{5}|42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|4294967[0-1][0-9]{2}|42949672[0-8][0-9]|429496729[0-5])(,|$))+$/</Mask>
</confed_peers>
<distance type="IntegerField">
<MinimumValue>1</MinimumValue>
<MaximumValue>255</MaximumValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
{% endif %}
{% if helpers.exists('OPNsense.quagga.bgp.asnumber') and OPNsense.quagga.bgp.asnumber != '' %}
router bgp {{ OPNsense.quagga.bgp.asnumber }}
{% if OPNsense.quagga.bgp.confed_asn|default('') != '' %}
bgp confederation identifier {{ OPNsense.quagga.bgp.confed_asn }}
{% endif %}
{% if OPNsense.quagga.bgp.confed_peers|default('') != '' %}
bgp confederation peers {{ OPNsense.quagga.bgp.confed_peers|replace(',', ' ') }}
{% endif %}
{% if not helpers.empty('OPNsense.quagga.bgp.logneighborchanges') %}
bgp log-neighbor-changes
{% endif %}
Expand Down