odhcp6c: add new argument option to disable script call
authorNicolas BESNARD <[email protected]>
Tue, 17 Dec 2024 15:28:15 +0000 (15:28 +0000)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 15:21:24 +0000 (16:21 +0100)
Problem: odhcp6c call user defined script (or /usr/sbin/odhcp6c-update
by default) on every state update. When using ubus event, this feature
is not needed.

Solution: add a new argument option to disable script call on state
update.

Signed-off-by: Nicolas BESNARD <[email protected]>
Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/106
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/odhcp6c.c
src/script.c

index 361de814d37722e8ebf99cb9f218950a2a7c9274..e784b5637e4cd712cab4d99b4d3263404dcc8c84 100644 (file)
@@ -187,7 +187,7 @@ int main(_unused int argc, char* const argv[])
        config_dhcp = config_dhcp_get();
        config_dhcp_reset();
 
-       while ((c = getopt(argc, argv, "S::DN:V:P:FB:c:i:r:Ru:Ux:s:kK:t:C:m:Lhedp:fav")) != -1) {
+       while ((c = getopt(argc, argv, "S::DN:V:P:FB:c:i:r:Ru:Ux:s:EkK:t:C:m:Lhedp:fav")) != -1) {
                switch (c) {
                case 'S':
                        config_set_allow_slaac_only((optarg) ? atoi(optarg) : -1);
@@ -342,7 +342,12 @@ int main(_unused int argc, char* const argv[])
                        break;
 
                case 's':
-                       script = optarg;
+                       if (script)
+                               script = optarg;
+                       break;
+
+               case 'E':
+                       script = NULL;
                        break;
 
                case 'k':
@@ -774,6 +779,7 @@ static int usage(void)
        "       -r <options>    Options to be requested (comma-separated)\n"
        "       -R              Do not request any options except those specified with -r\n"
        "       -s <script>     Status update script (/usr/sbin/odhcp6c-update)\n"
+       "       -E              Only use UBUS event and disable status update script\n"
        "       -a              Don't send Accept Reconfigure option\n"
        "       -f              Don't send Client FQDN option\n"
        "       -k              Don't send a RELEASE when stopping\n"
index cb2f48ca3b31d56fd84ec3bad6e69ac17965b5dd..eaa2fb3af37463bf0cfa484d60cad46e85e75dd7 100644 (file)
@@ -405,6 +405,9 @@ void script_call(const char *status, int delay, bool resume)
        time_t now = odhcp6c_get_milli_time() / 1000;
        bool running_script = false;
 
+       if (!argv[0])
+               return;
+
        if (running) {
                time_t diff = now - started;