All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sumit Pandya" <sumit@elitecore.com>
To: <netfilter-devel@lists.netfilter.org>
Subject: Difference between match and target
Date: Fri, 20 Jun 2003 18:33:58 +0530	[thread overview]
Message-ID: <009301c3372c$69cc47f0$010f430a@elitecore7> (raw)
In-Reply-To: 20030618222710.9325.98884.Mailman@kashyyyk

Hi All,

    What is difference between writing match and target extension for
netfilter? Is there something in match which I cannot achieve in target and
vice-versa?
    So far I's under impression that I cannot alter skb in match because of
prototype for "match_entry()". Today I did following test with ipt_tos.c

static int
-- match(const struct sk_buff *skb,
      const struct net_device *in,
static int
++ match( struct sk_buff *skb,
      const struct net_device *in,

       const struct ipt_tos_info *info = matchinfo;
--    const struct iphdr *iph = skb->nh.iph;
--
--     return (iph->tos == info->tos) ^ info->invert;
++    struct iphdr *iph = skb->nh.iph;
++    u_int16_t diffs[2];
++
++        diffs[0] = htons(iph->tos) ^ 0xFFFF;
++        iph->tos = (iph->tos & IPTOS_PREC_MASK) | 0xFF;
++        diffs[1] = htons(iph->tos);
++        iph->check = csum_fold(csum_partial((char *)diffs,
++                                            sizeof(diffs),
++                                             iph->check^0xFFFF));
++        skb->nfcache |= NFC_ALTERED;
++        return IPT_CONTINUE;

then appended a rule for tos match with this changed match module inserted
into kernel.
[root@manage netfilter]# iptables -I OUTPUT -p tcp --dport 25  -m tos \
--tos 0x04 -j RETURN

 And surprisingly(for me), On the other machine when I observed traffic for
port 25, I get packet with TOS set to 0xFF.

 Someone to throw some light on this design? Mr. Rusty, Mr. Harald?

-- Sumit

       reply	other threads:[~2003-06-20 13:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030618222710.9325.98884.Mailman@kashyyyk>
2003-06-20 13:03 ` Sumit Pandya [this message]
2003-06-24 16:08   ` Difference between match and target Harald Welte
     [not found] <20030624170402.8564.54425.Mailman@kashyyyk>
2003-06-25  6:29 ` Sumit Pandya
2003-06-25  9:10   ` Harald Welte
2003-06-27  8:42     ` Andy Whitcroft

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='009301c3372c$69cc47f0$010f430a@elitecore7' \
    --to=sumit@elitecore.com \
    --cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.