On Wed, Aug 30 2017, Kamil Shakirov <[email protected]> wrote:
> Hello,
>
>> Synopsis: Memory leak in dhclient(8) on OpenBSD-current
>> Category: system
>> Environment:
> System : OpenBSD 6.2
> Details : OpenBSD 6.2-beta (GENERIC.MP) #59: Tue Aug 29 15:56:07 MDT
> 2017
>
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine : amd64
>> Description:
> On OpenBSD-current when a network interface is configured to use dhcp and
> if it is
> physically disconnected (e.g. cable is unplugged or WiFi hotspot is not
> available)
> than dhclient goes to "sleep" and starts to leak memory very rapidly.
> This problem doesn't appear in OpenBSD 6.1.
>> How-To-Repeat:
> Configure your /etc/hostname.if to use dhcp and make sure that this network
> interface is not physically connected to the network. Reboot and watch
> dhclient's
> memory leak with top(1) or htop(1).
The dhclient on my em0 was indeed leaking memory. The diff below fixes
the leak but was only tested on a down, unplugged interface.
Index: dhclient.c
===================================================================
RCS file: /d/cvs/src/sbin/dhclient/dhclient.c,v
retrieving revision 1.496
diff -u -p -p -u -r1.496 dhclient.c
--- dhclient.c 26 Aug 2017 14:45:57 -0000 1.496
+++ dhclient.c 30 Aug 2017 08:15:21 -0000
@@ -235,6 +235,7 @@ interface_status(char *name)
{
struct ifaddrs *ifap, *ifa;
struct if_data *ifdata;
+ int ret = 0;
if (getifaddrs(&ifap) != 0)
fatalx("getifaddrs failed");
@@ -252,14 +253,16 @@ interface_status(char *name)
if ((ifa->ifa_flags & (IFF_UP|IFF_RUNNING)) !=
(IFF_UP|IFF_RUNNING))
- return 0;
+ break;
ifdata = ifa->ifa_data;
+ ret = LINK_STATE_IS_UP(ifdata->ifi_link_state);
+ break;
+ }
- return LINK_STATE_IS_UP(ifdata->ifi_link_state);
- }
+ freeifaddrs(ifap);
- return 0;
+ return ret;
}
void
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE