diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2018-04-23 20:06:34 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2018-05-09 21:23:06 +0000 |
commit | e07e95edd35f1608ecba94b281818d27f63812e3 (patch) | |
tree | 8e571ebd65e845771fcfe72c4a8176a80e78e863 /src/or/circuituse.c | |
parent | 7b09282dc723381e68fef79c3474a56315a0edfa (diff) | |
download | tor-e07e95edd35f1608ecba94b281818d27f63812e3.tar.gz tor-e07e95edd35f1608ecba94b281818d27f63812e3.zip |
Bug 25903: Perform accounting for new CIRC_BW fields.
Two new values in each direction. DELIVERED counts valid end-to-end circuit
data that is accepted by our end and OVERHEAD counts the slack unused data in
each of the relay command cells for those accepted cells.
Control port changes are in the next commit.
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 47e29c28dd..a584e3eca8 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -3083,3 +3083,41 @@ mark_circuit_unusable_for_new_conns(origin_circuit_t *circ) circ->unusable_for_new_conns = 1; } +/** + * Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to + * the valid delivered written fields and the overhead field, + * respectively. + */ +void +circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len) +{ + if (!circ) return; + + tor_assert_nonfatal(relay_body_len <= RELAY_PAYLOAD_SIZE); + + circ->n_delivered_written_circ_bw = + tor_add_u32_nowrap(circ->n_delivered_written_circ_bw, relay_body_len); + circ->n_overhead_written_circ_bw = + tor_add_u32_nowrap(circ->n_overhead_written_circ_bw, + RELAY_PAYLOAD_SIZE-relay_body_len); +} + +/** + * Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to + * the valid delivered read field and the overhead field, + * respectively. + */ +void +circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len) +{ + if (!circ) return; + + tor_assert_nonfatal(relay_body_len <= RELAY_PAYLOAD_SIZE); + + circ->n_delivered_read_circ_bw = + tor_add_u32_nowrap(circ->n_delivered_read_circ_bw, relay_body_len); + circ->n_overhead_read_circ_bw = + tor_add_u32_nowrap(circ->n_overhead_read_circ_bw, + RELAY_PAYLOAD_SIZE-relay_body_len); +} + |