diff mbox series

ltq-vdsl-app: disconnect when service is stopped

Message ID 20220427174050.2607214-1-jan@3e8.eu
State Accepted
Delegated to: Daniel Golle
Headers show
Series ltq-vdsl-app: disconnect when service is stopped | expand

Commit Message

Jan Hoffmann April 27, 2022, 5:40 p.m. UTC
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>
---
 .../ltq-vdsl-app/patches/200-autoboot.patch   | 75 +++++++++++++++++++
 .../ltq-vdsl-app/patches/201-sigterm.patch    |  2 +-
 .../ltq-vdsl-app/patches/300-ubus.patch       |  4 +-
 3 files changed, 78 insertions(+), 3 deletions(-)

Comments

Martin Blumenstingl April 29, 2022, 8:37 p.m. UTC | #1
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
On Wed, Apr 27, 2022 at 8:00 PM Jan Hoffmann <jan@3e8.eu> wrote:
>
> 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>
sysupgrade with this patch in my tree doesn't break, so:
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
diff mbox series

Patch

diff --git a/package/network/config/ltq-vdsl-app/patches/200-autoboot.patch b/package/network/config/ltq-vdsl-app/patches/200-autoboot.patch
index 5b882bf30ff4..cc6feb94aa9f 100644
--- a/package/network/config/ltq-vdsl-app/patches/200-autoboot.patch
+++ b/package/network/config/ltq-vdsl-app/patches/200-autoboot.patch
@@ -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++)
+    {
diff --git a/package/network/config/ltq-vdsl-app/patches/201-sigterm.patch b/package/network/config/ltq-vdsl-app/patches/201-sigterm.patch
index 68a416ce24fb..4e978359835e 100644
--- a/package/network/config/ltq-vdsl-app/patches/201-sigterm.patch
+++ b/package/network/config/ltq-vdsl-app/patches/201-sigterm.patch
@@ -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);
diff --git a/package/network/config/ltq-vdsl-app/patches/300-ubus.patch b/package/network/config/ltq-vdsl-app/patches/300-ubus.patch
index f218ea2208d6..d257ca2fc4ab 100644
--- a/package/network/config/ltq-vdsl-app/patches/300-ubus.patch
+++ b/package/network/config/ltq-vdsl-app/patches/300-ubus.patch
@@ -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: