Skip to content

Add support for Client Subnet in DNS Queries (RFC7871)#5614

Closed
normanmaurer wants to merge 1 commit into4.1from
dns_rcs
Closed

Add support for Client Subnet in DNS Queries (RFC7871)#5614
normanmaurer wants to merge 1 commit into4.1from
dns_rcs

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

Motivation:

RFC7871 defines an extension which allows to request responses for a given subset.

Modifications:

  • Add DnsOptPseudoRrRecord which can act as base class for extensions based on EDNS(0) as defined in RFC6891
  • Add DnsOptEcsRecord to support the Client Subnet in DNS Queries extension
  • Add tests

Result:

Client Subnet in DNS Queries extension is now supported.

@normanmaurer
Copy link
Copy Markdown
Member Author

@Scottmitch PTAL

// See https://tools.ietf.org/html/rfc6891#section-6.1.3
private static long packIntoLong(int val, int val2) {
// We are currently not support DO and Z fields, just use 0.
return ((val & 0xff) << 24 | (val2 & 0xff) << 16 | (0 & 0xff) << 8 | 0 & 0xff) & 0xFFFFFFFFL;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just do ((val & 0xff) << 24 | (val2 & 0xff) << 16) for now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep it as it is to make it "easier" to add support later. Its not a big deal imho to keep one more shift.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal ... also not hard to add later ... fine as as

// See http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml
final short addressNumber;
if (address instanceof Inet4Address) {
addressNumber = 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extend InternetProtocolFamily to include this information?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure... Good idea.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder: use the new addition to InternetProtocolFamily here

@normanmaurer normanmaurer force-pushed the dns_rcs branch 2 times, most recently from 110b8cd to 3fd962a Compare August 4, 2016 04:48
out.writeByte(scopePrefixLength); // Must be 0 in queries.

if (leftOverBits > 0) {
int bytesLength = payloadLength - 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the suggestion from https://github.com/netty/netty/pull/5614/files#r73321879 would avoid the need for the extra operation (this is the same as sourcePrefixLength / Byte.SIZE).

@normanmaurer normanmaurer force-pushed the dns_rcs branch 2 times, most recently from c83e518 to 797e8c1 Compare August 5, 2016 17:12
try {
// Same as:
// # /.bind-9.9.3-edns/bin/dig @ns1.google.com www.google.es +client=157.88.0.0/24
Future<List<InetAddress>> future = resolver.resolveAll("www.google.es",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid depending on external DNS servers for unit tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Scottmitch that is why it is marked as @Ignore. There is currently no known java based dns server that support it and so will allow us to test it like this. I put it mainly here as an example how to use it. The encoder itself is tested in DefaultDnsRecordEncoderTest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for clarifying ... @Ignore should do the trick for now.

@normanmaurer
Copy link
Copy Markdown
Member Author

@Scottmitch PTAL again

throw new Error();
}
}
@Override
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add line

@normanmaurer
Copy link
Copy Markdown
Member Author

@Scottmitch addressed comments

@normanmaurer normanmaurer self-assigned this Aug 8, 2016
return removed;
}

private static boolean emptyAdditionals(DnsRecord[] additionals) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Consider using varargs for methods or constructors which take an array the last parameter. rule

@normanmaurer normanmaurer modified the milestones: 4.1.5.Final, 4.1.6.Final Aug 29, 2016
public byte[] address() {
return address.clone();
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString?

@trustin
Copy link
Copy Markdown
Member

trustin commented Sep 2, 2016

Mostly style nits and validation stuff. Great job!

@normanmaurer
Copy link
Copy Markdown
Member Author

@trustin I think I addressed everything... PTAL

Motivation:

RFC7871 defines an extension which allows to request responses for a given subset.

Modifications:

- Add DnsOptPseudoRrRecord which can act as base class for extensions based on EDNS(0) as defined in RFC6891
- Add DnsOptEcsRecord to support the Client Subnet in DNS Queries extension
- Add tests

Result:

Client Subnet in DNS Queries extension is now supported.
@normanmaurer
Copy link
Copy Markdown
Member Author

Cherry-picked into 4.1 (dfa3bbb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants