[PR #728] [MERGED] Generate meaningfull EdnsCodes from EdnsOptions #1637

Closed
opened 2026-03-16 02:17:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/728
Author: @jonasbb
Created: 4/5/2019
Status: Merged
Merged: 4/5/2019
Merged by: @bluejekyll

Base: masterHead: fix-ednscode-from-ednsoption


📝 Commits (1)

  • 54acc35 Generate meaningfull EdnsCodes from EdnsOptions

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 crates/proto/src/rr/rdata/opt.rs (+1 -1)

📄 Description

My use case is setting and potentially overwriting EDNS options in parsed Messages.

This is an example for an EDNS section:

Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096,
  options: OPT { options: {Padding: Unknown(12, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])} } }

And here is how I try to modify the Padding option:

msg.edns_mut().set_option(
    EdnsOption::from((
        EdnsCode::Padding,
        &[1,2,3,4][..]
    ))
)

This is the result before my patch. Notice how there are two padding entries, but with the two different keys of EdnsCode::Padding and EdnsCode::Unknown(12).

Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096,
  options: OPT { options: {Padding: Unknown(12, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), Unknown(12): Unknown(12, [1, 2, 3, 4])} } }

This is what I want to get and what happens with this PR merged:

Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096,
  options: OPT { options: {Padding: Unknown(12, [1, 2, 3, 4])} } }

Before this commit the From<&'a EdnsOption> for EdnsCode implementation
always created Ednscode::Unknown entries. This is a problem, because the
OPT type is keyed by an EdnsCode value, but EdnsCode::Unknown(12) and
EdnsCode::Padding are not compared as equal.

This change improves the situation by always creating the meaningfull
EdnsCode variants instead of EdnsCode::Unknown.

I don't know if this fully fixes the problem. While EdnsCode::Unknown(12) and EdnsCode::Padding are differently structured they should probably compare as equal, since they logically represent the same thing. So it might be necessary to change the Eq implementation to ensure that EdnsCode::Padding == EdnsCode::Unknown(12) is true.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/728 **Author:** [@jonasbb](https://github.com/jonasbb) **Created:** 4/5/2019 **Status:** ✅ Merged **Merged:** 4/5/2019 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `master` ← **Head:** `fix-ednscode-from-ednsoption` --- ### 📝 Commits (1) - [`54acc35`](https://github.com/hickory-dns/hickory-dns/commit/54acc357e8b43003e4e2ef0dcabf731661609f9a) Generate meaningfull EdnsCodes from EdnsOptions ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/rr/rdata/opt.rs` (+1 -1) </details> ### 📄 Description My use case is setting and potentially overwriting EDNS options in parsed Messages. This is an example for an EDNS section: ```rust Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096, options: OPT { options: {Padding: Unknown(12, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])} } } ``` And here is how I try to modify the Padding option: ```rust msg.edns_mut().set_option( EdnsOption::from(( EdnsCode::Padding, &[1,2,3,4][..] )) ) ``` This is the result before my patch. Notice how there are two padding entries, but with the two different keys of `EdnsCode::Padding` and `EdnsCode::Unknown(12)`. ```rust Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096, options: OPT { options: {Padding: Unknown(12, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), Unknown(12): Unknown(12, [1, 2, 3, 4])} } } ``` This is what I want to get and what happens with this PR merged: ```rust Edns { rcode_high: 0, version: 0, dnssec_ok: false, max_payload: 4096, options: OPT { options: {Padding: Unknown(12, [1, 2, 3, 4])} } } ``` Before this commit the `From<&'a EdnsOption> for EdnsCode` implementation always created `Ednscode::Unknown` entries. This is a problem, because the `OPT` type is keyed by an `EdnsCode` value, but `EdnsCode::Unknown(12)` and `EdnsCode::Padding` are not compared as equal. This change improves the situation by always creating the meaningfull `EdnsCode` variants instead of `EdnsCode::Unknown`. I don't know if this fully fixes the problem. While `EdnsCode::Unknown(12)` and `EdnsCode::Padding` are differently structured they should probably compare as equal, since they logically represent the same thing. So it might be necessary to change the `Eq` implementation to ensure that `EdnsCode::Padding == EdnsCode::Unknown(12)` is true. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 02:17:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1637
No description provided.