From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1757238766; bh=QYJkDUqPScInb++VMNSGkVoQPSallRLoDFDx6IjQgYk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=luTprzkZZ7TgW5075Qhqx1FI2i+o9SMWi8NMS8rawh1v31IuhzahZd1fJJpUw+zpt yeY3SFqAQFK5iWLZpVPOo1AFUuRhJHXo1e7/Y0/lvPtwZTRmAchs0IMVx5dENdZga/ qT5zGUB7UD+xKu5KPvJUhCeePhzhxORx0otzSBrxnOSGNrqO8eokUbIx/jQQYkyCdx DgJK0l8mHAeTIYHp8e2b16fsHz2NeJxMbNAxFxURKz+tIlUTDqMLXYjMp5S4qbQoyb qp9TZxHmj4FPPJ3PBJ83SIanEUG9cn9owRC6JIKasBIBJGSlrkGa08aaKkzUyBI/Kq UQI3XCOanysHw== Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 9E47B3127999 for ; Sun, 7 Sep 2025 09:52:46 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-33c9f2bcdceso5641051fa.2 for ; Sun, 07 Sep 2025 02:52:46 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW3iztimS29DfQqSVIowbnC1HwBCaY9mSjIn37qbRlv6OQ9m/X4zxhsijOE9HE7TFLzvdEY@vger.gnuweeb.org X-Gm-Message-State: AOJu0YxqdVNQ7Sc+f8tcuo1xfpYq0vSuu74U7ZkGh0i5ETMSJh03ldb/ /PxgE1WKSkB2YuR6CdvQMlXqDA6g6jaqLbpknhHW9uASlXrf3UltLwcbit6+y1PBP6Ba4Q3o4TR vy03mykCcEL8JcQiszODKQzxI+UIV4vo= X-Google-Smtp-Source: AGHT+IGgriF1rjd71jf9/XYS3mG/ZW7VaeAjnJYMwSJ88zmqU4QmqKzRB4mM3GoefPWqNORgEotUj4qXjT8t8c+HwwI= X-Received: by 2002:a2e:a27c:0:b0:336:bcfc:a422 with SMTP id 38308e7fff4ca-33b551c55aemr8482651fa.26.1757238765818; Sun, 07 Sep 2025 02:52:45 -0700 (PDT) MIME-Version: 1.0 References: <20250829075557.598176-1-reyuki@gnuweeb.org> <20250829075557.598176-3-reyuki@gnuweeb.org> In-Reply-To: From: Ahmad Gani Date: Sun, 7 Sep 2025 16:52:09 +0700 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXwxLuHeS3qYgcXWZDv8VcBHNC8hAUkJYfxqKy7yZJuz0jGUkqJLjmlnQE8 Message-ID: Subject: Re: [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend To: Ammar Faizi Cc: Alviro Iskandar Setiawan , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: On Sun, Sep 7, 2025 at 11:23=E2=80=AFAM Ammar Faizi wrote: > Have these two structs: > > struct stack_u16 { > uint16_t sp; > uint16_t bp; > uint16_t *arr; > }; > > struct dns_resolver { > struct stack_u16 stack; > struct gwp_conn_pair **sess_map; > uint16_t sess_map_cap; > }; > > [ The struct dns_resolver MAY also cover socket, addr, etc. Now my > primary point here is about the session mapping data structure. ] > > 1) @stack is used to keep track of unused indexes in @sess_map. > > - Push all unused indexes into the @stack, the index will be used as > the DNS query txid. > > - When creating a DNS query, pop the stack, use the popped number as > the txid. The txid is also used to store the corresponding > gwp_conn_pair session (sess_map[txid] =3D ptr to conn session). > > - When the sess_map[txid] is no longer used, set > (sess_map[txid] =3D NULL) and push the txid back into the @stack. Could you elaborate on the usage of bp and sp? I'm a bit confused about how they are intended to be used in practice. My assumption is that bp points to index 0 as the base, and sp points to index sess_map_cap - 1. Is that correct? If so, why do we need bp in the first place, under what circumstances would bp change to something else? > - Double the size when the slot is exhausted. When double-ing the > size, the new allocated indexes are all pushed into the @stack. > The slot exhaustion happens when the @stack is empty, it can be > identified at the pop operation. So the @stack.arr is considered to be empty when sp =3D=3D bp or zero and at that moment, no more txid left to be used for incoming queries. > If the number of elements in the @stack is > equal to @sess_map_cap, that means @sess_map is 100% free and can > be reset to the initial state (back to size 16). Because I treat @stack.sp as an index that gets incremented gradually each time a push operation occurs, I assume you're talking about @stack.sp + 1 =3D=3D @sess_map_cap. -- Ahmad Gani