ifstate 1.10.0__tar.gz → 1.10.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ifstate-1.10.0 → ifstate-1.10.1}/PKG-INFO +1 -1
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/PKG-INFO +1 -1
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/__init__.py +8 -2
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/netns/__init__.py +6 -6
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/util.py +50 -1
- {ifstate-1.10.0 → ifstate-1.10.1}/schema/ifstate.conf.schema.json +2 -2
- {ifstate-1.10.0 → ifstate-1.10.1}/LICENSE +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/README.md +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate/ifstate.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate/shell.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/SOURCES.txt +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/dependency_links.txt +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/entry_points.txt +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/requires.txt +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/ifstate.egg-info/top_level.txt +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/address/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/bpf/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/bpf/ctypes.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/bpf/map.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/brport/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/exception.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/fdb/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/link/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/link/base.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/link/physical.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/link/tun.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/link/veth.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/log.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/neighbour/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/parser/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/parser/base.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/parser/yaml.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/routing/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/sysctl/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/tc/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/wireguard/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/libifstate/xdp/__init__.py +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/setup.cfg +0 -0
- {ifstate-1.10.0 → ifstate-1.10.1}/setup.py +0 -0
@@ -8,6 +8,7 @@ from libifstate.parser import Parser
|
|
8
8
|
from libifstate.tc import TC
|
9
9
|
from libifstate.exception import netlinkerror_classes
|
10
10
|
import bisect
|
11
|
+
import pyroute2
|
11
12
|
|
12
13
|
from pyroute2.netlink.rtnl.ifaddrmsg import IFA_F_PERMANENT
|
13
14
|
try:
|
@@ -46,7 +47,7 @@ import json
|
|
46
47
|
import errno
|
47
48
|
import logging
|
48
49
|
|
49
|
-
__version__ = "1.10.
|
50
|
+
__version__ = "1.10.1"
|
50
51
|
|
51
52
|
|
52
53
|
class IfState():
|
@@ -122,8 +123,13 @@ class IfState():
|
|
122
123
|
self._update(self.root_netns, ifstates)
|
123
124
|
if 'namespaces' in ifstates:
|
124
125
|
self.namespaces = {}
|
126
|
+
self.new_namespaces = []
|
125
127
|
for netns_name, netns_ifstates in ifstates['namespaces'].items():
|
128
|
+
is_new = netns_name not in pyroute2.netns.listnetns()
|
126
129
|
self.namespaces[netns_name] = NetNameSpace(netns_name)
|
130
|
+
if is_new:
|
131
|
+
self.new_namespaces.append(netns_name)
|
132
|
+
self.link_registry.inventory_netns(self.namespaces[netns_name])
|
127
133
|
self._update(self.namespaces[netns_name], netns_ifstates)
|
128
134
|
|
129
135
|
def _update(self, netns, ifstates):
|
@@ -415,7 +421,7 @@ class IfState():
|
|
415
421
|
|
416
422
|
# create and destroy namespaces to match config
|
417
423
|
if not by_vrrp and self.namespaces is not None:
|
418
|
-
prepare_netns(do_apply, self.namespaces.keys())
|
424
|
+
prepare_netns(do_apply, self.namespaces.keys(), self.new_namespaces)
|
419
425
|
logger.info("")
|
420
426
|
|
421
427
|
# get link dependency tree
|
@@ -63,17 +63,17 @@ class NetNameSpace():
|
|
63
63
|
else:
|
64
64
|
peer_ipr = netns_name_map[peer_netns_name]
|
65
65
|
peer_pid = peer_ipr.child
|
66
|
-
|
66
|
+
|
67
67
|
result = self.ipr.get_netnsid(pid=peer_pid)
|
68
68
|
if result['nsid'] == 4294967295:
|
69
69
|
self.ipr.set_netnsid(pid=peer_pid)
|
70
70
|
result = self.ipr.get_netnsid(pid=peer_pid)
|
71
|
-
|
71
|
+
|
72
72
|
peer_nsid = result['nsid']
|
73
73
|
|
74
74
|
return (peer_ipr, peer_nsid)
|
75
75
|
|
76
|
-
def prepare_netns(do_apply, target_netns_list):
|
76
|
+
def prepare_netns(do_apply, target_netns_list, new_netns_list):
|
77
77
|
logger.info("configure network namespaces...")
|
78
78
|
|
79
79
|
# get mapping of netns names to lists of pids
|
@@ -96,7 +96,7 @@ def prepare_netns(do_apply, target_netns_list):
|
|
96
96
|
pyroute2.netns.remove(name)
|
97
97
|
|
98
98
|
# create missing netns
|
99
|
-
elif name not in current_netns_list:
|
99
|
+
elif name not in current_netns_list or name in new_netns_list:
|
100
100
|
logger.log_add(name)
|
101
101
|
|
102
102
|
# log already existing namespaces
|
@@ -135,7 +135,7 @@ class LinkRegistry():
|
|
135
135
|
self.ignores = ignores
|
136
136
|
|
137
137
|
for namespace in namespaces:
|
138
|
-
self.
|
138
|
+
self.inventory_netns(namespace)
|
139
139
|
|
140
140
|
if logger.getEffectiveLevel() <= logging.DEBUG:
|
141
141
|
self.debug_dump()
|
@@ -155,7 +155,7 @@ class LinkRegistry():
|
|
155
155
|
return link
|
156
156
|
return None
|
157
157
|
|
158
|
-
def
|
158
|
+
def inventory_netns(self, target_netns):
|
159
159
|
for link in target_netns.ipr.get_links():
|
160
160
|
self.registry.append(LinkRegistryItem(
|
161
161
|
self,
|
@@ -2,7 +2,8 @@ from libifstate.log import logger, IfStateLogging
|
|
2
2
|
from pyroute2 import IPRoute, NetNS, netns
|
3
3
|
|
4
4
|
from pyroute2.netlink.rtnl.tcmsg import tcmsg
|
5
|
-
from pyroute2.netlink.rtnl import RTM_DELTFILTER
|
5
|
+
from pyroute2.netlink.rtnl import RTM_DELTFILTER, RTM_NEWNSID
|
6
|
+
from pyroute2.netlink.rtnl.nsidmsg import nsidmsg
|
6
7
|
from pyroute2.netlink import NLM_F_REQUEST
|
7
8
|
from pyroute2.netlink import NLM_F_ACK
|
8
9
|
from pyroute2.netlink import NLM_F_CREATE
|
@@ -139,6 +140,30 @@ class IPRouteExt(IPRoute):
|
|
139
140
|
|
140
141
|
return link.get_attr('IFLA_IFNAME')
|
141
142
|
|
143
|
+
def set_netnsid(self, nsid=None, pid=None, fd=None):
|
144
|
+
'''
|
145
|
+
call pyroute2's set_netnsid if available or use
|
146
|
+
fallback implementation for pyroute2 <=0.79
|
147
|
+
'''
|
148
|
+
if hasattr(super(), 'set_netnsid'):
|
149
|
+
return super().set_netnsid(nsid, pid, fd)
|
150
|
+
else:
|
151
|
+
msg = nsidmsg()
|
152
|
+
|
153
|
+
if nsid is None or nsid < 0:
|
154
|
+
# kernel auto select
|
155
|
+
msg['attrs'].append(('NETNSA_NSID', 4294967295))
|
156
|
+
else:
|
157
|
+
msg['attrs'].append(('NETNSA_NSID', nsid))
|
158
|
+
|
159
|
+
if pid is not None:
|
160
|
+
msg['attrs'].append(('NETNSA_PID', pid))
|
161
|
+
|
162
|
+
if fd is not None:
|
163
|
+
msg['attrs'].append(('NETNSA_FD', fd))
|
164
|
+
|
165
|
+
return self.nlm_request(msg, RTM_NEWNSID, NLM_F_REQUEST | NLM_F_ACK)
|
166
|
+
|
142
167
|
class NetNSExt(NetNS):
|
143
168
|
def __init__(self, *args, **kwargs):
|
144
169
|
super().__init__(*args, **kwargs)
|
@@ -226,6 +251,30 @@ class NetNSExt(NetNS):
|
|
226
251
|
|
227
252
|
return link.get_attr('IFLA_IFNAME')
|
228
253
|
|
254
|
+
def set_netnsid(self, nsid=None, pid=None, fd=None):
|
255
|
+
'''
|
256
|
+
call pyroute2's set_netnsid if available or use
|
257
|
+
fallback implementation for pyroute2 <=0.79
|
258
|
+
'''
|
259
|
+
if hasattr(super(), 'set_netnsid'):
|
260
|
+
return super().set_netnsid(nsid, pid, fd)
|
261
|
+
else:
|
262
|
+
msg = nsidmsg()
|
263
|
+
|
264
|
+
if nsid is None or nsid < 0:
|
265
|
+
# kernel auto select
|
266
|
+
msg['attrs'].append(('NETNSA_NSID', 4294967295))
|
267
|
+
else:
|
268
|
+
msg['attrs'].append(('NETNSA_NSID', nsid))
|
269
|
+
|
270
|
+
if pid is not None:
|
271
|
+
msg['attrs'].append(('NETNSA_PID', pid))
|
272
|
+
|
273
|
+
if fd is not None:
|
274
|
+
msg['attrs'].append(('NETNSA_FD', fd))
|
275
|
+
|
276
|
+
return self.nlm_request(msg, RTM_NEWNSID, NLM_F_REQUEST | NLM_F_ACK)
|
277
|
+
|
229
278
|
class LinkDependency:
|
230
279
|
def __init__(self, ifname, netns):
|
231
280
|
self.ifname = ifname
|
@@ -2,7 +2,7 @@
|
|
2
2
|
"$id": "https://ifstate.net/schema/ifstate.conf.schema.json",
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
4
4
|
"title": "ifstate.conf",
|
5
|
-
"description": "IfState 1.
|
5
|
+
"description": "IfState 1.10.1 Configuration Schema",
|
6
6
|
"type": "object",
|
7
7
|
"required": [
|
8
8
|
"interfaces"
|
@@ -2853,7 +2853,7 @@
|
|
2853
2853
|
"description": "XFRM interface",
|
2854
2854
|
"required": [
|
2855
2855
|
"kind",
|
2856
|
-
"
|
2856
|
+
"xfrm_if_id"
|
2857
2857
|
],
|
2858
2858
|
"additionalProperties": false,
|
2859
2859
|
"properties": {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|