From: "Colin Paton" <cozzarp@hotmail.com>
To: netfilter-devel@lists.netfilter.org
Subject: How to make conntrack ignore packets on certain interfaces?
Date: Wed, 23 Jun 2004 15:20:30 +0000 [thread overview]
Message-ID: <BAY22-F9OxHp2sdp2Mn0009ff98@hotmail.com> (raw)
Hi,
With the aid of someone on this mailing list I've figured out why the PPTP
connection tracking wasn't working correctly with tun interfaces. I have
created a really hacky solution which fixes the problem - but it's extremely
inelegant and I think there must be a better way.
To recap:
- Packets come in through an eth1.6 interface. This interface has no IP
address assigned; packets are read from it using a user-space program. This
program can perform certain packet mangling, and it then reinjects the
packets back into a tap interface. Netfilter/IP tables are then used to
route packets and do NAT, etc as usual.
Connection tracking wasn't correctly working with this scenario. It would
appear that a conntrack was created when the packet arrived, but was then
removed as the incoming packet was never routed through the kernel.
My evil hack which fixes things was just to ignore traffic on the incoming
interface - this way, packets reinjected via the tap interface would be
tracked, which is what is wanted.
My hack therefore looks like (from the code in ip_conntrack_core.c):
/* Netfilter hook itself. */
unsigned int ip_conntrack_in(unsigned int hooknum,
struct sk_buff **pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo;
struct ip_conntrack_protocol *proto;
int set_reply;
int ret;
/* FIXME: Do this right please. --RR */
(*pskb)->nfcache |= NFC_UNKNOWN;
+ /* cpaton hack stuff begins here... */
+ if (in && (!strcmp(in->name,"eth1.6")))
+ {
+ printk("ip_conntrack_in - ignoring packet on interface
%s\n",in->name);
+ return NF_ACCEPT;
+ }
....so that packets coming in on the eth1.6 interface aren't tracked. NAT
now works well.
I've been trying to think of a better way of doing this, but nothing jumps
out at me - connection tracking seems to have its own hook into netfilter,
so most iptables rules won't have any effect.
The options I've considered are:
- Register a higher-priority netfilter hook which is called before
conntrack_in() - this somehow(?!) causes the packet to jump over netfilter.
I'm not sure if 'jumping' over netfilter hooks is possible however.
- Tell the conntrack code (somehow) to ignore packet coming on eth1.6. While
it seems that iptables can read the connection tracking state I don't think
it can alter it.
I'm not sure if this is at all possible - is it possible to replicate my
evil hack using a better method?
Thanks,
Colin
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
next reply other threads:[~2004-06-23 15:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-23 15:20 Colin Paton [this message]
2004-06-25 0:07 ` How to make conntrack ignore packets on certain interfaces? Philip Craig
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=BAY22-F9OxHp2sdp2Mn0009ff98@hotmail.com \
--to=cozzarp@hotmail.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.