* [Qemu-devel] [PATCH] slirp: Remove our_addr code
@ 2009-07-23 1:37 Ed Swierk
2009-07-23 1:41 ` [Qemu-devel] " Ed Swierk
0 siblings, 1 reply; 4+ messages in thread
From: Ed Swierk @ 2009-07-23 1:37 UTC (permalink / raw)
To: qemu-devel
Three problems with our_addr:
- It's determined only once when qemu starts, but the address can change
(just like the DNS configuration can).
- It's supposed to be the IP address of a host network interface, but
there's no guarantee that gethostbyname(gethostname()) actually does
that: the host might be a laptop that has only a loopback interface up,
or the hostname might be localhost.localdomain, etc.
- It's useless: aside from the CU-SeeMe protocol emulation which I
propose removing, the only other reference is in get_dns_addr(), but
can't imagine why you would want to send DNS requests to a different IP
address if you're running a DNS server on the host and resolv.conf
points to 127.0.0.1.
These problems are easily solved by removing the code.
Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
---
diff --git a/slirp/main.h b/slirp/main.h
index e87b068..8d09df9 100644
--- a/slirp/main.h
+++ b/slirp/main.h
@@ -30,7 +30,6 @@ extern char *slirp_tty;
extern char *exec_shell;
extern u_int curtime;
extern fd_set *global_readfds, *global_writefds, *global_xfds;
-extern struct in_addr our_addr;
extern struct in_addr loopback_addr;
extern char *username;
extern char *socket_path;
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 3214c29..aead5b0 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -26,8 +26,6 @@
#include "slirp.h"
#include "hw/hw.h"
-/* host address */
-struct in_addr our_addr;
/* host loopback address */
struct in_addr loopback_addr;
@@ -129,8 +127,6 @@ int get_dns_addr(struct in_addr *pdns_addr)
if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
if (!inet_aton(buff2, &tmp_addr))
continue;
- if (tmp_addr.s_addr == loopback_addr.s_addr)
- tmp_addr = our_addr;
/* If it's the first one, set it to dns_addr */
if (!found) {
*pdns_addr = tmp_addr;
@@ -164,8 +160,6 @@ int get_dns_addr(struct in_addr *pdns_addr)
static void slirp_init_once(void)
{
static int initialized;
- struct hostent *he;
- char our_name[256];
#ifdef _WIN32
WSADATA Data;
#endif
@@ -181,17 +175,6 @@ static void slirp_init_once(void)
#endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- /* FIXME: This address may change during runtime */
- if (gethostname(our_name, sizeof(our_name)) == 0) {
- he = gethostbyname(our_name);
- if (he) {
- our_addr = *(struct in_addr *)he->h_addr;
- }
- }
- if (our_addr.s_addr == 0) {
- our_addr = loopback_addr;
- }
}
static void slirp_state_save(QEMUFile *f, void *opaque);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] slirp: Remove our_addr code
2009-07-23 1:37 [Qemu-devel] [PATCH] slirp: Remove our_addr code Ed Swierk
@ 2009-07-23 1:41 ` Ed Swierk
2009-07-23 6:51 ` Jan Kiszka
0 siblings, 1 reply; 4+ messages in thread
From: Ed Swierk @ 2009-07-23 1:41 UTC (permalink / raw)
To: qemu-devel
On Thu, Jul 23, 2009 at 1:37 AM, Ed Swierk<eswierk@aristanetworks.com> wrote:
> - It's useless: aside from the CU-SeeMe protocol emulation which I
> propose removing, the only other reference is in get_dns_addr(), but
> can't imagine why you would want to send DNS requests to a different IP
> address if you're running a DNS server on the host and resolv.conf
> points to 127.0.0.1.
>
> These problems are easily solved by removing the code.
Note that VirtualBox removed this code recently as well:
http://www.virtualbox.org/ticket/1470 .
--Ed
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] slirp: Remove our_addr code
2009-07-23 1:41 ` [Qemu-devel] " Ed Swierk
@ 2009-07-23 6:51 ` Jan Kiszka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2009-07-23 6:51 UTC (permalink / raw)
To: Ed Swierk; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
Ed Swierk wrote:
> On Thu, Jul 23, 2009 at 1:37 AM, Ed Swierk<eswierk@aristanetworks.com> wrote:
>> - It's useless: aside from the CU-SeeMe protocol emulation which I
>> propose removing, the only other reference is in get_dns_addr(), but
>> can't imagine why you would want to send DNS requests to a different IP
>> address if you're running a DNS server on the host and resolv.conf
>> points to 127.0.0.1.
>>
>> These problems are easily solved by removing the code.
>
> Note that VirtualBox removed this code recently as well:
> http://www.virtualbox.org/ticket/1470 .
While I don't consider VirtualBox as a good reference for changing QEMU
code ;), the patch has my conditional ack (depending on the CUSEEME
emulation removal).
Thanks for picking all this up!
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] slirp: Remove our_addr code
@ 2009-08-01 1:10 Ed Swierk
0 siblings, 0 replies; 4+ messages in thread
From: Ed Swierk @ 2009-08-01 1:10 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka
Three problems with our_addr:
- It's determined only once when qemu starts, but the address can change
(just like the DNS configuration can).
- It's supposed to be the IP address of a host network interface, but
there's no guarantee that gethostbyname(gethostname()) actually does
that: the host might be a laptop that has only a loopback interface up,
or the hostname might be localhost.localdomain, etc.
- It's useless: get_dns_addr() calls it, but can't imagine why you would
want to send DNS requests to a different IP address if you're running a
DNS server on the host and resolv.conf points to 127.0.0.1.
These problems are easily solved by removing the code.
Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
---
diff --git a/slirp/main.h b/slirp/main.h
index e87b068..8d09df9 100644
--- a/slirp/main.h
+++ b/slirp/main.h
@@ -30,7 +30,6 @@ extern char *slirp_tty;
extern char *exec_shell;
extern u_int curtime;
extern fd_set *global_readfds, *global_writefds, *global_xfds;
-extern struct in_addr our_addr;
extern struct in_addr loopback_addr;
extern char *username;
extern char *socket_path;
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 987aad9..7e3945e 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -27,8 +27,6 @@
#include "slirp.h"
#include "hw/hw.h"
-/* host address */
-struct in_addr our_addr;
/* host loopback address */
struct in_addr loopback_addr;
@@ -130,8 +128,6 @@ int get_dns_addr(struct in_addr *pdns_addr)
if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
if (!inet_aton(buff2, &tmp_addr))
continue;
- if (tmp_addr.s_addr == loopback_addr.s_addr)
- tmp_addr = our_addr;
/* If it's the first one, set it to dns_addr */
if (!found) {
*pdns_addr = tmp_addr;
@@ -165,8 +161,6 @@ int get_dns_addr(struct in_addr *pdns_addr)
static void slirp_init_once(void)
{
static int initialized;
- struct hostent *he;
- char our_name[256];
#ifdef _WIN32
WSADATA Data;
#endif
@@ -182,17 +176,6 @@ static void slirp_init_once(void)
#endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- /* FIXME: This address may change during runtime */
- if (gethostname(our_name, sizeof(our_name)) == 0) {
- he = gethostbyname(our_name);
- if (he) {
- our_addr = *(struct in_addr *)he->h_addr;
- }
- }
- if (our_addr.s_addr == 0) {
- our_addr = loopback_addr;
- }
}
static void slirp_state_save(QEMUFile *f, void *opaque);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-08-01 1:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 1:37 [Qemu-devel] [PATCH] slirp: Remove our_addr code Ed Swierk
2009-07-23 1:41 ` [Qemu-devel] " Ed Swierk
2009-07-23 6:51 ` Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2009-08-01 1:10 [Qemu-devel] " Ed Swierk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).