)]}'
{
  "commit": "ba404a60ffd9e9a6143a3f6f7e57e400607a5cae",
  "tree": "9fe27c2e435dab9ab0927b94ba9ee48d2e2e31b5",
  "parents": [
    "f69d84b0f2b8b363f42ed6a3c09523b75d002f94"
  ],
  "author": {
    "name": "Jan Schär",
    "email": "jan@monogon.tech",
    "time": "Thu Jul 11 10:46:27 2024 +0200"
  },
  "committer": {
    "name": "Jan Schär",
    "email": "jan@monogon.tech",
    "time": "Mon Jul 15 11:59:30 2024 +0000"
  },
  "message": "m/n/c/network: fix panic when DHCP lease expires\n\nThe statusCallback of the network service previously accessed\nnew.AssignedIP without checking if new is nil, which caused a panic when\nthe DHCP lease expired. When subsequently the DHCP service was restarted\nand a new lease obtained, CoreDNS was left without upstream servers\nconfigured. The reason for this is that just before the panic, CoreDNS\nwas configured with an empty list of upstreams, but the lease field of\nthe DHCP service was not updated. When the lease callback was called\nagain with the new lease, old and new lease had the same DNS servers, so\nCoreDNS was not configured to use the upstreams.\n\nTo fix the panic, this adds a check for a nil lease before accessing\nAssignedIP. I looked if all consumers of the ExternalAddress Status can\nhandle nil, and added a nil check in the statuspush worker. The\napiserver stops when the lease is lost, and starts again once it is\nreacquired; I\u0027m not sure if this is the intended behavior.\n\nThe DNS problem occured because the old lease passed to the callback was\nnot the last lease that the callback had seen, and it then mistakenly\nsuppressed the update. In general, a callback cannot rely on the old\nlease being the last lease that the callback has been called with. For\nexample, when a callback earlier in the Compose chain returns an error,\nlater callbacks are not called, so a callback may not see all lease\nchanges. Because the old lease parameter cannot be trusted, I removed\nit. Callbacks which need the previous lease should keep track of it\nthemselves.\n\nFor manually testing lease expiry, I modified\nmetropolis/test/nanoswitch/nanoswitch.go like this:\n\n+\t\tstart :\u003d time.Now()\n \t\tserver, err :\u003d server4.NewServer(link.Attrs().Name, \u0026laddr, func(conn net.PacketConn, peer net.Addr, m *dhcpv4.DHCPv4) {\n \t\t\tif m \u003d\u003d nil {\n \t\t\t\treturn\n \t\t\t}\n+\t\t\tif start.Add(50*time.Second).Before(time.Now()) \u0026\u0026 start.Add(90*time.Second).After(time.Now()) {\n+\t\t\t\tsupervisor.Logger(ctx).Infof(\"Dropping DHCP packet\")\n+\t\t\t\treturn\n+\t\t\t}\n \t\t\treply, err :\u003d dhcpv4.NewReplyFromRequest(m)\n\nChange-Id: Ifa0c039769c37ee53033ce013eed4f1af6f02142\nReviewed-on: https://review.monogon.dev/c/monogon/+/3214\nTested-by: Jenkins CI\nReviewed-by: Lorenz Brun \u003clorenz@monogon.tech\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cc21b4fab9e3d1d921b5ba15f6611ddca5d62fba",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/dhcp4c/callback/callback.go",
      "new_id": "2acc539441d4ca33b58288a272aa47705b8a887c",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/dhcp4c/callback/callback.go"
    },
    {
      "type": "modify",
      "old_id": "a1c459af676fcc4ebd5e005cecb1571056275d65",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/dhcp4c/callback/callback_test.go",
      "new_id": "e83596e88e0203e1b8aad338457033c5c47767a8",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/dhcp4c/callback/callback_test.go"
    },
    {
      "type": "modify",
      "old_id": "d14dee85208fa37d0fffeae49466fad6e6055a0c",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/dhcp4c/dhcpc.go",
      "new_id": "be3170020d439e8983889b1337b89586ccf29b52",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/dhcp4c/dhcpc.go"
    },
    {
      "type": "modify",
      "old_id": "ca3994adb12cb09c818c0656ed0864c34e1d8f6a",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/dhcp4c/dhcpc_test.go",
      "new_id": "d9d5dd2ba26ae6f728480505035ae7e8a7d4d48a",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/dhcp4c/dhcpc_test.go"
    },
    {
      "type": "modify",
      "old_id": "487a0eb837ae5e8ce0cf7631023c647107ed4d7e",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/main.go",
      "new_id": "5404660611785d2fea94e56590be29436cdc167b",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/main.go"
    },
    {
      "type": "modify",
      "old_id": "d69815c4fd74dbe402484bf883e4a52214776492",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/network/static.go",
      "new_id": "f0cc4e25e695fcf223efa85786d72a807e796f63",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/network/static.go"
    },
    {
      "type": "modify",
      "old_id": "1b269c628560531a82bbf4749ad294fd34536235",
      "old_mode": 33188,
      "old_path": "metropolis/node/core/roleserve/worker_statuspush.go",
      "new_id": "0cbc442bc2e5b95a87206886eb4141611fd4747b",
      "new_mode": 33188,
      "new_path": "metropolis/node/core/roleserve/worker_statuspush.go"
    }
  ]
}
