Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for Linux VRFs #1744

Merged
merged 2 commits into from
Oct 16, 2020
Merged

Conversation

milanlenco
Copy link
Collaborator

@milanlenco milanlenco commented Oct 14, 2020

This PR contains these changes in proto:

  • adds new special type of linux interface VRF_DEVICE
  • adds new field VrfMasterInterface to linux interface

Documentation for Linux VRF:

@codecov
Copy link

codecov bot commented Oct 14, 2020

Codecov Report

Merging #1744 into master will decrease coverage by 1.41%.
The diff coverage is 82.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1744      +/-   ##
==========================================
- Coverage   57.11%   55.69%   -1.42%     
==========================================
  Files         618      379     -239     
  Lines       44654    27954   -16700     
==========================================
- Hits        25502    15569    -9933     
+ Misses      16192    10895    -5297     
+ Partials     2960     1490    -1470     
Flag Coverage Δ
#e2e ?
#unittests 55.69% <82.97%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

func (d *InterfaceDescriptor) enableL3MasterDev() error {
value, err := getSysctl(sysctlL3MDevVar)
if err != nil {
err = fmt.Errorf("could not read sysctl value for %s: %v",
Copy link
Member

@ondrej-fabry ondrej-fabry Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use the format specifier with %w for error values, so they can be unwrapped by the caller(s) using Unwrap in the errors package.

quoted from fmt.Errorf docs:

If the format specifier includes a %w verb with an error operand, the returned error will implement an Unwrap method returning the operand. It is invalid to include more than one %w verb or to supply it with an operand that does not implement the error interface. The %w verb is otherwise a synonym for %v.

@@ -68,6 +68,8 @@ type LinuxIfMetadata struct {
VPPTapName string // empty for VETHs
Namespace *linux_namespace.NetNamespace
HostIfName string
Vrf string
VrfDevRT int // only set for VRF_DEVICE
Copy link
Member

@ondrej-fabry ondrej-fabry Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be uint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it should be and will change it.
I used int only because netlink package also uses it for the table ID, but negative values would not be valid, so...

Copy link
Member

@ondrej-fabry ondrej-fabry Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I see they use int, but only in Route. In the Vrf uint32 is used.

@ondrej-fabry ondrej-fabry added this to the v3.2.0 milestone Oct 14, 2020
// VRF to which this interface should be assigned to.
// The field should reference the logical name of a VRF device (i.e. instance of this Interface model with
// VRF_DEVICE type).
string vrf = 10;
Copy link
Member

@ondrej-fabry ondrej-fabry Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the naming vrf here.. since we use namings with *_interface/*interfaces practically everywhere else where interface is referenced (route, arps, iptables..).

I think using vrf_interface is more consistent and possibly clearer to the users that this should be interface and not name/ID of VRF/routing table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about vrf_master_interface or shorter variant vrf_master_if?
Just to make it more clear that what is being referenced is not some random interface inside a VRF, but the interface implementing VRF as a whole.
(master/slave terminology is not very popular these days but that's how they call it in Linux - ip link set dev eth1 master vrf-blue is said to enslave eth1 under vrf-blue interface/device)

Copy link
Member

@ondrej-fabry ondrej-fabry Oct 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I think that's okay anything better than just vrf because it's interface and not routing table/VRF ID like in case of VPP VRFs.

Signed-off-by: Milan Lenco <milan.lenco@pantheon.tech>
@milanlenco
Copy link
Collaborator Author

PR updated after the review.

ondrej-fabry
ondrej-fabry previously approved these changes Oct 16, 2020
Table: routingTable,
}
if err := netlink.LinkAdd(link); err != nil {
return errors.Wrapf(err, "failed to add VRF device: LinkAdd (vrf=%s, rt=%d)",
Copy link
Member

@ondrej-fabry ondrej-fabry Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part with failed to add VRF device: should not be added here, because it is already added by the caller, so it is redundant and would make the error look like:

...: creating X interface failed: failed to add VRF device X (rt: Z): failed to add VRF device: LinkAdd (vrf=Y, rt=Z)

Usually, errors returned to caller should only add context info that caller does not know about.

In this case failed to **add VRF device** is not needed because caller already knows it called AddVRFDevice function. What it does not know that this function failed during call to LinkAdd so that part is adding useful context info to the error.

Signed-off-by: Milan Lenco <milan.lenco@pantheon.tech>
@ondrej-fabry ondrej-fabry merged commit 81136ae into ligato:master Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants