netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirqus@gmail.com>
To: David Ward <david.ward@ll.mit.edu>
Cc: netdev@vger.kernel.org, Julian Anastasov <ja@ssi.bg>
Subject: Re: [PATCH 2/2] net: Handle different key sizes between address families in flow cache
Date: Sun, 4 Sep 2011 17:34:19 +0200	[thread overview]
Message-ID: <CAHXqBF+eF_zYAFPZv0hWUvDHv5YMHuFAR3-iB8MEZz2G7vCUyA@mail.gmail.com> (raw)
In-Reply-To: <1315141641-3120-3-git-send-email-david.ward@ll.mit.edu>

2011/9/4 David Ward <david.ward@ll.mit.edu>:
> With the conversion of struct flowi to a union of AF-specific structs, some
> operations on the flow cache need to account for the exact size of the key.
[...]
> --- a/include/net/flow.h
> +++ b/include/net/flow.h
[...]
> +typedef unsigned long flow_compare_t;
> +
> +static inline size_t flowi_size(u16 family)
> +{
> +       switch (family) {
> +       case AF_INET:
> +               BUILD_BUG_ON(sizeof(struct flowi4) % sizeof(flow_compare_t));
> +               return sizeof(struct flowi4);
> +       case AF_INET6:
> +               BUILD_BUG_ON(sizeof(struct flowi6) % sizeof(flow_compare_t));
> +               return sizeof(struct flowi6);
> +       case AF_DECnet:
> +               BUILD_BUG_ON(sizeof(struct flowidn) % sizeof(flow_compare_t));
> +               return sizeof(struct flowidn);
> +       }
> +       return 0;
> +}

Since most called user (flow_key_compare) uses returned value didided
by sizeof(flow_compare_t), you could just return divided value here
and save some shift operations by it.

Best Regards,
Michał Mirosław

  reply	other threads:[~2011-09-04 15:34 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
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 [this message]
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=CAHXqBF+eF_zYAFPZv0hWUvDHv5YMHuFAR3-iB8MEZz2G7vCUyA@mail.gmail.com \
    --to=mirqus@gmail.com \
    --cc=david.ward@ll.mit.edu \
    --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 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).