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 | --- |
| 31 | networking/udhcp/dhcpc.c | 29 +++++++++++++++++++++-------- |
| 32 | 1 files changed, 21 insertions(+), 8 deletions(-) |
| 33 | |
| 34 | Index: busybox-1.20.2/networking/udhcp/dhcpc.c |
| 35 | =================================================================== |
| 36 | --- busybox-1.20.2.orig/networking/udhcp/dhcpc.c |
| 37 | +++ busybox-1.20.2/networking/udhcp/dhcpc.c |
| 38 | @@ -29,6 +29,9 @@ |
| 39 | #include <netpacket/packet.h> |
| 40 | #include <linux/filter.h> |
| 41 | |
| 42 | +/* option whether to down the interface when reconfiguring */ |
| 43 | +static int allow_deconfig = 1; |
| 44 | + |
| 45 | /* "struct client_config_t client_config" is in bb_common_bufsiz1 */ |
| 46 | |
| 47 | |
| 48 | @@ -81,8 +84,9 @@ enum { |
| 49 | OPT_x = 1 << 18, |
| 50 | OPT_f = 1 << 19, |
| 51 | OPT_B = 1 << 20, |
| 52 | + OPT_D = 1 << 21, |
| 53 | /* The rest has variable bit positions, need to be clever */ |
| 54 | - OPTBIT_B = 20, |
| 55 | + OPTBIT_D = 21, |
| 56 | USE_FOR_MMU( OPTBIT_b,) |
| 57 | IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,) |
| 58 | IF_FEATURE_UDHCP_PORT( OPTBIT_P,) |
| 59 | @@ -1040,7 +1044,8 @@ static void perform_renew(void) |
| 60 | state = RENEW_REQUESTED; |
| 61 | break; |
| 62 | case RENEW_REQUESTED: /* impatient are we? fine, square 1 */ |
| 63 | - udhcp_run_script(NULL, "deconfig"); |
| 64 | + if (allow_deconfig) |
| 65 | + udhcp_run_script(NULL, "deconfig"); |
| 66 | case REQUESTING: |
| 67 | case RELEASED: |
| 68 | change_listen_mode(LISTEN_RAW); |
| 69 | @@ -1064,7 +1069,8 @@ static void perform_release(uint32_t ser |
| 70 | bb_info_msg("Unicasting a release of %s to %s", |
| 71 | inet_ntoa(temp_addr), buffer); |
| 72 | send_release(server_addr, requested_ip); /* unicast */ |
| 73 | - udhcp_run_script(NULL, "deconfig"); |
| 74 | + if (allow_deconfig) |
| 75 | + udhcp_run_script(NULL, "deconfig"); |
| 76 | } |
| 77 | bb_info_msg("Entering released state"); |
| 78 | |
| 79 | @@ -1215,7 +1221,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 80 | /* O,x: list; -T,-t,-A take numeric param */ |
| 81 | opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ; |
| 82 | IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) |
| 83 | - opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB" |
| 84 | + opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fBD" |
| 85 | USE_FOR_MMU("b") |
| 86 | IF_FEATURE_UDHCPC_ARPING("a") |
| 87 | IF_FEATURE_UDHCP_PORT("P:") |
| 88 | @@ -1316,6 +1322,9 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 89 | logmode |= LOGMODE_SYSLOG; |
| 90 | } |
| 91 | |
| 92 | + if (opt & OPT_D) |
| 93 | + allow_deconfig = 0; |
| 94 | + |
| 95 | /* Make sure fd 0,1,2 are open */ |
| 96 | bb_sanitize_stdio(); |
| 97 | /* Equivalent of doing a fflush after every \n */ |
| 98 | @@ -1330,7 +1339,8 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 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; |
| 108 | @@ -1484,7 +1494,8 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 109 | } |
| 110 | /* Timed out, enter init state */ |
| 111 | bb_info_msg("Lease lost, entering init state"); |
| 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 */ |
| 118 | @@ -1667,7 +1678,8 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 119 | send_decline(/*xid,*/ server_addr, packet.yiaddr); |
| 120 | |
| 121 | if (state != REQUESTING) |
| 122 | - udhcp_run_script(NULL, "deconfig"); |
| 123 | + if (allow_deconfig) |
| 124 | + udhcp_run_script(NULL, "deconfig"); |
| 125 | change_listen_mode(LISTEN_RAW); |
| 126 | state = INIT_SELECTING; |
| 127 | client_config.first_secs = 0; /* make secs field count from 0 */ |
| 128 | @@ -1711,7 +1723,8 @@ int udhcpc_main(int argc UNUSED_PARAM, c |
| 129 | bb_info_msg("Received DHCP NAK"); |
| 130 | udhcp_run_script(&packet, "nak"); |
| 131 | if (state != REQUESTING) |
| 132 | - udhcp_run_script(NULL, "deconfig"); |
| 133 | + if (allow_deconfig) |
| 134 | + udhcp_run_script(NULL, "deconfig"); |
| 135 | change_listen_mode(LISTEN_RAW); |
| 136 | sleep(3); /* avoid excessive network traffic */ |
| 137 | state = INIT_SELECTING; |