el1n/OpenWRT-package-softether

pid,log,tmp are created on overlay nvram, not /var (tempfs)

Closed this issue · 5 comments

Softether creates its log, pid, tmp files on the overlay root, which increases nvram wear. So we should find a way to either configure it to use /var or add some patches directly. Only the config and backup.config should be written to nvram.

/overlay/upper/usr/bin# ls -al

-rw-------    1 root     root             0 Mar 12 15:15 .VPN-CF8D586B43
-rw-------    1 root     root            11 Mar 12 15:15 .ctl_554D2CD9AC2C4933E7CEC49173007F26
-rw-------    1 root     root             5 Mar 12 15:15 .pid_554D2CD9AC2C4933E7CEC49173007F26
drwx------    2 root     root           160 Mar 12 15:13 backup.vpn_bridge.config
drwx------    2 root     root           160 Mar 12 15:14 backup.vpn_client.config
drwx------    2 root     root           160 Mar 12 15:15 backup.vpn_server.config
drwx------    2 root     root           320 Mar 12 15:13 client_log
drwx------    2 root     root           160 Mar 12 15:13 packet_log
drwx------    4 root     root           288 Mar 12 15:13 security_log
drwx------    2 root     root           160 Mar 12 15:15 server_log
-rw-------    1 root     root         11945 Mar 12 15:16 vpn_bridge.config
-rw-------    1 root     root          1227 Mar 12 15:16 vpn_client.config
-rw-------    1 root     root         12921 Mar 12 16:12 vpn_server.config

Log File Save Location & Format

All log files create the three subdirectories server_log, security_log and packet_log in the directory containing the vpnserver process (or vpnbridge process in the case of the VPN Bridge) executable files and write each of the server log, security log and packet log there. A further subdirectory is created for the security log and packet log written for each Virtual Hub. These logs are then written to this subdirectory, which is named after its Virtual Hub.

I guess a general way would be to ln the bins to /var/usr/bin and start the process from there, otherwise we would have to patch Cedar.h and related files, since i cant see a config option for none volatile files.

thx
Andy

I have it running using the ln trick and than we should also change:

uint64 AutoDeleteCheckDiskFreeSpaceMin 104857600
to
uint64 AutoDeleteCheckDiskFreeSpaceMin 1048576

in the server config, so softether logs can only grow to 1MB size on the tempfs.

el1n commented

the softether has create logs(dir) before loading the server configuration.
so i think hard to add logdir configuration.
(i guess not good to set log directory to /tmp with hard coding.)

try symlink as simple solution.

Yeah doing this right now, still need some extra handling for the backup stuff. This should be a option in the menuconfig than, so we can copy the correct init.d files for a exroot or /var configuration.

#!/bin/sh /etc/rc.common
START=60

start(){
    [ -d /var/softether ] || {
        mkdir -p /var/softether
        chmod 0775 /var/softether
    }

    [ -f /var/softether/vpnserver ] || ln -sf /usr/bin/vpnserver /var/softether/
    [ -f /var/softether/hamcore.se2 ] || ln -sf /usr/bin/hamcore.se2 /var/softether/
    [ -f /var/softether/vpn_server.config ] || ln -sf /usr/bin/vpn_server.config /var/softether/

    /usr/bin/env LANG=en_US.UTF-8 /var/softether/vpnserver start
}

stop(){
    /usr/bin/env LANG=en_US.UTF-8 /var/softether/vpnserver stop
}

in the server config, so softether logs can only grow to 1MB size on the tempfs.

AFAIK This is incorrect, "AutoDeleteCheckDiskFreeSpaceMin" is a setting for automatic log deletion if the free space is less than the variable is defined.

The VPN Server is set by default to delete old log files starting with the oldest until the space available on the drive to which the log files are being written is restored to 100MB or greater (104, 857,600 bytes to be precise).

I actually wonder how it was working until now, were the log files even written for users who have <100MB of disk space?

Ah you are correct, i did misunderstand the value than. That makes it more complicated, since i assume that the max. tmpfs size is just around half of your routers ram? In my case its set to 251.2M, since i have a 512 MB ram router.

If one would want to actually use the packet/security logfiles, we would have to figure out a safe/sane value inside the makefile, depending on the physical ram? This is to prevent eating up the ram via tmpfs. I assume 1-10MB logfles would be acceptable for most routers.