All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ward, David - 0663 - MITLL" <david.ward@ll.mit.edu>
To: Julian Anastasov <ja@ssi.bg>
Cc: David Miller <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: Initialize entire flowi struct
Date: Thu, 1 Sep 2011 09:34:27 -0400	[thread overview]
Message-ID: <4E5F89E3.5060903@ll.mit.edu> (raw)
In-Reply-To: <alpine.LFD.2.00.1108312321400.1826@ja.ssi.bg>

[-- Attachment #1: Type: text/plain, Size: 2527 bytes --]

Hi Julian,

On 08/31/2011 04:51 PM, Julian Anastasov wrote:
> On Wed, 31 Aug 2011, David Ward wrote
>> The entire flowi struct needs to be initialized by afinfo->decode_session,
>> because flow_hash_code operates over the entire struct and may otherwise
>> return different hash values for what is intended to be the same key.
> 	Such change will cause problems for callers that
> use flowi4 in stack. Examples:
>
> ip_route_me_harder
> icmp_route_lookup

Thanks for pointing this out.

> 	Not sure if adding size as parameter to flow_hash_code
> is better approach. May be flow_cache_lookup needs to
> determine size from family that can be used for flow_hash_code,
> flow_key_compare and the memcpy(&fle->key, key, sizeof(*key))
> after fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC).

Makes sense to me.  However should we just replace flow_key_compare with 
memcmp then, since the assumptions about constant size and alignment 
will no longer apply?  Or should there be a separate flow_key_compare 
function for each family, and have all of the flowi* structures become 
__attribute__((__aligned__(BITS_PER_LONG/8))) ?

David

> The question is how to get size by family.
>
>> Signed-off-by: David Ward<david.ward@ll.mit.edu>
>> ---
>>   net/ipv4/xfrm4_policy.c |    2 +-
>>   net/ipv6/xfrm6_policy.c |    2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
>> index fc5368a..afce24d 100644
>> --- a/net/ipv4/xfrm4_policy.c
>> +++ b/net/ipv4/xfrm4_policy.c
>> @@ -114,7 +114,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
>>   	u8 *xprth = skb_network_header(skb) + iph->ihl * 4;
>>   	struct flowi4 *fl4 =&fl->u.ip4;
>>
>> -	memset(fl4, 0, sizeof(struct flowi4));
>> +	memset(fl, 0, sizeof(struct flowi));
>>   	fl4->flowi4_mark = skb->mark;
>>
>>   	if (!ip_is_fragment(iph)) {
>> diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
>> index d879f7e..9088d38 100644
>> --- a/net/ipv6/xfrm6_policy.c
>> +++ b/net/ipv6/xfrm6_policy.c
>> @@ -129,7 +129,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
>>   	const unsigned char *nh = skb_network_header(skb);
>>   	u8 nexthdr = nh[IP6CB(skb)->nhoff];
>>
>> -	memset(fl6, 0, sizeof(struct flowi6));
>> +	memset(fl, 0, sizeof(struct flowi));
>>   	fl6->flowi6_mark = skb->mark;
>>
>>   	ipv6_addr_copy(&fl6->daddr, reverse ?&hdr->saddr :&hdr->daddr);
>> -- 
>> 1.7.4.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4184 bytes --]

  parent reply	other threads:[~2011-09-01 14:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 16:05 [PATCH] net: Initialize entire flowi struct David Ward
2011-08-31 20:51 ` Julian Anastasov
2011-08-31 20:47   ` David Miller
2011-09-01 13:34   ` Ward, David - 0663 - MITLL [this message]
2011-09-03  7:27     ` Julian Anastasov
2011-09-04 13:07       ` [PATCH 0/2] Fixes to flow cache for AF-specifc flowi structs David Ward
2011-09-04 13:07       ` [PATCH 1/2] net: Align AF-specific flowi structs to long David Ward
2011-09-16 22:57         ` David Miller
2011-09-04 13:07       ` [PATCH 2/2] net: Handle different key sizes between address families in flow cache David Ward
2011-09-04 15:34         ` Michał Mirosław
2011-09-06  2:47           ` [PATCH 0/2] Fixes to flow cache for AF-specifc flowi structs David Ward
2011-09-06  2:47           ` [PATCH 1/2] net: Align AF-specific flowi structs to long David Ward
2011-09-06  2:47           ` [PATCH 2/2] net: Handle different key sizes between address families in flow cache David Ward
2011-09-16 22:57         ` David Miller

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=4E5F89E3.5060903@ll.mit.edu \
    --to=david.ward@ll.mit.edu \
    --cc=davem@davemloft.net \
    --cc=ja@ssi.bg \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.