This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack
- From: sebastien Couret <sebastien dot couret at elios-informatique dot fr>
- To: Ecos-Discuss <ecos-discuss at sources dot redhat dot com>
- Cc: sebax at netcourrier dot com
- Date: Mon, 22 Dec 2003 11:26:59 +0100
- Subject: [ECOS] Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack
- Organization: Elios Informatique
- Reply-to: sebastien dot couret at elios-informatique dot fr
Hello,
I was playing around with the BSD TCP/IP stack port on eCOS.
I came to the conclusion, that trying to change an already set IP address
with ioctl (SIOCSIFADDR) failed. (While setting it for the first time works
...)
I get into the code, and I was drived to :
{repository}/net/bsd_tcpip/current/src/sys/netinet/in.c
in function int in_control [line 206]
The following code is scanning the correct interface entry(ia) in interfaces
chained list
if (ifp)
for (iap = in_ifaddrhead.tqh_first; iap;iap = iap->ia_link.tqe_next)
if (iap->ia_ifp == ifp)
{
if (((struct sockaddr_in
*)&ifr->ifr_addr)->sin_addr.s_addr==iap->ia_addr.sin_addr.s_addr)
{
ia = iap;
break;
}
else if (ia == NULL)
{
ia = iap;
if (ifr->ifr_addr.sa_family != AF_INET)
break;
}
}
In the SIOCSIFADDR case , we retrieve the same type of code :
for (oia = ia; ia; ia = ia->ia_link.tqe_next) {
if (ia->ia_ifp == ifp && ia->ia_addr.sin_addr.s_addr ==
ifra->ifra_addr.sin_addr.s_addr)
break;
But in our case (changing an already set IP) we got ia->ia_ifp == ifp &&
ia->ia_addr.sin_addr.s_addr =! ifra->ifra_addr.sin_addr.s_addr
as a result ia which was set correctly by the first scan is now not pointing
on the expected entry.
So my proposed correction is to comment the previous code which is kind of
redundant..
What do you think of it ? Am I wrong ?
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss