Browse Source

Merge "Load the glibc library only once for Pyroute2" into stable/rocky

changes/60/749960/2
Zuul 5 months ago
committed by Gerrit Code Review
parent
commit
5936e4cea9
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      neutron/privileged/agent/linux/ip_lib.py

+ 13
- 2
neutron/privileged/agent/linux/ip_lib.py View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import ctypes
from ctypes import util as ctypes_util
import errno
import socket
@ -30,6 +32,15 @@ LOG = logging.getLogger(__name__)
_IP_VERSION_FAMILY_MAP = {4: socket.AF_INET, 6: socket.AF_INET6}
_CDLL = None
def _get_cdll():
global _CDLL
if not _CDLL:
_CDLL = ctypes.CDLL(ctypes_util.find_library('c'), use_errno=True)
return _CDLL
def _get_scope_name(scope):
"""Return the name of the scope (given as a number), or the scope number
@ -423,7 +434,7 @@ def create_netns(name, **kwargs):
:param name: The name of the namespace to create
"""
try:
netns.create(name, **kwargs)
netns.create(name, libc=_get_cdll())
except OSError as e:
if e.errno != errno.EEXIST:
raise
@ -436,7 +447,7 @@ def remove_netns(name, **kwargs):
:param name: The name of the namespace to remove
"""
try:
netns.remove(name, **kwargs)
netns.remove(name, libc=_get_cdll())
except OSError as e:
if e.errno != errno.ENOENT:
raise


Loading…
Cancel
Save