From owner-freebsd-net@freebsd.org Thu Dec 7 21:59:51 2017 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3BB9E926D8 for ; Thu, 7 Dec 2017 21:59:51 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-qt0-x22a.google.com (mail-qt0-x22a.google.com [IPv6:2607:f8b0:400d:c0d::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 812FB78705 for ; Thu, 7 Dec 2017 21:59:51 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-qt0-x22a.google.com with SMTP id k19so21531069qtj.6 for ; Thu, 07 Dec 2017 13:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8VgOn65RH9mGkEllEHq7gEJXSYl3VovtfR58fIzoS3o=; b=Uz72a9eDQj0g6Zl7nMTVCYcKLehq6XsSPFD0/+ckM8ACOahPmsGHbrMAB3IfW6NAU3 Ko3aV3kNXVm5fukZPTVQV0vHW9+oKXaQXq6+2qxSfAgNptT7YSZrnFzCQ9G2snQa4IQY fakoiR124GRiZlWOCrnnmsMGS7NFLkid8uHPbA01d+33+ifmCHWALBRDtmszPcI8tyf0 zPSeGhCGznaOBPETv0YkmHprNDKX3B0MD+2eqhW/bzHS4YLk1fx/cYQ+kQbt9sbZ1trJ RhEHArW51/33P4vznnIjMW7BMGEvJoKi/T+Cm1Vck2j3U6rNBCdZODhg+Toz5zzccNDY PUdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8VgOn65RH9mGkEllEHq7gEJXSYl3VovtfR58fIzoS3o=; b=IQPxWkDilvUQZr/ts7HAU4h8s2lbjiC5yJQpHN3C6rT1v5G97JXKJsvyxCL+DcvqQB oqk7bW9pW59G+nv4VcfKfsY2YNHT7T4Ymj1ynDSCbt4+31Yl2vD6lPsaNZmfwK3gPsRb frAXi2fofmnmXksatc9iT5GL22y1AH62czlyXepT+OCAmjWKPBnZAxnb/v+m1G+LcWlA NWiLtCaIBmXnif/OHPLx4mjVfX70tyf4pEQRf+y/ptE7J1GHwZO3M5r37piaUqGm61hP gB7+FH3PVK9D4oaRApP/1wOEjORBiA1n+lVDZbBAtg/726bp5gEhKKvD34ONYYI2we7L QQaQ== X-Gm-Message-State: AKGB3mIaGQr6UE8IQ4ilA64DECuD4Yzpc7wWRpFmuG2+CTE2KJrbqFQh diGrq45CqnB2ERRaUrfJ9WuA1wm+wxikEBC5ar3Sgw== X-Google-Smtp-Source: AGs4zMbxQvdzp1rBWgoYtQVxjiFKaYluqzjfJRsOZB1mXyrgnIOFmTkQd+5LKsWObP+pjgrXbfA88kWQjila2vqkTyk= X-Received: by 10.200.45.89 with SMTP id o25mr11256069qta.227.1512683990205; Thu, 07 Dec 2017 13:59:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.39.211 with HTTP; Thu, 7 Dec 2017 13:59:49 -0800 (PST) From: Ryan Stone Date: Thu, 7 Dec 2017 16:59:49 -0500 Message-ID: Subject: [PATCH] ifaddr leak when modifying a route To: freebsd-net Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2017 21:59:51 -0000 I've put this phab review up that patches an ifaddr refcount leak in the routing code. When a route is modified in a way that modifies rt->rt_ifa, in most cases we don't release the reference on the old one, which can cause it to leak. I have a simple script here that I wrote to demonstrate the issue: https://people.freebsd.org/~rstone/route-change-leak If I run it on a stock -head system, I see 100 ifaddrs leak every time it's run: # sh route-change-leak Type InUse MemUse HighUse Requests Size(s) ifaddr 53 17K - 564 32,64,128,256,512,2048,4096 ifaddr 153 42K - 664 32,64,128,256,512,2048,4096 # sh route-change-leak Type InUse MemUse HighUse Requests Size(s) ifaddr 153 42K - 665 32,64,128,256,512,2048,4096 ifaddr 253 67K - 765 32,64,128,256,512,2048,4096 # sh route-change-leak Type InUse MemUse HighUse Requests Size(s) ifaddr 253 67K - 766 32,64,128,256,512,2048,4096 ifaddr 353 92K - 866 32,64,128,256,512,2048,4096 With my fix, the leak is gone: # sh route-change-leak Type InUse MemUse HighUse Requests Size(s) ifaddr 46 15K - 47 16,32,64,128,256,512,2048,4096 ifaddr 46 15K - 147 16,32,64,128,256,512,2048,4096 # sh route-change-leak Type InUse MemUse HighUse Requests Size(s) ifaddr 46 15K - 148 16,32,64,128,256,512,2048,4096 ifaddr 46 15K - 248 16,32,64,128,256,512,2048,4096 The review is here. I didn't subscribe freebsd-net to the review to try to reduce the noise on the mailing list, so if you would like to review this change please subscribe yourself to the review. Thanks. https://reviews.freebsd.org/D13417