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

expose mac address as part of networks-status in pod yaml #240

Merged

Conversation

SchSeba
Copy link
Collaborator

@SchSeba SchSeba commented Feb 2, 2023

this commit passes the mac address in the cni result.

this will also work in case the vf uses a user-space driver like vfio as we have the mac address for it from the PF

Signed-off-by: Sebastian Sch sebassch@gmail.com

@SchSeba SchSeba requested a review from adrianchiris February 2, 2023 10:21
@SchSeba
Copy link
Collaborator Author

SchSeba commented Feb 2, 2023

should be merged after #239

@coveralls
Copy link

coveralls commented Feb 2, 2023

Pull Request Test Coverage Report for Build 5045314882

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 4 of 9 (44.44%) changed or added relevant lines in 1 file are covered.
  • 116 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.1%) to 38.285%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/sriov/sriov.go 4 9 44.44%
Files with Coverage Reduction New Missed Lines %
pkg/utils/testing.go 21 59.65%
pkg/utils/utils.go 25 41.67%
pkg/sriov/sriov.go 70 37.65%
Totals Coverage Status
Change from base Build 4993903956: 0.1%
Covered Lines: 433
Relevant Lines: 1131

💛 - Coveralls

pkg/sriov/sriov.go Outdated Show resolved Hide resolved
pkg/sriov/sriov.go Outdated Show resolved Hide resolved
@SchSeba SchSeba force-pushed the expose_mac_address branch from c04f663 to 37f5417 Compare May 2, 2023 08:29
@SchSeba
Copy link
Collaborator Author

SchSeba commented May 2, 2023

Hi @adrianchiris when you have time please take a look :)

cmd/sriov/main.go Outdated Show resolved Hide resolved
pkg/types/types.go Outdated Show resolved Hide resolved
pkg/sriov/sriov.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
pkg/sriov/sriov.go Outdated Show resolved Hide resolved
@SchSeba SchSeba force-pushed the expose_mac_address branch from 37f5417 to 340d370 Compare May 22, 2023 11:39
@SchSeba SchSeba force-pushed the expose_mac_address branch from 340d370 to fd3bad0 Compare June 11, 2023 13:04
pkg/sriov/sriov.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
@SchSeba SchSeba force-pushed the expose_mac_address branch from fd3bad0 to fc28be5 Compare June 14, 2023 12:16
@mlguerrero12
Copy link
Contributor

LGTM, thanks @SchSeba

cmd/sriov/main.go Outdated Show resolved Hide resolved
@SchSeba SchSeba force-pushed the expose_mac_address branch 4 times, most recently from e377e15 to a78912a Compare June 21, 2023 11:18
Copy link
Member

@zeeke zeeke left a comment

Choose a reason for hiding this comment

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

LGTM

// if the device is on kernel mode we report that one back
// if not we check the administrative mac address on the PF
// if it is set and is not zero, report it.
func GetMacAddressToReport(netConf *sriovtypes.NetConf) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

i like the name in the comment better :) (GetMacAddressForResult)

that said, please align one to the other if u prefer GetMacAddressToReport

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

the commit allow to expose the mac address in the cni result object
also for devices that are attached to user-space drivers like vfio

mac address selection method:
1. if the vf is attached to the kernel use it
2. if the vf is attached to user-space driver check the vf admin mac
2.1 if the vf admin mac is not 0 publish it
2.2 if the vf admin mac is 0 don't publish the info

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@SchSeba SchSeba force-pushed the expose_mac_address branch from a78912a to 33f3ed9 Compare June 22, 2023 15:32
// if not we check the administrative mac address on the PF
// if it is set and is not zero, report it.
func GetMacAddressForResult(netConf *sriovtypes.NetConf) string {
if netConf.MAC != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this statement ?

if MAC is specified then we set as admin mac and in non-dpdk we set as effective as well.
so the two statements below will cover it.

plus it will match the description of the method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will not work for DPDK + static mac.
because we use netConf.OrigVfState.AdminMAC that contains the original adminMac not the static one we request in the MAC object

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed the fact that what we return below is the "Original" VF state so indeed when we override, the only place we keep that value is in netconf.MAC

sorry for the confusion.

@adrianchiris adrianchiris merged commit 4dcc2db into k8snetworkplumbingwg:master Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants