[Bug 242746] Deleting (or re-setting) an IP address with ifconfig holds (leaks?) memory

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Dec 20 21:13:27 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242746

            Bug ID: 242746
           Summary: Deleting (or re-setting) an IP address with ifconfig
                    holds (leaks?) memory
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: ghuckriede at blackberry.com

Overview:
Setting an IP address consumes 'ifaddr' typed memory.  When destroying the IP
address the memory is not freed.

This memory does not appear to be collected later, as running the below script
shows no recovery after continuously re-setting the ip address for 16 hours.

The leaked memory was tracked down to the ifa_alloc() function, see line 845 of
https://svnweb.freebsd.org/base/head/sys/net/if.c?revision=355070&view=markup
Instrumenting the code revealed that there are more ifa_ref() calls than
ifa_free() calls.  This results in the memory being held, as the system
believes there is still a reference to this memory.


Steps to Reproduce:
'ifconfig <interface> inet' an address and then 'ifconfig <interface> inet
delete' it.


Actual Results:
# vmstat -m | grep ifaddr
       ifaddr   141    36K       -      235  16,32,64,128,256,512,2048,4096
# 
# ifconfig em1 inet  192.168.200.44
# vmstat -m | grep ifaddr
       ifaddr   142    36K       -      236  16,32,64,128,256,512,2048,4096
# ifconfig em1 inet delete 192.168.200.44
# vmstat -m | grep ifaddr
       ifaddr   142    36K       -      236  16,32,64,128,256,512,2048,4096

# cat /tmp/loop
while true
do
        ifconfig em1 192.168.200.33 
        sleep 1 
        vmstat -m | grep ifaddr
done
# /tmp/loop
       ifaddr   135    37K       -      294  16,32,64,128,256,512,2048,4096
       ifaddr   136    38K       -      295  16,32,64,128,256,512,2048,4096
       ifaddr   137    38K       -      296  16,32,64,128,256,512,2048,4096
       ifaddr   138    39K       -      297  16,32,64,128,256,512,2048,4096
....snip (16 hours worth of logs)...
       ifaddr 1834875 917406K       -  1835088  16,32,64,128,256,512,2048,4096
       ifaddr 1834876 917407K       -  1835089  16,32,64,128,256,512,2048,4096
       ifaddr 1834877 917407K       -  1835090  16,32,64,128,256,512,2048,4096
       ifaddr 1834878 917408K       -  1835091  16,32,64,128,256,512,2048,4096
       ifaddr 1834879 917408K       -  1835092  16,32,64,128,256,512,2048,4096
^C
#


Expected Results:
Not to leak/hold onto memory.


Build Date & Hardware:
HEADr355854 on amd64 target with any networking interface

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list