The current code converts all unsupported (!isalnum()) characters
to '_'. Unfortunately, among all sysctl variables, more than
3/4 of themhave at least one underscore, and more than 99.9%
of them have a dot.On the other hand, some sysctl variables
are named very similarly. For example, in recent ZFS versions,
both the legacy "vfs.zfs.arc_max" and the new "vfs.zfs.arc.max"
are provided, and under the current rewriting rule, both of
them would be rewritten as "vfs_zfs_arc_max".
A full list of existing sysctl's that would create conflicting
names can be generated with:
sysctl -da | grep -E \("$(sysctl -Na | tr .-%\ _ | sort | \
uniq -c | sort -n | awk '{ if ($1 >1) print $2; }' | \
sed -e s,_,.,g | paste -sd \| -)"\):
Note that the other unsupported characters are making up only a
very small (slightly more than 5%) fraction of sysctl's, so
performing afull encode of every character like URLencode seems
to be not needed.
Solve this by repeating underscore one more time when
transforming.
PR: 259607