agent: Fix fd leak caused by netlink

See also: little-dude/netlink#165

Fixes: #1952

Because the author of netlink has no time to maintain the crate
(https://github.com/little-dude/netlink/issues/161), so we
need to switch the dependency to github temporarily.

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2021-06-02 16:39:14 +08:00
parent ac34f6dfd9
commit 1cc2ad3f34
2 changed files with 53 additions and 54 deletions

102
src/agent/Cargo.lock generated
View File

@ -104,12 +104,6 @@ dependencies = [
"iovec",
]
[[package]]
name = "bytes"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "bytes"
version = "1.0.1"
@ -347,7 +341,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite 0.2.4",
"pin-project-lite",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
@ -411,7 +405,7 @@ dependencies = [
"futures-core",
"inotify-sys",
"libc",
"tokio 1.2.0",
"tokio",
]
[[package]]
@ -478,8 +472,8 @@ dependencies = [
"libc",
"log",
"logging",
"netlink-packet-utils",
"netlink-sys",
"netlink-packet-utils 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"netlink-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.17.0",
"oci",
"prctl",
@ -497,7 +491,7 @@ dependencies = [
"slog-scope",
"slog-stdlog",
"tempfile",
"tokio 1.2.0",
"tokio",
"tokio-vsock",
"ttrpc",
]
@ -614,28 +608,26 @@ checksum = "2eb04b9f127583ed176e163fb9ec6f3e793b87e21deedd5734a69386a18a0151"
[[package]]
name = "netlink-packet-core"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "559c08b3ea479ace788a8f75388e3db15210561a4c0f37c4ec7bdf40a3be564e"
version = "0.2.4"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"anyhow",
"byteorder",
"libc",
"netlink-packet-utils",
"netlink-packet-utils 0.4.0 (git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326)",
]
[[package]]
name = "netlink-packet-route"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da1bf86b4324996fb58f8e17752b2a06176f4c5efc013928060ac94a3a329b71"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"anyhow",
"bitflags",
"byteorder",
"libc",
"netlink-packet-core",
"netlink-packet-utils",
"netlink-packet-utils 0.4.0 (git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326)",
]
[[package]]
@ -650,18 +642,28 @@ dependencies = [
"thiserror",
]
[[package]]
name = "netlink-packet-utils"
version = "0.4.0"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"anyhow",
"byteorder",
"paste",
"thiserror",
]
[[package]]
name = "netlink-proto"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b72e0d34a11ff4253bc7d38fbc246750c4d2d2718b318c9ad981d450ed62aa8"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"bytes 0.5.6",
"bytes 1.0.1",
"futures",
"log",
"netlink-packet-core",
"netlink-sys",
"tokio 1.2.0",
"netlink-sys 0.6.0 (git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326)",
"tokio",
"tokio-util",
]
@ -674,7 +676,18 @@ dependencies = [
"futures",
"libc",
"log",
"tokio 1.2.0",
"tokio",
]
[[package]]
name = "netlink-sys"
version = "0.6.0"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"futures",
"libc",
"log",
"tokio",
]
[[package]]
@ -846,12 +859,6 @@ dependencies = [
"fixedbitset",
]
[[package]]
name = "pin-project-lite"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
[[package]]
name = "pin-project-lite"
version = "0.2.4"
@ -877,7 +884,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "059a34f111a9dee2ce1ac2826a68b24601c4298cfeb1a587c3cb493d5ab46f52"
dependencies = [
"libc",
"nix 0.19.1",
"nix 0.20.0",
]
[[package]]
@ -1138,8 +1145,7 @@ dependencies = [
[[package]]
name = "rtnetlink"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c188dd8ddd43e195e483d255f4975d457a78021acf185ea2269e0667ef8b1a"
source = "git+https://github.com/little-dude/netlink?rev=a9367bc4700496ddebc088110c28f40962923326#a9367bc4700496ddebc088110c28f40962923326"
dependencies = [
"byteordered",
"futures",
@ -1148,7 +1154,7 @@ dependencies = [
"netlink-proto",
"nix 0.19.1",
"thiserror",
"tokio 1.2.0",
"tokio",
]
[[package]]
@ -1186,7 +1192,7 @@ dependencies = [
"slog",
"slog-scope",
"tempfile",
"tokio 1.2.0",
"tokio",
]
[[package]]
@ -1438,16 +1444,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "tokio"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48"
dependencies = [
"bytes 0.5.6",
"pin-project-lite 0.1.11",
]
[[package]]
name = "tokio"
version = "1.2.0"
@ -1461,7 +1457,7 @@ dependencies = [
"mio",
"num_cpus",
"once_cell",
"pin-project-lite 0.2.4",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"winapi",
@ -1480,16 +1476,16 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.2.0"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930"
checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592"
dependencies = [
"bytes 0.5.6",
"bytes 1.0.1",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.1.11",
"tokio 0.2.24",
"pin-project-lite",
"tokio",
]
[[package]]
@ -1501,7 +1497,7 @@ dependencies = [
"bytes 0.4.12",
"futures",
"libc",
"tokio 1.2.0",
"tokio",
"vsock",
]
@ -1520,7 +1516,7 @@ dependencies = [
"protobuf",
"protobuf-codegen-pure",
"thiserror",
"tokio 1.2.0",
"tokio",
"tokio-vsock",
]

View File

@ -25,7 +25,10 @@ tokio = { version = "1.2.0", features = ["rt", "rt-multi-thread", "sync", "macro
futures = "0.3.12"
netlink-sys = { version = "0.6.0", features = ["tokio_socket",]}
tokio-vsock = "0.3.1"
rtnetlink = "0.7.0"
# Because the author has no time to maintain the crate, we switch the dependency to github,
# Once the new version released on crates.io, we switch it back.
# https://github.com/little-dude/netlink/issues/161
rtnetlink = { git = "https://github.com/little-dude/netlink", rev = "a9367bc4700496ddebc088110c28f40962923326" }
netlink-packet-utils = "0.4.0"
ipnetwork = "0.17.0"