ifstate 1.13.1__py3-none-any.whl → 1.13.2__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ifstate
3
- Version: 1.13.1
3
+ Version: 1.13.2
4
4
  Summary: Manage host interface settings in a declarative manner
5
5
  Home-page: https://ifstate.net/
6
6
  Author: Thomas Liske
@@ -13,9 +13,9 @@ Requires-Dist: pyroute2
13
13
  Requires-Dist: pyyaml
14
14
  Requires-Dist: setproctitle
15
15
  Provides-Extra: shell
16
- Requires-Dist: pygments ; extra == 'shell'
16
+ Requires-Dist: pygments; extra == "shell"
17
17
  Provides-Extra: wireguard
18
- Requires-Dist: wgnlpy ; extra == 'wireguard'
18
+ Requires-Dist: wgnlpy; extra == "wireguard"
19
19
 
20
20
  # IfState
21
21
 
@@ -2,7 +2,7 @@ ifstate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  ifstate/ifstate.py,sha256=jNWVc-XPZOKwD--xSJvAXZP-DEomljmGXtMf8SAdmmU,8770
3
3
  ifstate/shell.py,sha256=7_JFpi4icr9MijynDzbb0v5mxhFsng6PCC4m3uQ255A,2177
4
4
  ifstate/vrrp.py,sha256=m-vkm_Yx82qx5RmTnouYceWpa1agziBUHr87yK9tBro,5542
5
- libifstate/__init__.py,sha256=0v7ECPwNFfreOiy5YidN9pHMmEol3gCIcEDFZ85I94w,30792
5
+ libifstate/__init__.py,sha256=huDCA228bd3MH4RnOD8_YishjW96RCO8R6QUQTBUe3Q,30950
6
6
  libifstate/exception.py,sha256=5i59BZdl56J_sNJbyU9n6uHuUNJEyDOO4FJ-neDn9Ds,2608
7
7
  libifstate/log.py,sha256=XVoZdwdQoWsjuupFIuG6OP0OrBpXpx7oqyAaUhQ-nJk,4553
8
8
  libifstate/util.py,sha256=vqNaa67QZ2G07bQNAisTyUKbVmp0JGkvEGgbKVTtmYA,10579
@@ -11,9 +11,9 @@ libifstate/bpf/__init__.py,sha256=NVzaunTmJU2PbIQg9eWBMKpFgLh3EnD3ujNa7Yt6rNc,76
11
11
  libifstate/bpf/ctypes.py,sha256=kLZJHZlba09Vc-tbsJAcKpDwdoNO2IjlYVLCopawHmA,4274
12
12
  libifstate/bpf/map.py,sha256=cLHNMvRBDNW2yVCEf3z242_oRdU0HqVbFEYVkKXng0w,10818
13
13
  libifstate/brport/__init__.py,sha256=NzdA8F4hr2se1bXKNnyKZbvOFlCWBq_cdjwsL1H0Y-o,2964
14
- libifstate/fdb/__init__.py,sha256=jMplRZZQKkgwFQT2L7Ua4YCdLKwOzkd43_6OFtet2No,6262
14
+ libifstate/fdb/__init__.py,sha256=9dpL5n8ct3CaA-z8I6ZEkD3yL6yWJQeq3fpIe9pc2zw,6486
15
15
  libifstate/link/__init__.py,sha256=epVw6jY8exNeJZUmmUas91yJoeupfgIY7rthq7SGIIw,142
16
- libifstate/link/base.py,sha256=UX_g8R5Hm9SbtezM2Hc6ED8rGk-LlchfNCOHmoE_OG0,33201
16
+ libifstate/link/base.py,sha256=5LicOYnsB-F3-qGhx8znqScrOdCLD4RIDOXDpSN9rB4,34256
17
17
  libifstate/link/dsa.py,sha256=Y3axTtcym6YL1voKblxctx4PoKDZHzpteKQNnEBUrS8,264
18
18
  libifstate/link/physical.py,sha256=cJiq-MCfy-3XQoU-OxzgfPZZtu_pJ8u2ioJgn9VYdGk,560
19
19
  libifstate/link/tun.py,sha256=m55o5cwO3h3DCLofUR-68fM4ggLoTKElp6ZJ2LrJSCc,959
@@ -29,9 +29,9 @@ libifstate/tc/__init__.py,sha256=inPdampCOIr_4oKNB3awqMkW0Eh4fpPh9jvSba6sPVg,120
29
29
  libifstate/wireguard/__init__.py,sha256=vM7vxioV9vQ3gq9SE_URf97ZfGhLsxNiam16y_gXZ5E,6225
30
30
  libifstate/xdp/__init__.py,sha256=X1xhEIGng7R5d5F4KsChykT2g6H-XBRWbWABijoYDQA,7208
31
31
  schema/ifstate.conf.schema.json,sha256=oDCBqgOI5uFbSjWUz9RcVmK-3i_90m3AMKA2uzGclRg,201291
32
- ifstate-1.13.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
33
- ifstate-1.13.1.dist-info/METADATA,sha256=1O1GTUtL-q0T6_QZctL8KntC-zC5RhHz7pnQHDaBlGw,1385
34
- ifstate-1.13.1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
35
- ifstate-1.13.1.dist-info/entry_points.txt,sha256=HF6jX7Uu_nF1Ly-J9uEPeiRapOxnM6LuHsb2y6Mt-k4,52
36
- ifstate-1.13.1.dist-info/top_level.txt,sha256=A7peI7aKBaM69fsiSPvMbL3rzTKZZr5qDxKC-pHMGdE,19
37
- ifstate-1.13.1.dist-info/RECORD,,
32
+ ifstate-1.13.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
33
+ ifstate-1.13.2.dist-info/METADATA,sha256=zAzGSLaKYExorE-9e2Y3bGmivS1tTar4exNN8AC7o8w,1383
34
+ ifstate-1.13.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
35
+ ifstate-1.13.2.dist-info/entry_points.txt,sha256=HF6jX7Uu_nF1Ly-J9uEPeiRapOxnM6LuHsb2y6Mt-k4,52
36
+ ifstate-1.13.2.dist-info/top_level.txt,sha256=A7peI7aKBaM69fsiSPvMbL3rzTKZZr5qDxKC-pHMGdE,19
37
+ ifstate-1.13.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
libifstate/__init__.py CHANGED
@@ -48,7 +48,7 @@ import json
48
48
  import errno
49
49
  import logging
50
50
 
51
- __version__ = "1.13.1"
51
+ __version__ = "1.13.2"
52
52
 
53
53
 
54
54
  class IfState():
@@ -111,6 +111,9 @@ class IfState():
111
111
  self.ipaddr_ignore = set()
112
112
  for ip in self.ignore.get('ipaddr', []):
113
113
  self.ipaddr_ignore.add(ip_network(ip))
114
+ self.fdb_ignore = None
115
+ if self.ignore.get('fdb'):
116
+ self.fdb_ignore = re.compile('|'.join(self.ignore.get('fdb')))
114
117
 
115
118
  # save cshaper profiles
116
119
  self.cshaper_profiles = ifstates['cshaper']
@@ -598,7 +601,7 @@ class IfState():
598
601
  'ipaddr_dynamic', True), do_apply)
599
602
 
600
603
  if ifname in netns.fdb:
601
- netns.fdb[ifname].apply(do_apply)
604
+ netns.fdb[ifname].apply(self.fdb_ignore, do_apply)
602
605
 
603
606
  if ifname in netns.neighbours:
604
607
  netns.neighbours[ifname].apply(do_apply)
@@ -88,7 +88,7 @@ class FDB():
88
88
 
89
89
  return fdb
90
90
 
91
- def apply(self, do_apply):
91
+ def apply(self, fdb_ignore_re, do_apply):
92
92
  logger.debug('getting fdb', extra={'iface': self.iface})
93
93
 
94
94
  # get ifindex and lladdr
@@ -108,41 +108,12 @@ class FDB():
108
108
  if linkinfo and linkinfo.get_attr('IFLA_INFO_KIND') in ['vxlan']:
109
109
  default_state |= NUD_NOARP
110
110
 
111
- # configure fdb entries
112
- ipr_entries = self.get_kernel_fdb()
111
+ # set default_state if missing
113
112
  for lladdr, entries in self.fdb.items():
114
113
  for entry in entries:
115
- # set default_state if missing
116
114
  if not 'state' in entry:
117
115
  entry['state'] = default_state
118
116
 
119
- # check if fdb entry is already present
120
- if lladdr in ipr_entries:
121
- if entry in ipr_entries[lladdr]:
122
- logger.log_ok('fdb', '= {}'.format(lladdr))
123
- continue
124
-
125
- # fdb entry needs to be added
126
- logger.log_add('fdb', '+ {}'.format(lladdr))
127
-
128
- # prepare arguments
129
- args = {
130
- 'ifindex': self.idx,
131
- 'family': AF_BRIDGE
132
- }
133
- args.update(entry)
134
- logger.debug("bridge fdb append: {}".format(
135
- " ".join("{}={}".format(k, v) for k, v in args.items())))
136
-
137
- if do_apply:
138
- try:
139
- self.netns.ipr.fdb("append", **args)
140
- except Exception as err:
141
- if not isinstance(err, netlinkerror_classes):
142
- raise
143
- logger.warning('add {} to fdb failed: {}'.format(
144
- entry['lladdr'], err.args[1]))
145
-
146
117
  # cleanup orphan fdb entries
147
118
  ipr_entries = self.get_kernel_fdb()
148
119
  for lladdr, entries in ipr_entries.items():
@@ -150,6 +121,10 @@ class FDB():
150
121
  if lladdr == self.lladdr:
151
122
  continue
152
123
 
124
+ # skip ignored lladdr
125
+ if fdb_ignore_re is not None and fdb_ignore_re.match(lladdr):
126
+ continue
127
+
153
128
  for entry in entries:
154
129
  # check if fdb entry is already present
155
130
  if lladdr not in self.fdb or entry not in self.fdb[lladdr]:
@@ -172,3 +147,34 @@ class FDB():
172
147
  raise
173
148
  logger.warning('remove {} from fdb failed: {}'.format(
174
149
  entry['lladdr'], err.args[1]))
150
+
151
+ # configure fdb entries
152
+ ipr_entries = self.get_kernel_fdb()
153
+ for lladdr, entries in self.fdb.items():
154
+ for entry in entries:
155
+ # check if fdb entry is already present
156
+ if lladdr in ipr_entries:
157
+ if entry in ipr_entries[lladdr]:
158
+ logger.log_ok('fdb', '= {}'.format(lladdr))
159
+ continue
160
+
161
+ # fdb entry needs to be added
162
+ logger.log_add('fdb', '+ {}'.format(lladdr))
163
+
164
+ # prepare arguments
165
+ args = {
166
+ 'ifindex': self.idx,
167
+ 'family': AF_BRIDGE
168
+ }
169
+ args.update(entry)
170
+ logger.debug("bridge fdb append: {}".format(
171
+ " ".join("{}={}".format(k, v) for k, v in args.items())))
172
+
173
+ if do_apply:
174
+ try:
175
+ self.netns.ipr.fdb("append", **args)
176
+ except Exception as err:
177
+ if not isinstance(err, netlinkerror_classes):
178
+ raise
179
+ logger.warning('add {} to fdb failed: {}'.format(
180
+ entry['lladdr'], err.args[1]))
libifstate/link/base.py CHANGED
@@ -66,6 +66,11 @@ class Link(ABC):
66
66
  1: "bandwidth",
67
67
  2: "count",
68
68
  },
69
+ # === bridge ===
70
+ 'br_vlan_protocol': {
71
+ 0x88a8: '802.1ad',
72
+ 0x8100: '802.1q',
73
+ },
69
74
  # === tuntap ===
70
75
  'tun_type': {
71
76
  1: 'tun',
@@ -104,6 +109,12 @@ class Link(ABC):
104
109
  'wireguard',
105
110
  'xfrm',
106
111
  ]
112
+ # the attributes will be unset using an emptry string,
113
+ # if unset they are not return via netlink and handled
114
+ # as a `None` value in ifstate
115
+ attr_empty_unset = [
116
+ 'ifalias',
117
+ ]
107
118
 
108
119
  def __new__(cls, *args, **kwargs):
109
120
  cname = cls.__name__
@@ -208,6 +219,10 @@ class Link(ABC):
208
219
  if 'bind_netns' in self.settings:
209
220
  del(self.settings['bind_netns'])
210
221
 
222
+ for attr in self.attr_empty_unset:
223
+ if attr in self.settings and self.settings[attr] == "":
224
+ self.settings[attr] = None
225
+
211
226
  def search_link_registry(self):
212
227
  for args in self.link_registry_search_args:
213
228
  item = self.ifstate.link_registry.get_link(**args)
@@ -723,6 +738,12 @@ class Link(ABC):
723
738
  if setting in self.settings:
724
739
  skipped_settings[setting] = self.settings.pop(setting)
725
740
 
741
+ # handle settings which are unset using empty strings (i.e. ifstate)
742
+ for setting in self.attr_empty_unset:
743
+ if setting in self.settings and self.settings[setting] == None:
744
+ skipped_settings[setting] = self.settings.pop(setting)
745
+ self.settings[setting] = ""
746
+
726
747
  if has_ifname_change:
727
748
  self.prevent_altname_conflict()
728
749
 
@@ -738,6 +759,10 @@ class Link(ABC):
738
759
  # None index references are configuration via the invalid ifindex 0
739
760
  value = 0
740
761
 
762
+ # these attributes are not returned if unset (i.e. ifstate)
763
+ if setting in self.attr_empty_unset and value == None:
764
+ value = ""
765
+
741
766
  if value != self.settings[setting]:
742
767
  if self.cap_create:
743
768
  logger.debug(' %s: setting could not be changed', setting, extra={'iface': self.settings['ifname']})