Michael Hunter wrote:


388,1123,1272,1323,1379,1420,1456: Whats the need for these uses of
pragma pack?  Under what circumstances have you shown they are needed?
Its esp. concerning given the comment above and the first structure
leading off with a bunch of bare 'int's.

Running a 32-bit userland application (e.g., snmp agent) on an amd64 system. The size of the structure returned by the kernel would then possibly be larger than what the user application is expecting, which could cause it to break.

Michael,

I also thought that using the pragma is not necessary. However now that I have looked into solving the issue I am not so sure.

The issue we are trying to resolve can not be solved by using types defined by size. Specifically we are using int64_t. On Solaris both 32 and 64 bit this is 8 byte aligned and there are no issues. On X86 it is 4 byte aligned for 32 and 8 byte for 64 bits and that is where the problem comes in. The documentation says int64_t is 4 byte aligned for X86 but 8 bytes is a multiple of 4 and so I guess the compiler is not at fault.

The options to solve this issue are

*) Hand construct the structure with proper padding. This could break if someone changes anything in the struct.

*) Use STRUCT_DECL(9F) and copy each  field.

*) Use the pragma and force the alignment.

The last option looks pretty clean and (easy :-)) and is already being used by SCTP so I think it should be OK for Anders to use as well.

ANSI doesn't guarantee that #pragma means anything.  Can't you used types
defined by size to achieve this goal?
ANSI may not gaurantee that #pragma means anything but Sun compilers do and these pragmas are documented so it should be legal to use them. in fact sun documentation says to us ethese pragmas.

I think the following thread lays out why I don't think you should use
pragma pack.

https://www.opensolaris.org/jive/thread.jspa?messageID=64062&#64062
I am not sure if this thread completely applies to this issue. However even in the thread folks have cited cases where it would be legal to use pragmas.

I hope you will let us use the pragma till we find a cleaner generic solution and fix all users such as SCTP.

Thanks again for taking the time to review this code.

Rao.

              mph


_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to