Skip to content

Commit 2a90eff

Browse files
author
Marcin Matlag
committed
initial attempt
1 parent d2f6c34 commit 2a90eff

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPNeighbor.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<label>Local Initiater IP</label>
7171
<type>text</type>
7272
<advanced>true</advanced>
73-
<help>Specify the local IP address used to establish connections with the neighbor. Only relevant for MD5 authentication.</help>
73+
<help>Specify the local IP address (IPv4 or IPv6) used as the source to initiate BGP/BFD sessions and connections with the neighbor, including MD5 authentication. Takes precedence over Update-Source Interface when set.</help>
7474
<grid_view>
7575
<visible>false</visible>
7676
</grid_view>

net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OPNsense\Quagga;
44

5+
use OPNsense\Base\Messages\Message;
56
use OPNsense\Base\BaseModel;
67

78
/*
@@ -28,4 +29,23 @@
2829
*/
2930
class BGP extends BaseModel
3031
{
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function performValidation($validateFullModel = false)
36+
{
37+
$messages = parent::performValidation($validateFullModel);
38+
foreach ($this->neighbors->neighbor->iterateItems() as $neighbor) {
39+
if (!$validateFullModel && !$neighbor->isFieldChanged()) {
40+
continue;
41+
}
42+
if (!$neighbor->updatesource->isEmpty() && !$neighbor->localip->isEmpty()) {
43+
$messages->appendMessage(new Message(
44+
gettext("Update-Source Interface and Local Initiator IP are mutually exclusive."),
45+
$neighbor->updatesource->__reference
46+
));
47+
}
48+
}
49+
return $messages;
50+
}
3151
}

net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bgp.volt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ POSSIBILITY OF SUCH DAMAGE.
3838
}
3939
});
4040

41+
function checkNeighborSourceConflict() {
42+
const $block = $('#help_block_neighbor\\.updatesource');
43+
if ($('#neighbor\\.updatesource').val() && $('#neighbor\\.localip').val()) {
44+
$block.text('{{ lang._("Update-Source Interface and Local Initiator IP are mutually exclusive.") }}');
45+
} else {
46+
$block.text('');
47+
}
48+
}
49+
$(document).on('change', '#neighbor\\.updatesource, #neighbor\\.localip', checkNeighborSourceConflict);
50+
4151
mapDataToFormUI({'frm_bgp_settings':"/api/quagga/bgp/get"}).done(function(data){
4252
formatTokenizersUI();
4353
$('.selectpicker').selectpicker('refresh');

net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ router bgp {{ OPNsense.quagga.bgp.asnumber }}
138138
{% if 'disable_connected_check' in neighbor and neighbor.disable_connected_check == '1' %}
139139
neighbor {{ neighbor.address }} disable-connected-check
140140
{% endif %}
141-
{% if ':' not in neighbor.address and 'updatesource' in neighbor and neighbor.updatesource != '' %}
141+
{% if 'localip' in neighbor and neighbor.localip != '' %}
142+
neighbor {{ neighbor.address }} update-source {{ neighbor.localip }}
143+
{% elif ':' not in neighbor.address and 'updatesource' in neighbor and neighbor.updatesource != '' %}
142144
neighbor {{ neighbor.address }} update-source {{ physical_interface(neighbor.updatesource) }}
143145
{% endif %}
144146
{% if ':' in neighbor.address and 'linklocalinterface' in neighbor and neighbor.linklocalinterface != '' %}

0 commit comments

Comments
 (0)