Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashed at internal/dhcpd/v4.go:298 #4722

Closed
TechCiel opened this issue Jul 8, 2022 · 2 comments
Closed

Crashed at internal/dhcpd/v4.go:298 #4722

TechCiel opened this issue Jul 8, 2022 · 2 comments
Assignees
Milestone

Comments

@TechCiel
Copy link

TechCiel commented Jul 8, 2022

Issue Details

The goroutine processing requests trying to add a static DHCP lease crashed.

  • Version of AdGuard Home server:
    • v0.107.7
  • How did you install AdGuard Home:
    • curl | sh
  • How did you setup DNS configuration:
    • In a Proxmox VE container
  • If it's a router or IoT, please write device model:
    • NUC8i5BEK
  • CPU architecture:
    • Intel i5-8259U
  • Operating system and version:
    • Debian 11

Expected Behavior

After filling MAC, IP and hostname in the New static lease modal and hit save, the record should be shown in table DHCP static leases.

Actual Behavior

Error: control/dhcp/add_static_lease | Network Error in red at the bottom-right corner. Nothing else happend.

Additional Information

Crashed request in cURL:
curl 'https://example.com/control/dhcp/add_static_lease' \
  -H 'content-type: application/json' \
  -H 'cookie: agh_session=[redacted]' \
  --data-raw '{"mac":"1C:69:00:00:00:00","ip":"172.23.3.2","hostname":"pve"}'
`dhcp` section in config:
dhcp:
  enabled: false
  interface_name: eth0
  local_domain_name: lan
  dhcpv4:
    gateway_ip: 172.23.3.1
    subnet_mask: 255.255.255.192
    range_start: 172.23.3.10
    range_end: 172.23.3.59
    lease_duration: 86400
    icmp_timeout_msec: 1000
    options: []
  dhcpv6:
    range_start: ""
    lease_duration: 86400
    ra_slaac_only: false
    ra_allow_slaac: false
Stack trace:
2022/07/08 17:08:56.601993 8207#310 [debug] POST /control/dhcp/add_static_lease
2022/07/08 17:08:56.602425 8207#310 [debug] web: plain: http: panic serving [redacted]: runtime error: invalid memory address or nil pointer dereference
goroutine 310 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1802 +0xb9
panic({0xbe1ea0, 0x2644620})
        runtime/panic.go:1047 +0x266
net.networkNumberAndMask(0xc0011233e0)
        net/ip.go:498
net.(*IPNet).Contains(0xba85e0, {0xc00067ab3c, 0x4, 0x1})
        net/ip.go:522 +0x27
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).addLease(0xc0003fc500, 0xc00257fce0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:298 +0x16c
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).AddStaticLease.func2(0xc0003fc500, 0xc00257fce0, 0xc0011234e0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:388 +0x205
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*v4Server).AddStaticLease(0xc0003fc500, 0xc00257fce0)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/v4.go:394 +0x1fe
github.com/AdguardTeam/AdGuardHome/internal/dhcpd.(*Server).handleDHCPAddStaticLease(0xc0003c7f00, {0x20ca250, 0xc0040dc4d0}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/dhcpd/http.go:513 +0x1fc
github.com/AdguardTeam/AdGuardHome/internal/home.ensure.func1({0x20ca250, 0xc0040dc4d0}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:219 +0x204
github.com/AdguardTeam/AdGuardHome/internal/home.(*httpHandler).ServeHTTP(0xba85e0, {0x20ca250, 0xc0040dc4d0}, 0x4)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:237 +0x2f
github.com/NYTimes/gziphandler.GzipHandlerWithOpts.func1.1({0x20ca070, 0xc000164000}, 0xc001109818)
        github.com/NYTimes/gziphandler@v1.1.1/gzip.go:336 +0x23c
net/http.HandlerFunc.ServeHTTP(0x40d094, {0x20ca070, 0xc000164000}, 0xc001109830)
        net/http/server.go:2047 +0x2f
github.com/AdguardTeam/AdGuardHome/internal/home.optionalAuth.func1({0x20ca070, 0xc000164000}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/auth.go:598 +0x374
github.com/AdguardTeam/AdGuardHome/internal/home.(*authHandler).ServeHTTP(0x7fc9601d5108, {0x20ca070, 0xc000164000}, 0xc000c79490)
        github.com/AdguardTeam/AdGuardHome/internal/home/auth.go:607 +0x9f
github.com/AdguardTeam/AdGuardHome/internal/home.postInstall.func1({0x20ca070, 0xc000164000}, 0xc0026ae300)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:336 +0x115
github.com/AdguardTeam/AdGuardHome/internal/home.(*postInstallHandlerStruct).ServeHTTP(0xc0011099b0, {0x20ca070, 0xc000164000}, 0xc000c79480)
        github.com/AdguardTeam/AdGuardHome/internal/home/control.go:345 +0x9f
net/http.(*ServeMux).ServeHTTP(0x20c83c8, {0x20ca070, 0xc000164000}, 0xc0026ae300)
        net/http/server.go:2425 +0x149
github.com/AdguardTeam/AdGuardHome/internal/home.limitRequestBody.func1({0x20ca070, 0xc000164000}, 0xc0026ae200)
        github.com/AdguardTeam/AdGuardHome/internal/home/middlewares.go:75 +0x352
net/http.HandlerFunc.ServeHTTP(0x0, {0x20ca070, 0xc000164000}, 0x6af720)
        net/http/server.go:2047 +0x2f
net/http.serverHandler.ServeHTTP({0x20c76f8}, {0x20ca070, 0xc000164000}, 0xc0026ae200)
        net/http/server.go:2879 +0x43b
net/http.(*conn).serve(0xc00012f860, {0x20d28b0, 0xc0003106f0})
        net/http/server.go:1930 +0xb08
created by net/http.(*Server).Serve
        net/http/server.go:3034 +0x4e8
@ainar-g ainar-g self-assigned this Jul 22, 2022
@ainar-g ainar-g added this to the v0.107.9 milestone Jul 22, 2022
@ainar-g
Copy link
Contributor

ainar-g commented Jul 22, 2022

Apologies for the long wait and thank you for the thorough bug report. We'll fix that in the next patch release.

@ainar-g ainar-g modified the milestones: v0.107.9, v0.107.10 Aug 3, 2022
@ainar-g ainar-g modified the milestones: v0.107.10, v0.107.11, v0.107.12 Aug 17, 2022
@ainar-g ainar-g assigned EugeneOne1 and unassigned ainar-g Aug 25, 2022
@ainar-g ainar-g modified the milestones: v0.107.12, v0.107.13 Sep 7, 2022
adguard pushed a commit that referenced this issue Sep 13, 2022
Merge in DNS/adguard-home from 4722-dhcp-http-panic to master

Updates #4722.

Squashed commit of the following:

commit 8a8db48
Merge: 39b344f b74b92f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 20:11:23 2022 +0300

    Merge branch 'master' into 4722-dhcp-http-panic

commit 39b344f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 18:33:56 2022 +0300

    dhcpd: imp code, fmt

commit a36d70d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 17:38:17 2022 +0300

    dhcpd: imp names, docs

commit 600d63d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 17:36:17 2022 +0300

    dhcpd: rename files, imp tags

commit 44f5507
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 16:40:26 2022 +0300

    dhcpd: add mock

commit cfc3cfb
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 16:15:27 2022 +0300

    all: use ptr instead of value

commit ec526c2
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:57:10 2022 +0300

    all: log changes

commit 0eca09f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:50:32 2022 +0300

    dhcpd: let v4 be unconfigured

commit 59636e9
Merge: 9238ca0 bc1503a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:50:17 2022 +0300

    Merge branch 'master' into 4722-dhcp-http-panic

commit 9238ca0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Sep 7 18:28:56 2022 +0300

    dhcpd: imp conf

commit 5f801c9
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 6 16:31:13 2022 +0300

    dhcpd: hide behind iface

commit a95c274
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 31 16:24:02 2022 +0300

    dhcpd: separate os files
@EugeneOne1
Copy link
Member

EugeneOne1 commented Sep 14, 2022

@TechCiel, hello. This should be fixed in the latest edge build. AGH should now respond with error on adding a static lease to the unconfigured DHCP server. Could you please check if the problem gone?

anphucnguyen pushed a commit to anphucnguyen/AdGuardHome that referenced this issue Sep 21, 2022
Merge in DNS/adguard-home from 4722-dhcp-http-panic to master

Updates AdguardTeam#4722.

Squashed commit of the following:

commit 8a8db48
Merge: 39b344f b74b92f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 20:11:23 2022 +0300

    Merge branch 'master' into 4722-dhcp-http-panic

commit 39b344f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 18:33:56 2022 +0300

    dhcpd: imp code, fmt

commit a36d70d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 17:38:17 2022 +0300

    dhcpd: imp names, docs

commit 600d63d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 17:36:17 2022 +0300

    dhcpd: rename files, imp tags

commit 44f5507
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 16:40:26 2022 +0300

    dhcpd: add mock

commit cfc3cfb
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 16:15:27 2022 +0300

    all: use ptr instead of value

commit ec526c2
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:57:10 2022 +0300

    all: log changes

commit 0eca09f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:50:32 2022 +0300

    dhcpd: let v4 be unconfigured

commit 59636e9
Merge: 9238ca0 bc1503a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 13 14:50:17 2022 +0300

    Merge branch 'master' into 4722-dhcp-http-panic

commit 9238ca0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Sep 7 18:28:56 2022 +0300

    dhcpd: imp conf

commit 5f801c9
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 6 16:31:13 2022 +0300

    dhcpd: hide behind iface

commit a95c274
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 31 16:24:02 2022 +0300

    dhcpd: separate os files
@ainar-g ainar-g closed this as completed Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants