Page MenuHomeFreeBSD

route: remove extra reference on ifa in rtinit1.
Needs ReviewPublic

Authored by jacob.e.keller_intel.com on Nov 5 2019, 5:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 10 2023, 9:46 PM
Unknown Object (File)
Dec 10 2023, 11:39 AM
Unknown Object (File)
Nov 24 2023, 8:26 AM
Unknown Object (File)
Sep 6 2023, 2:55 AM
Unknown Object (File)
Aug 14 2023, 8:44 PM
Unknown Object (File)
Jun 30 2023, 1:56 PM
Unknown Object (File)
May 8 2023, 12:33 PM
Unknown Object (File)
Mar 4 2023, 10:42 AM
Subscribers

Details

Reviewers
jhb
gallatin
erj
Summary

When initializing a new route, or deleting a route the ifa reference is
incremented in rtinit1. This is problematic for two reasons.

First, we increment the ifa reference twice when adding. This is because
we first increment the reference in rtinit1(), and then again in
rtrequest1_fib() when adding the route to the list. Second, during
deletion, we increment the ifa reference in rtinit1() the same as when
adding.

This results in two additional references on the ifaddr structure. The
end result is that the ifaddr structure for a new route will never be
free'd. This causes leaks for every address we add to an interface.

I'm not sure that simply removing this ifa_ref() is the best solution,
the reference counting code here is very tricky.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27361
Build 25611: arc lint + arc unit

Event Timeline

I'm really not sure this is the correct fix. Possibly we should just add an ifa_free after the rtrequest1_fib()?

You should be able to verify this leak by doing something like:

ifconfig dev0 <ip address>
ifconfig dev0 delete

and monitoring vmstat -m.

It looks like this change was part of the recently committed D22912 / rS356107