]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
Merge branch 'nits' into rrl-wip docs-develop-rrl-6r4hl4/deployments/4188 docs-develop-rrl-8r8r8r/deployments/4189
authorOto Šťáva <oto.stava@nic.cz>
Mon, 27 May 2024 12:16:33 +0000 (14:16 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Mon, 27 May 2024 12:23:14 +0000 (14:23 +0200)
1  2 
.gitlab-ci.yml
daemon/main.c
daemon/proxyv2.c
daemon/proxyv2.h
daemon/session2.c
daemon/worker.c
lib/utils.c
lib/utils.h

diff --cc .gitlab-ci.yml
Simple merge
diff --cc daemon/main.c
Simple merge
index 73eb576903cdf34a14a97d765a734368fd396681,5f2147ce8bfcc4bd611fc259db845218430acbd1..2fdd6c50540bd9adb04a20759fe64c33a0e2a37a
@@@ -128,8 -131,10 +131,7 @@@ static inline void next_tlv(struct prox
        *tlv = (struct proxy2_tlv *)next;
  }
  
--
 -/** Checks whether the use of PROXYv2 protocol is allowed for the specified
 - * address. */
 -static bool proxy_allowed(const struct sockaddr *saddr)
 +bool proxy_allowed(const struct sockaddr *saddr)
  {
        union kr_in_addr addr;
        trie_t *trie;
index a21f14b1eb69f0c023b2c32c2d0e423f911359bf,6a6bc1794905bdbf0617980442848acc652f5514..9de98843bd46617f8484e9c12d58dbbb216f64a7
@@@ -35,19 -31,5 +31,9 @@@ struct proxy_result 
        bool has_tls : 1;
  };
  
- /** Checks for a PROXY protocol version 2 signature in the specified buffer. */
- static inline bool proxy_header_present(const void* buf, const ssize_t nread)
- {
-       return nread >= PROXY2_MIN_SIZE &&
-               memcmp(buf, PROXY2_SIGNATURE, sizeof(PROXY2_SIGNATURE)) == 0;
- }
+ /** Initializes the protocol layers managed by the PROXYv2 "module". */
+ void proxy_protolayers_init(void);
 +
 +/** Checks whether the use of PROXYv2 protocol is allowed for the specified
 + * address. */
 +bool proxy_allowed(const struct sockaddr *saddr);
- /** Parses the PROXYv2 header from buf of size nread and writes the result into
-  * out. The function assumes that the PROXYv2 signature is present
-  * and has been already checked by the caller (like `udp_recv` or `tcp_recv`). */
- ssize_t proxy_process_header(struct proxy_result *out,
-                              const void *buf, ssize_t nread);
index a2c519a0789c9a2dc1b975a6cc9782fe7dc7326c,ca06e47be1fe8cbad03771f316b3366bd012cbe3..682815ad3b5b3eb7eb0bb32cbbe5676d99fe3902
@@@ -554,44 -600,28 +602,43 @@@ static int session2_submit
                struct protolayer_payload payload, const struct comm_info *comm,
                protolayer_finished_cb cb, void *baton)
  {
-       struct protolayer_manager *manager = s->layers;
+       if (session->closing)
+               return kr_error(ECANCELED);
 -
+       if (kr_fails_assert(session->proto < KR_PROTO_COUNT))
+               return kr_error(EFAULT);
 +      if (!comm)
-               comm = &manager->session->comm;
++              comm = &session->comm;
 +
 +      // RRL: at this point we might start doing nontrivial work,
 +      // but we may not know the client's IP yet.
 +      // Note two cases: incoming session (new request)
 +      // vs. outgoing session (resuming work on some request)
 +      if (direction == PROTOLAYER_UNWRAP) {
 +              kr_rrl_sample_start();
 +              // In particular we don't want to miss en/decryption work
 +              // for regular connections from clients.
-               if (!s->outgoing && s->secure && !proxy_allowed(comm->comm_addr))
++              if (!session->outgoing && session->secure && !proxy_allowed(comm->comm_addr))
 +                      kr_rrl_sample_addr((const union kr_sockaddr *)comm->comm_addr);
 +      }
 +      int ret;
 +
-       if (manager->session->closing) {
-               ret = kr_error(ECANCELED);
-               goto finish_ret;
-       }
-       struct protolayer_iter_ctx *ctx = malloc(manager->cb_ctx_size);
+       struct protolayer_iter_ctx *ctx = malloc(session->iter_ctx_size);
        kr_require(ctx);
  
-       VERBOSE_LOG(manager->session,
+       VERBOSE_LOG(session,
                        "%s submitted to grp '%s' in %s direction (%zu: %s)\n",
                        protolayer_payload_name(payload.type),
-                       protolayer_grp_name(manager->grp),
+                       kr_proto_name(session->proto),
                        (direction == PROTOLAYER_UNWRAP) ? "unwrap" : "wrap",
-                       layer_ix, layer_name(manager->grp, layer_ix));
+                       layer_ix, layer_name(session->proto, layer_ix));
  
        *ctx = (struct protolayer_iter_ctx) {
                .payload = payload,
 -              .comm = (comm) ? *comm : session->comm,
 +              .comm = *comm,
                .direction = direction,
                .layer_ix = layer_ix,
-               .manager = manager,
+               .session = session,
                .finished_cb = cb,
                .finished_cb_baton = baton
        };
                }
  
                if (globals->iter_init)
-                       globals->iter_init(manager, ctx, iter_data);
+                       globals->iter_init(ctx, iter_data);
        }
  
 -      return protolayer_step(ctx);
 +      ret = protolayer_step(ctx);
- finish_ret:
 +      if (direction == PROTOLAYER_UNWRAP)
 +              kr_rrl_sample_stop();
 +      return ret;
  }
  
- static void *get_init_param(enum protolayer_protocol p,
+ static void *get_init_param(enum protolayer_type p,
                              struct protolayer_data_param *layer_param,
                              size_t layer_param_count)
  {
diff --cc daemon/worker.c
Simple merge
diff --cc lib/utils.c
Simple merge
diff --cc lib/utils.h
Simple merge