summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch')
-rw-r--r--meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch471
1 files changed, 471 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch b/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch
new file mode 100644
index 0000000000..113b0a06ef
--- /dev/null
+++ b/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-use-numeric-protocol-ids-instead-of-protoent-structs.patch
@@ -0,0 +1,471 @@
1autofs-5.0.7 - use numeric protocol ids instead of protoent structs
2
3From: Leonardo Chiquitto <leonardo.lists@gmail.com>
4
5The function getprotobyname() is not reentrant, so we can't call
6it simultaneously from multiple threads. Instead of switching to
7the reentrant version which adds more complexity to the code,
8lets use numeric protocol IDs instead of protoent structures.
9---
10
11 CHANGELOG | 1 +
12 include/rpc_subs.h | 4 +--
13 lib/rpc_subs.c | 80 ++++++++++++++++++--------------------------------
14 modules/replicated.c | 42 +++++++++++---------------
15 4 files changed, 50 insertions(+), 77 deletions(-)
16
17
18diff --git a/CHANGELOG b/CHANGELOG
19index 4cf5621..ba1d65b 100644
20--- a/CHANGELOG
21+++ b/CHANGELOG
22@@ -23,6 +23,7 @@
23 - fix use get_proximity() without libtirpc.
24 - don't use dirent d_type to filter out files in scandir()
25 - don't schedule new alarms after readmap.
26+- use numeric protocol ids instead of protoent structs.
27
28 25/07/2012 autofs-5.0.7
29 =======================
30diff --git a/include/rpc_subs.h b/include/rpc_subs.h
31index ca474d9..b6d59f9 100644
32--- a/include/rpc_subs.h
33+++ b/include/rpc_subs.h
34@@ -54,7 +54,7 @@ struct conn_info {
35 unsigned short port;
36 unsigned long program;
37 unsigned long version;
38- struct protoent *proto;
39+ int proto;
40 unsigned int send_sz;
41 unsigned int recv_sz;
42 struct timeval timeout;
43@@ -66,7 +66,7 @@ int rpc_udp_getclient(struct conn_info *, unsigned int, unsigned int);
44 void rpc_destroy_udp_client(struct conn_info *);
45 int rpc_tcp_getclient(struct conn_info *, unsigned int, unsigned int);
46 void rpc_destroy_tcp_client(struct conn_info *);
47-int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, const char *, unsigned int);
48+int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, int, unsigned int);
49 int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *);
50 int rpc_ping_proto(struct conn_info *);
51 int rpc_ping(const char *, long, long, unsigned int);
52diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
53index d33a3c4..ad1d557 100644
54--- a/lib/rpc_subs.c
55+++ b/lib/rpc_subs.c
56@@ -170,7 +170,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
57
58 *client = NULL;
59
60- proto = info->proto->p_proto;
61+ proto = info->proto;
62 if (proto == IPPROTO_UDP)
63 type = SOCK_DGRAM;
64 else
65@@ -201,7 +201,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
66 in4_raddr = (struct sockaddr_in *) addr;
67 in4_raddr->sin_port = htons(info->port);
68
69- switch (info->proto->p_proto) {
70+ switch (info->proto) {
71 case IPPROTO_UDP:
72 clnt = clntudp_bufcreate(in4_raddr,
73 info->program, info->version,
74@@ -241,7 +241,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
75
76 *client = NULL;
77
78- proto = info->proto->p_proto;
79+ proto = info->proto;
80 if (proto == IPPROTO_UDP)
81 type = SOCK_DGRAM;
82 else
83@@ -292,11 +292,11 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i
84 nb_addr.maxlen = nb_addr.len = slen;
85 nb_addr.buf = addr;
86
87- if (info->proto->p_proto == IPPROTO_UDP)
88+ if (info->proto == IPPROTO_UDP)
89 clnt = clnt_dg_create(*fd, &nb_addr,
90 info->program, info->version,
91 info->send_sz, info->recv_sz);
92- else if (info->proto->p_proto == IPPROTO_TCP) {
93+ else if (info->proto == IPPROTO_TCP) {
94 ret = connect_nb(*fd, addr, slen, &info->timeout);
95 if (ret < 0)
96 return ret;
97@@ -355,7 +355,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
98 memset(&hints, 0, sizeof(hints));
99 hints.ai_flags = AI_ADDRCONFIG;
100 hints.ai_family = AF_UNSPEC;
101- if (info->proto->p_proto == IPPROTO_UDP)
102+ if (info->proto == IPPROTO_UDP)
103 hints.ai_socktype = SOCK_DGRAM;
104 else
105 hints.ai_socktype = SOCK_STREAM;
106@@ -370,7 +370,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
107
108 haddr = ai;
109 while (haddr) {
110- if (haddr->ai_protocol != info->proto->p_proto) {
111+ if (haddr->ai_protocol != info->proto) {
112 haddr = haddr->ai_next;
113 continue;
114 }
115@@ -417,16 +417,11 @@ out_close:
116 int rpc_udp_getclient(struct conn_info *info,
117 unsigned int program, unsigned int version)
118 {
119- struct protoent *pe_proto;
120 CLIENT *client;
121 int ret;
122
123 if (!info->client) {
124- pe_proto = getprotobyname("udp");
125- if (!pe_proto)
126- return -ENOENT;
127-
128- info->proto = pe_proto;
129+ info->proto = IPPROTO_UDP;
130 info->timeout.tv_sec = RPC_TOUT_UDP;
131 info->timeout.tv_usec = 0;
132 info->send_sz = UDPMSGSIZE;
133@@ -458,16 +453,11 @@ void rpc_destroy_udp_client(struct conn_info *info)
134 int rpc_tcp_getclient(struct conn_info *info,
135 unsigned int program, unsigned int version)
136 {
137- struct protoent *pe_proto;
138 CLIENT *client;
139 int ret;
140
141 if (!info->client) {
142- pe_proto = getprotobyname("tcp");
143- if (!pe_proto)
144- return -ENOENT;
145-
146- info->proto = pe_proto;
147+ info->proto = IPPROTO_TCP;
148 info->timeout.tv_sec = RPC_TOUT_TCP;
149 info->timeout.tv_usec = 0;
150 info->send_sz = 0;
151@@ -513,23 +503,18 @@ void rpc_destroy_tcp_client(struct conn_info *info)
152
153 int rpc_portmap_getclient(struct conn_info *info,
154 const char *host, struct sockaddr *addr, size_t addr_len,
155- const char *proto, unsigned int option)
156+ int proto, unsigned int option)
157 {
158- struct protoent *pe_proto;
159 CLIENT *client;
160 int ret;
161
162- pe_proto = getprotobyname(proto);
163- if (!pe_proto)
164- return -ENOENT;
165-
166 info->host = host;
167 info->addr = addr;
168 info->addr_len = addr_len;
169 info->program = PMAPPROG;
170 info->port = PMAPPORT;
171 info->version = PMAPVERS;
172- info->proto = pe_proto;
173+ info->proto = proto;
174 info->send_sz = RPCSMALLMSGSIZE;
175 info->recv_sz = RPCSMALLMSGSIZE;
176 info->timeout.tv_sec = PMAP_TOUT_UDP;
177@@ -537,7 +522,7 @@ int rpc_portmap_getclient(struct conn_info *info,
178 info->close_option = option;
179 info->client = NULL;
180
181- if (pe_proto->p_proto == IPPROTO_TCP)
182+ if (info->proto == IPPROTO_TCP)
183 info->timeout.tv_sec = PMAP_TOUT_TCP;
184
185 ret = create_client(info, &client);
186@@ -555,7 +540,7 @@ int rpc_portmap_getport(struct conn_info *info,
187 struct conn_info pmap_info;
188 CLIENT *client;
189 enum clnt_stat status;
190- int proto = info->proto->p_proto;
191+ int proto = info->proto;
192 int ret;
193
194 memset(&pmap_info, 0, sizeof(struct conn_info));
195@@ -633,13 +618,13 @@ int rpc_ping_proto(struct conn_info *info)
196 {
197 CLIENT *client;
198 enum clnt_stat status;
199- int proto = info->proto->p_proto;
200+ int proto = info->proto;
201 int ret;
202
203 if (info->client)
204 client = info->client;
205 else {
206- if (info->proto->p_proto == IPPROTO_UDP) {
207+ if (info->proto == IPPROTO_UDP) {
208 info->send_sz = UDPMSGSIZE;
209 info->recv_sz = UDPMSGSIZE;
210 }
211@@ -688,7 +673,7 @@ int rpc_ping_proto(struct conn_info *info)
212
213 static unsigned int __rpc_ping(const char *host,
214 unsigned long version,
215- char *proto,
216+ int proto,
217 long seconds, long micros,
218 unsigned int option)
219 {
220@@ -696,6 +681,7 @@ static unsigned int __rpc_ping(const char *host,
221 struct conn_info info;
222 struct pmap parms;
223
224+ info.proto = proto;
225 info.host = host;
226 info.addr = NULL;
227 info.addr_len = 0;
228@@ -710,13 +696,9 @@ static unsigned int __rpc_ping(const char *host,
229
230 status = RPC_PING_FAIL;
231
232- info.proto = getprotobyname(proto);
233- if (!info.proto)
234- return status;
235-
236 parms.pm_prog = NFS_PROGRAM;
237 parms.pm_vers = version;
238- parms.pm_prot = info.proto->p_proto;
239+ parms.pm_prot = info.proto;
240 parms.pm_port = 0;
241
242 status = rpc_portmap_getport(&info, &parms, &info.port);
243@@ -734,19 +716,19 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
244 unsigned long vers2 = NFS2_VERSION;
245 unsigned int status;
246
247- status = __rpc_ping(host, vers2, "udp", seconds, micros, option);
248+ status = __rpc_ping(host, vers2, IPPROTO_UDP, seconds, micros, option);
249 if (status > 0)
250 return RPC_PING_V2 | RPC_PING_UDP;
251
252- status = __rpc_ping(host, vers3, "udp", seconds, micros, option);
253+ status = __rpc_ping(host, vers3, IPPROTO_UDP, seconds, micros, option);
254 if (status > 0)
255 return RPC_PING_V3 | RPC_PING_UDP;
256
257- status = __rpc_ping(host, vers2, "tcp", seconds, micros, option);
258+ status = __rpc_ping(host, vers2, IPPROTO_TCP, seconds, micros, option);
259 if (status > 0)
260 return RPC_PING_V2 | RPC_PING_TCP;
261
262- status = __rpc_ping(host, vers3, "tcp", seconds, micros, option);
263+ status = __rpc_ping(host, vers3, IPPROTO_TCP, seconds, micros, option);
264 if (status > 0)
265 return RPC_PING_V3 | RPC_PING_TCP;
266
267@@ -769,7 +751,7 @@ int rpc_time(const char *host,
268 double taken;
269 struct timeval start, end;
270 struct timezone tz;
271- char *proto = (ping_proto & RPC_PING_UDP) ? "udp" : "tcp";
272+ int proto = (ping_proto & RPC_PING_UDP) ? IPPROTO_UDP : IPPROTO_TCP;
273 unsigned long vers = ping_vers;
274
275 gettimeofday(&start, &tz);
276@@ -791,12 +773,12 @@ static int rpc_get_exports_proto(struct conn_info *info, exports *exp)
277 {
278 CLIENT *client;
279 enum clnt_stat status;
280- int proto = info->proto->p_proto;
281+ int proto = info->proto;
282 unsigned int option = info->close_option;
283 int vers_entry;
284 int ret;
285
286- if (info->proto->p_proto == IPPROTO_UDP) {
287+ if (info->proto == IPPROTO_UDP) {
288 info->send_sz = UDPMSGSIZE;
289 info->recv_sz = UDPMSGSIZE;
290 }
291@@ -903,11 +885,9 @@ exports rpc_get_exports(const char *host, long seconds, long micros, unsigned in
292 parms.pm_port = 0;
293
294 /* Try UDP first */
295- info.proto = getprotobyname("udp");
296- if (!info.proto)
297- goto try_tcp;
298+ info.proto = IPPROTO_UDP;
299
300- parms.pm_prot = info.proto->p_proto;
301+ parms.pm_prot = info.proto;
302
303 status = rpc_portmap_getport(&info, &parms, &info.port);
304 if (status < 0)
305@@ -920,11 +900,9 @@ exports rpc_get_exports(const char *host, long seconds, long micros, unsigned in
306 return exportlist;
307
308 try_tcp:
309- info.proto = getprotobyname("tcp");
310- if (!info.proto)
311- return NULL;
312+ info.proto = IPPROTO_TCP;
313
314- parms.pm_prot = info.proto->p_proto;
315+ parms.pm_prot = info.proto;
316
317 status = rpc_portmap_getport(&info, &parms, &info.port);
318 if (status < 0)
319diff --git a/modules/replicated.c b/modules/replicated.c
320index 6b96320..dbd5513 100644
321--- a/modules/replicated.c
322+++ b/modules/replicated.c
323@@ -419,7 +419,7 @@ void free_host_list(struct host **list)
324
325 static unsigned int get_nfs_info(unsigned logopt, struct host *host,
326 struct conn_info *pm_info, struct conn_info *rpc_info,
327- const char *proto, unsigned int version, int port)
328+ int proto, unsigned int version, int port)
329 {
330 unsigned int random_selection = host->options & MOUNT_FLAG_RANDOM_SELECT;
331 unsigned int use_weight_only = host->options & MOUNT_FLAG_USE_WEIGHT_ONLY;
332@@ -433,22 +433,18 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,
333 int status, count = 0;
334
335 if (host->addr)
336- debug(logopt, "called with host %s(%s) proto %s version 0x%x",
337+ debug(logopt, "called with host %s(%s) proto %d version 0x%x",
338 host->name, get_addr_string(host->addr, buf, len),
339 proto, version);
340 else
341 debug(logopt,
342- "called for host %s proto %s version 0x%x",
343+ "called for host %s proto %d version 0x%x",
344 host->name, proto, version);
345
346- rpc_info->proto = getprotobyname(proto);
347- if (!rpc_info->proto)
348- return 0;
349-
350+ rpc_info->proto = proto;
351 memset(&parms, 0, sizeof(struct pmap));
352-
353 parms.pm_prog = NFS_PROGRAM;
354- parms.pm_prot = rpc_info->proto->p_proto;
355+ parms.pm_prot = proto;
356
357 if (!(version & NFS4_REQUESTED))
358 goto v3_ver;
359@@ -479,7 +475,7 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,
360 }
361 }
362
363- if (rpc_info->proto->p_proto == IPPROTO_UDP)
364+ if (rpc_info->proto == IPPROTO_UDP)
365 status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
366 else
367 status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION);
368@@ -540,7 +536,7 @@ v3_ver:
369 goto v2_ver;
370 }
371
372- if (rpc_info->proto->p_proto == IPPROTO_UDP)
373+ if (rpc_info->proto == IPPROTO_UDP)
374 status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
375 else
376 status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION);
377@@ -587,7 +583,7 @@ v2_ver:
378 goto done_ver;
379 }
380
381- if (rpc_info->proto->p_proto == IPPROTO_UDP)
382+ if (rpc_info->proto == IPPROTO_UDP)
383 status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
384 else
385 status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION);
386@@ -618,7 +614,7 @@ v2_ver:
387 }
388
389 done_ver:
390- if (rpc_info->proto->p_proto == IPPROTO_UDP) {
391+ if (rpc_info->proto == IPPROTO_UDP) {
392 rpc_destroy_udp_client(rpc_info);
393 rpc_destroy_udp_client(pm_info);
394 } else {
395@@ -675,7 +671,7 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
396
397 if (version & TCP_REQUESTED) {
398 supported = get_nfs_info(logopt, host,
399- &pm_info, &rpc_info, "tcp", vers, port);
400+ &pm_info, &rpc_info, IPPROTO_TCP, vers, port);
401 if (IS_ERR(supported)) {
402 if (ERR(supported) == EHOSTUNREACH ||
403 ERR(supported) == ETIMEDOUT)
404@@ -688,7 +684,7 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
405
406 if (version & UDP_REQUESTED) {
407 supported = get_nfs_info(logopt, host,
408- &pm_info, &rpc_info, "udp", vers, port);
409+ &pm_info, &rpc_info, IPPROTO_UDP, vers, port);
410 if (IS_ERR(supported)) {
411 if (!ret && ERR(supported) == ETIMEDOUT)
412 return ret;
413@@ -709,7 +705,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
414 socklen_t len = INET6_ADDRSTRLEN;
415 char buf[len + 1];
416 struct conn_info pm_info, rpc_info;
417- const char *proto;
418+ int proto;
419 unsigned int vers;
420 struct timeval start, end;
421 struct timezone tz;
422@@ -748,10 +744,10 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
423 * So, we do the conversion here.
424 */
425 if (version & UDP_SELECTED_MASK) {
426- proto = "udp";
427+ proto = IPPROTO_UDP;
428 version >>= 8;
429 } else
430- proto = "tcp";
431+ proto = IPPROTO_TCP;
432
433 switch (version) {
434 case NFS2_SUPPORTED:
435@@ -768,9 +764,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
436 return 0;
437 }
438
439- rpc_info.proto = getprotobyname(proto);
440- if (!rpc_info.proto)
441- return 0;
442+ rpc_info.proto = proto;
443
444 if (port > 0)
445 rpc_info.port = port;
446@@ -786,14 +780,14 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
447
448 memset(&parms, 0, sizeof(struct pmap));
449 parms.pm_prog = NFS_PROGRAM;
450- parms.pm_prot = rpc_info.proto->p_proto;
451+ parms.pm_prot = rpc_info.proto;
452 parms.pm_vers = vers;
453 ret = rpc_portmap_getport(&pm_info, &parms, &rpc_info.port);
454 if (ret < 0)
455 goto done;
456 }
457
458- if (rpc_info.proto->p_proto == IPPROTO_UDP)
459+ if (rpc_info.proto == IPPROTO_UDP)
460 status = rpc_udp_getclient(&rpc_info, NFS_PROGRAM, vers);
461 else
462 status = rpc_tcp_getclient(&rpc_info, NFS_PROGRAM, vers);
463@@ -815,7 +809,7 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
464 }
465 }
466 done:
467- if (rpc_info.proto->p_proto == IPPROTO_UDP) {
468+ if (rpc_info.proto == IPPROTO_UDP) {
469 rpc_destroy_udp_client(&rpc_info);
470 rpc_destroy_udp_client(&pm_info);
471 } else {