Skip to content

Commit bb0f8a7

Browse files
committed
validation: warn if a priority is not set for a routing-policy
The iproute2 guidance says "Each rule should have an explicitly set unique priority value", and further warns: For historical reasons ip rule add does not require any priority value and allows the priority value to be non-unique. If the user had not supplied a priority value then one was assigned by the kernel. If the user requested creating a rule with a priority value which already existed then the kernel did not reject the request and added the new rule before all old rules of the same priority. This is a mistake in the current design, nothing more. It should be fixed by the time you read this so please do not rely on this feature. You should always use explicit priorities when creating rules. So let's inspect each routing-policy entry and emit a warning if a priority has not been specified. ref. http://www.policyrouting.org/iproute2.doc.html#ss9.6.1
1 parent 86c700a commit bb0f8a7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/validation.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ adopt_and_validate_vrf_routes(__unused const NetplanParser *npp, GHashTable *net
523523
if (nd->ip_rules) {
524524
for (size_t i = 0; i < nd->ip_rules->len; i++) {
525525
NetplanIPRule* r = g_array_index(nd->ip_rules, NetplanIPRule*, i);
526+
if (r->priority == NETPLAN_IP_RULE_PRIO_UNSPEC)
527+
g_warning("%s: No priority specified for routing-policy %zu", nd->id, i);
526528
if (r->table == nd->vrf_table) {
527529
g_debug("%s: Ignoring redundant routing-policy table %d (matches VRF table)", nd->id, r->table);
528530
continue;

0 commit comments

Comments
 (0)