From: Aaro Koskinen <[email protected]>

Busybox sysctl is incompatible with procps when '.' appears in
directory name, mostly happens with VLANs.

        busybox syntax (since 2008): net.ipv4.conf.eth0.100.mc_forwarding
         procps syntax (since 2002): net.ipv4.conf.eth0/100.mc_forwarding
                 (supported by both: net/ipv4/conf/eth0.100/mc_forwarding)

Make procps syntax the default; for users relying on the old behaviour
provide a config option for time being.

Signed-off-by: Aaro Koskinen <[email protected]>
---
 procps/sysctl.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/procps/sysctl.c b/procps/sysctl.c
index 5fa7646d1..3e79e3927 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -15,6 +15,23 @@
 //config:      default y
 //config:      help
 //config:      Configure kernel parameters at runtime.
+//config:config SYSCTL_OLDBUSYBOX_COMPAT
+//config:      bool "sysctl compatibility with older busybox versions"
+//config:      default n
+//config:      depends on BB_SYSCTL
+//config:      help
+//config:      Older busybox versions are incompatible with procps when
+//config:      handling VLAN interfaces. Busybox supported syntax:
+//config:              net.ipv4.conf.eth0.100.mc_forwarding
+//config:      while procps supports:
+//config:              net.ipv4.conf.eth0/100.mc_forwarding
+//config:
+//config:      Choose this option only if you are upgrading from an older
+//config:      busybox and need to maintain compatilibity e.g. for scripts
+//config:      that configure VLAN interfaces using sysctl. This option may be
+//config:      deprecated in the future so consider migrating to the procps
+//config:      syntax.
+//config:
 
 //applet:IF_BB_SYSCTL(APPLET_NOEXEC(sysctl, sysctl, BB_DIR_SBIN, BB_SUID_DROP, 
sysctl))
 
@@ -56,6 +73,7 @@ enum {
 
 static void sysctl_dots_to_slashes(char *name)
 {
+#ifdef CONFIG_SYSCTL_OLDBUSYBOX_COMPAT
        char *cptr, *last_good, *end;
 
        /* Convert minimum number of '.' to '/' so that
@@ -97,6 +115,25 @@ static void sysctl_dots_to_slashes(char *name)
                cptr--;
        }
        *end = '\0';
+#else /* CONFIG_SYSCTL_OLDBUSYBOX_COMPAT */
+       char *cptr;
+       int n = 0;
+
+       cptr = name;
+       while (*cptr) {
+               if (*cptr == '.') {
+                       *cptr = '/';
+                       n++;
+               } else if (*cptr == '/') {
+                       if (!n)
+                               return; /* slash syntax is used */
+                       *cptr = '.';
+               } else if (*cptr == '=') {
+                       return;
+               }
+               cptr++;
+       }
+#endif /* CONFIG_SYSCTL_OLDBUSYBOX_COMPAT */
 }
 
 static int sysctl_act_on_setting(char *setting)
@@ -112,6 +149,10 @@ static int sysctl_act_on_setting(char *setting)
        while (*cptr) {
                if (*cptr == '/')
                        *cptr = '.';
+#ifndef CONFIG_SYSCTL_OLDBUSYBOX_COMPAT
+               else if (*cptr == '.')
+                       *cptr = '/';
+#endif
                cptr++;
        }
 
-- 
2.17.0

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to