Well of course this is the right patch
Index: dhclient.c
===================================================================
RCS file: /cvs/src/sbin/dhclient/dhclient.c,v
retrieving revision 1.347
diff -u -p -r1.347 dhclient.c
--- dhclient.c 16 Jan 2015 06:39:56 -0000 1.347
+++ dhclient.c 30 Jan 2015 09:23:43 -0000
@@ -2297,8 +2297,10 @@ clone_lease(struct client_lease *oldleas
return (newlease);
cleanup:
- if (newlease)
+ if (newlease) {
+ newlease->is_static = 0;
free_client_lease(newlease);
+ }
return (NULL);
}
On Fri, 30 Jan 2015 00:12:13 +0100 (CET)
[email protected] wrote:
> >Synopsis: Possible memory leak in dhclient program
> >Category: system
> >Environment:
> System : OpenBSD 5.6
> Details : OpenBSD 5.6-stable (GENERIC.MP) #0: Thu Jan 15 17:43:09
> CET 2015
>
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine : amd64
> >Description:
> Watching the memory size (ps -v or top) of the dhclient proces (user
> _dhcp)
> shows that it increases over time. It is very visible that the used
> memory increases
> (nearly) every time when waking up after waiting the renewal time.
> The memory leakage is not huge: about 4 kilobytes per renewal action.
> Only when the DHCP server is configured to use very small values for
> lease-time
> and renewal time, the leakage becomes a practical problem, but there is
> no reason
> found yet to believe the leakage is not occuring with higher lease time
> values.
> In my personal case my WAN provider configured a lease time of only 2
> minutes.
>
> More info...
>
> Initial discussion:
>
> https://plus.google.com/103502519278004437108/posts/6CSRsX9wxWt
>
> Request for info from other people, which proves I am not the only one:
>
> https://plus.google.com/103502519278004437108/posts/fKANHvhm1Dg
>
> >How-To-Repeat:
> 1. Connect a standard OpenBSD host to a network using DHCP for its IP
> address
> 2. If possible configure the DHCP server to use low lease-time values:
> e.g. lease-time: 120 seconds,
> rebinding-time: 105 seconds,
> renewal-time: 60 seconds.
> 3. Whatch the memory size of the dhclient proces. e.g. use a ksh
> command on
> root terminal:
> # while true; do
> > ps -v -p <pid>
> > sleep 5
> > done
> The 5 seconds sleep should be adjusted depending on renewal time.
> In this example I have 12 samples per renewal period.
>
> >Fix:
> Fix yet unknown.
> Should investigate the dhclient software how/when malloc() take place.
>
>
> # cat dhclient.leases.em2
> lease {
> interface "em2";
> fixed-address xxx.xxx.xxx.xxx;
> next-server 0.0.0.0;
> option subnet-mask 255.255.254.0;
> option routers xxx.xxx.xxx.x;
> option domain-name-servers xx.xxx.x.xxx,xx.xxx.x.xxx;
> option broadcast-address xxx.xxx.xxx.xxx;
> option dhcp-lease-time 120;
> option dhcp-message-type 5;
> option dhcp-server-identifier xxx.xxx.xxx.x;
> option dhcp-renewal-time 60;
> option dhcp-rebinding-time 105;
> option dhcp-client-identifier 1:0:c:29:e5:31:94;
> option option-212 10:28:2a:1:6:70:6a:0:0:0:0:0:0:0:0:0:0:0:58:9f:1:10;
> renew 4 2015/01/29 22:43:49 UTC;
> rebind 4 2015/01/29 22:44:34 UTC;
> expire 4 2015/01/29 22:44:49 UTC;
> }
>
> # ps uaxw | head -1; ps uaxw | grep dhcp | grep -v grep
> USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
> _dhcp 29922 0.0 0.6 23984 1584 ?? Ss Sun09PM 0:07.21 dhclient:
> em2 (dhclient)
>
>
>
> dmesg:
>
> OpenBSD 5.6-stable (GENERIC.MP) #0: Thu Jan 15 17:43:09 CET 2015
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 251592704 (239MB)
> avail mem = 236228608 (225MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (364 entries)
> bios0: vendor Phoenix Technologies LTD version "6.00" date 07/30/2013
> bios0: VMware, Inc. VMware Virtual Platform
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S1 S4 S5
> acpi0: tables DSDT FACP BOOT APIC MCFG SRAT HPET WAET
> acpi0: wakeup devices PCI0(S3) USB_(S1) P2P0(S3) S1F0(S3) S2F0(S3) S3F0(S3)
> S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3) S10F(S3) S11F(S3)
> S12F(S3) S13F(S3) [...]
> acpitimer0 at acpi0: 3579545 Hz, 24 bits
> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: Intel(R) Xeon(R) CPU X3430 @ 2.40GHz, 2393.77 MHz
> cpu0:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,SSE3,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,NXE,LONG,LAHF,PERF,ITSC
> cpu0: 256KB 64b/line 8-way L2 cache
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
> cpu0: apic clock running at 65MHz
> cpu1 at mainbus0: apid 1 (application processor)
> cpu1: Intel(R) Xeon(R) CPU X3430 @ 2.40GHz, 2393.96 MHz
> cpu1:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,SSE3,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,NXE,LONG,LAHF,PERF,ITSC
> cpu1: 256KB 64b/line 8-way L2 cache
> cpu1: smt 0, core 0, package 2
> ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 11, 24 pins
> acpimcfg0 at acpi0 addr 0xf0000000, bus 0-127
> acpihpet0 at acpi0: 14318179 Hz
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpicpu0 at acpi0
> acpicpu1 at acpi0
> acpibat0 at acpi0: BAT1 not present
> acpibat1 at acpi0: BAT2 not present
> acpiac0 at acpi0: AC unit online
> acpibtn0 at acpi0: SLPB
> acpibtn1 at acpi0: LID_
> vmt0 at mainbus0
> pci0 at mainbus0 bus 0
> pchb0 at pci0 dev 0 function 0 "Intel 82443BX AGP" rev 0x01
> ppb0 at pci0 dev 1 function 0 "Intel 82443BX AGP" rev 0x01
> pci1 at ppb0 bus 1
> pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x08
> pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0
> configured to compatibility, channel 1 configured to compatibility
> pciide0: channel 0 disabled (no drives)
> atapiscsi0 at pciide0 channel 1 drive 0
> scsibus1 at atapiscsi0: 2 targets
> cd0 at scsibus1 targ 0 lun 0: <NECVMWar, VMware IDE CDR10, 1.00> ATAPI
> 5/cdrom removable
> cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
> piixpm0 at pci0 dev 7 function 3 "Intel 82371AB Power" rev 0x08: SMBus
> disabled
> "VMware VMCI" rev 0x10 at pci0 dev 7 function 7 not configured
> vga1 at pci0 dev 15 function 0 "VMware SVGA II" rev 0x00
> wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
> wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
> mpi0 at pci0 dev 16 function 0 "Symbios Logic 53c1030" rev 0x01: apic 2 int 17
> mpi0: 0, firmware 1.3.41.32
> scsibus2 at mpi0: 16 targets, initiator 7
> sd0 at scsibus2 targ 0 lun 0: <VMware, Virtual disk, 1.0> SCSI2 0/direct fixed
> sd0: 8192MB, 512 bytes/sector, 16777216 sectors
> mpi0: target 0 Sync at 160MHz width 16bit offset 127 QAS 1 DT 1 IU 1
> ppb1 at pci0 dev 17 function 0 "VMware PCI" rev 0x02
> pci2 at ppb1 bus 2
> em0 at pci2 dev 1 function 0 "Intel 82545EM" rev 0x01: apic 2 int 19, address
> 00:0c:29:e5:31:80
> em1 at pci2 dev 2 function 0 "Intel 82545EM" rev 0x01: apic 2 int 16, address
> 00:0c:29:e5:31:8a
> em2 at pci2 dev 3 function 0 "Intel 82545EM" rev 0x01: apic 2 int 17, address
> 00:0c:29:e5:31:94
> em3 at pci2 dev 4 function 0 "Intel 82545EM" rev 0x01: apic 2 int 18, address
> 00:0c:29:e5:31:9e
> ppb2 at pci0 dev 21 function 0 "VMware PCIE" rev 0x01
> pci3 at ppb2 bus 3
> ppb3 at pci0 dev 21 function 1 "VMware PCIE" rev 0x01
> pci4 at ppb3 bus 4
> ppb4 at pci0 dev 21 function 2 "VMware PCIE" rev 0x01
> pci5 at ppb4 bus 5
> ppb5 at pci0 dev 21 function 3 "VMware PCIE" rev 0x01
> pci6 at ppb5 bus 6
> ppb6 at pci0 dev 21 function 4 "VMware PCIE" rev 0x01
> pci7 at ppb6 bus 7
> ppb7 at pci0 dev 21 function 5 "VMware PCIE" rev 0x01
> pci8 at ppb7 bus 8
> ppb8 at pci0 dev 21 function 6 "VMware PCIE" rev 0x01
> pci9 at ppb8 bus 9
> ppb9 at pci0 dev 21 function 7 "VMware PCIE" rev 0x01
> pci10 at ppb9 bus 10
> ppb10 at pci0 dev 22 function 0 "VMware PCIE" rev 0x01
> pci11 at ppb10 bus 11
> ppb11 at pci0 dev 22 function 1 "VMware PCIE" rev 0x01
> pci12 at ppb11 bus 12
> ppb12 at pci0 dev 22 function 2 "VMware PCIE" rev 0x01
> pci13 at ppb12 bus 13
> ppb13 at pci0 dev 22 function 3 "VMware PCIE" rev 0x01
> pci14 at ppb13 bus 14
> ppb14 at pci0 dev 22 function 4 "VMware PCIE" rev 0x01
> pci15 at ppb14 bus 15
> ppb15 at pci0 dev 22 function 5 "VMware PCIE" rev 0x01
> pci16 at ppb15 bus 16
> ppb16 at pci0 dev 22 function 6 "VMware PCIE" rev 0x01
> pci17 at ppb16 bus 17
> ppb17 at pci0 dev 22 function 7 "VMware PCIE" rev 0x01
> pci18 at ppb17 bus 18
> ppb18 at pci0 dev 23 function 0 "VMware PCIE" rev 0x01
> pci19 at ppb18 bus 19
> ppb19 at pci0 dev 23 function 1 "VMware PCIE" rev 0x01
> pci20 at ppb19 bus 20
> ppb20 at pci0 dev 23 function 2 "VMware PCIE" rev 0x01
> pci21 at ppb20 bus 21
> ppb21 at pci0 dev 23 function 3 "VMware PCIE" rev 0x01
> pci22 at ppb21 bus 22
> ppb22 at pci0 dev 23 function 4 "VMware PCIE" rev 0x01
> pci23 at ppb22 bus 23
> ppb23 at pci0 dev 23 function 5 "VMware PCIE" rev 0x01
> pci24 at ppb23 bus 24
> ppb24 at pci0 dev 23 function 6 "VMware PCIE" rev 0x01
> pci25 at ppb24 bus 25
> ppb25 at pci0 dev 23 function 7 "VMware PCIE" rev 0x01
> pci26 at ppb25 bus 26
> ppb26 at pci0 dev 24 function 0 "VMware PCIE" rev 0x01
> pci27 at ppb26 bus 27
> ppb27 at pci0 dev 24 function 1 "VMware PCIE" rev 0x01
> pci28 at ppb27 bus 28
> ppb28 at pci0 dev 24 function 2 "VMware PCIE" rev 0x01
> pci29 at ppb28 bus 29
> ppb29 at pci0 dev 24 function 3 "VMware PCIE" rev 0x01
> pci30 at ppb29 bus 30
> ppb30 at pci0 dev 24 function 4 "VMware PCIE" rev 0x01
> pci31 at ppb30 bus 31
> ppb31 at pci0 dev 24 function 5 "VMware PCIE" rev 0x01
> pci32 at ppb31 bus 32
> ppb32 at pci0 dev 24 function 6 "VMware PCIE" rev 0x01
> pci33 at ppb32 bus 33
> ppb33 at pci0 dev 24 function 7 "VMware PCIE" rev 0x01
> pci34 at ppb33 bus 34
> isa0 at pcib0
> isadma0 at isa0
> com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
> com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
> pckbc0 at isa0 port 0x60/5
> pckbd0 at pckbc0 (kbd slot)
> pckbc0: using irq 1 for kbd slot
> wskbd0 at pckbd0: console keyboard, using wsdisplay0
> pms0 at pckbc0 (aux slot)
> pckbc0: using irq 12 for aux slot
> wsmouse0 at pms0 mux 0
> pcppi0 at isa0 port 0x61
> spkr0 at pcppi0
> lpt0 at isa0 port 0x378/4 irq 7
> fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
> vscsi0 at root
> scsibus3 at vscsi0: 256 targets
> softraid0 at root
> scsibus4 at softraid0: 256 targets
> root on sd0a (8b7166cbab3bf5c2.a) swap on sd0b dump on sd0b
>
> usbdevs:
> usbdevs: no USB controllers found
>