Page MenuHomeFreeBSD

atf_python/vnet: Make it possible to set the FIB of vnet interfaces
Needs RevisionPublic

Authored by markj on Fri, Jan 30, 3:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Feb 1, 4:50 AM
Unknown Object (File)
Sun, Feb 1, 4:37 AM
Unknown Object (File)
Sun, Feb 1, 2:43 AM
Unknown Object (File)
Sun, Feb 1, 12:14 AM
Unknown Object (File)
Sun, Feb 1, 12:08 AM
Unknown Object (File)
Sat, Jan 31, 11:58 PM

Details

Reviewers
ngie
Group Reviewers
network
tests

Diff Detail

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

Event Timeline

zlei added inline comments.
tests/atf_python/sys/net/vnet.py
146

The 0 is a perfect valid fib number. Why not supporting setting fib 0 ?

ngie requested changes to this revision.Fri, Jan 30, 5:04 PM
ngie added a subscriber: ngie.
ngie added inline comments.
tests/atf_python/sys/net/vnet.py
60

Setting a default here would be wise: that allows you to skip a lot of the baked-in defaults elsewhere in the diff.

Other considerations:

  • It might be a really good idea to create a setter to validate the input argument before setting the value as well. typing.assert_type could help enforce the type, unless you want to get fancy and implement an isinstance / ValueError pattern, but you should also ensure that the domain is >= 0, since negative FIB values don't make sense.
  • It might be a good idea to use a constant here as well, e.g., NO_FIB.
146

No need for an explicit test, per PEP8.

381–384

General comment: using dict.get with hardcoded defaults sprinkled around instead of using explicit property variables adds a lot of fragile complexity in this module (and other API consumers):

  1. If defaults change, you now have to do a sweeping change to update all of the defaults around the module and the consumers.
  2. It makes it difficult to impossible for static analyzers like flake8 or ruff to figure out what's going on in the code.
This revision now requires changes to proceed.Fri, Jan 30, 5:04 PM
tests/atf_python/sys/net/vnet.py
146

Only because that's the default. But yes we could set it unconditionally. The only downside is an extra fork+exec per interface (which isn't free when running tests under QEMU).