[GH-ISSUE #872] Not all records are returned from the additional section when making an SRV query #552

Open
opened 2026-03-15 23:07:01 +03:00 by kerem · 3 comments
Owner

Originally created by @rjloura on GitHub (Sep 23, 2019).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/872

Describe the bug
Made an SRV query which should return 12 SRV records in the answer section and 3 IN A records in the additional section. All 12 SRV records are returned but only the first (?) record from the additional section is returned.

To Reproduce
Steps to reproduce the behavior:

let resolver = Resolver::from_system_conf()?;
let response = resolver.lookup_srv(host)?;
dbg!(&response);

Expected behavior
Expected to see all 3 IN A records from the additional section. (See below for dig output)

System:

  • OS: illumos/smartos
  • Architecture: x86_64
  • Version: Trunk
  • rustc version: 1.37

Version:
Crate: resolver
Version: 0.12

Additional context

[rui@5cd5a1ca-e9ad-62c8-e838-83169cceb68a ~/git/srvlookup]$ dig +noall +answer +additional -t SRV _moray._tcp.1.moray.east.joyent.us
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2021 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2022 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2023 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2024 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2021 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2022 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2023 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2024 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2021 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2022 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2023 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us.
_moray._tcp.1.moray.east.joyent.us. 60 IN SRV   0 10 2024 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us.
052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. 60 IN A 10.77.77.17
5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. 60 IN A 10.77.77.16
06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. 60 IN A 10.77.77.15
[rui@5cd5a1ca-e9ad-62c8-e838-83169cceb68a ~/git/srvlookup]$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `target/debug/srvlookup`
[src/main.rs:5] &response = SrvLookup(
    Lookup {
        query: Query {
            name: Name {
                is_fqdn: true,
                labels: [
                    _moray,
                    _tcp,
                    1,
                    moray,
                    east,
                    joyent,
                    us,
                ],
            },
            query_type: SRV,
            query_class: IN,
        },
        records: [
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2021,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                5b9c1da0-2212-4edd-a252-fada9a400325,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2022,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                5b9c1da0-2212-4edd-a252-fada9a400325,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2023,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                5b9c1da0-2212-4edd-a252-fada9a400325,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2024,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                5b9c1da0-2212-4edd-a252-fada9a400325,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2021,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                052c75d9-b293-48b5-96e8-0434092fbc66,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2022,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                052c75d9-b293-48b5-96e8-0434092fbc66,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2023,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                052c75d9-b293-48b5-96e8-0434092fbc66,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2024,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                052c75d9-b293-48b5-96e8-0434092fbc66,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2021,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                06be11d5-f8dd-4239-847d-0822e16444c8,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2022,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                06be11d5-f8dd-4239-847d-0822e16444c8,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2023,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                06be11d5-f8dd-4239-847d-0822e16444c8,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        _moray,
                        _tcp,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: SRV,
                dns_class: IN,
                ttl: 60,
                rdata: SRV(
                    SRV {
                        priority: 0,
                        weight: 10,
                        port: 2024,
                        target: Name {
                            is_fqdn: true,
                            labels: [
                                06be11d5-f8dd-4239-847d-0822e16444c8,
                                1,
                                moray,
                                east,
                                joyent,
                                us,
                            ],
                        },
                    },
                ),
            },
            Record {
                name_labels: Name {
                    is_fqdn: true,
                    labels: [
                        06be11d5-f8dd-4239-847d-0822e16444c8,
                        1,
                        moray,
                        east,
                        joyent,
                        us,
                    ],
                },
                rr_type: A,
                dns_class: IN,
                ttl: 60,
                rdata: A(
                    10.77.77.15,
                ),
            },
        ],
        valid_until: Instant {
            tv_sec: 539685,
            tv_nsec: 827593297,
        },
    },
)
Originally created by @rjloura on GitHub (Sep 23, 2019). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/872 **Describe the bug** Made an SRV query which should return 12 SRV records in the answer section and 3 IN A records in the additional section. All 12 SRV records are returned but only the first (?) record from the additional section is returned. **To Reproduce** Steps to reproduce the behavior: ```rust let resolver = Resolver::from_system_conf()?; let response = resolver.lookup_srv(host)?; dbg!(&response); ``` **Expected behavior** Expected to see all 3 `IN A` records from the additional section. (See below for `dig` output) **System:** - OS: illumos/smartos - Architecture: x86_64 - Version: Trunk - rustc version: 1.37 **Version:** Crate: resolver Version: 0.12 **Additional context** ``` [rui@5cd5a1ca-e9ad-62c8-e838-83169cceb68a ~/git/srvlookup]$ dig +noall +answer +additional -t SRV _moray._tcp.1.moray.east.joyent.us _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2021 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2022 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2023 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2024 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2021 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2022 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2023 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2024 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2021 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2022 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2023 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. _moray._tcp.1.moray.east.joyent.us. 60 IN SRV 0 10 2024 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. 052c75d9-b293-48b5-96e8-0434092fbc66.1.moray.east.joyent.us. 60 IN A 10.77.77.17 5b9c1da0-2212-4edd-a252-fada9a400325.1.moray.east.joyent.us. 60 IN A 10.77.77.16 06be11d5-f8dd-4239-847d-0822e16444c8.1.moray.east.joyent.us. 60 IN A 10.77.77.15 [rui@5cd5a1ca-e9ad-62c8-e838-83169cceb68a ~/git/srvlookup]$ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.18s Running `target/debug/srvlookup` [src/main.rs:5] &response = SrvLookup( Lookup { query: Query { name: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, query_type: SRV, query_class: IN, }, records: [ Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2021, target: Name { is_fqdn: true, labels: [ 5b9c1da0-2212-4edd-a252-fada9a400325, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2022, target: Name { is_fqdn: true, labels: [ 5b9c1da0-2212-4edd-a252-fada9a400325, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2023, target: Name { is_fqdn: true, labels: [ 5b9c1da0-2212-4edd-a252-fada9a400325, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2024, target: Name { is_fqdn: true, labels: [ 5b9c1da0-2212-4edd-a252-fada9a400325, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2021, target: Name { is_fqdn: true, labels: [ 052c75d9-b293-48b5-96e8-0434092fbc66, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2022, target: Name { is_fqdn: true, labels: [ 052c75d9-b293-48b5-96e8-0434092fbc66, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2023, target: Name { is_fqdn: true, labels: [ 052c75d9-b293-48b5-96e8-0434092fbc66, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2024, target: Name { is_fqdn: true, labels: [ 052c75d9-b293-48b5-96e8-0434092fbc66, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2021, target: Name { is_fqdn: true, labels: [ 06be11d5-f8dd-4239-847d-0822e16444c8, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2022, target: Name { is_fqdn: true, labels: [ 06be11d5-f8dd-4239-847d-0822e16444c8, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2023, target: Name { is_fqdn: true, labels: [ 06be11d5-f8dd-4239-847d-0822e16444c8, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ _moray, _tcp, 1, moray, east, joyent, us, ], }, rr_type: SRV, dns_class: IN, ttl: 60, rdata: SRV( SRV { priority: 0, weight: 10, port: 2024, target: Name { is_fqdn: true, labels: [ 06be11d5-f8dd-4239-847d-0822e16444c8, 1, moray, east, joyent, us, ], }, }, ), }, Record { name_labels: Name { is_fqdn: true, labels: [ 06be11d5-f8dd-4239-847d-0822e16444c8, 1, moray, east, joyent, us, ], }, rr_type: A, dns_class: IN, ttl: 60, rdata: A( 10.77.77.15, ), }, ], valid_until: Instant { tv_sec: 539685, tv_nsec: 827593297, }, }, ) ```
Author
Owner

@bluejekyll commented on GitHub (Sep 23, 2019):

Hm, it's possible that there is a bug/feature in the SRV lookup logic. We might only be resolving the first SRV record fully? Given that this is just a filter on the IPs: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup.rs#L323

It probably means that not all the IPs were added to the Lookup. I'm pretty sure the logic for resolving the SRV record happens here: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup_state.rs#L205-L314

It might be that it's not following all the targets from all the SRV records returned?

<!-- gh-comment-id:534292933 --> @bluejekyll commented on GitHub (Sep 23, 2019): Hm, it's possible that there is a bug/feature in the SRV lookup logic. We might only be resolving the first SRV record fully? Given that this is just a filter on the IPs: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup.rs#L323 It probably means that not all the IPs were added to the Lookup. I'm pretty sure the logic for resolving the SRV record happens here: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup_state.rs#L205-L314 It might be that it's not following all the targets from all the SRV records returned?
Author
Owner

@bluejekyll commented on GitHub (Sep 23, 2019):

More specifically, this might be the problem area: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup_state.rs#L261-L291

We might be filtering a little too aggressively. The trust-dns-resolver tries to put an easy to use API around this stuff, and I think that in the case of CNAME/SRV it might only follow that to a single record? I'll need to review this in more detail later, but we probably need make it more accepting of additional records, where it might currently be limiting the additionals returned.

<!-- gh-comment-id:534295368 --> @bluejekyll commented on GitHub (Sep 23, 2019): More specifically, this might be the problem area: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup_state.rs#L261-L291 We might be filtering a little too aggressively. The trust-dns-resolver tries to put an easy to use API around this stuff, and I think that in the case of CNAME/SRV it might only follow that to a single record? I'll need to review this in more detail later, but we probably need make it more accepting of additional records, where it might currently be limiting the additionals returned.
Author
Owner

@davepacheco commented on GitHub (Mar 2, 2022):

Thanks for the details. I just ran into the same issue.

<!-- gh-comment-id:1057441889 --> @davepacheco commented on GitHub (Mar 2, 2022): Thanks for the details. I just ran into the same issue.
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#552
No description provided.