]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: drop unused ret_messages argument
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Dec 2025 15:28:55 +0000 (00:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Dec 2025 23:24:28 +0000 (08:24 +0900)
This is not only unused, the kernel never provide any meaningful reply
for batch message. Let's drop it.

src/libsystemd/sd-netlink/netlink-internal.h
src/libsystemd/sd-netlink/netlink-message-nfnl.c
src/shared/firewall-util.c

index 158e2e55779e29ae0a5d5f21a9846363b4bcd1df..51e523c1ba7a307632b1aab27cefa11e02f8d7d0 100644 (file)
@@ -187,8 +187,7 @@ int sd_nfnl_call_batch(
                 sd_netlink *nfnl,
                 sd_netlink_message **messages,
                 size_t n_messages,
-                uint64_t usec,
-                sd_netlink_message ***ret_messages);
+                uint64_t usec);
 int sd_nfnl_message_new(
                 sd_netlink *nfnl,
                 sd_netlink_message **ret,
index 2b6e1dd82b52411999353305442fab5faa56c352..8708aac102307abc65beda4bf435ec1816951b09 100644 (file)
@@ -178,10 +178,8 @@ int sd_nfnl_call_batch(
                 sd_netlink *nfnl,
                 sd_netlink_message **messages,
                 size_t n_messages,
-                uint64_t usec,
-                sd_netlink_message ***ret_messages) {
+                uint64_t usec) {
 
-        _cleanup_free_ sd_netlink_message **replies = NULL;
         _cleanup_free_ uint32_t *serials = NULL;
         int r;
 
@@ -190,25 +188,15 @@ int sd_nfnl_call_batch(
         assert_return(messages, -EINVAL);
         assert_return(n_messages > 0, -EINVAL);
 
-        if (ret_messages) {
-                replies = new0(sd_netlink_message*, n_messages);
-                if (!replies)
-                        return -ENOMEM;
-        }
-
         r = sd_nfnl_send_batch(nfnl, messages, n_messages, &serials);
         if (r < 0)
                 return r;
 
         for (size_t i = 0; i < n_messages; i++)
-                RET_GATHER(r,
-                           sd_netlink_read(nfnl, serials[i], usec, ret_messages ? replies + i : NULL));
+                RET_GATHER(r, sd_netlink_read(nfnl, serials[i], usec, /* ret= */ NULL));
         if (r < 0)
                 return r;
 
-        if (ret_messages)
-                *ret_messages = TAKE_PTR(replies);
-
         return 0;
 }
 
index b59740166e794a1409e872b730d176ae08735095..0f4073a0857859082f4d508e2244855403db8869 100644 (file)
@@ -807,7 +807,7 @@ static int fw_nftables_init_family(sd_netlink *nfnl, int family) {
                 return r;
 
         assert(msgcnt < ELEMENTSOF(messages));
-        r = sd_nfnl_call_batch(nfnl, messages, msgcnt, NFNL_DEFAULT_TIMEOUT_USECS, NULL);
+        r = sd_nfnl_call_batch(nfnl, messages, msgcnt, NFNL_DEFAULT_TIMEOUT_USECS);
         if (r < 0 && r != -EEXIST)
                 return r;
 
@@ -919,7 +919,7 @@ int nft_set_element_modify_iprange(
         if (r < 0)
                 return r;
 
-        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS, NULL);
+        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS);
 }
 
 int nft_set_element_modify_ip(
@@ -959,7 +959,7 @@ int nft_set_element_modify_ip(
         if (r < 0)
                 return r;
 
-        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS, NULL);
+        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS);
 }
 
 int nft_set_element_modify_any(
@@ -987,7 +987,7 @@ int nft_set_element_modify_any(
         if (r < 0)
                 return r;
 
-        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS, NULL);
+        return sd_nfnl_call_batch(nfnl, &m, 1, NFNL_DEFAULT_TIMEOUT_USECS);
 }
 
 static int af_to_nfproto(int af) {
@@ -1124,7 +1124,7 @@ static int fw_nftables_add_local_dnat_internal(
                 return r;
 
         assert(msgcnt < ELEMENTSOF(messages));
-        r = sd_nfnl_call_batch(nfnl, messages, msgcnt, NFNL_DEFAULT_TIMEOUT_USECS, NULL);
+        r = sd_nfnl_call_batch(nfnl, messages, msgcnt, NFNL_DEFAULT_TIMEOUT_USECS);
         if (r == -EOVERFLOW && af == AF_INET6) {
                 /* The current implementation of DNAT in systemd requires kernel's
                  * fdb9c405e35bdc6e305b9b4e20ebc141ed14fc81 (v5.8), and the older kernel returns