public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy
@ 2012-08-17 13:50 bugzilla-daemon
  2012-08-17 13:54 ` [Bug 1001656] " bugzilla-daemon
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: bugzilla-daemon @ 2012-08-17 13:50 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

           Summary: FreeBSD: add AF_PACKET socket familiy
           Product: eCos
           Version: CVS
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: high
         Component: Patches and contributions
        AssignedTo: unassigned@bugs.ecos.sourceware.org
        ReportedBy: bernd.edlinger@hotmail.de
                CC: ecos-patches@ecos.sourceware.org
             Class: Advice Request


Hello,

this patch implements the Raw Ethernet Packet Sockets in the Free BSD stack.

That is a pretty cool feature which can be found nowhere else.

A fiew minor bugs are fixed too:
  - strict aliasing fixed (IPv6)
  - mbuf leaks
  - multicast output, when no gateway is configured
  - IFF_ALLMULTI changeable
  - added SIOCGIFINDEX as in linux
  - fixed SIOCADDMULTI/SIOCDELMULTI work as in linux
  - error handling in accept() looses socket resource
  - send() behaves different on SS_NBIO and MSG_DONTWAIT
  - packet loss every 20 minutes when ARP timeout expires
  - sbcompress() optimized to create less fragments

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
@ 2012-08-17 13:54 ` bugzilla-daemon
  2012-08-17 15:12 ` bugzilla-daemon
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2012-08-17 13:54 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #1 from Bernd Edlinger <bernd.edlinger@hotmail.de> 2012-08-17 14:53:49 BST ---
Created an attachment (id=1900)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id=1900)
patch to implement packet sockets

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
  2012-08-17 13:54 ` [Bug 1001656] " bugzilla-daemon
@ 2012-08-17 15:12 ` bugzilla-daemon
  2012-09-14 14:08 ` bugzilla-daemon
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2012-08-17 15:12 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #2 from Bernd Edlinger <bernd.edlinger@hotmail.de> 2012-08-17 16:11:56 BST ---
Regarding AF_PACKET:

The protocol AF_PACKET will only be available when you call
cyg_use_af_packet() somewhere in your application.

If this function is not called the af_packet.c is not linked and
the binary will not become any larger due to this enhancement.

After this is done, these sockets can be used exactly as described here:

man 7 packet

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
  2012-08-17 13:54 ` [Bug 1001656] " bugzilla-daemon
  2012-08-17 15:12 ` bugzilla-daemon
@ 2012-09-14 14:08 ` bugzilla-daemon
  2013-06-25 17:11 ` bugzilla-daemon
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2012-09-14 14:08 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Bernd Edlinger <bernd.edlinger@hotmail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #1900|0                           |1
        is obsolete|                            |

--- Comment #3 from Bernd Edlinger <bernd.edlinger@hotmail.de> 2012-09-14 15:08:25 BST ---
Created an attachment (id=1937)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id=1937)
patch to implement packet sockets, Updated.

Hello,

now I added a missing lock around sblock() and sbunlock().

This can cause problems if different threads use sendto() on the same socket.
or recv() and shutdown(SD_RECV) on the same socket at the same time.

See the discussion on ecos-discuss@ecos.sourceware.org: "BSD socket stall"‏

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (2 preceding siblings ...)
  2012-09-14 14:08 ` bugzilla-daemon
@ 2013-06-25 17:11 ` bugzilla-daemon
  2013-07-15 12:01 ` bugzilla-daemon
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-06-25 17:11 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Bernd Edlinger <bernd.edlinger@hotmail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #1937|0                           |1
        is obsolete|                            |

--- Comment #4 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2268
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2268&action=edit
patch to implement packet sockets and various bug-fixes.

Hello,

my previus change introduced an unbalanced splnet/splx sequence in sosend().

this will be fixed with the attached update of the patch.

the only change is:
moved the splx in sosend() inside the do { } while loop.

-     splx(s);
      mp = &top;
      space -= clen;
      do {
+          splx(s);

           ....

           s = splnet();                               /* XXX */

           ...

      while (resid && space > 0);

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (3 preceding siblings ...)
  2013-06-25 17:11 ` bugzilla-daemon
@ 2013-07-15 12:01 ` bugzilla-daemon
  2013-07-15 12:58 ` bugzilla-daemon
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-07-15 12:01 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Juergen Lambrecht <J.Lambrecht@televic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |J.Lambrecht@televic.com

--- Comment #5 from Juergen Lambrecht <J.Lambrecht@televic.com> ---
(In reply to comment #2)
> Regarding AF_PACKET:
> 
> The protocol AF_PACKET will only be available when you call
> cyg_use_af_packet() somewhere in your application.
> 
> If this function is not called the af_packet.c is not linked and
> the binary will not become any larger due to this enhancement.
> 
> After this is done, these sockets can be used exactly as described here:
> 
> man 7 packet

Hi Bernd,

Because I am porting the busybox dhcp server to eCos, I am using your raw
packet patch.
When I do 'man 7 packet' on my linux, I get a slightly different definition of
'struct sockaddr_ll' (as also used by busybox): I have 'int sll_ifindex;'
instead of 'u_short sll_index;' and 'unsigned char sll_addr[8];' instead of
'u_char sll_addr[22];'.
I guess the naming difference is because your code is based on the freeBSD, and
the busybox is based on Linux.
But why 22 bytes for the address ('ssl_addr'), you only use 6B of it
(EHTER_ADDR_LEN)?

Kind regards,
Jürgen

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (4 preceding siblings ...)
  2013-07-15 12:01 ` bugzilla-daemon
@ 2013-07-15 12:58 ` bugzilla-daemon
  2013-07-15 15:39 ` bugzilla-daemon
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-07-15 12:58 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #6 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
(In reply to comment #5)
Hi Jürgen,

> Because I am porting the busybox dhcp server to eCos, I am using your raw
> packet patch.
> When I do 'man 7 packet' on my linux, I get a slightly different definition
> of 'struct sockaddr_ll' (as also used by busybox): I have 'int sll_ifindex;'
> instead of 'u_short sll_index;' and 'unsigned char sll_addr[8];' instead of
> 'u_char sll_addr[22];'.
> I guess the naming difference is because your code is based on the freeBSD,
> and the busybox is based on Linux.
> But why 22 bytes for the address ('ssl_addr'), you only use 6B of it
> (EHTER_ADDR_LEN)?

good questions...

1. actually the name should be sll_ifindex. I somehow missed that typo.

2. the data type that is used by the bsd stack to index the interfaces
   is u_short, therefore I thought it would be better to use that instead.
   Same for the SIOCGIFINDEX ioctl, which uses only u_short.

3. in linux sizeof (struct sockaddr_ll) = 20 which is larger than
   sizeof(struct sockaddr) = 16.
   But on eCos the sockaddr is 32 bytes. Therefore the sockaddr_ll
   must be at least 32 bytes. Therefore I enlarged the sll_addr to 22.

Note: All socket addressses should be exactly 32 bytes in eCos,
because of this code in ./io/fileio/current/src/socket.cxx:

__externC int   bind (int s, const struct sockaddr *sa, unsigned int len)
{
...
    struct sockaddr sa2 = *sa;



regading 1, I will change the name.

regarding 2, I could change the type to int, and cast it
to u_short later, but only if that improves protability.

Is it your impression that this change would improve the
portability of the busybox dhcp server?

regarding 3, the sizeof sll_addr should be irrelevant to
the application as only 6 bytes are really used.

Does the existion code use the size of the sll_addr array
for anything? Does it break unless this array is exactly 8 bytes?


Regards
Bernd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (5 preceding siblings ...)
  2013-07-15 12:58 ` bugzilla-daemon
@ 2013-07-15 15:39 ` bugzilla-daemon
  2013-07-23 18:48 ` bugzilla-daemon
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-07-15 15:39 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #7 from Juergen Lambrecht <J.Lambrecht@televic.com> ---
(In reply to comment #6)
> (In reply to comment #5)
> Hi Jürgen,
> 
> > Because I am porting the busybox dhcp server to eCos, I am using your raw
> > packet patch.
> > When I do 'man 7 packet' on my linux, I get a slightly different definition
> > of 'struct sockaddr_ll' (as also used by busybox): I have 'int sll_ifindex;'
> > instead of 'u_short sll_index;' and 'unsigned char sll_addr[8];' instead of
> > 'u_char sll_addr[22];'.
> > I guess the naming difference is because your code is based on the freeBSD,
> > and the busybox is based on Linux.
> > But why 22 bytes for the address ('ssl_addr'), you only use 6B of it
> > (EHTER_ADDR_LEN)?
> 
> good questions...
> 
> 1. actually the name should be sll_ifindex. I somehow missed that typo.
> 
> 2. the data type that is used by the bsd stack to index the interfaces
>    is u_short, therefore I thought it would be better to use that instead.
>    Same for the SIOCGIFINDEX ioctl, which uses only u_short.
> 
> 3. in linux sizeof (struct sockaddr_ll) = 20 which is larger than
>    sizeof(struct sockaddr) = 16.
>    But on eCos the sockaddr is 32 bytes. Therefore the sockaddr_ll
>    must be at least 32 bytes. Therefore I enlarged the sll_addr to 22.
> 
> Note: All socket addressses should be exactly 32 bytes in eCos,
> because of this code in ./io/fileio/current/src/socket.cxx:
> 
> __externC int   bind (int s, const struct sockaddr *sa, unsigned int len)
> {
> ...
>     struct sockaddr sa2 = *sa;
> 
> 
> 
> regading 1, I will change the name.
OK, I did the same
> 
> regarding 2, I could change the type to int, and cast it
> to u_short later, but only if that improves protability.
> 
> Is it your impression that this change would improve the
> portability of the busybox dhcp server?
No, it's OK. The code compiled without warnings so far.
> 
> regarding 3, the sizeof sll_addr should be irrelevant to
> the application as only 6 bytes are really used.
> 
> Does the existion code use the size of the sll_addr array
> for anything? Does it break unless this array is exactly 8 bytes?
No. Busybox code also only uses 6B instead of the 8 they have.
So it is OK.

Thanks for your reply,
Jürgen
> 
> 
> Regards
> Bernd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (6 preceding siblings ...)
  2013-07-15 15:39 ` bugzilla-daemon
@ 2013-07-23 18:48 ` bugzilla-daemon
  2013-11-26  9:49 ` bugzilla-daemon
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-07-23 18:48 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Bernd Edlinger <bernd.edlinger@hotmail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #2268|0                           |1
        is obsolete|                            |

--- Comment #8 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2337
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2337&action=edit
patch to implement packet sockets and various bug-fixes

renamed sll_index to sll_ifindex due to recent discussion.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (7 preceding siblings ...)
  2013-07-23 18:48 ` bugzilla-daemon
@ 2013-11-26  9:49 ` bugzilla-daemon
  2013-11-26 10:21 ` bugzilla-daemon
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-11-26  9:49 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #9 from D.Zebralla <daniel.zebralla@arcor.de> ---
Created attachment 2388
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2388&action=edit
Simple test to send a raw ethernet packet and to receive a raw ethernet packet

Hello,

I just wanted to confirm that this patch is working, applied to eCos revision
3272 (checked out from ecoscentric mercurial repository).

I attached a c-file with two simple functions:
* sendPacket() - sends a raw packet with a given ethernet type
* receivePacket() - busy wait until a packet is received with the given
ethernet type

I DID NOT test the effects of the additional bug fixes, so I can not give
feedback on those!

I would like to see this patch included into the ecos repository sometime soon!

Regards
- Daniel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (8 preceding siblings ...)
  2013-11-26  9:49 ` bugzilla-daemon
@ 2013-11-26 10:21 ` bugzilla-daemon
  2013-12-06 10:03 ` bugzilla-daemon
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-11-26 10:21 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #10 from Juergen Lambrecht <J.Lambrecht@televic.com> ---
(In reply to comment #9)
> Created attachment 2388 [details]
> Simple test to send a raw ethernet packet and to receive a raw ethernet
> packet
> 
> Hello,
> 
> I just wanted to confirm that this patch is working, applied to eCos
> revision 3272 (checked out from ecoscentric mercurial repository).
I also want to confirm this patch works for me. I updated to the ecos CVS
repository from 7/2013.
> 
> I attached a c-file with two simple functions:
> * sendPacket() - sends a raw packet with a given ethernet type
> * receivePacket() - busy wait until a packet is received with the given
> ethernet type
> 
> I DID NOT test the effects of the additional bug fixes, so I can not give
> feedback on those!
Same for me, but we are testing 3 applications with it for the past months and
no eCos issues so far.
> 
> I would like to see this patch included into the ecos repository sometime
> soon!
same for me
> 
> Regards
> - Daniel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (9 preceding siblings ...)
  2013-11-26 10:21 ` bugzilla-daemon
@ 2013-12-06 10:03 ` bugzilla-daemon
  2013-12-06 15:37 ` bugzilla-daemon
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-12-06 10:03 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #11 from D.Zebralla <daniel.zebralla@arcor.de> ---
I stumbled across a problem sending normal UDP packets with this patch.
I'm not sure whether the problem is introduced by this patch or our way of
opening a UDP socket is wrong.

I'm referring to this change of the patch:

diff -Nur ecos-cvs-120723/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c
ecos/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c
--- ecos-cvs-120723/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c   
2009-01-29 18:49:56.000000000 +0100
+++ ecos/packages/net/bsd_tcpip/current/src/sys/kern/sockio.c    2012-08-02
10:15:18.000000000 +0200
@@ -234,7 +234,8 @@
 {
     int error;
     sockaddr sa1=*sa;
-    
+    sa1.sa_len = len;
+
     error = sobind((struct socket *)fp->f_data, (sockaddr *)&sa1, 0);
     return error;
 }


We're starting the UDP connection like this (error checking omitted for
readability):
    memset(&hints, 0, sizeof hints); // make sure the struct is empty
    hints.ai_family = AF_INET6; // IPv6
    hints.ai_socktype = SOCK_DGRAM; // UDP
    hints.ai_flags = AI_PASSIVE; // fill in my IP for me

    getaddrinfo(NULL, "12345", &hints, &servinfo);

    acceptSocket = socket(servinfo->ai_family, servinfo->ai_socktype,
servinfo->ai_protocol);

    setsockopt(acceptSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&on,sizeof(on);

    bind(acceptSocket, servinfo->ai_addr, servinfo->ai_addrlen);

servinfo->ai_addrlen was set to 32 Bytes (size of struct sockaddr) inside
alloc_addrinfo-function:
    struct sockaddr * sa;
    [...]
    nai->ai_addrlen = sizeof(*sa);


Due to the patch inside bsd_bind sa1.sa_len is now changed from 28 (size of
struct sockaddr_in6) to 32 (size of struct sockaddr).

After finally arriving in the udp6_output function, the following sanity check
now fails because addr6->m_len is now 32 instead of 28:
    if (addr6) {
    [...]
        sin6 = mtod(addr6, struct sockaddr_in6 *);

        if (addr6->m_len != sizeof(*sin6))
            return(EINVAL);
    [...]
    }


Can someone please confirm this or point me to errors we may have made?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (10 preceding siblings ...)
  2013-12-06 10:03 ` bugzilla-daemon
@ 2013-12-06 15:37 ` bugzilla-daemon
  2013-12-09 14:25 ` bugzilla-daemon
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-12-06 15:37 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #12 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Hi,

thanks for reporting this.
I had not done much testing in the IPv6 area.

The issue with the bind is, that

 sockaddr sa1=*sa;

copies exacly 32 bytes. So all sockaddr_xx structures should
have at least 32 bytes, otherwise we get access beyound the end
at this point.

I had not seen that sockaddr_in6 is shorter than sockaddr.
that looks wrong indeed.

I'd suggest you try to make sockaddr 4 bytes larger

struct sockaddr_in6 {
        u_int8_t        sin6_len;       /* length of this struct(sa_family_t)*/
        u_int8_t        sin6_family;    /* AF_INET6 (sa_family_t) */
        u_int16_t       sin6_port;      /* Transport layer port # (in_port_t)*/
        u_int32_t       sin6_flowinfo;  /* IP6 flow information */
        struct in6_addr sin6_addr;      /* IP6 address */
        u_int32_t       sin6_scope_id;  /* scope zone index */
        char            sin6_zero[4];   /* padding */
};

does this work?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (11 preceding siblings ...)
  2013-12-06 15:37 ` bugzilla-daemon
@ 2013-12-09 14:25 ` bugzilla-daemon
  2013-12-31  0:13 ` bugzilla-daemon
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-12-09 14:25 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #13 from D.Zebralla <daniel.zebralla@arcor.de> ---
After the first quick test: Yes, it looks like the IPv6 UDP packet is now sent.

However, I am wondering if it's really the right thing to stuff padding bytes
into sockaddr_in6. I am not familiar with the whole networking code stuff, but
I saw that in the Windows world and partly in various unix flavors 28 Bytes for
sockaddr_in6 or even little less seem common.

Is there any RFC, ISO or POSIX standard where it's said that these structures
should have the same size?

What about this sockaddr_storage struct?

On a sidenote: Why was there even a 'len'-parameter in bsd_bind() when it was
not used up until your patch?

Thanks in advance!

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (12 preceding siblings ...)
  2013-12-09 14:25 ` bugzilla-daemon
@ 2013-12-31  0:13 ` bugzilla-daemon
  2014-01-21 16:46 ` bugzilla-daemon
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2013-12-31  0:13 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #14 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
(In reply to comment #13)
> After the first quick test: Yes, it looks like the IPv6 UDP packet is now
> sent.

Good.

> However, I am wondering if it's really the right thing to stuff
> padding bytes into sockaddr_in6. I am not familiar with the whole networking
> code stuff, but I saw that in the Windows world and partly in various unix
> flavors 28 Bytes for sockaddr_in6 or even little less seem common.
> Is there
> any RFC, ISO or POSIX standard where it's said that these structures should
> have the same size?

probably not. The goal is to be compatible to other O/S where possible.
However for eCos an exact binary compatiblity is not required.
Even the defines for AF_INET and AF_INET6 may be different from what they
are on linux.

For whatever reason eCos chose to enlarge struct sockaddr from 16 bytes
(as it is on linux) to 32 bytes. I always assumed that was a smart move,
which was done to make struct sockaddr large enough to hold a sockaddr_in6,
but I never checked that, and I did not much testing with IPv6 either...

Well, struct sockaddr is the base-class of all socket types,
and therefore all other socket types should be at least as large as 32 bytes.

As a consequence sockaddr_in has a padding enlarged from 8 (as it is on linux)
enlarged to 24. But sockaddr_in6 should have done the same.

> sidenote: Why was there even a 'len'-parameter in bsd_bind() when it was not
> used up until your patch?

Definitely a BUG.

Fact is:
The code in bsd_bind does _only_ work under the assumption that
len == sizeof(sockaddr) otherwise you access beyond the end of *sa
or you only copy a part of the underlying structure.

I did not want to add more complexity here, like using dynamic allocations,
because with AF_INET/AF_INET6/AF_PACKET I can make sure that all socket
structures are exactly the same size.

On the other hand, on linux nobody sets "sa_len" but uses the len
parameter instead to tell bind() how long the structure is.
So I figured it would be better to use the len parameter to set
that member, because inside the network stack, there is no "len",
but always sa_len.

So, my intention was just to improve compatibilty to linux here,
and still have the right data in sa_len for the network stack.


Regards
Bernd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (13 preceding siblings ...)
  2013-12-31  0:13 ` bugzilla-daemon
@ 2014-01-21 16:46 ` bugzilla-daemon
  2014-01-22  7:46 ` bugzilla-daemon
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-21 16:46 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Grant Edwards <grant.b.edwards@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grant.b.edwards@gmail.com

--- Comment #15 from Grant Edwards <grant.b.edwards@gmail.com> ---
First, thanks for taking the time to find/fix all these bugs.

I'd like to start working on getting these committed.  After a
preliminary look through the patches I have a few suggestions on how
to more quickly get things committed.

The patches contain hundreds diffs where nothing has changed but
whitespace (usually at the end of the line):

  diff -Nur ecos-cvs-120723/packages/io/eth/current/src/net/eth_drv.c
ecos/packages/io/eth/current/src/net/eth_drv.c
  --- ecos-cvs-120723/packages/io/eth/current/src/net/eth_drv.c    2009-01-29
18:49:45.000000000 +0100
  +++ ecos/packages/io/eth/current/src/net/eth_drv.c    2012-08-02
14:30:54.000000000 +0200
  @@ -146,8 +146,8 @@
   static int
   simulate_fail( struct eth_drv_sc *sc, int which )
   {
  -    struct simulated_failure_state *s;  
  -    
  +    struct simulated_failure_state *s;
  +
       for ( s = &simulated_failure_states[0]; s <
&simulated_failure_states[2];
             s++ ) {
           if ( 0 == s->sc ) {

Having to wade through the non-changes visually searching for the real
changes makes it that much more difficult to review.  Applying the
patches and then using a diff tool like meld that can ignore
whitespace changes is one work-around, but being able to use
Bugzilla's built-in (though somewhat less intelligent) tools makes
life easier for anybody reviewing the code.

I realize that deleting trailing whitespace is a side-effect of using
certain editors and probably wasn't done intentionally.  Cleaning up
whitespace from ends of lines is fine, but it it should probably be in
a separate patch that does nothing but whitespace cleanup.

Splitting the changes up into smaller patches would also make it much
easier.  A separate patch for the AF_PACKET support and for each of
the 10 bugs you listed would be ideal.  That way somebody reviewing
the code doesn't have to try to figure out which bug a particular
change is addressing.  It also means that the work of reviewing and
committing the changes can be divided up among multiple maintainers.

Next is the question of copyright assignment.  I'm not sure where the
threshold is for "trivial" changes above which a copyright assignment
is needed, and hopefully some other maintainers to comment on
that. There's probably a good chance that for a contribution this
large a copyright assignment will be needed.

-- 
Grant

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (14 preceding siblings ...)
  2014-01-21 16:46 ` bugzilla-daemon
@ 2014-01-22  7:46 ` bugzilla-daemon
  2014-01-31 10:39 ` bugzilla-daemon
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-22  7:46 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #16 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
(In reply to comment #15)
> First, thanks for taking the time to find/fix all these bugs.
> 
> I'd like to start working on getting these committed.  After a
> preliminary look through the patches I have a few suggestions on how
> to more quickly get things committed.
> 
> The patches contain hundreds diffs where nothing has changed but
> whitespace (usually at the end of the line):
> 

OK, separating the white-space changes is easy I will do that.

> Splitting the changes up into smaller patches would also make it much
> easier.  A separate patch for the AF_PACKET support and for each of
> the 10 bugs you listed would be ideal.  That way somebody reviewing
> the code doesn't have to try to figure out which bug a particular
> change is addressing.  It also means that the work of reviewing and
> committing the changes can be divided up among multiple maintainers.
> 

Well, maybe I should start with writing a change-log.

I am not sure how to test each part of that patch separately.
But I will try to isolate obviously independent parts and
separate that where possible.

> Next is the question of copyright assignment.  I'm not sure where the
> threshold is for "trivial" changes above which a copyright assignment
> is needed, and hopefully some other maintainers to comment on
> that. There's probably a good chance that for a contribution this
> large a copyright assignment will be needed.
> 

The copyright-assignment was signed by
my company (softing.com) on 2012-10-25
and counter-signed by FSF on 2012-12-17

Bernd.

> -- 
> Grant

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (15 preceding siblings ...)
  2014-01-22  7:46 ` bugzilla-daemon
@ 2014-01-31 10:39 ` bugzilla-daemon
  2014-01-31 10:41 ` bugzilla-daemon
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-31 10:39 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #17 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Hi,

Now I have separated the white-space changes from the code changes and put
it in another patch file, which is to be applied after the code changes,
otherwise the context won't match.

And I wrote a change log for all the code changes.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (16 preceding siblings ...)
  2014-01-31 10:39 ` bugzilla-daemon
@ 2014-01-31 10:41 ` bugzilla-daemon
  2014-01-31 10:43 ` bugzilla-daemon
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-31 10:41 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #18 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2414
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2414&action=edit
Change-Log entry for all the bsd stack changes

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (17 preceding siblings ...)
  2014-01-31 10:41 ` bugzilla-daemon
@ 2014-01-31 10:43 ` bugzilla-daemon
  2014-01-31 10:44 ` bugzilla-daemon
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-31 10:43 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Bernd Edlinger <bernd.edlinger@hotmail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #2337|0                           |1
        is obsolete|                            |

--- Comment #19 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2415
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2415&action=edit
patch to implement packet sockets and various bug-fixes

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (18 preceding siblings ...)
  2014-01-31 10:43 ` bugzilla-daemon
@ 2014-01-31 10:44 ` bugzilla-daemon
  2014-01-31 10:51 ` bugzilla-daemon
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-31 10:44 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #20 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2416
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2416&action=edit
white space changes extracted from previous patch

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (19 preceding siblings ...)
  2014-01-31 10:44 ` bugzilla-daemon
@ 2014-01-31 10:51 ` bugzilla-daemon
  2015-06-10  8:48 ` bugzilla-daemon
  2015-06-10  8:53 ` bugzilla-daemon
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2014-01-31 10:51 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #21 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Hi,

I forgot to mention:

The updated patch has the padding added to sockaddr_in6.
So IPv6 should be working now.

Bernd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (20 preceding siblings ...)
  2014-01-31 10:51 ` bugzilla-daemon
@ 2015-06-10  8:48 ` bugzilla-daemon
  2015-06-10  8:53 ` bugzilla-daemon
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2015-06-10  8:48 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

--- Comment #22 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Created attachment 2598
  --> http://bugs.ecos.sourceware.org/attachment.cgi?id=2598&action=edit
Bug-Fixes for Achilles Test

Hi,

I have been doing some Testing with an Achilles System here
on an eCos / eCosPro Target recently.  See http://www.wurldtech.com

I was able to fix a few anomalies that were found in these tests.

The attached patch file is meant to be applied in addition to the
previous patches.

Here are some explanations, what this patch does:

* src/sys/netinet/ip_icmp.c:

- fix crash in Achilles UDP Fuzzer test.

This test sent an UDP packet with maximum size IP header.
The bsd stack tried to send an ICMP unreachable response.

But it triggered this panic, in the icmp_error handler:

        if (m->m_data - sizeof(struct ip) < m->m_pktdat)
                panic("icmp len");

That is because the maximum payload of a MBUF with m_hdr and
pkthdr is MHLEN = 128-20-24 = 84 bytes, but the ICMP response should
contain an 8 bytes ICMP header, plus the original IP header
and up to 8 bytes of the original UDP header, and of course
the minimum IP header in front:
That can be up to 20 + 8 + 60 + 8 = 96 bytes.

This patch throws this packet away, instead of crashing.


* src/sys/netinet/tcp_input.c:

- fix the Achilles test cases:
- TCP SYN Storm from Broadcast (L2)
- TCP Data Grammar (L2)

  M_BCAST/M_MCAST is only set if ethernet header is a BCAST address
ff:ff:ff:ff:ff:ff.
  but Achilles sends UNICAST ethernet header with network local broad cast
172.17.255.255
  addresses in the IP header source address field, and the bsd_stack sent
  back to the unicast ethernet address with IP bcast address in IP destination
field.

This avoids sending SYN/ACK and RST packets to broadcast addresses.

I have no idea what do to about the "normal" TCP SYN Storm Test:
This is still failing, because we do not have tcp_syncookies.


* include/net/if.h, src/sys/netinet/if_ether.c:

- increase IFQ_MAXLEN to 1024
- and use it also for the ARP request queue

This is necessary to pass the UDP Data Grammar tests,
which send 64KB UDP packets (which has 46 fragments)
and if the IFQ_MAXLEN is at 50 this leaves too little
headroom for additional ICMP and UDP packets, which must
be handled to pass the test.

In order to pass the ICMP and ARP storm tests, you
have to allocate _many_ (>3000) MBUFs, and using a too
small IFQ_MAXLEN would throw away some important packets,
which may cause the test to fail.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug 1001656] FreeBSD: add AF_PACKET socket familiy
  2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
                   ` (21 preceding siblings ...)
  2015-06-10  8:48 ` bugzilla-daemon
@ 2015-06-10  8:53 ` bugzilla-daemon
  22 siblings, 0 replies; 24+ messages in thread
From: bugzilla-daemon @ 2015-06-10  8:53 UTC (permalink / raw)
  To: ecos-patches

Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001656

Bernd Edlinger <bernd.edlinger@hotmail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickg@ecoscentric.com

--- Comment #23 from Bernd Edlinger <bernd.edlinger@hotmail.de> ---
Nick,

You may probably want to use the Achilles patch on eCosPro too?


Bernd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2015-06-10  8:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 13:50 [Bug 1001656] New: FreeBSD: add AF_PACKET socket familiy bugzilla-daemon
2012-08-17 13:54 ` [Bug 1001656] " bugzilla-daemon
2012-08-17 15:12 ` bugzilla-daemon
2012-09-14 14:08 ` bugzilla-daemon
2013-06-25 17:11 ` bugzilla-daemon
2013-07-15 12:01 ` bugzilla-daemon
2013-07-15 12:58 ` bugzilla-daemon
2013-07-15 15:39 ` bugzilla-daemon
2013-07-23 18:48 ` bugzilla-daemon
2013-11-26  9:49 ` bugzilla-daemon
2013-11-26 10:21 ` bugzilla-daemon
2013-12-06 10:03 ` bugzilla-daemon
2013-12-06 15:37 ` bugzilla-daemon
2013-12-09 14:25 ` bugzilla-daemon
2013-12-31  0:13 ` bugzilla-daemon
2014-01-21 16:46 ` bugzilla-daemon
2014-01-22  7:46 ` bugzilla-daemon
2014-01-31 10:39 ` bugzilla-daemon
2014-01-31 10:41 ` bugzilla-daemon
2014-01-31 10:43 ` bugzilla-daemon
2014-01-31 10:44 ` bugzilla-daemon
2014-01-31 10:51 ` bugzilla-daemon
2015-06-10  8:48 ` bugzilla-daemon
2015-06-10  8:53 ` bugzilla-daemon

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