Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 53626cd06a3ef05ed847daea802ef0aa9661caa7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Anders Darander <anders@chargestorm.se> |
| 3 | Date: Thu, 3 Nov 2011 08:51:31 +0100 |
| 4 | Subject: [PATCH] busybox-udhcpc-no_deconfig.patch |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Add a new option -D to the udhcpc client that allows for |
| 9 | dhcp renewal to occur without having to down the interface |
| 10 | in the process. |
| 11 | |
| 12 | Signed-off-by: Greg Moffatt <greg.moffatt@windriver.com> |
| 13 | |
| 14 | Updated to latest Busybox 1.17.3 |
| 15 | |
| 16 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> |
| 17 | |
| 18 | Updated to Busybox 1.18.4 |
| 19 | option spec is changed |
| 20 | |
| 21 | Signed-off-by: Qing He <qing.he@intel.com> |
| 22 | |
| 23 | Updated to Busybox 1.19.3 |
| 24 | |
| 25 | Signed-off-by: Anders Darander <anders@chargestorm.se> |
| 26 | |
| 27 | Fixed options -b, -a and -P. |
| 28 | |
| 29 | Signed-off-by: Andreas Oberritter <obi@opendreambox.org> |
| 30 | --- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | networking/udhcp/dhcpc.c | 29 ++++++++++++++++------ |
| 32 | 1 file changed, 21 insertions(+), 8 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 34 | Index: busybox-1.29.1/networking/udhcp/dhcpc.c |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | =================================================================== |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 36 | --- busybox-1.29.1.orig/networking/udhcp/dhcpc.c |
| 37 | +++ busybox-1.29.1/networking/udhcp/dhcpc.c |
| 38 | @@ -48,6 +48,8 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | }; |
| 40 | #endif |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 42 | +/* option whether to down the interface when reconfiguring */ |
| 43 | +static int allow_deconfig = 1; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | /* "struct client_config_t client_config" is in bb_common_bufsiz1 */ |
| 46 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 47 | @@ -103,8 +105,9 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | 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 */ |
| 53 | - OPTBIT_B = 20, |
| 54 | + OPTBIT_D = 21, |
| 55 | USE_FOR_MMU( OPTBIT_b,) |
| 56 | IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,) |
| 57 | IF_FEATURE_UDHCP_PORT( OPTBIT_P,) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 58 | @@ -1116,7 +1119,8 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | state = RENEW_REQUESTED; |
| 60 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 68 | @@ -1152,7 +1156,8 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | * 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 76 | change_listen_mode(LISTEN_NONE); |
| 77 | state = RELEASED; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 78 | @@ -1265,7 +1270,7 @@ |
| 79 | /* 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | USE_FOR_MMU("b") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 85 | IF_FEATURE_UDHCPC_ARPING("a::") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | IF_FEATURE_UDHCP_PORT("P:") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 87 | @@ -1376,6 +1381,10 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | logmode |= LOGMODE_SYSLOG; |
| 89 | } |
| 90 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 91 | + if (opt & OPT_D) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 | + allow_deconfig = 0; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 93 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | + |
| 95 | /* Make sure fd 0,1,2 are open */ |
| 96 | bb_sanitize_stdio(); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 97 | /* Create pidfile */ |
| 98 | @@ -1388,7 +1397,8 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 99 | srand(monotonic_us()); |
| 100 | |
| 101 | state = INIT_SELECTING; |
| 102 | - 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 108 | @@ -1555,7 +1565,8 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | } |
| 110 | /* Timed out, enter init state */ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 111 | bb_error_msg("lease lost, entering init state"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | - udhcp_run_script(NULL, "deconfig"); |
| 113 | + if (allow_deconfig) |
| 114 | + udhcp_run_script(NULL, "deconfig"); |
| 115 | state = INIT_SELECTING; |
| 116 | client_config.first_secs = 0; /* make secs field count from 0 */ |
| 117 | /*timeout = 0; - already is */ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 118 | @@ -1748,8 +1759,10 @@ |
| 119 | "(got ARP reply), declining"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | send_decline(/*xid,*/ server_addr, packet.yiaddr); |
| 121 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 122 | - if (state != REQUESTING) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | - udhcp_run_script(NULL, "deconfig"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 124 | + if (state != REQUESTING) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | + if (allow_deconfig) |
| 126 | + udhcp_run_script(NULL, "deconfig"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 127 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | change_listen_mode(LISTEN_RAW); |
| 129 | state = INIT_SELECTING; |
| 130 | client_config.first_secs = 0; /* make secs field count from 0 */ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 131 | @@ -1818,8 +1831,10 @@ |
| 132 | /* return to init state */ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 133 | bb_error_msg("received %s", "DHCP NAK"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | udhcp_run_script(&packet, "nak"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 135 | - if (state != REQUESTING) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | - udhcp_run_script(NULL, "deconfig"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 137 | + if (state != REQUESTING) { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | + if (allow_deconfig) |
| 139 | + udhcp_run_script(NULL, "deconfig"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 140 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 141 | change_listen_mode(LISTEN_RAW); |
| 142 | sleep(3); /* avoid excessive network traffic */ |
| 143 | state = INIT_SELECTING; |