[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.3.5] hs: Get rid of duplicate hs_cell_introd_ack_status_t



commit dcc1d8d15bf11ca1c4e2760bbc47d5fa3df3814d
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Thu May 9 13:01:15 2019 -0400

    hs: Get rid of duplicate hs_cell_introd_ack_status_t
    
    This enum was the exact same as hs_intro_ack_status_t that was removed at the
    previous commit. It was used client side when parsing the INTRODUCE_ACK cell.
    
    Now, the entire code dealing with the INTRODUCE_ACK cell (both sending and
    receiving) have been modified to all use the same ABI defined in the trunnel
    introduce1 file.
    
    Finally, the client will default to the normal behavior when receiving an
    unknown NACK status code which is to note down that we've failed and re-extend
    to the next intro point. This way, unknown status code won't trigger a
    different behavior client side.
    
    Part of #30454.
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/or/hs_cell.c   |  4 ++--
 src/or/hs_cell.h   |  8 --------
 src/or/hs_client.c | 18 +++++++++---------
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c
index 03273a44f..ba80653a7 100644
--- a/src/or/hs_cell.c
+++ b/src/or/hs_cell.c
@@ -881,9 +881,9 @@ hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len)
    * do a special case. */
   if (payload_len <= 1) {
     if (payload_len == 0) {
-      ret = HS_CELL_INTRO_ACK_SUCCESS;
+      ret = TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS;
     } else {
-      ret = HS_CELL_INTRO_ACK_FAILURE;
+      ret = TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID;
     }
     goto end;
   }
diff --git a/src/or/hs_cell.h b/src/or/hs_cell.h
index 958dde4ff..ed4af3c5a 100644
--- a/src/or/hs_cell.h
+++ b/src/or/hs_cell.h
@@ -16,14 +16,6 @@
  * 3.2.2 of the specification). Below this value, the cell must be padded. */
 #define HS_CELL_INTRODUCE1_MIN_SIZE 246
 
-/* Status code of an INTRODUCE_ACK cell. */
-typedef enum {
-  HS_CELL_INTRO_ACK_SUCCESS = 0x0000, /* Cell relayed to service. */
-  HS_CELL_INTRO_ACK_FAILURE = 0x0001, /* Service ID not recognized */
-  HS_CELL_INTRO_ACK_BADFMT  = 0x0002, /* Bad message format */
-  HS_CELL_INTRO_ACK_NORELAY = 0x0003, /* Can't relay cell to service */
-} hs_cell_introd_ack_status_t;
-
 /* Onion key type found in the INTRODUCE1 cell. */
 typedef enum {
   HS_CELL_ONION_KEY_TYPE_NTOR = 1,
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 8ecefc120..7d44952e4 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -35,6 +35,8 @@
 #include "router.h"
 #include "routerset.h"
 
+#include "trunnel/hs/cell_introduce1.h"
+
 /* Return a human-readable string for the client fetch status code. */
 static const char *
 fetch_status_to_string(hs_client_fetch_status_t status)
@@ -1018,23 +1020,21 @@ handle_introduce_ack(origin_circuit_t *circ, const uint8_t *payload,
 
   status = hs_cell_parse_introduce_ack(payload, payload_len);
   switch (status) {
-  case HS_CELL_INTRO_ACK_SUCCESS:
+  case TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS:
     ret = 0;
     handle_introduce_ack_success(circ);
     goto end;
-  case HS_CELL_INTRO_ACK_FAILURE:
-  case HS_CELL_INTRO_ACK_BADFMT:
-  case HS_CELL_INTRO_ACK_NORELAY:
+  case TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID:
+  case TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT:
+  /* It is possible that the intro point can send us an unknown status code
+   * for the NACK that we do not know about like a new code for instance.
+   * Just fallthrough so we can note down the NACK and re-extend. */
+  default:
     handle_introduce_ack_bad(circ, status);
     /* We are going to see if we have to close the circuits (IP and RP) or we
      * can re-extend to a new intro point. */
     ret = close_or_reextend_intro_circ(circ);
     break;
-  default:
-    log_info(LD_PROTOCOL, "Unknown INTRODUCE_ACK status code %u from %s",
-        status,
-        safe_str_client(extend_info_describe(circ->build_state->chosen_exit)));
-    break;
   }
 
  end:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits