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: Wed, 5 Jan 2005 17:48:32 +0100 [thread overview]
Message-ID: <20050105164832.GB17836@postel.suug.ch> (raw)
In-Reply-To: <20050105144514.GQ26856@postel.suug.ch>
> Most importantly I don't want to touch any of the hashing code in u32.
> I really like and it should stay as it is. The existing u32 match can
> be easly made an ematch so this would safe us the extra work in u32 to
> implement logic relations again and to fiddle with complicated selector
> TLVs. The only problem with this is the nexthdr bits because it relies
> on the hashing code. So we have to make this data available to the
> ematch which is actually not a bad idea anyway. So I'm thinking about
> introducing a new structure tcf_em_pkt_info or alike which carries
> some additional information found out by the classifiers which can be
> used by ematches. This can be information about the next header,
> already extracted dscp values, etc.
Here's what I mean, it moves the u32 match as-is to an ematch so it
benefits from logic relations, inversion and can be used from other
classifiers as well. All we have to do is set info->ptr and
info->nexthdr to ptr respetively off2 before we evaluate the ematch
tree. The pkt_info struct is then passed to tcf_em_tree_match and
made available to every ematch.
Thoughts?
diff -Nru linux-2.6.10-bk8.orig/include/linux/pkt_cls.h linux-2.6.10-bk8/include/linux/pkt_cls.h
--- linux-2.6.10-bk8.orig/include/linux/pkt_cls.h 2005-01-05 17:40:02.000000000 +0100
+++ linux-2.6.10-bk8/include/linux/pkt_cls.h 2005-01-05 17:38:42.000000000 +0100
@@ -351,6 +351,7 @@
TCF_EM_CONTAINER,
TCF_EM_CMP,
TCF_EM_NBYTE,
+ TCF_EM_U32,
__TCF_EM_MAX
};
diff -Nru linux-2.6.10-bk8.orig/include/net/pkt_cls.h linux-2.6.10-bk8/include/net/pkt_cls.h
--- linux-2.6.10-bk8.orig/include/net/pkt_cls.h 2005-01-05 17:40:02.000000000 +0100
+++ linux-2.6.10-bk8/include/net/pkt_cls.h 2005-01-05 17:39:08.000000000 +0100
@@ -274,6 +274,8 @@
struct tcf_pkt_info
{
+ u8 * ptr;
+ int nexthdr;
};
static inline u32 tcf_read_bucket(u8 *ptr, u8 align)
diff -Nru linux-2.6.10-bk8.orig/net/sched/Kconfig linux-2.6.10-bk8/net/sched/Kconfig
--- linux-2.6.10-bk8.orig/net/sched/Kconfig 2005-01-05 17:38:26.000000000 +0100
+++ linux-2.6.10-bk8/net/sched/Kconfig 2005-01-05 17:41:59.000000000 +0100
@@ -408,6 +408,12 @@
To compile this code as a module, choose M here: the
module will be called em_nbyte.
+config NET_EMATCH_U32
+ tristate "U32 hashing key"
+ depends on NET_EMATCH
+ ---help---
+ TODO
+
config NET_CLS_ACT
bool "Packet ACTION"
depends on EXPERIMENTAL && NET_CLS && NET_QOS
diff -Nru linux-2.6.10-bk8.orig/net/sched/Makefile linux-2.6.10-bk8/net/sched/Makefile
--- linux-2.6.10-bk8.orig/net/sched/Makefile 2005-01-05 17:38:26.000000000 +0100
+++ linux-2.6.10-bk8/net/sched/Makefile 2005-01-05 17:40:15.000000000 +0100
@@ -36,3 +36,4 @@
obj-$(CONFIG_NET_EMATCH) += ematch.o
obj-$(CONFIG_NET_EMATCH_CMP) += em_cmp.o
obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o
+obj-$(CONFIG_NET_EMATCH_U32) += em_u32.o
diff -Nru linux-2.6.10-bk8.orig/net/sched/em_u32.c linux-2.6.10-bk8/net/sched/em_u32.c
--- linux-2.6.10-bk8.orig/net/sched/em_u32.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10-bk8/net/sched/em_u32.c 2005-01-05 17:38:42.000000000 +0100
@@ -0,0 +1,53 @@
+/*
+ * net/sched/em_u32.c U32 Ematch
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Thomas Graf <tgraf@suug.ch>
+ * Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ *
+ * Based on net/sched/cls_u32.c
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <net/pkt_cls.h>
+
+static int em_u32_match(struct sk_buff *skb, struct tcf_ematch *m,
+ struct tcf_pkt_info *info)
+{
+ struct tc_u32_key *k = (struct tc_u32_key *) m->data;
+ u8 *ptr = info->ptr + k->off + (info->nexthdr & k->offmask);
+
+ return !((*(u32*) ptr ^ k->val) & k->mask);
+}
+
+static struct tcf_ematch_ops em_u32_ops = {
+ .kind = TCF_EM_U32,
+ .datalen = sizeof(struct tc_u32_key),
+ .match = em_u32_match,
+ .owner = THIS_MODULE,
+ .link = LIST_HEAD_INIT(em_u32_ops.link)
+};
+
+static int __init init_em_u32(void)
+{
+ return tcf_em_register(&em_u32_ops);
+}
+
+static void __exit exit_em_u32(void)
+{
+ tcf_em_unregister(&em_u32_ops);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(init_em_u32);
+module_exit(exit_em_u32);
+
next prev parent reply other threads:[~2005-01-05 16:48 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
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 [this message]
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=20050105164832.GB17836@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).