kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: cakturk@gmail.com (Cihangir Akturk)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Question about memory in C
Date: Wed, 10 Feb 2016 23:25:53 +0200	[thread overview]
Message-ID: <20160210212553.GA8415@portege> (raw)
In-Reply-To: <CANpwN=u71yvBSc8B7y5D3zVs1=AYNo_jbOMPQPEkHsmqx9HEHw@mail.gmail.com>

On Wed, Feb 10, 2016 at 11:40:44AM -0200, Victor Detoni wrote:
> Hi all,
> 
> I'm working for a network security prototype and I would like to know the
> best way to read diferent configs from the memory, for example:
> 
> My program will receive many pkts from network interface and it needs to
> know what's profile it will use based on source ip address.
> 
> First all, I'm thinking to use array in C, for example:
> 
> for (i=0;i<=PROFILES;i++) {
>     if (pkt.ip_addr == source_ip[i])
>         do_something(pkt,i)
> }
> 
> I will process at about millions entries per second and ~100 profiles. What
> do you think? It will work fine? fast? any suggest?
> 
> thanks
> Victor

Hi Victor,

I would consider using a simple hash table. Use ipaddr as a key to
do fast lookup of the value. Take a look at scripts/fixdep.c which
includes a FNV hash table implementation.

  parent reply	other threads:[~2016-02-10 21:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 13:40 Question about memory in C Victor Detoni
2016-02-10 13:54 ` Skm Prabhu
2016-02-10 21:25 ` Cihangir Akturk [this message]
2016-02-10 22:49   ` Victor Detoni
2016-02-10 23:19     ` Greg KH

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=20160210212553.GA8415@portege \
    --to=cakturk@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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).