summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2013-12-30 05:19:27 +0000
committerscottl <scottl@FreeBSD.org>2013-12-30 05:19:27 +0000
commitdb06903b8464dde6952e2099f6625f6df1760fe9 (patch)
treed2671b27f916faa7a57ef6d38c89cb70ee74e697 /sys/net
parent63558da0f9110285f93152cec05f2b2deb11d6b1 (diff)
downloadFreeBSD-src-db06903b8464dde6952e2099f6625f6df1760fe9.zip
FreeBSD-src-db06903b8464dde6952e2099f6625f6df1760fe9.tar.gz
Merge r256563:
In the flowtable scanner, restart the scan at the last found position, not at position 0. Changes the scanner from O(N^2) to O(N). Reviewed by: emax Obtained from: Netflix
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/flowtable.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c
index 6995798..32b953c 100644
--- a/sys/net/flowtable.c
+++ b/sys/net/flowtable.c
@@ -1401,7 +1401,7 @@ fle_free(struct flentry *fle, struct flowtable *ft)
static void
flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)
{
- int curbit = 0, count;
+ int curbit = 0, count, tmpsize;
struct flentry *fle, **flehead, *fleprev;
struct flentry *flefreehead, *flefreetail, *fletmp;
bitstr_t *mask, *tmpmask;
@@ -1410,6 +1410,7 @@ flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)
flefreehead = flefreetail = NULL;
mask = flowtable_mask(ft);
tmpmask = ft->ft_tmpmask;
+ tmpsize = ft->ft_size;
memcpy(tmpmask, mask, ft->ft_size/8);
/*
* XXX Note to self, bit_ffs operates at the byte level
@@ -1479,7 +1480,9 @@ flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)
bit_clear(mask, curbit);
FL_ENTRY_UNLOCK(ft, curbit);
bit_clear(tmpmask, curbit);
- bit_ffs(tmpmask, ft->ft_size, &curbit);
+ tmpmask += (curbit / 8);
+ tmpsize -= (curbit / 8) * 8;
+ bit_ffs(tmpmask, tmpsize, &curbit);
}
count = 0;
while ((fle = flefreehead) != NULL) {
OpenPOWER on IntegriCloud