]> git.ipfire.org Git - thirdparty/lxc.git/commit
Improve efficiency of lxc_ifname_alnum_case_sensitive 3487/head
authorSam Boyles <sam.boyles42@gmail.com>
Fri, 17 Jul 2020 02:26:51 +0000 (14:26 +1200)
committerGitHub <noreply@github.com>
Fri, 17 Jul 2020 02:26:51 +0000 (14:26 +1200)
commit4810a7a3e6423c85690676474976ee54c3733c9e
tree237acb962c334320f366bb0c9a18a5b39cc295cb
parent19be19a35249038495dc6fc0e162ec0e5ddb4804
Improve efficiency of lxc_ifname_alnum_case_sensitive

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>
src/lxc/network.c