netdev
[Top] [All Lists]

Re: [PATCH 2/6] PKT_SCHED: Simple comparison ematch (cmp)

To: Patrick McHardy <kaber@xxxxxxxxx>
Subject: Re: [PATCH 2/6] PKT_SCHED: Simple comparison ematch (cmp)
From: Thomas Graf <tgraf@xxxxxxx>
Date: Mon, 24 Jan 2005 01:55:43 +0100
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>, netdev@xxxxxxxxxxx
In-reply-to: <41F43DD4.8070306@trash.net>
References: <20050123230012.GB23931@postel.suug.ch> <20050123230221.GD23931@postel.suug.ch> <41F43DD4.8070306@trash.net>
Sender: netdev-bounce@xxxxxxxxxxx
* Patrick McHardy <41F43DD4.8070306@xxxxxxxxx> 2005-01-24 01:14
> Thomas Graf wrote:
> >+static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
> >+                    struct tcf_pkt_info *info)
> >+{
> >+    struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
> >+    unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
> >+    u32 val = 0;
> >+
> >+    if (!tcf_valid_offset(skb, ptr, cmp->align))
> >+            return 0;
> >+
> >+    switch (cmp->align) {
> >+            case TCF_EM_ALIGN_U8:
> >+                    val = *ptr;
> >+                    break;
> >+
> >+            case TCF_EM_ALIGN_U16:
> >+                    val = *ptr << 8;
> >+                    val |= *(ptr+1);
> >+
> >+                    if (cmp_needs_transformation(cmp))
> >+                            val = be16_to_cpu(val);
> > 
> >
> Why not simply convert cmp->val in userspace ?

To allow comparing with lt and gt. I favoured transforming over byte
order specific comparison routines.

<Prev in Thread] Current Thread [Next in Thread>