Commit 85cbcd7c authored by Peter V. Saveliev's avatar Peter V. Saveliev

ifinfmsg: allow paths in the net_ns_fd NLA

Examples::

        # default netns location
        net_ns_fd = 'test'
        # in the current directory
        net_ns_fd = './test'
        # absolute path
        net_ns_fd = '/var/run/my_service/test'

Bug-Url: https://github.com/svinota/pyroute2/issues/317
parent e8ee4a29
......@@ -355,8 +355,11 @@ class ifinfbase(object):
if isinstance(self.value, int):
self['value'] = self.value
else:
self.netns_fd = os.open('%s/%s' % (self.netns_run_dir,
self.value), os.O_RDONLY)
if '/' in self.value:
netns_path = self.value
else:
netns_path = '%s/%s' % (self.netns_run_dir, self.value)
self.netns_fd = os.open(netns_path, os.O_RDONLY)
self['value'] = self.netns_fd
self.register_clean_cb(self.close)
nla.encode(self)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment