Skip to content

Commit

Permalink
ATTN: validation: warn if a priority is not set for a routing-policy
Browse files Browse the repository at this point in the history
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
  • Loading branch information
drafnel authored and slyon committed Nov 14, 2024
1 parent 3aba58e commit ae09e2c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ adopt_and_validate_vrf_routes(__unused const NetplanParser *npp, GHashTable *net
if (nd->ip_rules) {
for (size_t i = 0; i < nd->ip_rules->len; i++) {
NetplanIPRule* r = g_array_index(nd->ip_rules, NetplanIPRule*, i);
if (r->priority == NETPLAN_IP_RULE_PRIO_UNSPEC) {
g_warning("%s: No priority specified for routing-policy %zu", nd->id, i);
}
if (r->table == nd->vrf_table) {
g_debug("%s: Ignoring redundant routing-policy table %d (matches VRF table)", nd->id, r->table);
continue;
Expand Down

0 comments on commit ae09e2c

Please sign in to comment.