summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-10 07:24:00 +0000
committerGerrit Code Review <review@openstack.org>2019-01-10 07:24:00 +0000
commit6749ebec192b5a3d65f0834ff9e3af5111458ba3 (patch)
tree74139bc91dfb5fd8279490e2765115ef58ee7613
parent4cddf62bbe571472c453c8c9e86bc4ea0e65d5ba (diff)
parentc6d358d4c6926638fe9d5194e3da112c2750c6a4 (diff)
Merge "Define types for C calls in netlink_lib"
-rw-r--r--neutron/privileged/agent/linux/netlink_lib.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/neutron/privileged/agent/linux/netlink_lib.py b/neutron/privileged/agent/linux/netlink_lib.py
index 8a10a0c..71ce3b0 100644
--- a/neutron/privileged/agent/linux/netlink_lib.py
+++ b/neutron/privileged/agent/linux/netlink_lib.py
@@ -49,9 +49,44 @@ from neutron.privileged.agent.linux import netlink_constants as nl_constants
49 49
50LOG = logging.getLogger(__name__) 50LOG = logging.getLogger(__name__)
51 51
52nfct = ctypes.CDLL(util.find_library('netfilter_conntrack')) 52nfct_lib = util.find_library('netfilter_conntrack')
53nfct = ctypes.CDLL(nfct_lib)
53libc = ctypes.CDLL(util.find_library('libc.so.6')) 54libc = ctypes.CDLL(util.find_library('libc.so.6'))
54 55
56# In unit tests the actual nfct library may not be installed, and since we
57# don't make actual calls to it we don't want to add a hard dependency.
58if nfct_lib:
59 # It's important that the types be defined properly on all of the functions
60 # we call from nfct, otherwise pointers can be truncated and cause
61 # segfaults.
62 nfct.nfct_set_attr.argtypes = [ctypes.c_void_p,
63 ctypes.c_int,
64 ctypes.c_void_p]
65 nfct.nfct_set_attr_u8.argtypes = [ctypes.c_void_p,
66 ctypes.c_int,
67 ctypes.c_uint8]
68 nfct.nfct_set_attr_u16.argtypes = [ctypes.c_void_p,
69 ctypes.c_int,
70 ctypes.c_uint16]
71 nfct.nfct_snprintf.argtypes = [ctypes.c_char_p,
72 ctypes.c_uint,
73 ctypes.c_void_p,
74 ctypes.c_uint,
75 ctypes.c_uint,
76 ctypes.c_uint]
77 nfct.nfct_new.restype = ctypes.c_void_p
78 nfct.nfct_destroy.argtypes = [ctypes.c_void_p]
79 nfct.nfct_query.argtypes = [ctypes.c_void_p,
80 ctypes.c_int,
81 ctypes.c_void_p]
82 nfct.nfct_callback_register.argtypes = [ctypes.c_void_p,
83 ctypes.c_int,
84 ctypes.c_void_p,
85 ctypes.c_void_p]
86 nfct.nfct_open.restype = ctypes.c_void_p
87 nfct.nfct_close.argtypes = [ctypes.c_void_p]
88
89
55IP_VERSIONS = [constants.IP_VERSION_4, constants.IP_VERSION_6] 90IP_VERSIONS = [constants.IP_VERSION_4, constants.IP_VERSION_6]
56DATA_CALLBACK = None 91DATA_CALLBACK = None
57 92