<div dir="ltr">Hello Everyone,<div><br></div><div>Can anyone  guide me here ?</div><div><br></div><div>Thanks,</div><div>Ashok</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 13, 2022 at 3:51 PM ashok athukuri <<a href="mailto:athukuriashok@gmail.com">athukuriashok@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">Hello George,</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)"><br>Thanks for the quick response, Yes I am using libunbound version 1.12</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">Yes I am setting config for a separate context</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">but SERVE_EXPIRED_REPLY_TTL  is a global variable and the same is used in different places example dns.c tomsg() function<br>I feel because of this global variable this part of the code is creating problems for different cache conf.<br>I tested with multiple caches and its holding only 1 configuration (I doubt it because of code services/cache/dns.c#594)</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)"><br>SERVE_EXPIRED_REPLY is assigned in build/util/config_file.c#2056 (config_apply)2056      </pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">SERVE_EXPIRED_REPLY_TTL = (time_t)config->serve_expired_reply_ttl;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)"><br>below code tomsg() is depending on SERVE_EXPIRED_REPLY_TTL to make this works these variables should be set in the context before actually calling tomsg() function. </pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">Else these values may remain un changed and apply for all caches.<br><br>As you can see in the below code services/cache/dns.c#594<br>589   msg = gen_dns_msg(region, q, r->rrset_count);</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">590      if(!msg) return NULL;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">591         msg->rep->flags = r->flags;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">592          msg->rep->qdcount = r->qdcount;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">593      msg->rep->ttl = is_expired</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">594              ?SERVE_EXPIRED_REPLY_TTL</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">595              :r->ttl - now;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">596     if(r->prefetch_ttl > now)</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">597               msg->rep->prefetch_ttl = r->prefetch_ttl - now;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">598      else</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">599                  msg->rep->prefetch_ttl = PREFETCH_TTL_CALC(msg->rep->ttl);</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">600        msg->rep->serve_expired_ttl = msg->rep->ttl + SERVE_EXPIRED_TTL;</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)"><br>Thanks,</pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">Ashok<br></pre><pre style="border:0px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)"><span style="display:inline"><br></span></pre></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 13, 2022 at 3:07 PM George Thessalonikefs via Unbound-users <<a href="mailto:unbound-users@lists.nlnetlabs.nl" target="_blank">unbound-users@lists.nlnetlabs.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Ashok,<br>
<br>
The Unbound daemon runs as one cache resolver.<br>
Are you perhaps using libunound and creating your own contexts?<br>
In that case yes the options are per context.<br>
You can have different options per context though, if you use the <br>
'ub_ctx_set_option' function.<br>
Since the options you mention are configurable and not hard coded, the <br>
aforementioned function works on them.<br>
<br>
Best regards,<br>
-- George<br>
<br>
On 13/05/2022 07:25, ashok athukuri via Unbound-users wrote:<br>
> Hello All,<br>
> <br>
> I am a newbie for unbound, please apologize if my question is wrong or <br>
> my understanding is wrong.<br>
> <br>
> I see below variables make unbound to use a single configuration for all <br>
> cache resolvers.<br>
> As these variables are global and don't bind with any unbound context or <br>
> configuration for each cache<br>
> <br>
> I wonder how to solve this problem? as I need different cache conf for <br>
> different cache resolvers.<br>
> <br>
> 64   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#64" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#64</a>>/** If we serve expired entries and prefetch them */<br>
> 65   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#65" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#65</a>>THREAD  <<a href="https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs</a>>  *int*  SERVE_EXPIRED  <<a href="https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED&project=tmos-dns-bugs</a>>  = 0;<br>
> 66   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#66" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#66</a>>/** Time to serve records after expiration */<br>
> 67   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#67" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#67</a>>THREAD  <<a href="https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs</a>>  time_t  <<a href="https://indexing2.f5net.com/source/s?defs=time_t&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?defs=time_t&project=tmos-dns-bugs</a>>  SERVE_EXPIRED_TTL  <<a href="https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED_TTL&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED_TTL&project=tmos-dns-bugs</a>>  = 0;<br>
> 68   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#68" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#68</a>>/** TTL to use for expired records */<br>
> 69   <<a href="https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#69" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/xref/tmos-dns-bugs/ports/unbound/build/util/data/msgreply.c#69</a>>THREAD  <<a href="https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?defs=THREAD&project=tmos-dns-bugs</a>>  time_t  <<a href="https://indexing2.f5net.com/source/s?defs=time_t&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?defs=time_t&project=tmos-dns-bugs</a>>  SERVE_EXPIRED_REPLY_TTL  <<a href="https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED_REPLY_TTL&project=tmos-dns-bugs" rel="noreferrer" target="_blank">https://indexing2.f5net.com/source/s?refs=SERVE_EXPIRED_REPLY_TTL&project=tmos-dns-bugs</a>>  =30;<br>
> <br>
> <br>
> Thanks,<br>
> <br>
> Ashok<br>
> <br>
</blockquote></div></div>
</blockquote></div>