blob: 2a0a40c512724b996cc5a1c6dfe5b9b7a8c3dc9a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From 53626cd06a3ef05ed847daea802ef0aa9661caa7 Mon Sep 17 00:00:00 2001
2From: Anders Darander <anders@chargestorm.se>
3Date: Thu, 3 Nov 2011 08:51:31 +0100
4Subject: [PATCH] busybox-udhcpc-no_deconfig.patch
5
6Upstream-Status: Pending
7
8Add a new option -D to the udhcpc client that allows for
9dhcp renewal to occur without having to down the interface
10in the process.
11
12Signed-off-by: Greg Moffatt <greg.moffatt@windriver.com>
13
14Updated to latest Busybox 1.17.3
15
16Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
17
18Updated to Busybox 1.18.4
19option spec is changed
20
21Signed-off-by: Qing He <qing.he@intel.com>
22
23Updated to Busybox 1.19.3
24
25Signed-off-by: Anders Darander <anders@chargestorm.se>
26
27Fixed options -b, -a and -P.
28
29Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
30---
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 networking/udhcp/dhcpc.c | 29 ++++++++++++++++------
32 1 file changed, 21 insertions(+), 8 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033
Brad Bishop96ff1982019-08-19 13:50:42 -040034Index: busybox-1.31.0/networking/udhcp/dhcpc.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035===================================================================
Brad Bishop96ff1982019-08-19 13:50:42 -040036--- busybox-1.31.0.orig/networking/udhcp/dhcpc.c
37+++ busybox-1.31.0/networking/udhcp/dhcpc.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038@@ -48,6 +48,8 @@
Brad Bishop316dfdd2018-06-25 12:45:53 -040039 };
40 #endif
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
42+/* option whether to down the interface when reconfiguring */
43+static int allow_deconfig = 1;
Brad Bishop316dfdd2018-06-25 12:45:53 -040044
Brad Bishop96ff1982019-08-19 13:50:42 -040045 /* "struct client_data_t client_data" is in bb_common_bufsiz1 */
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046
Brad Bishop96ff1982019-08-19 13:50:42 -040047@@ -103,8 +105,10 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 OPT_x = 1 << 18,
49 OPT_f = 1 << 19,
50 OPT_B = 1 << 20,
51+ OPT_D = 1 << 21,
52 /* The rest has variable bit positions, need to be clever */
Brad Bishop96ff1982019-08-19 13:50:42 -040053 OPTBIT_B = 20,
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054+ OPTBIT_D = 21,
55 USE_FOR_MMU( OPTBIT_b,)
56 IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
57 IF_FEATURE_UDHCP_PORT( OPTBIT_P,)
Brad Bishop96ff1982019-08-19 13:50:42 -040058@@ -1124,7 +1128,8 @@
59 client_data.state = RENEW_REQUESTED;
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 break;
61 case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
62- udhcp_run_script(NULL, "deconfig");
63+ if (allow_deconfig)
64+ udhcp_run_script(NULL, "deconfig");
65 case REQUESTING:
66 case RELEASED:
67 change_listen_mode(LISTEN_RAW);
Brad Bishop96ff1982019-08-19 13:50:42 -040068@@ -1160,7 +1165,8 @@
Brad Bishop316dfdd2018-06-25 12:45:53 -040069 * Users requested to be notified in all cases, even if not in one
70 * of the states above.
71 */
72- udhcp_run_script(NULL, "deconfig");
73+ if (allow_deconfig)
74+ udhcp_run_script(NULL, "deconfig");
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075
Brad Bishop316dfdd2018-06-25 12:45:53 -040076 change_listen_mode(LISTEN_NONE);
Brad Bishop96ff1982019-08-19 13:50:42 -040077 client_data.state = RELEASED;
78@@ -1278,7 +1284,7 @@
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080079 /* Parse command line */
80 opt = getopt32long(argv, "^"
81 /* O,x: list; -T,-t,-A take numeric param */
82- "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
83+ "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fBD"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 USE_FOR_MMU("b")
Brad Bishop316dfdd2018-06-25 12:45:53 -040085 IF_FEATURE_UDHCPC_ARPING("a::")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 IF_FEATURE_UDHCP_PORT("P:")
Brad Bishop96ff1982019-08-19 13:50:42 -040087@@ -1389,6 +1395,10 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 logmode |= LOGMODE_SYSLOG;
89 }
90
Brad Bishop316dfdd2018-06-25 12:45:53 -040091+ if (opt & OPT_D) {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092+ allow_deconfig = 0;
Brad Bishop316dfdd2018-06-25 12:45:53 -040093+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080095 /* Create pidfile */
Brad Bishop96ff1982019-08-19 13:50:42 -040096 write_pidfile(client_data.pidfile);
97 /* Goes to stdout (unless NOMMU) and possibly syslog */
98@@ -1397,7 +1407,8 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 srand(monotonic_us());
100
Brad Bishop96ff1982019-08-19 13:50:42 -0400101 client_data.state = INIT_SELECTING;
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102- udhcp_run_script(NULL, "deconfig");
103+ if (allow_deconfig)
104+ udhcp_run_script(NULL, "deconfig");
105 change_listen_mode(LISTEN_RAW);
106 packet_num = 0;
107 timeout = 0;
Brad Bishop96ff1982019-08-19 13:50:42 -0400108@@ -1570,7 +1581,8 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109 }
110 /* Timed out, enter init state */
Brad Bishop96ff1982019-08-19 13:50:42 -0400111 bb_info_msg("lease lost, entering init state");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112- udhcp_run_script(NULL, "deconfig");
113+ if (allow_deconfig)
114+ udhcp_run_script(NULL, "deconfig");
Brad Bishop96ff1982019-08-19 13:50:42 -0400115 client_data.state = INIT_SELECTING;
116 client_data.first_secs = 0; /* make secs field count from 0 */
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 /*timeout = 0; - already is */
Brad Bishop96ff1982019-08-19 13:50:42 -0400118@@ -1762,8 +1774,10 @@
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800119 "(got ARP reply), declining");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120 send_decline(/*xid,*/ server_addr, packet.yiaddr);
121
Brad Bishop96ff1982019-08-19 13:50:42 -0400122- if (client_data.state != REQUESTING)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123- udhcp_run_script(NULL, "deconfig");
Brad Bishop96ff1982019-08-19 13:50:42 -0400124+ if (client_data.state != REQUESTING) {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125+ if (allow_deconfig)
126+ udhcp_run_script(NULL, "deconfig");
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800127+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 change_listen_mode(LISTEN_RAW);
Brad Bishop96ff1982019-08-19 13:50:42 -0400129 client_data.state = INIT_SELECTING;
130 client_data.first_secs = 0; /* make secs field count from 0 */
131@@ -1832,8 +1846,10 @@
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800132 /* return to init state */
Brad Bishop96ff1982019-08-19 13:50:42 -0400133 bb_info_msg("received %s", "DHCP NAK");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 udhcp_run_script(&packet, "nak");
Brad Bishop96ff1982019-08-19 13:50:42 -0400135- if (client_data.state != REQUESTING)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136- udhcp_run_script(NULL, "deconfig");
Brad Bishop96ff1982019-08-19 13:50:42 -0400137+ if (client_data.state != REQUESTING) {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138+ if (allow_deconfig)
139+ udhcp_run_script(NULL, "deconfig");
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800140+ }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141 change_listen_mode(LISTEN_RAW);
142 sleep(3); /* avoid excessive network traffic */
Brad Bishop96ff1982019-08-19 13:50:42 -0400143 client_data.state = INIT_SELECTING;