1 Star 0 Fork 98

Mingtai/systemd_1

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-sd-dhcp-server-rename-server_send_nak-server_send_na.patch 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
From 96acfde5aae2017e1cad042b51f179ad20aba38d Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Fri, 28 Jan 2022 02:14:47 +0900
Subject: [PATCH] sd-dhcp-server: rename server_send_nak() ->
server_send_nak_or_ignore()
And logs error in the function.
(cherry picked from commit eb5bff9c9de2bd218f5ac431e3aead4b5747ecd9)
(cherry picked from commit 7f36fb25d5c6681dbabb067a9fb083bfad37a804)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/96acfde5aae2017e1cad042b51f179ad20aba38d
---
src/libsystemd-network/sd-dhcp-server.c | 29 ++++++++++++++-----------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 070f4ec1c2..d594aeb7cd 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -583,16 +583,28 @@ static int server_send_offer_or_ack(
return 0;
}
-static int server_send_nak(sd_dhcp_server *server, DHCPRequest *req) {
+static int server_send_nak_or_ignore(sd_dhcp_server *server, bool init_reboot, DHCPRequest *req) {
_cleanup_free_ DHCPPacket *packet = NULL;
size_t offset;
int r;
+ /* When a request is refused, RFC 2131, section 4.3.2 mentioned we should send NAK when the
+ * client is in INITREBOOT. If the client is in other state, there is nothing mentioned in the
+ * RFC whether we should send NAK or not. Hence, let's silently ignore the request. */
+
+ if (!init_reboot)
+ return 0;
+
r = server_message_init(server, &packet, DHCP_NAK, &offset, req);
if (r < 0)
- return r;
+ return log_dhcp_server_errno(server, r, "Failed to create NAK message: %m");
+
+ r = dhcp_server_send_packet(server, req, packet, DHCP_NAK, offset);
+ if (r < 0)
+ return log_dhcp_server_errno(server, r, "Could not send NAK message: %m");
- return dhcp_server_send_packet(server, req, packet, DHCP_NAK, offset);
+ log_dhcp_server(server, "NAK (0x%x)", be32toh(req->message->xid));
+ return DHCP_NAK;
}
static int server_send_forcerenew(sd_dhcp_server *server, be32_t address,
@@ -1079,18 +1091,9 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz
server->callback(server, SD_DHCP_SERVER_EVENT_LEASE_CHANGED, server->callback_userdata);
return DHCP_ACK;
-
- } else if (init_reboot) {
- r = server_send_nak(server, req);
- if (r < 0)
- /* this only fails on critical errors */
- return log_dhcp_server_errno(server, r, "Could not send nak: %m");
-
- log_dhcp_server(server, "NAK (0x%x)", be32toh(req->message->xid));
- return DHCP_NAK;
}
- break;
+ return server_send_nak_or_ignore(server, init_reboot, req);
}
case DHCP_RELEASE: {
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangmingtaip/systemd_1.git
git@gitee.com:yangmingtaip/systemd_1.git
yangmingtaip
systemd_1
systemd_1
master

搜索帮助