From 8bc1a7afdac5d9c2f174b141b32dc2b58deef1ee Mon Sep 17 00:00:00 2001
From: zhangyao2022 <zhangyao108@huawei.com>
Date: Mon, 27 Nov 2023 10:44:12 +0800
Subject: [PATCH] fix: fixed ListenNetlink parsing

---
 core/coms/socket/src/config.rs | 2 +-
 core/coms/socket/src/rentry.rs | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/core/coms/socket/src/config.rs b/core/coms/socket/src/config.rs
index 69cdc32..9585d5f 100755
--- a/core/coms/socket/src/config.rs
+++ b/core/coms/socket/src/config.rs
@@ -207,7 +207,7 @@ impl SocketConfig {
         let config = &self.data.borrow().Socket;
         self.parse_sockets(config.ListenStream.as_ref(), ListenItem::Stream)?;
         self.parse_sockets(config.ListenDatagram.as_ref(), ListenItem::Datagram)?;
-        self.parse_sockets(&[config.ListenNetlink.clone()], ListenItem::Netlink)?;
+        self.parse_sockets(config.ListenNetlink.as_ref(), ListenItem::Netlink)?;
         self.parse_sockets(
             config.ListenSequentialPacket.as_ref(),
             ListenItem::SequentialPacket,
diff --git a/core/coms/socket/src/rentry.rs b/core/coms/socket/src/rentry.rs
index 8b20c7e..3a25761 100755
--- a/core/coms/socket/src/rentry.rs
+++ b/core/coms/socket/src/rentry.rs
@@ -42,6 +42,10 @@ fn deserialize_pathbuf_vec(s: &str) -> Result<Vec<PathBuf>, core::error::Error>
     Ok(res)
 }
 
+fn deserialize_netlink_vec(s: &str) -> Result<Vec<String>, core::error::Error> {
+    Ok(vec![s.to_string()])
+}
+
 #[derive(UnitSection, Default, Clone, Debug, Serialize, Deserialize)]
 #[allow(dead_code)]
 pub(super) struct SectionSocket {
@@ -60,8 +64,8 @@ pub(super) struct SectionSocket {
     pub ListenStream: Vec<String>,
     #[entry(multiple)]
     pub ListenDatagram: Vec<String>,
-    #[entry(default = String::new())]
-    pub ListenNetlink: String,
+    #[entry(multiple, myparser = deserialize_netlink_vec)]
+    pub ListenNetlink: Vec<String>,
     #[entry(multiple)]
     pub ListenSequentialPacket: Vec<String>,
     #[entry(multiple)]
-- 
2.33.0

