Commit 0830106
ipv4: take dst->__refcnt when caching dst in fib
In IPv4 routing code, fib_nh and fib_nh_exception can hold pointers
to struct rtable but they never increment dst->__refcnt.
This leads to the need of the dst garbage collector because when user
is done with this dst and calls dst_release(), it can only decrement
dst->__refcnt and can not free the dst even it sees dst->__refcnt
drops from 1 to 0 (unless DST_NOCACHE flag is set) because the routing
code might still hold reference to it.
And when the routing code tries to delete a route, it has to put the
dst to the gc_list if dst->__refcnt is not yet 0 and have a gc thread
running periodically to check on dst->__refcnt and finally to free dst
when refcnt becomes 0.
This patch increments dst->__refcnt when
fib_nh/fib_nh_exception holds reference to this dst and properly release
the dst when fib_nh/fib_nh_exception has been updated with a new dst.
This patch is a preparation in order to fully get rid of dst gc later.
Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent 4a6ce2b commit 0830106
2 files changed
+20
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | | - | |
| 198 | + | |
| 199 | + | |
198 | 200 | | |
| 201 | + | |
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
606 | 607 | | |
607 | 608 | | |
608 | 609 | | |
609 | 610 | | |
610 | 611 | | |
| 612 | + | |
611 | 613 | | |
612 | 614 | | |
613 | 615 | | |
| |||
1332 | 1334 | | |
1333 | 1335 | | |
1334 | 1336 | | |
| 1337 | + | |
1335 | 1338 | | |
1336 | | - | |
| 1339 | + | |
| 1340 | + | |
1337 | 1341 | | |
| 1342 | + | |
1338 | 1343 | | |
1339 | 1344 | | |
1340 | 1345 | | |
| |||
1357 | 1362 | | |
1358 | 1363 | | |
1359 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
1360 | 1369 | | |
1361 | 1370 | | |
1362 | | - | |
| 1371 | + | |
| 1372 | + | |
1363 | 1373 | | |
1364 | | - | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
1365 | 1377 | | |
| 1378 | + | |
1366 | 1379 | | |
1367 | 1380 | | |
1368 | 1381 | | |
| |||
0 commit comments