From: Vlad Yasevich <vyasevich@gmail.com>
To: Fan Du <fan.du@windriver.com>
Cc: nhorman@tuxdriver.com, nicolas.dichtel@6wind.com,
	davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [RFC PATCH] sctp: Don't lookup dst if transport dst is still valid
Date: Wed, 03 Jul 2013 10:11:59 -0400	[thread overview]
Message-ID: <51D4312F.1010802@gmail.com> (raw)
In-Reply-To: <51D425B7.20204@gmail.com>
On 07/03/2013 09:23 AM, Vlad Yasevich wrote:
> On 07/02/2013 10:18 PM, Fan Du wrote:
>>
>>
>> On 2013年07月02日 22:29, Vlad Yasevich wrote:
>>> On 07/02/2013 02:39 AM, Fan Du wrote:
>>>> When sctp sits on IPv6, sctp_transport_dst_check pass cookie as ZERO,
>>>> as a result ip6_dst_check always fail out. This behaviour makes
>>>> transport->dst useless, because every sctp_packet_transmit must look
>>>> for valid dst(Is this what supposed to be?)
>>>>
>>>> One aggressive way is to call rt_genid_bump which invalid all dst to
>>>> make new dst for transport, apparently it also hurts others.
>>>> I'm sure this may not be the best for all, so any commnets?
>>>>
>>>> Signed-off-by: Fan Du <fan.du@windriver.com>
>>>> ---
>>>> include/net/sctp/sctp.h | 18 ++++++++++++------
>>>> net/sctp/ipv6.c | 2 ++
>>>> 2 files changed, 14 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
>>>> index cd89510..f05af01 100644
>>>> --- a/include/net/sctp/sctp.h
>>>> +++ b/include/net/sctp/sctp.h
>>>> @@ -719,14 +719,20 @@ static inline void sctp_v4_map_v6(union
>>>> sctp_addr *addr)
>>>> addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff);
>>>> }
>>>>
>>>> -/* The cookie is always 0 since this is how it's used in the
>>>> - * pmtu code.
>>>> - */
>>>> +/* Set cookie with the right one for IPv6 and zero for others */
>>>> static inline struct dst_entry *sctp_transport_dst_check(struct
>>>> sctp_transport *t)
>>>> {
>>>> - if (t->dst && !dst_check(t->dst, 0)) {
>>>> - dst_release(t->dst);
>>>> - t->dst = NULL;
>>>> +
>>>> + if (t->dst) {
>>>> + struct rt6_info *rt = (struct rt6_info *)t->dst;
>>>> + u32 cookie = 0;
>>>> +
>>>> + if ((t->af_specific->sa_family == AF_INET6) && rt->rt6i_node)
>>>> + cookie = rt->rt6i_node->fn_sernum;
>>>> + if (!dst_check(t->dst, cookie)) {
>>>> + dst_release(t->dst);
>>>> + t->dst = NULL;
>>>> + }
>>>> }
>>>
>>> I think it would be better if we stored the dst_cookie in the
>>> transport structure and initialized it at lookup time. If you do that,
>>> then if the route table changes, we'd correctly detect it without
>>> artificially bumping rt_genid (and hurting ipv4).
>>
>> Hi Vlad/Neil
>>
>> Is this what you mean?
>
> Yes, exactly.
>
> -vlad
>
>>
>> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
>> index cd89510..0a646a5 100644
>> --- a/include/net/sctp/sctp.h
>> +++ b/include/net/sctp/sctp.h
>> @@ -724,7 +724,7 @@ static inline void sctp_v4_map_v6(union sctp_addr
>> *addr)
>>    */
>>   static inline struct dst_entry *sctp_transport_dst_check(struct
>> sctp_transport *t)
>>   {
>> -       if (t->dst && !dst_check(t->dst, 0)) {
>> +       if (t->dst && !dst_check(t->dst, t->dst_cookie)) {
>>                  dst_release(t->dst);
>>                  t->dst = NULL;
>>          }
>> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
>> index 1bd4c41..cafdd19 100644
>> --- a/include/net/sctp/structs.h
>> +++ b/include/net/sctp/structs.h
>> @@ -946,6 +946,8 @@ struct sctp_transport {
>>          __u64 hb_nonce;
>>
>>          struct rcu_head rcu;
>> +
>> +       u32 dst_cookie;
>>   };
One comment is that you might try to find a way to put the dst_cookie 
closer to the cached dst.  See if there is a hole the you can fill.
-vlad
>>
>>   struct sctp_transport *sctp_transport_new(struct net *, const union
>> sctp_addr *,
>> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
>> index 8ee553b..82a420f 100644
>> --- a/net/sctp/ipv6.c
>> +++ b/net/sctp/ipv6.c
>> @@ -350,6 +350,7 @@ out:
>>                  struct rt6_info *rt;
>>                  rt = (struct rt6_info *)dst;
>>                  t->dst = dst;
>> +               t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum
>> : 0;
>>                  SCTP_DEBUG_PRINTK("rt6_dst:%pI6 rt6_src:%pI6\n",
>>                          &rt->rt6i_dst.addr, &fl6->saddr);
>>          } else {
>>
>>
>>
>>
>>
>>> -vlad
>>>
>>>>
>>>> return t->dst;
>>>> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
>>>> index 8ee553b..cfae77e 100644
>>>> --- a/net/sctp/ipv6.c
>>>> +++ b/net/sctp/ipv6.c
>>>> @@ -137,6 +137,8 @@ static int sctp_inet6addr_event(struct
>>>> notifier_block *this, unsigned long ev,
>>>> break;
>>>> }
>>>>
>>>> + /* invalid all transport dst forcing to look up new dst */
>>>> + rt_genid_bump(net);
>>>> return NOTIFY_DONE;
>>>> }
>>>>
>>>>
>>>
>>>
>>
>
next prev parent reply	other threads:[~2013-07-03 14:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02  6:39 [RFC PATCH] sctp: Don't lookup dst if transport dst is still valid Fan Du
2013-07-02 14:29 ` Vlad Yasevich
2013-07-02 15:55   ` Neil Horman
2013-07-03  2:39     ` Fan Du
2013-07-03 13:48       ` Vlad Yasevich
2013-07-02 19:47   ` David Miller
2013-07-03  2:18   ` Fan Du
2013-07-03 13:23     ` Vlad Yasevich
2013-07-03 14:11       ` Vlad Yasevich [this message]
2013-07-04  2:33       ` Fan Du
2013-07-05 13:03         ` Neil Horman
2013-07-09  7:11           ` Fan Du
2013-07-09 11:38             ` Neil Horman
2013-07-05 14:09         ` Vlad Yasevich
2013-07-09 15:11           ` Vlad Yasevich
2013-07-10  5:26             ` Fan Du
2013-07-12 11:19               ` Neil Horman
2013-07-16  9:13                 ` Fan Du
2013-07-13 12:21               ` Vlad Yasevich
2013-07-17  7:04                 ` Fan Du
2013-07-12  3:15             ` Fan Du
2013-07-12 22:58               ` David Miller
2013-07-13 12:18                 ` Vlad Yasevich
2013-07-16  9:58                 ` Fan Du
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=51D4312F.1010802@gmail.com \
    --to=vyasevich@gmail.com \
    --cc=davem@davemloft.net \
    --cc=fan.du@windriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=nicolas.dichtel@6wind.com \
    /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 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 NNTP newsgroup(s).