public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Gary Thomas <gary@mlbassoc.com>
To: Nick Garnett <nickg@ecoscentric.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Sturle Mastberg <sturle.mastberg@tandberg.net>,
	eCos Discussion <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] Possible fix for duplicated ARP entries in the FreeBSD stack
Date: Fri, 17 Jun 2005 12:57:00 -0000	[thread overview]
Message-ID: <1119013047.13965.253.camel@hermes> (raw)
In-Reply-To: <m3d5ql2lh0.fsf@xl5.calivar.com>

On Fri, 2005-06-17 at 13:53 +0100, Nick Garnett wrote:
> Andrew Lunn <andrew@lunn.ch> writes:
> 
> > On Fri, Jun 17, 2005 at 12:57:49PM +0200, Sturle Mastberg wrote:
> > > Gary Thomas wrote:
> > > >On Fri, 2005-06-17 at 10:52 +0200, Sturle Mastberg wrote:
> > > >
> > > >>Hello,
> > > >>
> > > >>For some time I've had problem with duplicated ARP entries that have 
> > > >>caused all sorts of problems. I searched the archive and discovered that 
> > > >>the problem had been reported before:
> > > >>
> > > >>
> > > >>http://sourceware.org/ml/ecos-discuss/2004-11/msg00097.html
> > > >>
> > > >>
> > > >>My proposal to a fix is to make the sockaddr_inarp struct 
> > > >>(include/netinet/if_ether.h) equal in size to the sockaddr struct by 
> > > >>padding it at the end. This is exactly what is done to the sockaddr_in 
> > > >>struct (include/netinet/in.h) for different reasons.
> > > >>
> > > >>
> > > >>I reached this conclusion after I discovered that two virutally 
> > > >>identical calls to rtalloc1 (net/route.c) returned different results. 
> > > >>The first instance appears in arplookup (netinet/if_ether.c) where the 
> > > >>first parameter to rtalloc1 is a struct sockaddr_inarp cast to a struct 
> > > >>sockaddr. The second instance appears in ip_output (netinet/ip_output) 
> > > >>via rtalloc_ign (net/route.c) where the first parameter to rtalloc1 is 
> > > >>an actual struct sockaddr. The rtalloc1 function does a radix tree 
> > > >>search with a call to the rn_match function (net/radix.c). A closer look 
> > > >>at this code reveals that it does indeed depend on the size of the 
> > > >>supplied struct.
> > > >>
> > > >>
> > > >>The only conclusion a can draw from this is that the three structs: 
> > > >>sockaddr, sockaddr_in and sockaddr_inarp must all be of equal size. I 
> > > >>have checked the FreeBSD source repository that this is the case for the 
> > > >>original code.
> > > >>
> > > >>
> > > >>While browsing the FreeBSD source repository I discovered that the 
> > > >>sa_data character array member of the sockaddr struct was increased in 
> > > >>size in the eCos FreeBSD stack. Does anyone know why this increase was 
> > > >>introduced in eCos?
> > 
> > I beleave Nick did this for IPv6. This bigger size allows an IPv6
> > address to be placed into a sockaddr which you cannot normally do.
> 
> I thought that initially and had a look. The change I made was to
> struct sockaddr_in to make it match the increased sockaddr size so
> that some punned data structures would match. I think the change to
> struct sockaddr was done by Gary during the initial port to make IPv6
> addresses fit correctly. I'm sure it all has something to do with the
> lack of user/kernel space and the fact that we don't copy things to
> and fro as much as the BSD kernel does.

This is as I remember it as well.  Note the comment in the structure
(which I did not add or change) that bodes of this inconsistency.

Of course, if someone has a better way to handle it, feel free to
post a patch :-)

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


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

  reply	other threads:[~2005-06-17 12:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-17  8:52 Sturle Mastberg
2005-06-17 10:01 ` Gary Thomas
2005-06-17 10:58   ` Sturle Mastberg
2005-06-17 11:30     ` Andrew Lunn
2005-06-17 12:53       ` Nick Garnett
2005-06-17 12:57         ` Gary Thomas [this message]
2005-06-20  9:05           ` [ECOS] RE : [ECOS] Possible fix for duplicated ARP entries in the FreeBSDstack Arnaud Chataignier
2005-06-20 10:12             ` [ECOS] " Sturle Mastberg
2005-06-20 10:26             ` [ECOS] " Nick Garnett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1119013047.13965.253.camel@hermes \
    --to=gary@mlbassoc.com \
    --cc=andrew@lunn.ch \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=nickg@ecoscentric.com \
    --cc=sturle.mastberg@tandberg.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).