netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: jamal <hadi@cyberus.ca>
Cc: netdev@oss.sgi.com
Subject: Re: [RFC] ematch API, u32 ematch, nbyte ematch, basic classifier
Date: Tue, 4 Jan 2005 14:46:29 +0100	[thread overview]
Message-ID: <20050104134629.GK26856@postel.suug.ch> (raw)
In-Reply-To: <1104844753.1085.99.camel@jzny.localdomain>

* jamal <1104844753.1085.99.camel@jzny.localdomain> 2005-01-04 08:19
> On Tue, 2005-01-04 at 07:03, Thomas Graf wrote:
> >  change() (Optional)
> 
> My thinking is:
> It doesnt have to be simple 32 bit data.
> If i pass you a struct and tell you what length it is, then you as the
> classifier dont know need to know anything about it. You just store
> mystruct as data and datalen from the TLV. you then pass the datastruct
> to match() -  Of course the match() will have to know what that struct
> means.

That's exactly how it is, basically the logic is:

	if (ops->change) {
		err = ops->change(tp, data, datalen, m);
		if (err < 0)
			goto errout;
	} else if (datalen > 0) {
		if (mh->flags & TCF_EM_SIMPLE) {
			if (datalen != sizeof(u32))
				goto errout;
			m->data = *(u32 *) data;
		} else {
			void *v = kmalloc(datalen, GFP_KERNEL);
			if (v == NULL) {
				err = -ENOBUFS;
				goto errout;
			}
			memcpy(v, data, datalen);
			m->data = (unsigned long) v;
		}
	}
	m->datalen = datalen;

> >  destroy() (Optional)
> >    Called if provided, otheriwse m->data is freed in ematch api unless
> >    TCF_EM_SIMPLE is set.
> 
> Again using the above logic, destroy becomes just kfree(mystruct)

Right, that's exactly how it is

	if (m->ops->destroy)
		m->ops->destroy(tp, m);
	else if (!(m->hdr.flags & TCF_EM_SIMPLE) && m->data)
		kfree((void *) m->data);


> >  dump() (Optional)
> >    Called if provided, otherwise m->data is dumped onto the skb with
> >    m->datalen as L. Special handling again for TCF_EM_SIMPLE.
> 
> and dump becomes a matter of looking at datalen and encapsulating
> mystruct in a TLV without thinking about what the content is.

Absolutely true, you know about the code before you read it ;->

	if (m->ops->dump) {
		if (m->ops->dump(skb, m) < 0)
			goto rtattr_failure;
	} else if (m->hdr.flags & TCF_EM_SIMPLE) {
		u32 u = m->data;
		RTA_PUT_NOHDR(skb, sizeof(u32), &u);
	} else if (m->datalen > 0)
		RTA_PUT_NOHDR(skb, m->datalen, (void *) m->data);

  reply	other threads:[~2005-01-04 13:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-03 12:56 [RFC] ematch API, u32 ematch, nbyte ematch, basic classifier Thomas Graf
2005-01-04  4:13 ` jamal
2005-01-04 12:03   ` Thomas Graf
2005-01-04 13:19     ` jamal
2005-01-04 13:46       ` Thomas Graf [this message]
2005-01-04 12:27   ` Thomas Graf
2005-01-04 13:22     ` jamal
2005-01-04 13:41       ` Thomas Graf
2005-01-05  2:54         ` jamal
2005-01-05 11:09           ` Thomas Graf
2005-01-04 22:36 ` Thomas Graf
2005-01-05  3:12   ` jamal
2005-01-05 11:00     ` Thomas Graf
2005-01-05 13:33       ` jamal
2005-01-05 14:45         ` Thomas Graf
2005-01-05 16:48           ` Thomas Graf
2005-01-06 14:03             ` jamal
2005-01-06 13:47           ` jamal
2005-01-06 19:41             ` Thomas Graf
2005-01-07 13:45               ` jamal
2005-01-08 14:54                 ` Thomas Graf
2005-01-10 13:26                   ` jamal
2005-01-10 21:17                     ` Thomas Graf
2005-01-10 22:05                       ` jamal
2005-01-10 23:30                         ` Thomas Graf
2005-01-13 17:41                         ` [RFC] meta ematch Thomas Graf
2005-01-13 18:54                           ` Patrick McHardy
2005-01-13 19:20                             ` Thomas Graf
2005-01-14  1:13                               ` Patrick McHardy
2005-01-14 15:14                                 ` Thomas Graf
2005-01-16 14:58                                   ` jamal
2005-01-16 15:09                                     ` Thomas Graf
2005-01-16 15:37                                       ` jamal
2005-01-16 15:57                                         ` Thomas Graf
2005-01-16 16:19                                           ` jamal
2005-01-16 16:49                                             ` Thomas Graf
2005-01-16 16:11                                   ` jamal
2005-01-16 16:32                                     ` Thomas Graf
2005-01-16 17:18                                       ` jamal
2005-01-16 18:47                                         ` Thomas Graf
2005-01-16 16:32                                     ` Patrick McHardy
2005-01-16 17:24                                       ` jamal
2005-01-05 13:32 ` [RFC] ematch API, u32 ematch, nbyte ematch, basic classifier Florian Weimer
2005-01-05 13:45   ` jamal

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=20050104134629.GK26856@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=hadi@cyberus.ca \
    --cc=netdev@oss.sgi.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).