diff mbox

[net-next,1/2] include/uapi/linux/xfrm.h: Pack struct xfrm_userpolicy_info

Message ID 1389077339-12814-2-git-send-email-fan.du@windriver.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

fan.du Jan. 7, 2014, 6:48 a.m. UTC
Otherwise 64bits kernel has sizeof(struct xfrm_userpolicy_info) 168 bytes,
while 32bits compiled iproute2 see the same structure as 164 bytes, which
leading deficit xfrm policy, in turn broken IPsec connectivity.

Fix this by packing the structure.

Signed-off-by: Fan Du <fan.du@windriver.com>
---
 include/uapi/linux/xfrm.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergei Shtylyov Jan. 7, 2014, 10:52 p.m. UTC | #1
Hello.

On 07-01-2014 10:48, Fan Du wrote:

> Otherwise 64bits kernel has sizeof(struct xfrm_userpolicy_info) 168 bytes,
> while 32bits compiled iproute2 see the same structure as 164 bytes, which
> leading deficit xfrm policy, in turn broken IPsec connectivity.

> Fix this by packing the structure.

    This will force byte-by-byte access to all members on some arches like ARM...

> Signed-off-by: Fan Du <fan.du@windriver.com>
> ---
>   include/uapi/linux/xfrm.h |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
> index a8cd6a4..470bfae 100644
> --- a/include/uapi/linux/xfrm.h
> +++ b/include/uapi/linux/xfrm.h
> @@ -405,7 +405,7 @@ struct xfrm_userpolicy_info {
>   	/* Automatically expand selector to include matching ICMP payloads. */
>   #define XFRM_POLICY_ICMP	2
>   	__u8				share;
> -};
> +} __attribute__((packed));

    Please use the __packed macro instead. I guess you haven't run checkpatch.pl?

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
fan.du Jan. 9, 2014, 8:39 a.m. UTC | #2
On 2014年01月08日 06:52, Sergei Shtylyov wrote:
> Hello.
>
> On 07-01-2014 10:48, Fan Du wrote:
>
>> Otherwise 64bits kernel has sizeof(struct xfrm_userpolicy_info) 168 bytes,
>> while 32bits compiled iproute2 see the same structure as 164 bytes, which
>> leading deficit xfrm policy, in turn broken IPsec connectivity.
>
>> Fix this by packing the structure.
>
>     This will force byte-by-byte access to all members on some arches like ARM...
>
>> Signed-off-by: Fan Du <fan.du@windriver.com>
>> ---
>>   include/uapi/linux/xfrm.h |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>
>> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
>> index a8cd6a4..470bfae 100644
>> --- a/include/uapi/linux/xfrm.h
>> +++ b/include/uapi/linux/xfrm.h
>> @@ -405,7 +405,7 @@ struct xfrm_userpolicy_info {
>>       /* Automatically expand selector to include matching ICMP payloads. */
>>   #define XFRM_POLICY_ICMP    2
>>       __u8                share;
>> -};
>> +} __attribute__((packed));
>
>     Please use the __packed macro instead. I guess you haven't run checkpatch.pl?

Lucky me, I run checkpatch every time before sending patch out.
Sergei Shtylyov Jan. 9, 2014, 10:58 p.m. UTC | #3
On 01/09/2014 11:39 AM, Fan Du wrote:

>>> Otherwise 64bits kernel has sizeof(struct xfrm_userpolicy_info) 168 bytes,
>>> while 32bits compiled iproute2 see the same structure as 164 bytes, which
>>> leading deficit xfrm policy, in turn broken IPsec connectivity.

>>> Fix this by packing the structure.

>>     This will force byte-by-byte access to all members on some arches like
>> ARM...

>>> Signed-off-by: Fan Du <fan.du@windriver.com>
>>> ---
>>>   include/uapi/linux/xfrm.h |    2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)

>>> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
>>> index a8cd6a4..470bfae 100644
>>> --- a/include/uapi/linux/xfrm.h
>>> +++ b/include/uapi/linux/xfrm.h
>>> @@ -405,7 +405,7 @@ struct xfrm_userpolicy_info {
>>>       /* Automatically expand selector to include matching ICMP payloads. */
>>>   #define XFRM_POLICY_ICMP    2
>>>       __u8                share;
>>> -};
>>> +} __attribute__((packed));

>>     Please use the __packed macro instead. I guess you haven't run
>> checkpatch.pl?

> Lucky me, I run checkpatch every time before sending patch out.

    Ah, this time it didn't have the *struct* start in the context, so that's 
why there was no complaint (probably). Usually, it suggests using __packed...

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov Jan. 9, 2014, 11:07 p.m. UTC | #4
On 01/10/2014 01:58 AM, Sergei Shtylyov wrote:

>>>> Otherwise 64bits kernel has sizeof(struct xfrm_userpolicy_info) 168 bytes,
>>>> while 32bits compiled iproute2 see the same structure as 164 bytes, which
>>>> leading deficit xfrm policy, in turn broken IPsec connectivity.

>>>> Fix this by packing the structure.

>>>     This will force byte-by-byte access to all members on some arches like
>>> ARM...

>>>> Signed-off-by: Fan Du <fan.du@windriver.com>
>>>> ---
>>>>   include/uapi/linux/xfrm.h |    2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)

>>>> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
>>>> index a8cd6a4..470bfae 100644
>>>> --- a/include/uapi/linux/xfrm.h
>>>> +++ b/include/uapi/linux/xfrm.h
>>>> @@ -405,7 +405,7 @@ struct xfrm_userpolicy_info {
>>>>       /* Automatically expand selector to include matching ICMP payloads. */
>>>>   #define XFRM_POLICY_ICMP    2
>>>>       __u8                share;
>>>> -};
>>>> +} __attribute__((packed));

>>>     Please use the __packed macro instead. I guess you haven't run
>>> checkpatch.pl?

>> Lucky me, I run checkpatch every time before sending patch out.

>     Ah, this time it didn't have the *struct* start in the context, so that's
> why there was no complaint (probably). Usually, it suggests using __packed...

    Ah, no. Looking at the script, it just doesn't WARN about this in the 
files under include/uapi/. Probably the macro is undefined in this context.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index a8cd6a4..470bfae 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -405,7 +405,7 @@  struct xfrm_userpolicy_info {
 	/* Automatically expand selector to include matching ICMP payloads. */
 #define XFRM_POLICY_ICMP	2
 	__u8				share;
-};
+} __attribute__((packed));
 
 struct xfrm_userpolicy_id {
 	struct xfrm_selector		sel;