1 Star 0 Fork 24

njzlisme/dhcp

forked from src-openEuler/dhcp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dhcp-dhclient-decline-backoff.patch 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:36 . Package init
diff -up dhcp-4.3.4/client/dhclient.c.backoff dhcp-4.3.4/client/dhclient.c
--- dhcp-4.3.4/client/dhclient.c.backoff 2016-04-29 12:16:26.976245611 +0200
+++ dhcp-4.3.4/client/dhclient.c 2016-04-29 12:16:26.979245609 +0200
@@ -1423,6 +1423,8 @@ void state_init (cpp)
void *cpp;
{
struct client_state *client = cpp;
+ enum dhcp_state init_state = client->state;
+ struct timeval tv;
ASSERT_STATE(state, S_INIT);
@@ -1435,9 +1437,18 @@ void state_init (cpp)
client -> first_sending = cur_time;
client -> interval = client -> config -> initial_interval;
- /* Add an immediate timeout to cause the first DHCPDISCOVER packet
- to go out. */
- send_discover (client);
+ if (init_state != S_DECLINED) {
+ /* Add an immediate timeout to cause the first DHCPDISCOVER packet
+ to go out. */
+ send_discover(client);
+ } else {
+ /* We've received an OFFER and it has been DECLINEd by dhclient-script.
+ * wait for a random time between 1 and backoff_cutoff seconds before
+ * trying again. */
+ tv . tv_sec = cur_time + ((1 + (random() >> 2)) % client->config->backoff_cutoff);
+ tv . tv_usec = 0;
+ add_timeout(&tv, send_discover, client, 0, 0);
+ }
}
/*
@@ -1734,5 +1745,6 @@ void bind_lease (client)
#endif
exit(2);
} else {
+ client -> state = S_DECLINED;
state_init(client);
return;
}
@@ -4626,6 +4638,7 @@ void client_location_changed ()
case S_INIT:
case S_REBINDING:
case S_STOPPED:
+ case S_DECLINED:
break;
}
client -> state = S_INIT;
diff -up dhcp-4.3.4/includes/dhcpd.h.backoff dhcp-4.3.4/includes/dhcpd.h
--- dhcp-4.3.4/includes/dhcpd.h.backoff 2016-04-29 12:16:26.980245609 +0200
+++ dhcp-4.3.4/includes/dhcpd.h 2016-04-29 12:17:30.893203533 +0200
@@ -1171,7 +1171,8 @@ enum dhcp_state {
S_BOUND = 5,
S_RENEWING = 6,
S_REBINDING = 7,
- S_STOPPED = 8
+ S_STOPPED = 8,
+ S_DECLINED = 9
};
/* Possible pending client operations. */
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/z00377906/dhcp.git
git@gitee.com:z00377906/dhcp.git
z00377906
dhcp
dhcp
master

搜索帮助