This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Buggy ioctl (SIOCSIFADDR) with BSD TCP/IP stack


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]