diff options
author | Ben Pfaff <blp@nicira.com> | 2012-05-08 15:44:21 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-05-22 10:32:05 -0700 |
commit | 0d085684619be0baef309957a3d7410a23cb5f27 (patch) | |
tree | 212ad7c9bd8e67c80065da7ed1968f6a5bd5af61 /ofproto/pktbuf.c | |
parent | 44bac24ba5d22fe238bd96702707eb2029efec41 (diff) |
Add support for tracking and logging daemon memory usage.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ofproto/pktbuf.c')
-rw-r--r-- | ofproto/pktbuf.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ofproto/pktbuf.c b/ofproto/pktbuf.c index acc0d34d3..71be34a61 100644 --- a/ofproto/pktbuf.c +++ b/ofproto/pktbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -232,3 +232,23 @@ pktbuf_discard(struct pktbuf *pb, uint32_t id) p->buffer = NULL; } } + +/* Returns the number of packets buffered in 'pb'. Returns 0 if 'pb' is + * null. */ +unsigned int +pktbuf_count_packets(const struct pktbuf *pb) +{ + int n = 0; + + if (pb) { + int i; + + for (i = 0; i < PKTBUF_CNT; i++) { + if (pb->packets[i].buffer) { + n++; + } + } + } + + return n; +} |