Page MenuHomeFreeBSD

netlink: Add RTA_PRIORITY support (metric)
Needs ReviewPublic

Authored by pouria on Wed, Apr 8, 9:56 PM.
Tags
None
Referenced Files
F151956854: D56323.diff
Sat, Apr 11, 6:37 PM
F151951672: D56323.id175201.diff
Sat, Apr 11, 5:41 PM
F151951549: D56323.diff
Sat, Apr 11, 5:40 PM
Unknown Object (File)
Fri, Apr 10, 6:27 AM
Subscribers

Details

Reviewers
melifaro
markj
glebius
Group Reviewers
network
Summary

Also, fix weight overflow of RTA_MULTIPATH, use metric instead
Our weight values are 24-bit. In the original netlink, rtnh_hops is
indeed 8-bit. For backward compatibility, send metric instead of increasing
its size and also send RTA_WEIGHT for multipath routes.

Test Plan

See patches to the route(8) command in the stack revision.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 72093
Build 68976: arc lint + arc unit

Event Timeline

pouria requested review of this revision.Wed, Apr 8, 9:56 PM

These changes can be tested in latter route revisions in the revision stack.

sys/netlink/route/route.h
336

It would be awesome to increase rtnh_hops size here.
But we can't, since it's defined at netlink specs.
So we pass the metric instead to avoid overflow below.

sys/netlink/route/rt.c
220

This is where I changed the rtnh_nhops from weight to metric.
But both kernel and userland (even outside the tree) should be okay with this change.
Since the value of weight was always incorrect anyway and now it actually mean something.

You can verify the invalid values by using route -n6 monitor and adding a weight bigger than 8-bit value.

227

To preserve the functionality. I return the weight using another well-known TLV here and I also document it in next revision.

907–908

If user filled the metric, add it to weight.
However, userland may want to directly set the weight and metric at the same time since we return the weight + metric value to them as a single value due to netlink spec restrictions.
In that case, ignore the metric.

Good for backward compatibility. Simple logic.

pouria retitled this revision from netlink: Fix weight overflow of RTA_MULTIPATH, use metric instead to netlink: Add RTA_PRIORITY support (metric).Thu, Apr 9, 10:51 PM
pouria edited the summary of this revision. (Show Details)
pouria edited the test plan for this revision. (Show Details)

There is a specific netlink attribute for metric.
Use that instead.

sys/netlink/route/rt.c
907–908

If user filled the metric, add it to weight.
However, userland may want to directly set the weight and metric at the same time since we return the weight + metric value to them as a single value due to netlink spec restrictions.
In that case, ignore the metric.

Good for backward compatibility. Simple logic.

With new attribute, I removed the dirty hack and the sentence above is no longer true.