aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox/busybox-udhcpc-no_deconfig.patch
blob: f29513a6dc8ff44746d7afadcc8a063d00df5907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Subject: [PATCH] busybox-udhcpc-no_deconfig.patch

Upstream-Status: Pending

Add a new option -D to the udhcpc client that allows for
dhcp renewal to occur without having to down the interface
in the process.

Signed-off-by: Greg Moffatt <greg.moffatt@windriver.com>

Updated to latest Busybox 1.17.3

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

Updated to Busybox 1.18.4
option spec is changed

Signed-off-by: Qing He <qing.he@intel.com>

Updated to Busybox 1.19.3

Signed-off-by: Anders Darander <anders@chargestorm.se>

Fixed options -b, -a and -P.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
---
 networking/udhcp/dhcpc.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index fc7b621..5222fb3 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -42,6 +42,8 @@ struct tpacket_auxdata {
 };
 #endif
 
+/* option whether to down the interface when reconfiguring */
+static int allow_deconfig = 1;
 
 /* "struct client_config_t client_config" is in bb_common_bufsiz1 */
 
@@ -95,8 +97,9 @@ enum {
 	OPT_x = 1 << 18,
 	OPT_f = 1 << 19,
 	OPT_B = 1 << 20,
+	OPT_D = 1 << 21,
 /* The rest has variable bit positions, need to be clever */
-	OPTBIT_B = 20,
+	OPTBIT_B = 21,
 	USE_FOR_MMU(             OPTBIT_b,)
 	IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
 	IF_FEATURE_UDHCP_PORT(   OPTBIT_P,)
@@ -1101,7 +1104,8 @@ static void perform_renew(void)
 		state = RENEW_REQUESTED;
 		break;
 	case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
-		udhcp_run_script(NULL, "deconfig");
+		if (allow_deconfig)
+			udhcp_run_script(NULL, "deconfig");
 	case REQUESTING:
 	case RELEASED:
 		change_listen_mode(LISTEN_RAW);
@@ -1281,7 +1285,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 	/* O,x: list; -T,-t,-A take numeric param */
 	opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ;
 	IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
-	opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"
+	opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fBD"
 		USE_FOR_MMU("b")
 		IF_FEATURE_UDHCPC_ARPING("a::")
 		IF_FEATURE_UDHCP_PORT("P:")
@@ -1390,6 +1394,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 		logmode |= LOGMODE_SYSLOG;
 	}
 
+	if (opt & OPT_D)
+		allow_deconfig = 0;
+
 	/* Make sure fd 0,1,2 are open */
 	bb_sanitize_stdio();
 	/* Equivalent of doing a fflush after every \n */
@@ -1404,7 +1411,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 	srand(monotonic_us());
 
 	state = INIT_SELECTING;
-	udhcp_run_script(NULL, "deconfig");
+	if (allow_deconfig)
+		udhcp_run_script(NULL, "deconfig");
 	change_listen_mode(LISTEN_RAW);
 	packet_num = 0;
 	timeout = 0;
@@ -1558,7 +1566,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 				}
 				/* Timed out, enter init state */
 				bb_error_msg("lease lost, entering init state");
-				udhcp_run_script(NULL, "deconfig");
+				if (allow_deconfig)
+					udhcp_run_script(NULL, "deconfig");
 				state = INIT_SELECTING;
 				client_config.first_secs = 0; /* make secs field count from 0 */
 				/*timeout = 0; - already is */
@@ -1751,7 +1760,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 						send_decline(/*xid,*/ server_addr, packet.yiaddr);
 
 						if (state != REQUESTING)
-							udhcp_run_script(NULL, "deconfig");
+							if (allow_deconfig)
+								udhcp_run_script(NULL, "deconfig");
 						change_listen_mode(LISTEN_RAW);
 						state = INIT_SELECTING;
 						client_config.first_secs = 0; /* make secs field count from 0 */
@@ -1822,7 +1832,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 				bb_error_msg("received %s", "DHCP NAK");
 				udhcp_run_script(&packet, "nak");
 				if (state != REQUESTING)
-					udhcp_run_script(NULL, "deconfig");
+					if (allow_deconfig)
+						udhcp_run_script(NULL, "deconfig");
 				change_listen_mode(LISTEN_RAW);
 				sleep(3); /* avoid excessive network traffic */
 				state = INIT_SELECTING;
-- 
2.1.0