]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add a 1 byte version number to edns option OTTRACEIDS
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 21 Jul 2025 12:44:51 +0000 (14:44 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 21 Jul 2025 12:44:51 +0000 (14:44 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/dnsdistdist/dnsdist-actions-factory.cc
pdns/protozero-trace.cc
pdns/sdig.cc

index 07e8ea9b19d722fd3135953eb459df80fb0e7edc..e8f5d7af20fc2782766d02af1aafbef02aa63343 100644 (file)
@@ -1521,7 +1521,7 @@ public:
 
     auto [protocol, httpProtocol] = ProtocolToDNSTap(dnsquestion->getProtocol());
     // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
-    DnstapMessage message(std::move(data), !dnsquestion->getHeader()->qr ? DnstapMessage::MessageType::client_query : DnstapMessage::MessageType::client_response, d_identity, &dnsquestion->ids.origRemote, &dnsquestion->ids.origDest, protocol, reinterpret_cast<const char*>(dnsquestion->getData().data()), dnsquestion->getData().size(), &dnsquestion->getQueryRealTime(), nullptr, boost::none, httpProtocol);
+    DnstapMessagemessage(std::move(data), !dnsquestion->getHeader()->qr ? DnstapMessage::MessageType::client_query : DnstapMessage::MessageType::client_response, d_identity, &dnsquestion->ids.origRemote, &dnsquestion->ids.origDest, protocol, reinterpret_cast<const char*>(dnsquestion->getData().data()), dnsquestion->getData().size(), &dnsquestion->getQueryRealTime(), nullptr, boost::none, httpProtocol);
     {
       if (d_alterFunc) {
         auto lock = g_lua.lock();
index 3599b688d8aa159bfa147c706acb47e1318f4dc9..c4b4a7228561aee780bab3e461237c532c59793e 100644 (file)
@@ -515,13 +515,14 @@ void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::InitialSpanInfo
   const auto traceIDSize = span.trace_id.size();
 
   if (const auto& option = map.find(EDNSOptionCode::OTTRACEIDS); option != map.end()) {
+    // 1 byte version, then tracid  then optinal spanid
     if (option->second.values.size() > 0) {
-      if (option->second.values.at(0).size >= traceIDSize) {
+      if (option->second.values.at(0).size >= 1 + traceIDSize) {
         traceidset = true;
-        pdns::trace::fill(span.trace_id, option->second.values.at(0).content, traceIDSize);
+        pdns::trace::fill(span.trace_id, &option->second.values.at(0).content[1], traceIDSize);  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) it's the API
       }
-      if (option->second.values.at(0).size == traceIDSize + span.parent_span_id.size()) {
-        pdns::trace::fill(span.parent_span_id, &option->second.values.at(0).content[traceIDSize], span.parent_span_id.size()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) it's the API
+      if (option->second.values.at(0).size == 1 + traceIDSize + span.parent_span_id.size()) {
+        pdns::trace::fill(span.parent_span_id, &option->second.values.at(0).content[traceIDSize + 1], span.parent_span_id.size()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) it's the API
       }
     }
   }
index 6de3a4a95121f39d076401b49214882bc3fade36..98cbc91c1029ec28e517c21a7c01f9dc94bc7008 100644 (file)
@@ -97,9 +97,10 @@ static void fillPacket(vector<uint8_t>& packet, const string& q, const string& t
     if (otids) {
       const auto traceid = otids->first;
       const auto spanid = otids->second;
-      std::array<uint8_t, traceid.size() + spanid.size()> data{};
-      std::copy(traceid.begin(), traceid.end(), data.begin());
-      std::copy(spanid.begin(), spanid.end(), data.begin() + traceid.size());
+      std::array<uint8_t, 1 + traceid.size() + spanid.size()> data{};
+      data.at(0) = 0; // version
+      std::copy(traceid.begin(), traceid.end(), &data.at(1));
+      std::copy(spanid.begin(), spanid.end(), &data.at(1 + traceid.size()));
       opts.emplace_back(EDNSOptionCode::OTTRACEIDS, std::string_view(reinterpret_cast<const char*>(data.data()), data.size())); // NOLINT
     }
     pw.addOpt(bufsize, 0, dnssec ? EDNSOpts::DNSSECOK : 0, opts);