Guest User

Untitled

a guest
Oct 5th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.88 KB | None | 0 0
  1. related to the new overload detection code
  2. armadev
  3. so dgoulet and ahf have been near that code recently
  4. armadev
  5. double fraction = (double) overload_onionskin_assessment.n_ntor_dropped /
  6. armadev
  7. (double) overload_onionskin_assessment.n_ntor_requested;
  8. armadev
  9. so it would seem 'dropped' is higher than 'requested'
  10. armadev
  11. rep_hist_note_circuit_handshake_requested() is where one of them gets incremented
  12. armadev
  13. and rep_hist_note_circuit_handshake_dropped() is for the other
  14. armadev
  15. so, look through for places that call the _dropped() when nobody called _requested()
  16. armadev
  17. this one will be fun because you get to learn more about the "incoming create cell comes in, gets handed to cpuworker" logic
  18. armadev
  19. if (!channel_is_client(chan)) {
  20. armadev
  21. /* remember create types we've seen, but don't remember them from
  22. armadev
  23. * clients, to be extra conservative about client statistics. */
  24. armadev
  25. rep_hist_note_circuit_handshake_requested(create_cell->handshake_type);
  26. armadev
  27. }
  28. armadev
  29. is your hint
  30. armadev
  31. do we only count requested ones when !channel_is_client(),
  32. armadev
  33. but do we count dropped ones always?
  34. andy6
  35. I'm glad you sent me that because I was looking at something completely different
  36. armadev
  37. feel free to paste all of my backlog here onto the ticket
  38. armadev
  39. it will help the person reviewing your patch
  40. andy6
  41. Thanks
  42. armadev
  43. also i bet geko will be interested in seeing this patched, because the network health team is trying to understand why relays are saying they are overloaded,
  44. armadev
  45. and if the relays are counting wrong that makes the rest of the analysis harder
  46. armadev
  47. it looks like every guard node (as in, relay that often sees client circuits) will count wrong
  48. andy6
  49. So I'm looking at this and I'm possibly being very dumb here but the if statement you sent me only triggers the requested method. It doesn't trigger the dropped method at all.
  50. armadev
  51. yep
  52. armadev
  53. we count one in one place, and the other in a different place
  54. andy6
  55. They are both in for loops in test_overload_onionskin_ntor
  56. andy6
  57. The places dropped is called
  58. andy6
  59. But both the dropped calls are proceeded by requested calls
  60. armadev
  61. woah, you're looking at the unit tests
  62. armadev
  63. i am looking at the actual tor code
  64. andy6
  65. So I am
  66. andy6
  67. I just searched the whole project for that method name
  68. armadev
  69. ok
  70. armadev
  71. the important files are:
  72. armadev
  73. src/feature/stats/rephist.c where the counts are modified
  74. armadev
  75. src/core/or/command.c where the _requested is called
  76. loki_val has left IRC (Remote host closed the connection)
  77. andy6
  78. Yeah I am there now
  79. armadev
  80. src/feature/relay/onion_queue.c where the _dropped is called
  81. armadev
  82. just those three, mercifully
  83. armadev
  84. let me know when you want another hint :)
  85. andy6
  86. So were calling dropped when have_room_for_onionskin in onion_pending_add is false. Were calling onion_pending_add from assign_onionskin_to_cpuworker in cpuworker.c if total_pending_tasks >= max_pending_tasks.
  87. armadev
  88. yep!
  89. ggus
  90. could someone fix gettor@tpo email?
  91. armadev
  92. ggus: i verified that gettor@torproject.org email gets successfully delivered to gettor@rdsys-frontend.torproject.org
  93. Disconnected
  94. You have joined the channel
  95. andy6 has joined (~andy6@c-174-51-54-86.hsd1.co.comcast.net)
  96. Topic: This is the channel for developing Tor. Feel free to watch, but please take commentary to #tor-project and usage questions to #tor. | Relay operator discussion at #tor-relays | Commit and bug notifications -> #tor-bots | "it's a simple fix, just have to work out which lines to change" -- teor
  97. ChanServ set the topic at: Aug 14, 2022 at 1:53 PM
  98. Mode: +ntcR
  99. Created at: Sep 15, 2008 at 9:00 PM
  100. andy6
  101. So if channel_is_client returns true and total_pending_tasks >= max_pending_tasks I think we will call dropped without calling requested
  102. armadev
  103. yep!
  104. ribe has left IRC (Ping timeout: 480 seconds)
  105. andy6
  106. Do you think I should change it so that if total pending >= max pending and channel_is_client returns false we just call requested?
  107. andy6
  108. I'm thinking of adding this within the total pending >= max pending if statment
  109. armadev
  110. no, because then requested would be a weird combination of "not client + dropped"
  111. armadev
  112. i think there are two possible fixes. one of them is to drop that if channel_is_client check, and just count both correctly
  113. armadev
  114. the other is to, inside onion_pending_add(),
  115. andy6
  116. Okay I will get it fixed up and a merge request out.
  117. armadev
  118. also check if channel_is_client(circ->p_chan)
  119. armadev
  120. i think the second fix is probably the better one
  121. armadev
  122. that is, don't count either of them if it's a client channel
  123. andy6
  124. Thank you for being so helpful by the way. This is way more help than you get from most projects.
  125. armadev
  126. since that was pretty clearly the original intent, with the comment around the _requested() call
  127. Disconnected
  128. You have joined the channel
  129. andy6 has joined (~andy6@c-174-51-54-86.hsd1.co.comcast.net)
  130. Topic: This is the channel for developing Tor. Feel free to watch, but please take commentary to #tor-project and usage questions to #tor. | Relay operator discussion at #tor-relays | Commit and bug notifications -> #tor-bots | "it's a simple fix, just have to work out which lines to change" -- teor
  131. ChanServ set the topic at: Aug 14, 2022 at 1:53 PM
  132. Mode: +ntcR
  133. Created at: Sep 15, 2008 at 9:00 PM
  134. armadev
  135. andy6: ok. let me know when you have a patch
  136. armadev
  137. i predict you will run into a confusing compile error,
  138. armadev
  139. because the channel_is_client() function isn't known by anything in onion_queue.c
  140. armadev
  141. when you get there let me know
  142. andy6
  143. I've got my fix together
  144. andy6
  145. Is it just a case of specifying the correct namespace?
  146. armadev
  147. maybe. can you post your fix somewhere? either as a git branch you push to some git repo, or just as a 'git diff' posted to paste.debian.net
  148. armadev
  149. also, 'does it build' is a good middle step
  150. richard has left IRC (Ping timeout: 480 seconds)
  151. richard has joined (~richard@8VQAAC5QD.tor-irc.dnsbl.oftc.net)
  152. ChanServ has changed mode: +v richard
  153. meejah has left IRC (Remote host closed the connection)
  154. andy6
  155. Right now it does not build. I need to get a reference to channel_is_client into onion_pending_add
  156. armadev
  157. yep! so the way you do that in c is with includes
  158. armadev
  159. go up to the top of onion_queue.c
  160. armadev
  161. and add #include "core/or/channel.h" in the list
  162. armadev
  163. that's because the channel_is_client() function is in core/or/channel.c and its prototype is listed, for other people to use, in core/or/channel.h
  164. bentham has left IRC (Remote host closed the connection)
  165. bentham has joined (~bentham@0002691c.user.oftc.net)
  166. andy6
  167. Thanks
  168. andy6
  169. So right now I've added the opposite check of the one in command_process_create_cell to onion_pending_add
  170. andy6
  171. So if the one in command_process_create_cell fails then the one in onion_pending_add will trigger but both shouldn't trigger.
  172. andy6
  173. if(channel_is_client(circ->p_chan)){
  174. andy6
  175. rep_hist_note_circuit_handshake_requested(onionskin->handshake_type);
  176. andy6
  177. }
  178. andy6
  179. Is now added to onion_pending_add.
  180. andy6
  181. It also compiled with that include statement.
  182. armadev
  183. hm, don't you want the same check, not the opposite?
  184. armadev
  185. you want failed to only increment if requested also increments
  186. armadev
  187. oh i see, you are adding to requested inside onion_pending_add
  188. armadev
  189. i think the goal of the original code was: never count anything regarding a channel that comes from a client
  190. armadev
  191. that is, don't count requested, don't count dropped
  192. andy6
  193. I'm possibly getting this wrong here but I want the check to activate if the check in command_process_create_cell fails. That way you don't get the check in command_process_create_cell to add 1 requested and the check in onion_pending_add to add 1 as well
  194. andy6
  195. So if the check fails we don't want to count dropped
  196. andy6
  197. So what do you think about this instead:
  198. andy6
  199. if (!have_room_for_onionskin(queue_idx) && !channel_is_client(chan)) {
  200. andy6
  201. #define WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL (60)
  202. andy6
  203. static ratelim_t last_warned =
  204. andy6
  205. RATELIM_INIT(WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL);
  206. andy6
  207. rep_hist_note_circuit_handshake_dropped(queue_idx);
  208. andy6
  209. That way the dropped call wont activate unless the requested activated in command_process_create_cel
  210. andy6
  211. That way the dropped call wont activate unless the requested activated in command_process_create_cel
  212. andy6
  213. The check is !channel_is_client(circ->p_chan) as you mentioned earlier as well.
  214. armadev
  215. closer, but, if you do it that way then you won't actually drop the cell, if !channel_is_client().
  216. armadev
  217. you want to still drop it, just, not count it in the dropped stat
  218. armadev
  219. otherwise you will end up adding a onionskin when have_room_for_onionskin() says there's no room
  220. armadev
  221. that would make sense if you *also* wanted to change the design to "never drop circuit create requests if they're from a client"
  222. armadev
  223. but that is a pretty drastic change
  224. andy6
  225. So looking at the dropped method it just seems to increment things
  226. andy6
  227. If I wrap just the call to dropped in the channel_is_client check whatever code is actually dropping these connections should still work but we wont count them in the dropped stats
  228. armadev
  229. yep
  230. andy6
  231. if (!have_room_for_onionskin(queue_idx) ) {
  232. andy6
  233. #define WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL (60)
  234. andy6
  235. static ratelim_t last_warned =
  236. andy6
  237. RATELIM_INIT(WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL);
  238. andy6
  239. if(!channel_is_client(circ->p_chan)){
  240. andy6
  241. rep_hist_note_circuit_handshake_dropped(queue_idx);
  242. andy6
  243. }
  244. andy6
  245. if (queue_idx == ONION_HANDSHAKE_TYPE_NTOR) {
  246. andy6
  247. char *m;
  248. andy6
  249. if ((m = rate_limit_log(&last_warned, approx_time()))) {
  250. andy6
  251. log_warn(LD_GENERAL,
  252. andy6
  253. "Your computer is too slow to handle this many circuit "
  254. andy6
  255. "creation requests! Please consider using the "
  256. andy6
  257. "MaxAdvertisedBandwidth config option or choosing a more "
  258. andy6
  259. "restricted exit policy.%s",
  260. andy6
  261. m);
  262. andy6
  263. tor_free(m);
  264. andy6
  265. }
  266. andy6
  267. }
  268. andy6
  269. tor_free(tmp);
  270. andy6
  271. return -1;
  272. andy6
  273. }
  274. andy6
  275. Like this?
  276. armadev
  277. whoops, that's a lot of lines to paste. in the future, when it's more than a few, put them on https://paste.debian.net/
  278. andy6
  279. Not a problem
  280. armadev
  281. but yes, that sounds good. two little changes to do, and then it should be ready:
  282. armadev
  283. (a) add some spaces on the new 'if' line so the spacing is like the other lines
  284. armadev
  285. (b) add a comment explaining that you're explicitly avoiding counting create cells from clients, because see the matching check in that-other-function
  286. armadev
  287. in command_process_create_cell()
  288. 20:56 armadev
  289. that way when people see the new code in onion_pending_add() they won't be as surprised
  290. armadev
  291. and also that way if somebody wants to change this one day, they know to go look at command_process_create_cell() and maybe they'll need to change something there too.
Add Comment
Please, Sign In to add comment