Where is dahdi_cfg called from on system boot?

317 Views Asked by At

I install DAHDI on Debian stable (Buster) via module-assistant like this:

apt-get install dahdi dahdi-source module-assistant
module-assistant auto-install dahdi

I also create /etc/dahdi/system.conf and /etc/dahdi/assigned-spans.conf.

I cannot figure out who calls dahdi_cfg during system boot. I can confirm that it does get called by something, because if I remove dahdi_cfg and reboot, echo and dahdi_echocan_oslec modules are missing from lsmod (echo cancellation is specified in system.conf).

I found /usr/share/dahdi/span_config.d/10-dahdi-cfg, but I have no idea what may run this.

So, where is dahdi_cfg called from during system boot?

UPDATE

I found out that if system.conf is missing, echo cancellation modules are loaded anyways. Mandatory conditions are:

  • presence of dahdi_cfg
  • /etc/dahdi/assigned-spans.conf

UPDATE2

One more observation: if /etc/dahdi/assigned-spans.conf is removed and options dahdi auto_assign_spans=1 is added to /etc/modprobe.d/dahdi.conf, echo cancellation modules are not loaded (system.conf is still removed). So it seems auto_assign_spans=1 is not working.


Can anybody answer new questions in my answer?

2

There are 2 best solutions below

0
On

Use the following patch for /lib/udev/rules.d/60-dahdi.rules:

+SUBSYSTEM=="dahdi_spans", RUN+="/usr/sbin/dahdi_cfg"
 LABEL="dahdi_add_end"
0
On

First of all, let's deal with auto_assign_spans=1:

Remove auto_assign_spans=1. Result: /proc/dahdi/ is empty. Use auto_assign_spans=1. Result: /proc/dahdi/ is not empty.

So, this is the way how to check the effect of auto_assign_spans=1.

This is the example:

Span 1: WCTDM/0 "Wildcard TDM410P" (MASTER) 

       1 WCTDM/0/0 RED 
       2 WCTDM/0/1 
       3 WCTDM/0/2 
       4 WCTDM/0/3 

Now run dahdi_genconf system and check /proc/dahdi/1 again:

Span 1: WCTDM/0 "Wildcard TDM410P" (MASTER) 

   1 WCTDM/0/0 FXSKS RED 
   2 WCTDM/0/1 FXOKS 
   3 WCTDM/0/2 FXOKS 
   4 WCTDM/0/3 FXOKS 

We have seen that dahdi_genconf messes with the span. Is this a bug?

Then run dahdi_cfg and check /proc/dahdi/1 again:

Span 1: WCTDM/0 "Wildcard TDM410P" (MASTER) 

   1 WCTDM/0/0 FXSKS RED (EC: OSLEC - INACTIVE) 
   2 WCTDM/0/1 FXOKS (EC: OSLEC - INACTIVE) 
   3 WCTDM/0/2 FXOKS (EC: OSLEC - INACTIVE) 
   4 WCTDM/0/3 FXOKS (EC: OSLEC - INACTIVE) 

Now we see that everything is properly configured.


Next, dahdi_handle_device is called by udev. It does nothing (because auto_assign_spans=1 is used).

Then dahdi_span_config is called by udev. It does nothing also for the same reason.

And this is the interesting part: dahdi_cfg is not called if auto_assign_spans=1 is used. Is this a bug?

------------------------------

On the contrary, if auto_assign_spans=1 is not used, dahdi_cfg is called by dahdi_span_config.

This is a bit confusing. Why is it prohibited to run dahdi_cfg if auto_assign_spans=1 is used? If we have only one card, this is perfectly acceptable. auto_assign_spans=1 is even documented in dahdi-tools README as the use case for such scenario:

Normally (with auto_assign_spans=1 in the module dahdi, which is the default), when a device is discovered and loaded, it registers with the DAHDI core and its spans automatically become available. However if you have more than one device, you may be interested to set explicit spans and channels numbers for them.

Is it safe to add dahdi_cfg to dahdi_span_config manually?

BTW, system.conf need not even be created - it is generated dynamically if it does not exist, but again, only if auto_assign_spans=1 is not used. If this deficiency is corrected somehow, the only thing needed to configure DAHDI would be just

echo options dahdi auto_assign_spans=1 >/etc/modprobe.d/dahdi.conf