All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: James Chapman <jchapman@katalix.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v4] netfilter: introduce l2tp match extension
Date: Thu, 2 Jan 2014 21:59:07 +0100	[thread overview]
Message-ID: <20140102205907.GA4598@localhost> (raw)
In-Reply-To: <20140102205713.GA3758@localhost>

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

On Thu, Jan 02, 2014 at 09:57:13PM +0100, Pablo Neira Ayuso wrote:
[...]
> I'm testing this with the last userspace iptables patch that you
> posted [1]. I'm using the example in the manpage:
> 
> # iptables -A INPUT -s 1.2.3.4 -m l2tp --tid 42
> iptables: Invalid argument. Run `dmesg' for more information.
> # dmesg
> ...
> [  490.827569] xt_l2tp: missing encapsulation
> 
> The error message is added by the patch I made on top of your last
> kernel patch (find it attached, feel free to merge it to your next v5).

Forgot attachment, here it comes.

[-- Attachment #2: for-james.patch --]
[-- Type: text/x-diff, Size: 2095 bytes --]

diff --git a/net/netfilter/xt_l2tp.c b/net/netfilter/xt_l2tp.c
index d4ec208..f2104aa 100644
--- a/net/netfilter/xt_l2tp.c
+++ b/net/netfilter/xt_l2tp.c
@@ -221,33 +221,45 @@ static int l2tp_mt_check(const struct xt_mtchk_param *par)
 
 	/* Check for invalid flags */
 	if (info->flags & ~(XT_L2TP_TID | XT_L2TP_SID | XT_L2TP_VERSION |
-			    XT_L2TP_ENCAP | XT_L2TP_TYPE))
+			    XT_L2TP_ENCAP | XT_L2TP_TYPE)) {
+		pr_info("unknown flags: %x\n", info->flags);
 		return -EINVAL;
+	}
 
 	/* At least one of tid, sid or type=control must be specified */
 	if ((!(info->flags & XT_L2TP_TID)) &&
 	    (!(info->flags & XT_L2TP_SID)) &&
 	    ((!(info->flags & XT_L2TP_TYPE)) ||
-	     (info->type != XT_L2TP_TYPE_CONTROL)))
+	     (info->type != XT_L2TP_TYPE_CONTROL))) {
+		pr_info("invalid flags combination: %x\n", info->flags);
 		return -EINVAL;
+	}
 
 	/* If version 2 is specified, check that incompatible params
 	 * are not supplied
 	 */
 	if (info->flags & XT_L2TP_VERSION) {
-		if ((info->version < 2) || (info->version > 3))
+		if ((info->version < 2) || (info->version > 3)) {
+			pr_info("wrong L2TP version: %u\n", info->version);
 			return -EINVAL;
+		}
 
 		if (info->version == 2) {
 			if ((info->flags & XT_L2TP_TID) &&
-			    (info->tid > 0xffff))
+			    (info->tid > 0xffff)) {
+				pr_info("tid > 0xffff: %u\n", info->tid);
 				return -EINVAL;
+			}
 			if ((info->flags & XT_L2TP_SID) &&
-			    (info->sid > 0xffff))
+			    (info->sid > 0xffff)) {
+				pr_info("sid > 0xffff: %u\n", info->sid);
 				return -EINVAL;
+			}
 			if ((info->flags & XT_L2TP_ENCAP) &&
-			    (info->encap == XT_L2TP_ENCAP_IP))
+			    (info->encap == XT_L2TP_ENCAP_IP)) {
+				pr_info("v2 doesn't support IP mode\n");
 				return -EINVAL;
+			}
 
 			/* Force UDP encap */
 			info->encap = XT_L2TP_ENCAP_UDP;
@@ -256,8 +268,10 @@ static int l2tp_mt_check(const struct xt_mtchk_param *par)
 	}
 
 	/* Encap must be specified */
-	if (!(info->flags & XT_L2TP_ENCAP))
+	if (!(info->flags & XT_L2TP_ENCAP)) {
+		pr_info("missing encapsulation\n");
 		return -EINVAL;
+	}
 
 	return 0;
 }

  reply	other threads:[~2014-01-02 20:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 14:13 [PATCH v4] netfilter: introduce l2tp match extension James Chapman
2014-01-02 20:57 ` Pablo Neira Ayuso
2014-01-02 20:59   ` Pablo Neira Ayuso [this message]
2014-01-03 10:04   ` James Chapman

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=20140102205907.GA4598@localhost \
    --to=pablo@netfilter.org \
    --cc=jchapman@katalix.com \
    --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.