Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin J. Thompson
Tor
Commits
91109bc8
Commit
91109bc8
authored
7 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge branch 'maint-0.2.9' into maint-0.3.1
parents
b2c4d4e7
e91bae66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changes/bug23318
+11
-0
11 additions, 0 deletions
changes/bug23318
changes/bug24170
+3
-0
3 additions, 0 deletions
changes/bug24170
src/or/routerlist.c
+31
-17
31 additions, 17 deletions
src/or/routerlist.c
with
45 additions
and
17 deletions
changes/bug23318
0 → 100644
+
11
−
0
View file @
91109bc8
o Minor bugfixes (path selection):
- When selecting relays by bandwidth, avoid a rounding error that
could sometimes cause load to be imbalanced incorrectly. Previously,
we would always round upwards; now, we round towards the nearest
integer. This had the biggest effect when a relay's weight adjustments
should have given it weight 0, but it got weight 1 instead.
Fixes bug 23318; bugfix on 0.2.4.3-alpha.
- When calculating the fraction of nodes that have descriptors, and all
all nodes in the network have zero bandwidths, count the number of nodes
instead.
Fixes bug 23318; bugfix on 0.2.4.10-alpha.
This diff is collapsed.
Click to expand it.
changes/bug24170
0 → 100644
+
3
−
0
View file @
91109bc8
o Minor bugfixes (path selection):
- Actually log the total bandwidth in compute_weighted_bandwidths().
Fixes bug 24170; bugfix on 0.2.4.3-alpha.
This diff is collapsed.
Click to expand it.
src/or/routerlist.c
+
31
−
17
View file @
91109bc8
...
...
@@ -150,7 +150,8 @@ typedef struct cert_list_t cert_list_t;
/* static function prototypes */
static
int
compute_weighted_bandwidths
(
const
smartlist_t
*
sl
,
bandwidth_weight_rule_t
rule
,
double
**
bandwidths_out
);
double
**
bandwidths_out
,
double
*
total_bandwidth_out
);
static
const
routerstatus_t
*
router_pick_trusteddirserver_impl
(
const
smartlist_t
*
sourcelist
,
dirinfo_type_t
auth
,
int
flags
,
int
*
n_busy_out
);
...
...
@@ -2506,7 +2507,7 @@ smartlist_choose_node_by_bandwidth_weights(const smartlist_t *sl,
double
*
bandwidths_dbl
=
NULL
;
uint64_t
*
bandwidths_u64
=
NULL
;
if
(
compute_weighted_bandwidths
(
sl
,
rule
,
&
bandwidths_dbl
)
<
0
)
if
(
compute_weighted_bandwidths
(
sl
,
rule
,
&
bandwidths_dbl
,
NULL
)
<
0
)
return
NULL
;
bandwidths_u64
=
tor_calloc
(
smartlist_len
(
sl
),
sizeof
(
uint64_t
));
...
...
@@ -2526,18 +2527,24 @@ smartlist_choose_node_by_bandwidth_weights(const smartlist_t *sl,
* smartlist_choose_node_by_bandwidth_weights, compute weighted bandwidth
* values for each node and store them in a freshly allocated
* *<b>bandwidths_out</b> of the same length as <b>sl</b>, and holding results
* as doubles. Return 0 on success, -1 on failure. */
* as doubles. If <b>total_bandwidth_out</b> is non-NULL, set it to the total
* of all the bandwidths.
* Return 0 on success, -1 on failure. */
static
int
compute_weighted_bandwidths
(
const
smartlist_t
*
sl
,
bandwidth_weight_rule_t
rule
,
double
**
bandwidths_out
)
double
**
bandwidths_out
,
double
*
total_bandwidth_out
)
{
int64_t
weight_scale
;
double
Wg
=
-
1
,
Wm
=
-
1
,
We
=
-
1
,
Wd
=
-
1
;
double
Wgb
=
-
1
,
Wmb
=
-
1
,
Web
=
-
1
,
Wdb
=
-
1
;
uint64_t
weighted_bw
=
0
;
guardfraction_bandwidth_t
guardfraction_bw
;
double
*
bandwidths
;
double
*
bandwidths
=
NULL
;
double
total_bandwidth
=
0
.
0
;
tor_assert
(
sl
);
tor_assert
(
bandwidths_out
);
/* Can't choose exit and guard at same time */
tor_assert
(
rule
==
NO_WEIGHTING
||
...
...
@@ -2546,6 +2553,12 @@ compute_weighted_bandwidths(const smartlist_t *sl,
rule
==
WEIGHT_FOR_MID
||
rule
==
WEIGHT_FOR_DIR
);
*
bandwidths_out
=
NULL
;
if
(
total_bandwidth_out
)
{
*
total_bandwidth_out
=
0
.
0
;
}
if
(
smartlist_len
(
sl
)
==
0
)
{
log_info
(
LD_CIRC
,
"Empty routerlist passed in to consensus weight node "
...
...
@@ -2706,17 +2719,22 @@ compute_weighted_bandwidths(const smartlist_t *sl,
final_weight
=
weight
*
this_bw
;
}
bandwidths
[
node_sl_idx
]
=
final_weight
+
0
.
5
;
bandwidths
[
node_sl_idx
]
=
final_weight
;
total_bandwidth
+=
final_weight
;
}
SMARTLIST_FOREACH_END
(
node
);
log_debug
(
LD_CIRC
,
"Generated weighted bandwidths for rule %s based "
"on weights "
"Wg=%f Wm=%f We=%f Wd=%f with total bw
"
U64_FORMAT
,
"Wg=%f Wm=%f We=%f Wd=%f with total bw
%f"
,
bandwidth_weight_rule_to_string
(
rule
),
Wg
,
Wm
,
We
,
Wd
,
U64_PRINTF_ARG
(
weighted_bw
)
);
Wg
,
Wm
,
We
,
Wd
,
total_bandwidth
);
*
bandwidths_out
=
bandwidths
;
if
(
total_bandwidth_out
)
{
*
total_bandwidth_out
=
total_bandwidth
;
}
return
0
;
}
...
...
@@ -2733,7 +2751,8 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
if
(
smartlist_len
(
sl
)
==
0
)
return
0
.
0
;
if
(
compute_weighted_bandwidths
(
sl
,
rule
,
&
bandwidths
)
<
0
)
{
if
(
compute_weighted_bandwidths
(
sl
,
rule
,
&
bandwidths
,
&
total
)
<
0
||
total
<=
0
.
0
)
{
int
n_with_descs
=
0
;
SMARTLIST_FOREACH
(
sl
,
const
node_t
*
,
node
,
{
if
(
node_has_descriptor
(
node
))
...
...
@@ -2742,19 +2761,14 @@ frac_nodes_with_descriptors(const smartlist_t *sl,
return
((
double
)
n_with_descs
)
/
(
double
)
smartlist_len
(
sl
);
}
total
=
present
=
0
.
0
;
present
=
0
.
0
;
SMARTLIST_FOREACH_BEGIN
(
sl
,
const
node_t
*
,
node
)
{
const
double
bw
=
bandwidths
[
node_sl_idx
];
total
+=
bw
;
if
(
node_has_descriptor
(
node
))
present
+=
b
w
;
present
+=
b
andwidths
[
node_sl_idx
]
;
}
SMARTLIST_FOREACH_END
(
node
);
tor_free
(
bandwidths
);
if
(
total
<
1
.
0
)
return
0
;
return
present
/
total
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment