radvd-project / radvd

radvd | Official repository: https://github.com/radvd-project/radvd
https://radvd.litech.org/
Other
203 stars 107 forks source link

memory leak in kernel space because the memory registered by IPV6_ADD_MEMBERLAND is not released #228

Open xdbob opened 8 months ago

xdbob commented 8 months ago

Related-To: https://github.com/radvd-project/radvd/issues/177

When an interface is deleted IPV6_DROP_MEMBERSHIP is not called leaking mc memory in kernel making radvd fail to send RA on new interfaces with the following errors:

sendmsg: No buffer space available
can't join ipv6-allrouters on tap1
can't join ipv6-allrouters on tap1
can't join ipv6-allrouters on tap1
[...]

The following script reproduces the issue:

#!/bin/bash

IFNAME=tap1

for i in {1..1000}; do
    echo "Iteration: $i"
    echo "Creating tap..."
    ip tuntap add mode tap ${IFNAME}
    ip link set ${IFNAME} up

    echo "Spawning qemu..."
    # radvd waits 1 second by default before joining the multicast group
    timeout 1.5 qemu-system-x86_64 -boot n -net nic -net tap,ifname=${IFNAME},script=no,downscript=no -nographic

    echo "Removing tap..."
    ip link delete ${IFNAME}
done

with the following config file:

interface tap1 {
        IgnoreIfMissing on;
        AdvSendAdvert on;
        AdvManagedFlag on;
        AdvOtherConfigFlag on;
};

Note: on our kernel the issue happens on about ~366 iterations with the following config:

$ sysctl net.core.optmem_max
net.core.optmem_max = 20480
Neustradamus commented 8 months ago

@robbat2: Have you seen this issue and the PR?