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

Improve efficiency of lxc_ifname_alnum_case_sensitive #3487

Merged
merged 1 commit into from
Jul 17, 2020
Merged

Improve efficiency of lxc_ifname_alnum_case_sensitive #3487

merged 1 commit into from
Jul 17, 2020

Conversation

samboyles1
Copy link
Contributor

To detect if a newly generated interface name is a duplicate of an existing interface lxc_ifname_alnum_case_sensitive() currently gets a list of all interfaces using netns_getifaddrs(). When the system has a small number of interfaces this works fine, however when there are thousands or tens of thousands of interfaces this quickly becomes less than optimal.

As we only need to check if an interface name exists, and do not need the detailed information about the interfaces provided by netns_getifaddrs(), we can instead use the if_nametoindex() function, which is much more efficient.

Signed-off-by: Sam Boyles sam.boyles@alliedtelesis.co.nz

To detect if a newly generated interface name is a duplicate of an existing interface lxc_ifname_alnum_case_sensitive() currently gets a list of all interfaces using netns_getifaddrs(). When the system has a small number of interfaces this works fine, however when there are thousands or tens of thousands of interfaces this quickly becomes less than optimal.

As we only need to check if an interface name exists, and do not need the detailed information about the interfaces provided by netns_getifaddrs(), we can instead use the if_nametoindex() function, which is much more efficient.

Signed-off-by: Sam Boyles <sam.boyles@alliedtelesis.co.nz>
@lxc-jenkins
Copy link

This pull request didn't trigger Jenkins as its author isn't in the whitelist.

An organization member must perform one of the following:

  • To have this branch tested by Jenkins, use the "ok to test" command.
  • To have a one time test done, use the "test this please" command.

Those commands are simple Github comments of the format: "jenkins: COMMAND"

@brauner
Copy link
Member

brauner commented Jul 17, 2020

jenkins: test this please

break;
}
Copy link
Member

Choose a reason for hiding this comment

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

The only tiny thing I have is: We don't do {} around single-line if statements. :)

@lxc-jenkins
Copy link

Testsuite passed

@brauner brauner merged commit 8bbca3c into lxc:master Jul 17, 2020
@brauner
Copy link
Member

brauner commented Jul 17, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants