public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack
@ 2003-12-22 11:37 sebastien Couret
  2003-12-22 14:13 ` Nick Garnett
  0 siblings, 1 reply; 2+ messages in thread
From: sebastien Couret @ 2003-12-22 11:37 UTC (permalink / raw)
  To: Ecos-Discuss; +Cc: sebax

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack
  2003-12-22 11:37 [ECOS] Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack sebastien Couret
@ 2003-12-22 14:13 ` Nick Garnett
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Garnett @ 2003-12-22 14:13 UTC (permalink / raw)
  To: sebastien.couret; +Cc: Ecos-Discuss, sebax

sebastien Couret <sebastien.couret@elios-informatique.fr> writes:

> 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 
> ...)

[snip]

> 
> So my proposed correction is to comment the previous code which is kind of 
> redundant..
> 
> What do you think of it ? Am I wrong ?

Without going into any detail about this particular issue, I would
suggest you be very cautions about changing any of this code. It has
been running successfully for something in the region of 20
years. Most likely the code behaves the way it does for a
reason. Making aparrently innocuous changes to make it work the way
you want is likely to break something else. It is possible that you
are misunderstanding or misusing the ioctls in some way.

However, if there really is a bug here, it may have already been fixed
in later versions of FreeBSD. So compare this code with the latest
release from freebsd.org. If they have fixed a bug in this area since
we took our snapshot, then we would be willing to upgrade our code to
fix it. We have done this in the past.


-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-22 12:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-22 11:37 [ECOS] Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack sebastien Couret
2003-12-22 14:13 ` Nick Garnett

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 read-only IMAP folder(s) and NNTP newsgroup(s).