Skip to content

Commit 21679ab

Browse files
committed
added more mask entries, improved kmod error handling and dependency
checking Signed-off-by: Zen <[email protected]>
1 parent 976ee1d commit 21679ab

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

src/ugrd/kmod/kmod.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class DependencyResolutionError(Exception):
1313
pass
1414

1515

16+
class IgnoredKernelModuleError(Exception):
17+
pass
18+
19+
1620
def _process_kmod_ignore_multi(self, module: str) -> None:
1721
"""
1822
Adds ignored modules to self['kmod_ignore'].
@@ -40,17 +44,17 @@ def _process_kernel_modules_multi(self, module: str) -> None:
4044
Adds the passed kernel module to self['kernel_modules']
4145
Checks if the module is ignored
4246
"""
43-
if module in self['kmod_ignore']:
44-
self.logger.warning("Not adding ignored kernel module to kernel_modules: %s" % module)
45-
_remove_kmod(self, module, 'Ignored')
46-
return
47-
4847
try:
4948
_get_kmod_info(self, module)
50-
except DependencyResolutionError:
51-
if module in self['kmod_init'] or module in self['_kmod_depend']:
52-
raise DependencyResolutionError("Failed to get modinfo for kernel required module: %s" % module)
53-
self.logger.error("Failed to get modinfo for kernel module: %s" % module)
49+
except IgnoredKernelModuleError:
50+
self.logger.debug("[%s] Kernel module is in ignore list." % module)
51+
return
52+
except DependencyResolutionError as e:
53+
if module in self['_kmod_depend']:
54+
raise DependencyResolutionError("Failed to get modinfo for required kernel module: %s" % module)
55+
elif module in self['kmod_init']:
56+
self.logger.warning("Failed to get modinfo for init kernel module: %s" % module)
57+
self.logger.debug("[%s] Failed to get modinfo for kernel module: %s" % (module, e))
5458
self['kmod_ignore'] = module
5559
return
5660

@@ -70,8 +74,9 @@ def _process_kernel_modules_multi(self, module: str) -> None:
7074

7175
for dependency in dependencies:
7276
if dependency in self['kmod_ignore']:
73-
self.logger.error("Kernel module dependency is in ignore list: %s" % dependency)
77+
self.logger.warning("[%s] Kernel module dependency is in ignore list: %s" % (module, dependency))
7478
self['kmod_ignore'] = module
79+
return
7580
self.logger.debug("[%s] Processing dependency: %s" % (module, dependency))
7681
self['kernel_modules'] = dependency
7782

@@ -85,10 +90,13 @@ def _process_kernel_modules_multi(self, module: str) -> None:
8590

8691
def _process_kmod_init_multi(self, module: str) -> None:
8792
""" Adds init modules to self['kernel_modules']. """
93+
if module in self['kmod_ignore']:
94+
self.logger.debug("[%s] Module is in ignore list." % module)
95+
return
8896
# First append it to kmod_init
8997
self['kmod_init'].append(module)
9098
self.logger.debug("Adding kmod_init module to kernel_modules: %s", module)
91-
# If it's an ignored module, kernel_modules processing will resolve that issue
99+
# If it has ignored dependencies, kernel_modules processing will resolve that issue
92100
self['kernel_modules'] = module
93101

94102

@@ -98,6 +106,9 @@ def _get_kmod_info(self, module: str):
98106
self.logger.log(5, "Module info already exists for: %s" % module)
99107
return
100108

109+
if module in self['kmod_ignore']:
110+
raise IgnoredKernelModuleError("[%s] Module is in ignore list." % module)
111+
101112
args = ['modinfo', module]
102113
# Set kernel version if it exists, otherwise use the running kernel
103114
if self.get('kernel_version'):

src/ugrd/kmod/nonetwork.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
mod_depends = ['ugrd.kmod.kmod']
22

3-
kmod_ignore = ['r8169', 'iwlwifi', 'r8169', 'stp', 'rfkill', '8021q', 'llc', 'garp', 'net_failover', 'failover', 'mrp']
3+
kmod_ignore = ['r8169', 'iwlwifi', 'r8169', 'stp', 'rfkill', '8021q', 'llc', 'garp', 'net_failover', 'failover', 'mrp', 'btusb',
4+
'tun', 'r8152', 'ip6table_nat', 'xt_MASQUERADE', 'btbcm', 'tap', 'nf_defrag_ipv6', 'xt_conntrack',
5+
'iptable_filter', 'nf_conntrack', 'nf_defrag_ipv4', 'ip6_tables', 'usbnet', 'wireguard', 'ip6table_filter',
6+
'iptable_mangle', 'mac80211', 'ipt_REJECT', 'ip_tables', 'xt_CHECKSUM', 'iptable_nat', 'nf_reject_ipv4',
7+
'ip6_udp_tunnel', 'udp_tunnel', 'nf_nat', 'btmtk', 'bluetooth', 'ip6table_mangle', 'bridge', 'iwlmvm',
8+
'btintel', 'btrtl', 'r8153_ecm', 'cdc_ether', 'cfg80211', 'vhost_net']

src/ugrd/kmod/nosound.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
mod_depends = ['ugrd.kmod.kmod']
22

3-
kmod_ignore = ['snd_hda_intel', 'snd-hda-core', 'snd-hda-codec', 'snd', 'snd-intel-dspcfg', 'snd-pcm', 'snd-hwdep', 'soundcore', 'snd-intel-sdw-acpi', 'snd-timer', 'ledtrig_audio']
3+
kmod_ignore = ['snd_hda_intel', 'snd', 'soundcore', 'ledtrig_audio', 'snd_intel_sdw_acpi', 'snd_rawmidi', 'snd_seq_dummy',
4+
'snd_hda_codec', 'snd_seq_device', 'snd_hrtimer', 'snd_hwdep', 'snd_usbmidi_lib', 'snd_pcm', 'snd_hda_codec_hdmi',
5+
'snd_timer', 'snd_usb_audio', 'snd_hda_core', 'snd-seq-device', 'snd_seq', 'snd_intel_dspcfg']

src/ugrd/kmod/novideo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
mod_depends = ['ugrd.kmod.kmod']
22

3-
kmod_ignore = ['amdgpu', 'drm_kms_helper', 'ttm', 'drm_display_helper', 'gpu-sched', 'drm_buddy', 'video', 'drm_ttm_helper']
3+
kmod_ignore = ['amdgpu', 'drm_kms_helper', 'ttm', 'drm_display_helper', 'gpu_sched', 'drm_buddy', 'video', 'drm_ttm_helper',
4+
'videobuf2_common', 'uvc', 'amdxcp', 'videobuf2_v4l2', 'drm_suballoc_helper', 'uvcvideo', 'videobuf2_vmalloc',
5+
'videodev', 'videobuf2_memops']

0 commit comments

Comments
 (0)