Allow multiple prefix list selections in a route map in OSPF6 as well

This commit is contained in:
Monviech 2026-05-20 12:03:11 +02:00
parent 842ec4b972
commit 6333186c95
3 changed files with 12 additions and 7 deletions

View file

@ -31,7 +31,6 @@
<id>routemap.match2</id>
<label>Prefix List</label>
<type>select_multiple</type>
<style>tokenize</style>
<allownew>true</allownew>
<help>Allows for matching based on prefix lists, multiple selections enabled.</help>
</field>

View file

@ -194,12 +194,14 @@
</id>
<match2 type="ModelRelationField">
<Model>
<template>
<prefixlists>
<source>OPNsense.quagga.ospf6</source>
<items>prefixlists.prefixlist</items>
<display>name</display>
</template>
<display>name,seqnumber</display>
<display_format>%s:%s</display_format>
</prefixlists>
</Model>
<Multiple>Y</Multiple>
<ValidationMessage>Related item not found.</ValidationMessage>
</match2>
<set type="TextField"/>

View file

@ -80,12 +80,16 @@ ipv6 prefix-list {{ prefixlist.name }} seq {{ prefixlist.seqnumber }} {{ prefixl
{% for routemap in helpers.sortDictList(OPNsense.quagga.ospf6.routemaps.routemap, 'name', 'id' ) %}
{% if routemap.enabled == '1' %}
route-map {{ routemap.name }} {{ routemap.action }} {{ routemap.id }}
{# XXX: Multiple prefix lists that have the same name can be selected (intentionally), but each is stored as unique item. #}
{# The relationship is a bit loose, unique solves part of this issue. #}
{% if routemap.match2|default("") != "" %}
{% set prefixlist_names = [] %}
{% for prefixlist in routemap.match2.split(",") %}
{% set prefixlist_data = helpers.getUUID(prefixlist) %}
{% if 'match2' in routemap and routemap.match2 != '' %}
match ipv6 address prefix-list {{ prefixlist_data.name }}
{% endif %}
{% do prefixlist_names.append(prefixlist_data.name) %}
{% endfor %}
{% for prefixlist_name in prefixlist_names | unique %}
match ip address prefix-list {{ prefixlist_name }}
{% endfor %}
{% endif %}
{% if routemap.set|default("") != "" %}