[bug #57344] IS_SOCK_ADDR_ALIGNED(name) in sockets.c is 4-byte aligned, not aligned to MEM_ALIGNMENT

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #57344] IS_SOCK_ADDR_ALIGNED(name) in sockets.c is 4-byte aligned, not aligned to MEM_ALIGNMENT

Simon Goldschmidt
URL:
  <https://savannah.nongnu.org/bugs/?57344>

                 Summary: IS_SOCK_ADDR_ALIGNED(name) in sockets.c is 4-byte
aligned, not aligned to MEM_ALIGNMENT
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: vbrzeski
            Submitted on: Mon 02 Dec 2019 07:00:16 PM UTC
                Category: sockets/netconn
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head

    _______________________________________________________

Details:

As suggested, the socket API in sockets.c has a macro to detect misaligned
socket addresses as so:

#define IS_SOCK_ADDR_ALIGNED(name) \
  ((((mem_ptr_t)(name)) % 4) == 0)

it seems it should be as so:

#define IS_SOCK_ADDR_ALIGNED(name) \
  ((((mem_ptr_t)(name)) % MEM_ALIGNMENT) == 0)

The effect is that my 16-bit system will not be able to allocate the sock addr
on a normal alignment for my architecture. While there are work-arounds with
arch.h, these induce tight-coupling to lwIP for my application code.






    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57344>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #57344] IS_SOCK_ADDR_ALIGNED(name) in sockets.c is 4-byte aligned, not aligned to MEM_ALIGNMENT

Simon Goldschmidt
Update of bug #57344 (project lwip):

                  Status:                    None => Fixed                  
             Assigned to:                    None => goldsimon              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #1:

Hmm, ok, on 16 bit architectures you have a problem here. I'm afraid our 16
bit support is not that well tested nowadays, where most platforms are 32
bit.

OTOH, I'm not sure MEM_ALIGNMENT is correct here: even platforms with
MEM_ALIGNMENT of 8 may automatically align this to 4 since the biggest member
is an u32_t.

I've changed it to:
#define IS_SOCK_ADDR_ALIGNED(name) ((((mem_ptr_t)(name)) % LWIP_MIN(4,
MEM_ALIGNMENT)) == 0)

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57344>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel