From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH 15/27] xt_length match, revision 1
Date: Fri, 04 Jan 2008 16:22:49 +0100 [thread overview]
Message-ID: <477E4F49.3000405@trash.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0801022129270.14900@fbirervta.pbzchgretzou.qr>
Jan Engelhardt wrote:
> commit ad446d5b2c0b32ead9dd86b9c10356c4617eeaf5
> Author: Jan Engelhardt <jengelh@computergmbh.de>
> Date: Wed Jan 2 18:22:16 2008 +0100
>
> [NETFILTER]: xt_length match, revision 1
>
> Introduce xt_length match revision 1. It adds support for layer4 and
> layer5 length matching.
>
> +enum {
> + XT_LENGTH_INVERT = 1 << 0,
> +
> + /* IP header plus payload */
> + XT_LENGTH_LAYER3 = 1 << 3,
> +
> + /* TCP/UDP/etc. header plus payload */
> + XT_LENGTH_LAYER4 = 1 << 4,
> +
> + /* TCP/UDP/etc. payload */
> + XT_LENGTH_LAYER5 = 1 << 5,
This seems a bit odd, please don't leave holes.
> +++ b/net/netfilter/xt_length.c
> @@ -1,18 +1,32 @@
> -/* Kernel module to match packet length. */
> -/* (C) 1999-2001 James Morris <jmorros@intercode.com.au>
> +/*
> + * xt_length - Netfilter module to match packet length
> *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> + * (C) 1999-2001 James Morris <jmorros@intercode.com.au>
> + * Copyright © CC Computer Consultants GmbH, 2007-2008
> + * Jan Engelhardt <jengelh@computergmbh.de>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> */
> -
> #include <linux/module.h>
> #include <linux/skbuff.h>
> +#include <linux/icmp.h>
> +#include <linux/ip.h>
> #include <linux/ipv6.h>
> +#include <linux/tcp.h>
> +#include <linux/udp.h>
> #include <net/ip.h>
> -
> -#include <linux/netfilter/xt_length.h>
> +#include <net/ipv6.h>
> #include <linux/netfilter/x_tables.h>
> +#include <linux/netfilter/xt_length.h>
> +#include <linux/netfilter_ipv6/ip6_tables.h>
> +#ifndef NEXTHDR_IPV4
> +# define NEXTHDR_IPV4 4
This should be IPPROTO_IPIP I guess.
> +#endif
> +#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
> +# define WITH_IPV6 1
Please use the CONFIG defines directly, its only one or two chunks of
code that need them.
> +static bool xtlength_layer5_tcp(unsigned int *length, const struct sk_buff *skb,
> + unsigned int offset)
> +{
> + const struct tcphdr *tcph;
> + struct tcphdr buf;
> +
> + tcph = skb_header_pointer(skb, offset, sizeof(buf), &buf);
> + if (tcph == NULL)
> + return false;
> +
> + *length = skb->len - offset - 4 * tcph->doff;
This can underflow. The extra function also seems like overkill.
> + return true;
> +}
> +
> +static inline bool
> +xtlength_layer5(unsigned int *length, const struct sk_buff *skb,
> + unsigned int prot, unsigned int offset)
> +{
> + switch (prot) {
> + case IPPROTO_TCP:
> + return xtlength_layer5_tcp(length, skb, offset);
> + case IPPROTO_UDP:
> + case IPPROTO_UDPLITE:
> + *length = skb->len - offset - sizeof(struct udphdr);
> + return true;
> + case IPPROTO_ICMP:
> + *length = skb->len - offset - sizeof(struct icmphdr);
> + return true;
> + case IPPROTO_ICMPV6:
> + *length = skb->len - offset - offsetof(struct icmp6hdr, icmp6_dataun);
> + return true;
> + case IPPROTO_AH:
> + *length = skb->len - offset - sizeof(struct ip_auth_hdr);
> + return true;
> + case IPPROTO_ESP:
> + *length = skb->len - offset - sizeof(struct ip_esp_hdr);
> + return true;
> + }
I'm missing SCTP and DCCP. We try to consistently support at least all
protocols implemented in Linux itself. I'm also wondering what this is
actually useful for? The only useful thing I can imagine is TCP since
its useful for matching on ACKs without data, all others have fixed
sizes and can easily be implemented in userspace.
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-01-04 15:25 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-02 20:18 [PATCH 0/27] Netfilter update Jan Engelhardt
2008-01-02 20:24 ` [PATCH 1/27] remove ipt_TOS.c Jan Engelhardt
2008-01-02 20:25 ` Jan Engelhardt
2008-01-04 14:25 ` Patrick McHardy
2008-01-02 20:25 ` [PATCH 2/27] Change semantic of mask value in xt_TOS Jan Engelhardt
2008-01-04 14:27 ` Patrick McHardy
2008-01-02 20:26 ` [PATCH 3/27] Properly set the TOS field " Jan Engelhardt
2008-01-04 14:30 ` Patrick McHardy
2008-01-02 20:26 ` [PATCH 4/27] Annotate start of kernel fields in NF headers Jan Engelhardt
2008-01-04 14:33 ` Patrick McHardy
2008-01-02 20:26 ` [PATCH 5/27] Remove CONFIG_COMPAT code in xt_hashlimit, xt_limit Jan Engelhardt
2008-01-04 14:37 ` Patrick McHardy
2008-01-10 23:01 ` Jan Engelhardt
2008-01-11 9:36 ` Patrick McHardy
2008-01-02 20:27 ` [PATCH 6/27] xt_CONNMARK target, revision 1 Jan Engelhardt
2008-01-04 14:41 ` Patrick McHardy
2008-01-04 14:46 ` Jan Engelhardt
2008-01-04 14:45 ` Patrick McHardy
2008-01-04 15:02 ` Jan Engelhardt
2008-01-04 15:00 ` Patrick McHardy
2008-01-02 20:27 ` [PATCH 7/27] xt_MARK target, revision 2 Jan Engelhardt
2008-01-04 14:46 ` Patrick McHardy
2008-01-02 20:27 ` [PATCH 8/27] xt_connmark match, revision 1 Jan Engelhardt
2008-01-04 14:47 ` Patrick McHardy
2008-01-04 14:56 ` Patrick McHardy
2008-01-04 15:03 ` Jan Engelhardt
2008-01-04 15:05 ` Patrick McHardy
2008-01-02 20:28 ` [PATCH 9/27] Extend nf_inet_addr with in{,6}_addr Jan Engelhardt
2008-01-04 14:49 ` Patrick McHardy
2008-01-04 15:01 ` Jan Engelhardt
2008-01-02 20:28 ` [PATCH 10/27] xt_conntrack match, revision 1 Jan Engelhardt
2008-01-04 14:53 ` Patrick McHardy
2008-01-04 15:05 ` Jan Engelhardt
2008-01-04 15:07 ` Patrick McHardy
2008-01-04 15:28 ` Jan Engelhardt
2008-01-15 6:48 ` Patrick McHardy
2008-01-15 12:31 ` Jan Engelhardt
2008-01-15 14:13 ` Patrick McHardy
2008-01-16 18:02 ` [NETFILTER]: xt_conntrack: add port and direction matching Jan Engelhardt
2008-01-17 13:52 ` Pablo Neira Ayuso
2008-01-17 15:00 ` Jan Engelhardt
2008-01-20 13:00 ` Patrick McHardy
2008-01-20 13:12 ` Jan Engelhardt
2008-01-20 13:15 ` Patrick McHardy
2008-01-20 16:48 ` Jan Engelhardt
2008-01-20 16:55 ` Patrick McHardy
2008-01-21 1:14 ` Pablo Neira Ayuso
2008-01-21 1:15 ` Jan Engelhardt
2008-01-21 1:18 ` Pablo Neira Ayuso
2008-01-21 1:31 ` Jan Engelhardt
2008-01-21 1:19 ` Patrick McHardy
2008-01-02 20:28 ` [PATCH 11/27] xt_hashlimit: use the new union nf_inet_addr Jan Engelhardt
2008-01-04 14:57 ` Patrick McHardy
2008-01-15 5:53 ` Patrick McHardy
2008-01-02 20:28 ` [PATCH 12/27] xt_hashlimit match, revision 1 Jan Engelhardt
2008-01-04 14:59 ` Patrick McHardy
2008-01-04 15:07 ` Jan Engelhardt
2008-01-02 20:29 ` [PATCH 13/27] xt_helper: Do not bypass RCU Jan Engelhardt
2008-01-04 15:01 ` Patrick McHardy
2008-01-04 15:09 ` Jan Engelhardt
2008-01-02 20:29 ` [PATCH 14/27] xt_helper match, revision 1 Jan Engelhardt
2008-01-04 15:03 ` Patrick McHardy
2008-01-02 20:29 ` [PATCH 15/27] xt_length " Jan Engelhardt
2008-01-04 15:22 ` Patrick McHardy [this message]
2008-01-04 15:43 ` Jan Engelhardt
2008-01-02 20:30 ` [PATCH 16/27] xt_mark " Jan Engelhardt
2008-01-04 15:23 ` Patrick McHardy
2008-01-02 20:30 ` [PATCH 17/27] xt_pkttype: Add explicit check for IPv4 Jan Engelhardt
2008-01-04 15:24 ` Patrick McHardy
2008-01-02 20:30 ` [PATCH 18/27] xt_pkttype IPv6 multicast address recognition Jan Engelhardt
2008-01-04 15:26 ` Patrick McHardy
2008-01-02 20:30 ` [PATCH 19/27] xt_policy: use the new unoin nf_inet_addr Jan Engelhardt
2008-01-08 15:48 ` Patrick McHardy
2008-01-08 15:54 ` Jan Engelhardt
2008-01-08 15:54 ` Patrick McHardy
2008-01-08 16:42 ` Jan Engelhardt
2008-01-02 20:30 ` [PATCH 20/27] Update modules' descriptions Jan Engelhardt
2008-01-08 15:50 ` Patrick McHardy
2008-01-08 15:55 ` Jan Engelhardt
2008-01-08 15:54 ` Patrick McHardy
2008-01-08 16:13 ` Jan Engelhardt
2008-01-08 16:18 ` Patrick McHardy
2008-01-02 20:31 ` [PATCH 21/27] Convert unfixated types to fixated ones Jan Engelhardt
2008-01-08 15:52 ` Patrick McHardy
2008-01-08 16:14 ` Jan Engelhardt
2008-01-02 20:31 ` [PATCH 22/27] Rename ipt_iprange to xt_iprange Jan Engelhardt
2008-01-08 15:55 ` Patrick McHardy
2008-01-08 16:16 ` Jan Engelhardt
2008-01-08 16:22 ` Patrick McHardy
2008-01-08 16:25 ` Patrick McHardy
2008-01-09 13:55 ` Jan Engelhardt
2008-01-10 15:52 ` Patrick McHardy
2008-01-02 20:31 ` [PATCH 23/27] xt_iprange match, revision 1 Jan Engelhardt
2008-01-08 15:56 ` Patrick McHardy
2008-01-08 16:22 ` Jan Engelhardt
2008-01-08 16:26 ` Patrick McHardy
2008-01-02 20:33 ` [PATCH 24/27] Merge ipt_REJECT and ip6t_REJECT into xt_REJECT Jan Engelhardt
2008-01-08 15:59 ` Patrick McHardy
2008-01-02 20:34 ` [PATCH 25/27] Merge ipt_ah and ip6t_ah into xt_ah Jan Engelhardt
2008-01-08 16:03 ` Patrick McHardy
2008-01-02 20:34 ` [PATCH 26/27] Unknot xt_ah IPv6 logic Jan Engelhardt
2008-01-02 20:34 ` [PATCH 27/27] Update feature-removal-schedule.txt Jan Engelhardt
2008-01-08 16:33 ` Patrick McHardy
2008-01-08 16:38 ` Jan Engelhardt
2008-01-08 16:39 ` Patrick McHardy
2008-01-08 16:56 ` Jan Engelhardt
2008-01-15 16:16 ` Patrick McHardy
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=477E4F49.3000405@trash.net \
--to=kaber@trash.net \
--cc=jengelh@computergmbh.de \
--cc=netfilter-devel@vger.kernel.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.