diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 16:26:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 17:39:11 +0200 |
commit | e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a (patch) | |
tree | 0962142ac9830312cd3df52994db41e8ac47c73c /networking/udhcp | |
parent | 5598bdf0d3d46a865a4d23785e2d09e6db9be420 (diff) | |
download | busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.gz busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.bz2 busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.zip |
libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):
function old new delta
read_config 210 228 +18
doCommands 2279 2294 +15
ipneigh_list_or_flush 763 772 +9
ipaddr_list_or_flush 1256 1261 +5
display_process_list 1301 1306 +5
conspy_main 1378 1383 +5
do_lzo_compress 352 355 +3
do_lzo_decompress 565 567 +2
push 46 44 -2
inetd_main 2136 2134 -2
uevent_main 421 418 -3
addLines 97 92 -5
bb_common_bufsiz1 8193 1024 -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181) Total: -7119 bytes
text data bss dec hex filename
829850 4086 9080 843016 cdd08 busybox_old
829901 4086 1904 835891 cc133 busybox_unstripped
FEATURE_USE_BSS_TAIL=y:
read_config 210 228 +18
doCommands 2279 2294 +15
ipneigh_list_or_flush 763 772 +9
ipaddr_list_or_flush 1256 1261 +5
display_process_list 1301 1306 +5
conspy_main 1378 1383 +5
do_lzo_compress 352 355 +3
do_lzo_decompress 565 567 +2
inetd_main 2136 2134 -2
bb_common_bufsiz1 8193 - -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195) Total: -8133 bytes
text data bss dec hex filename
829850 4086 9080 843016 cdd08 busybox_old
829911 4086 880 834877 cbd3d busybox_unstripped
FIXME: setup_common_bufsiz() calls are missing.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/common.h | 1 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.h | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcprelay.c | 2 | ||||
-rw-r--r-- | networking/udhcp/files.c | 46 |
4 files changed, 27 insertions, 24 deletions
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 496ab11a1..a526494d7 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #define UDHCP_COMMON_H 1 | 9 | #define UDHCP_COMMON_H 1 |
10 | 10 | ||
11 | #include "libbb.h" | 11 | #include "libbb.h" |
12 | #include "common_bufsiz.h" | ||
12 | #include <netinet/udp.h> | 13 | #include <netinet/udp.h> |
13 | #include <netinet/ip.h> | 14 | #include <netinet/ip.h> |
14 | 15 | ||
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h index 183e7e24c..9dd5bef9e 100644 --- a/networking/udhcp/dhcpd.h +++ b/networking/udhcp/dhcpd.h | |||
@@ -57,7 +57,7 @@ struct server_config_t { | |||
57 | struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ | 57 | struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ |
58 | } FIX_ALIASING; | 58 | } FIX_ALIASING; |
59 | 59 | ||
60 | #define server_config (*(struct server_config_t*)&bb_common_bufsiz1) | 60 | #define server_config (*(struct server_config_t*)bb_common_bufsiz1) |
61 | /* client_config sits in 2nd half of bb_common_bufsiz1 */ | 61 | /* client_config sits in 2nd half of bb_common_bufsiz1 */ |
62 | 62 | ||
63 | #if ENABLE_FEATURE_UDHCP_PORT | 63 | #if ENABLE_FEATURE_UDHCP_PORT |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index f82ac05b4..1722a85de 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -33,7 +33,7 @@ struct xid_item { | |||
33 | struct xid_item *next; | 33 | struct xid_item *next; |
34 | } FIX_ALIASING; | 34 | } FIX_ALIASING; |
35 | 35 | ||
36 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) | 36 | #define dhcprelay_xid_list (*(struct xid_item*)bb_common_bufsiz1) |
37 | 37 | ||
38 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) | 38 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) |
39 | { | 39 | { |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 7b57c6258..b22425352 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -57,33 +57,35 @@ static int FAST_FUNC read_staticlease(const char *const_line, void *arg) | |||
57 | struct config_keyword { | 57 | struct config_keyword { |
58 | const char *keyword; | 58 | const char *keyword; |
59 | int (*handler)(const char *line, void *var) FAST_FUNC; | 59 | int (*handler)(const char *line, void *var) FAST_FUNC; |
60 | void *var; | 60 | unsigned ofs; |
61 | const char *def; | 61 | const char *def; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #define OFS(field) offsetof(struct server_config_t, field) | ||
65 | |||
64 | static const struct config_keyword keywords[] = { | 66 | static const struct config_keyword keywords[] = { |
65 | /* keyword handler variable address default */ | 67 | /* keyword handler variable address default */ |
66 | {"start" , udhcp_str2nip , &server_config.start_ip , "192.168.0.20"}, | 68 | {"start" , udhcp_str2nip , OFS(start_ip ), "192.168.0.20"}, |
67 | {"end" , udhcp_str2nip , &server_config.end_ip , "192.168.0.254"}, | 69 | {"end" , udhcp_str2nip , OFS(end_ip ), "192.168.0.254"}, |
68 | {"interface" , read_str , &server_config.interface , "eth0"}, | 70 | {"interface" , read_str , OFS(interface ), "eth0"}, |
69 | /* Avoid "max_leases value not sane" warning by setting default | 71 | /* Avoid "max_leases value not sane" warning by setting default |
70 | * to default_end_ip - default_start_ip + 1: */ | 72 | * to default_end_ip - default_start_ip + 1: */ |
71 | {"max_leases" , read_u32 , &server_config.max_leases , "235"}, | 73 | {"max_leases" , read_u32 , OFS(max_leases ), "235"}, |
72 | {"auto_time" , read_u32 , &server_config.auto_time , "7200"}, | 74 | {"auto_time" , read_u32 , OFS(auto_time ), "7200"}, |
73 | {"decline_time" , read_u32 , &server_config.decline_time , "3600"}, | 75 | {"decline_time" , read_u32 , OFS(decline_time ), "3600"}, |
74 | {"conflict_time", read_u32 , &server_config.conflict_time, "3600"}, | 76 | {"conflict_time", read_u32 , OFS(conflict_time), "3600"}, |
75 | {"offer_time" , read_u32 , &server_config.offer_time , "60"}, | 77 | {"offer_time" , read_u32 , OFS(offer_time ), "60"}, |
76 | {"min_lease" , read_u32 , &server_config.min_lease_sec, "60"}, | 78 | {"min_lease" , read_u32 , OFS(min_lease_sec), "60"}, |
77 | {"lease_file" , read_str , &server_config.lease_file , LEASES_FILE}, | 79 | {"lease_file" , read_str , OFS(lease_file ), LEASES_FILE}, |
78 | {"pidfile" , read_str , &server_config.pidfile , "/var/run/udhcpd.pid"}, | 80 | {"pidfile" , read_str , OFS(pidfile ), "/var/run/udhcpd.pid"}, |
79 | {"siaddr" , udhcp_str2nip , &server_config.siaddr_nip , "0.0.0.0"}, | 81 | {"siaddr" , udhcp_str2nip , OFS(siaddr_nip ), "0.0.0.0"}, |
80 | /* keywords with no defaults must be last! */ | 82 | /* keywords with no defaults must be last! */ |
81 | {"option" , udhcp_str2optset, &server_config.options , ""}, | 83 | {"option" , udhcp_str2optset, OFS(options ), ""}, |
82 | {"opt" , udhcp_str2optset, &server_config.options , ""}, | 84 | {"opt" , udhcp_str2optset, OFS(options ), ""}, |
83 | {"notify_file" , read_str , &server_config.notify_file , NULL}, | 85 | {"notify_file" , read_str , OFS(notify_file ), NULL}, |
84 | {"sname" , read_str , &server_config.sname , NULL}, | 86 | {"sname" , read_str , OFS(sname ), NULL}, |
85 | {"boot_file" , read_str , &server_config.boot_file , NULL}, | 87 | {"boot_file" , read_str , OFS(boot_file ), NULL}, |
86 | {"static_lease" , read_staticlease, &server_config.static_leases, ""}, | 88 | {"static_lease" , read_staticlease, OFS(static_leases), ""}, |
87 | }; | 89 | }; |
88 | enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 }; | 90 | enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 }; |
89 | 91 | ||
@@ -95,17 +97,17 @@ void FAST_FUNC read_config(const char *file) | |||
95 | char *token[2]; | 97 | char *token[2]; |
96 | 98 | ||
97 | for (i = 0; i < KWS_WITH_DEFAULTS; i++) | 99 | for (i = 0; i < KWS_WITH_DEFAULTS; i++) |
98 | keywords[i].handler(keywords[i].def, keywords[i].var); | 100 | keywords[i].handler(keywords[i].def, (char*)&server_config + keywords[i].ofs); |
99 | 101 | ||
100 | parser = config_open(file); | 102 | parser = config_open(file); |
101 | while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { | 103 | while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { |
102 | for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) { | 104 | for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) { |
103 | if (strcasecmp(token[0], k->keyword) == 0) { | 105 | if (strcasecmp(token[0], k->keyword) == 0) { |
104 | if (!k->handler(token[1], k->var)) { | 106 | if (!k->handler(token[1], (char*)&server_config + k->ofs)) { |
105 | bb_error_msg("can't parse line %u in %s", | 107 | bb_error_msg("can't parse line %u in %s", |
106 | parser->lineno, file); | 108 | parser->lineno, file); |
107 | /* reset back to the default value */ | 109 | /* reset back to the default value */ |
108 | k->handler(k->def, k->var); | 110 | k->handler(k->def, (char*)&server_config + k->ofs); |
109 | } | 111 | } |
110 | break; | 112 | break; |
111 | } | 113 | } |