# [solved] "gentoo way" to define modules dependencies?

## EricHsu

Hi all,

I'm using iwlwifi driver for my intel 3945 wireless card. when modprobing the iwlwifi module, the mac80211 module automatically loaded, that's good. However, I need to connect to WPA2 encrypted network, then I need the aes, arc4 and ecb modules loaded *before* iwlwifi is loaded, otherwise, I will get the following errors:

```

wmaster0: Selected rate control algorithm 'iwl-3945-rs'

wmaster0: Failed to initialize wep

iwl3945: Failed to register network device (error -12)

```

So, as long as I load aes, arc4, ecb first, then udevd loads iwlwifi, everything will work flawlessly. 

I tried to place these modules into the /etc/modules.autoload.d/kernel-2.6, but udev probes the iwlwifi module earlier than these modules, so it doesn't work; then I tried to edit the /lib64/modules/2.6.23-gentoo-r1/modules.dep file, and added these three modules to the iwlwifi.ko as its dependencies, then reboot, it works, but after reboot, modules.dep seems got recovered/restored by some other program (?).

Is there any more elegant/gentoo way to let the system know it needs to load these crypto modules first, then the iwlwifi? (If there's none, I think the best way would be built-in these modules...)

TIA  :Smile: 

----------

## ksp7498

Perhaps you could try disabling automatic module loading in the kernel?

```
keith@tualatin /usr/src/linux $ zgrep CONFIG_KMOD /usr/src/linux/.config

CONFIG_KMOD=y

```

You could try disabling this and then supposedly the modules will only be loaded in the order that you specifically define.  I haven't played with it though as I don't use many modules, and it also seems like disabling this would make it much less convenient to use modules with the kernel (as you'd have to modprobe lots and lots of modules by hand instead of just letting one modules rope in all the others).  Worth playing with, though, I think.

----------

## 96140

No, keep automatic module loading built into your kernel. Disabling that is a bad idea. I've posted before on forcing module load order. What you need to do is read the relevant part of the udev Guide on forcing module load order.

----------

## EricHsu

 *ksp7498 wrote:*   

> Perhaps you could try disabling automatic module loading in the kernel? 

 

I think it would be a headache to figure out all the modules order for my system - I compiled all most everything as module :p But thanks for the reply all the same  :Smile: 

@nightmorph:

The udev Guide is really helpful to me! I tried the "index" option, however, seems thoese crypto modules won't accept it, and udev won't auto load them either. 

But the blacklist method works! I simply blacklist the iwl3945 in the /etc/modprobe.d/blacklist file, update-modules, added the following lines to /etc/modules.autoload.d/kernel-2.6:

```

aes

arc4

ecb

iwl3945

```

Now it's perfect! Big thanks!

----------

## 96140

--Last edited by 96140 on Fri Sep 13, 2013 8:53 am; edited 1 time in total

----------

## EricHsu

WoW! Thank you very much nightmorph! Your informations have been very helpful to me, so happy to learn so many things at the same time  :Very Happy: 

----------

## swimmer

How about controlling it with 'pre-install' in your /etc/modules.d/iwl3945?

```
pre-install iwl3945 modprobe aes; modprobe arc4; modprobe ecb
```

Just an idea - not sure if that works as you wish ....

HTH

swimmer

----------

## EricHsu

 *swimmer wrote:*   

> How about controlling it with 'pre-install' in your /etc/modules.d/iwl3945?

 

wOw! It works, too! Steps I've done:

 1. remove iwl3945 from /etc/modprobe.d/blacklist - so it's not blacklisted.

 2. remove aes, arc4, ecb, iwl3945 from /etc/modules.autoload.d/kernel-2.6, so they're not managed by this file

 3. create/edit the /etc/modules.d/iwl3945 and put the line in as you suggested

 4. sudo update-modules to update the /etc/modprobe.conf, I noticed that the following line has been generated:

```

install iwl3945 { modprobe aes; modprobe arc4; modprobe ecb; } ; /sbin/modprobe --first-time --ignore-install iwl3945

```

Reboot, perfect!

Big thanks to swimmer!

Thank you all guys  :Very Happy: 

----------

## swimmer

Glad I could help  :Very Happy: 

----------

