aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/ll_map.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-13 16:27:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-13 16:27:11 +0200
commit94466b8b8c8b8dbdc496eefe947ee364fa85fdfb (patch)
tree82df0787bc9b2e7f10ba1b370b029ac6bb22fe97 /networking/libiproute/ll_map.c
parent0bf44d00a42dec70514c2e51926f4ca37b4b2367 (diff)
downloadbusybox-w32-94466b8b8c8b8dbdc496eefe947ee364fa85fdfb.tar.gz
busybox-w32-94466b8b8c8b8dbdc496eefe947ee364fa85fdfb.tar.bz2
busybox-w32-94466b8b8c8b8dbdc496eefe947ee364fa85fdfb.zip
libiproute: code and data shrink
function old new delta rtnl_a2n - 126 +126 ll_remember_index 233 263 +30 find_by_index 26 36 +10 rtnl_rtprot_initialize 66 70 +4 static.unit_chars 7 9 +2 rtnl_rttable_initialize 73 75 +2 rtnl_rtscope_initialize 83 85 +2 rtnl_rtrealm_initialize 43 45 +2 rtnl_rtdsfield_initialize 43 45 +2 rtnl_rttable_n2a 62 63 +1 rtnl_rtscope_n2a 62 63 +1 rtnl_rtrealm_n2a 62 63 +1 rtnl_dsfield_n2a 70 71 +1 ll_init_map 36 33 -3 make_human_readable_str 262 258 -4 static.fmt 97 92 -5 static.fmt_tenths 10 - -10 static.str 21 4 -17 static.res 20 - -20 static.cache 24 4 -20 idxmap 64 4 -60 rtnl_rttable_a2n 154 39 -115 rtnl_rtscope_a2n 159 39 -120 rtnl_rtrealm_a2n 159 39 -120 rtnl_rtprot_a2n 159 39 -120 rtnl_dsfield_a2n 162 39 -123 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 12/11 up/down: 184/-737) Total: -553 bytes text data bss dec hex filename 820376 445 7668 828489 ca449 busybox_old 819950 445 7548 827943 ca227 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/ll_map.c')
-rw-r--r--networking/libiproute/ll_map.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c
index 62528cc83..3c4ef2c32 100644
--- a/networking/libiproute/ll_map.c
+++ b/networking/libiproute/ll_map.c
@@ -27,15 +27,16 @@ struct idxmap {
27 char name[16]; 27 char name[16];
28}; 28};
29 29
30static struct idxmap *idxmap[16]; 30static struct idxmap **idxmap; /* treat as *idxmap[16] */
31 31
32static struct idxmap *find_by_index(int idx) 32static struct idxmap *find_by_index(int idx)
33{ 33{
34 struct idxmap *im; 34 struct idxmap *im;
35 35
36 for (im = idxmap[idx & 0xF]; im; im = im->next) 36 if (idxmap)
37 if (im->index == idx) 37 for (im = idxmap[idx & 0xF]; im; im = im->next)
38 return im; 38 if (im->index == idx)
39 return im;
39 return NULL; 40 return NULL;
40} 41}
41 42
@@ -59,8 +60,10 @@ int FAST_FUNC ll_remember_index(const struct sockaddr_nl *who UNUSED_PARAM,
59 if (tb[IFLA_IFNAME] == NULL) 60 if (tb[IFLA_IFNAME] == NULL)
60 return 0; 61 return 0;
61 62
62 h = ifi->ifi_index & 0xF; 63 if (!idxmap)
64 idxmap = xzalloc(sizeof(idxmap[0]) * 16);
63 65
66 h = ifi->ifi_index & 0xF;
64 for (imp = &idxmap[h]; (im = *imp) != NULL; imp = &im->next) 67 for (imp = &idxmap[h]; (im = *imp) != NULL; imp = &im->next)
65 if (im->index == ifi->ifi_index) 68 if (im->index == ifi->ifi_index)
66 goto found; 69 goto found;
@@ -152,13 +155,15 @@ int FAST_FUNC xll_name_to_index(const char *name)
152 ret = icache; 155 ret = icache;
153 goto out; 156 goto out;
154 } 157 }
155 for (i = 0; i < 16; i++) { 158 if (idxmap) {
156 for (im = idxmap[i]; im; im = im->next) { 159 for (i = 0; i < 16; i++) {
157 if (strcmp(im->name, name) == 0) { 160 for (im = idxmap[i]; im; im = im->next) {
158 icache = im->index; 161 if (strcmp(im->name, name) == 0) {
159 strcpy(ncache, name); 162 icache = im->index;
160 ret = im->index; 163 strcpy(ncache, name);
161 goto out; 164 ret = im->index;
165 goto out;
166 }
162 } 167 }
163 } 168 }
164 } 169 }
@@ -195,6 +200,6 @@ int FAST_FUNC xll_name_to_index(const char *name)
195int FAST_FUNC ll_init_map(struct rtnl_handle *rth) 200int FAST_FUNC ll_init_map(struct rtnl_handle *rth)
196{ 201{
197 xrtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK); 202 xrtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK);
198 xrtnl_dump_filter(rth, ll_remember_index, &idxmap); 203 xrtnl_dump_filter(rth, ll_remember_index, NULL);
199 return 0; 204 return 0;
200} 205}