ltq-vdsl-app: disconnect when service is stopped
authorJan Hoffmann <jan@3e8.eu>
Wed, 27 Apr 2022 17:40:50 +0000 (19:40 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 4 May 2022 00:38:04 +0000 (01:38 +0100)
Stop the connection when the control daemon is terminated. The code is
a modified version of the termination routine in version 4.23.1 of the
daemon (which doesn't support VR9 modems anymore).

This could also be implemented by calling the acos and acs commands via
dsl_cpe_pipe.sh in the init script. However, doing it in the daemon
itself has the advantage of also working if it is terminated in another
way (for example during sysupgrade).

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
package/network/config/ltq-vdsl-app/patches/200-autoboot.patch
package/network/config/ltq-vdsl-app/patches/201-sigterm.patch
package/network/config/ltq-vdsl-app/patches/300-ubus.patch

index 5b882bf30ff4302e1bc9e2ee1ed52f7e5ce63b02..cc6feb94aa9f9abcb652b391c94131e3d80b9034 100644 (file)
@@ -1,3 +1,10 @@
+This enables automatic connection after the control daemon is started,
+and also stops the connection on termination.
+
+Using the autoboot restart command is necessary because the stop command
+doesn't actually stop the connection, and would also leave the driver in
+a state where an explicit start command is necessary to connect again.
+
 --- a/src/dsl_cpe_init_cfg.c
 +++ b/src/dsl_cpe_init_cfg.c
 @@ -27,7 +27,7 @@ DSL_InitData_t gInitCfgData =
@@ -9,3 +16,71 @@
     DSL_CPE_AUTOBOOT_CFG_SET(DSL_FALSE, DSL_FALSE, DSL_FALSE),
     DSL_CPE_TEST_MODE_CTRL_SET(DSL_TESTMODE_DISABLE),
     DSL_CPE_LINE_ACTIVATE_CTRL_SET(DSL_G997_INHIBIT_LDSF, DSL_G997_INHIBIT_ACSF, DSL_G997_NORMAL_STARTUP),
+--- a/src/dsl_cpe_control.c
++++ b/src/dsl_cpe_control.c
+@@ -6515,10 +6515,13 @@ DSL_CPE_STATIC  void DSL_CPE_Termination
+ DSL_CPE_STATIC  DSL_void_t DSL_CPE_Termination (void)
+ {
+ #ifdef INCLUDE_DSL_CPE_CLI_SUPPORT
+-   DSL_int_t nDevice = 0;
+    DSL_char_t buf[32] = "quit";
+ #endif
++   DSL_Error_t nRet = DSL_SUCCESS;
++   DSL_int_t nDevice = 0;
++   DSL_AutobootConfig_t sAutobootCfg;
++   DSL_AutobootControl_t sAutobootCtl;
+    DSL_CPE_Control_Context_t *pCtrlCtx;
+    pCtrlCtx = DSL_CPE_GetGlobalContext();
+@@ -6527,6 +6530,50 @@ DSL_CPE_STATIC  DSL_void_t DSL_CPE_Termi
+       pCtrlCtx->bRun = DSL_FALSE;
+    }
++   for (nDevice = 0; nDevice < DSL_CPE_MAX_DSL_ENTITIES; ++nDevice)
++   {
++      g_bWaitBeforeConfigWrite[nDevice]    = DSL_TRUE;
++      g_bWaitBeforeLinkActivation[nDevice] = DSL_TRUE;
++      g_bWaitBeforeRestart[nDevice]        = DSL_TRUE;
++
++      g_bAutoContinueWaitBeforeConfigWrite[nDevice]    = DSL_FALSE;
++      g_bAutoContinueWaitBeforeLinkActivation[nDevice] = DSL_FALSE;
++      g_bAutoContinueWaitBeforeRestart[nDevice]        = DSL_FALSE;
++
++      memset(&sAutobootCfg, 0x0, sizeof(DSL_AutobootConfig_t));
++      sAutobootCfg.data.nStateMachineOptions.bWaitBeforeConfigWrite    = DSL_TRUE;
++      sAutobootCfg.data.nStateMachineOptions.bWaitBeforeLinkActivation = DSL_TRUE;
++      sAutobootCfg.data.nStateMachineOptions.bWaitBeforeRestart        = DSL_TRUE;
++
++      nRet = (DSL_Error_t)DSL_CPE_Ioctl(
++         DSL_CPE_GetGlobalContext()->fd[nDevice],
++         DSL_FIO_AUTOBOOT_CONFIG_SET, (DSL_int_t)&sAutobootCfg);
++
++      if (nRet < DSL_SUCCESS)
++      {
++         DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
++            "Autoboot configuration for device (%d) failed!, nRet = %d!"
++            DSL_CPE_CRLF, nDevice, sAutobootCtl.accessCtl.nReturn));
++      }
++
++      memset(&sAutobootCtl, 0, sizeof(DSL_AutobootControl_t));
++      sAutobootCtl.data.nCommand = DSL_AUTOBOOT_CTRL_RESTART;
++
++      nRet = (DSL_Error_t)DSL_CPE_Ioctl(
++         DSL_CPE_GetGlobalContext()->fd[nDevice],
++         DSL_FIO_AUTOBOOT_CONTROL_SET, (DSL_int_t)&sAutobootCtl);
++
++      if (nRet < DSL_SUCCESS)
++      {
++         DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
++            "Autoboot restart for device (%d) failed!, nRet = %d!"
++            DSL_CPE_CRLF, nDevice, sAutobootCtl.accessCtl.nReturn));
++      }
++   }
++
++   DSL_CCA_DEBUG(DSL_CCA_DBG_MSG, (DSL_CPE_PREFIX
++      "Autoboot restart executed" DSL_CPE_CRLF));
++
+ #ifdef INCLUDE_DSL_CPE_CLI_SUPPORT
+    for (nDevice = 0; nDevice < DSL_CPE_MAX_DSL_ENTITIES; nDevice++)
+    {
index 68a416ce24fb5fe4317debb092cd27ae5738e5b1..4e978359835e2e46deb5ff89eebe65d08809db32 100644 (file)
@@ -9,7 +9,7 @@
     {
        DSL_CCA_DEBUG(DSL_CCA_DBG_MSG, (DSL_CPE_PREFIX "terminated" DSL_CPE_CRLF));
        DSL_CPE_Termination ();
-@@ -6756,6 +6756,7 @@ DSL_int_t dsl_cpe_daemon (
+@@ -6803,6 +6803,7 @@ DSL_int_t dsl_cpe_daemon (
  
  #ifndef RTEMS
     signal (SIGINT, DSL_CPE_TerminationHandler);
index f218ea2208d6a16d87f1083082c3b3b85808b03e..d257ca2fc4ab6379933d2c6d71dacbcac4dcb3a2 100644 (file)
@@ -10,7 +10,7 @@
  DSL_char_t *g_sFirmwareName1 = DSL_NULL;
  DSL_FirmwareFeatures_t g_nFwFeatures1 = {DSL_FW_XDSLMODE_CLEANED, DSL_FW_XDSLFEATURE_CLEANED,
     DSL_FW_XDSLFEATURE_CLEANED};
-@@ -6759,6 +6762,8 @@ DSL_int_t dsl_cpe_daemon (
+@@ -6806,6 +6809,8 @@ DSL_int_t dsl_cpe_daemon (
     signal (SIGTERM, DSL_CPE_TerminationHandler);
  #endif /* RTEMS*/
  
@@ -19,7 +19,7 @@
     /* Open DSL_CPE_MAX_DSL_ENTITIES devices*/
     for (nDevice = 0; nDevice < DSL_CPE_MAX_DSL_ENTITIES; nDevice++)
     {
-@@ -7213,6 +7218,7 @@ DSL_int_t dsl_cpe_daemon (
+@@ -7260,6 +7265,7 @@ DSL_int_t dsl_cpe_daemon (
  #endif /* INCLUDE_DSL_CPE_CLI_SUPPORT */
  
  DSL_CPE_CONTROL_EXIT: