From ffe36c63e0e2af7d92ef26a36a7151f97c972ea6 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Sun, 30 Mar 2014 21:38:52 +0300 Subject: [PATCH] xpp: dahdi_registration: force re-assignment * The system state causing the bug: - DAHDI has auto_assign_spans==1 - No /etc/dahdi/assigned-spans.conf * The bug scenario: - During initial device detection, they are assigned by DAHDI driver. - Later we run "dahdi_span_assignment remove" - Then, a "dahdi_registration on" would not assign any span. * The fix: - Using the '-R' option, force "dahdi_registration on" to also do "dahdi_span_assignment auto" on relevant devices. - This is the way it's called by /usr/share/dahdi/dahdi_auto_assign_compat Signed-off-by: Tzafrir Cohen Acked-by: Shaun Ruffell --- xpp/dahdi_registration | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xpp/dahdi_registration b/xpp/dahdi_registration index 32bd746..7202e76 100755 --- a/xpp/dahdi_registration +++ b/xpp/dahdi_registration @@ -41,6 +41,11 @@ my $span_types_config = $ENV{'SPAN_TYPES_CONF_FILE'} || '/etc/dahdi/span-types.c my $have_assigned_spans_config = -f $assigned_spans_config || 0; my $have_span_types_config = -f $span_types_config || 0; +# Spans will be auto-assigned by default if either: +# - Driver $auto_assign_spans them or +# - Udev script see that we $have_span_types_config and it "add" them +my $default_auto_assign = $auto_assign_spans || $have_assigned_spans_config; + my $sorter; my $sort_order = $opts{'s'}; if(defined $sort_order) { @@ -100,11 +105,14 @@ foreach my $xbus (Dahdi::Xpp::xbuses($sorter)) { } myprintf "%3s ==> %3s\n", state2str($prev), state2str($on); } - if (defined($on) && $on && ! $have_assigned_spans_config && ! $auto_assign_spans) { + next unless defined($on) && $on; + # Only assign if no default assignment, or forced by '-R' option + if ($opts{'R'} || ! $default_auto_assign) { # Emulate /etc/dahdi/assigned-spans.conf: # - We iterate over $xbus according to /etc/dahdi/xpp_order # - We "auto" assign all spans of current $xbus my $devpath = sprintf "/sys/bus/dahdi_devices/devices/astribanks:xbus-%02d", $xbus->num; + myprintf "auto-assign $devpath\n"; my @cmd = ('dahdi_span_assignments', 'auto', $devpath); system @cmd; warn "Failed '@cmd' (status=$?)\n" if $?;