[tor-bugs] #31111 [Core Tor/Tor]: negotiate one machine per index

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Jul 9 09:17:50 UTC 2019


#31111: negotiate one machine per index
--------------------------------+------------------------------
 Reporter:  pulls               |          Owner:  (none)
     Type:  defect              |         Status:  new
 Priority:  Medium              |      Component:  Core Tor/Tor
  Version:  Tor: 0.4.1.3-alpha  |       Severity:  Normal
 Keywords:                      |  Actual Points:
Parent ID:                      |         Points:
 Reviewer:                      |        Sponsor:
--------------------------------+------------------------------
 As part of `circuitpadding.c`, in `circpad_add_matching_machines()`, the
 macros `FOR_EACH_CIRCUIT_MACHINE_BEGIN` and
 `SMARTLIST_FOREACH_REVERSE_BEGIN` currently expand to a for loop each.
 Below a slightly cropped (...) version of
 `circpad_add_matching_machines()`:

 {{{
 circpad_add_matching_machines(origin_circuit_t *on_circ,
                               smartlist_t *machines_sl)
 {
   ...
   FOR_EACH_CIRCUIT_MACHINE_BEGIN(i) {
     ...
     SMARTLIST_FOREACH_REVERSE_BEGIN(machines_sl,
                                     circpad_machine_spec_t *,
                                     machine) {
         ...
         if (circpad_negotiate_padding(on_circ, machine->machine_num,
                                   machine->target_hopnum,
                                   CIRCPAD_COMMAND_START) < 0) {
           log_info(LD_CIRC, "Padding not negotiated. Cleaning machine");
           circpad_circuit_machineinfo_free_idx(circ, i);
           circ->padding_machine[i] = NULL;
           on_circ->padding_negotiation_failed = 1;
         } else {
           /* Success. Don't try any more machines */
           return;
         }
       }
     } SMARTLIST_FOREACH_END(machine);
   } FOR_EACH_CIRCUIT_MACHINE_END;
 }
 }}}

 The outer loop goes over each machine index (currently 2, set by
 `CIRCPAD_MAX_MACHINES`), while the inner loop looks for a suitable machine
 for that index to negotiate. As soon as one is found and negotiated,
 currently, the function returns without looking for a machine for later
 indices in the outer loop. The `return` should be replaced by a `break` to
 continue looking for a machine for the next index.

 See https://github.com/torproject/tor/pull/1168 for a PR.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31111>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list