rfc3514
Subsystems (2)
Hi
Here's a partial implementation of rfc3514.
It just implements a match and a target.
There's a small problem with the match, it doesn't take any options thus doesn't accept an invert flag... oh well.
And there's another small problem regarding conntrack... conntrack tries to reassemble all fragments and this doesn't really work with these packets :)
Patches against kernel 2.5 (Kconfig stuff need converting to Config.in for 2.4)
Signature · 1 line
/Martin
include/linux/netfilter_ipv4/ipt_EVIL.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _IPT_EVIL_H_target +#define _IPT_EVIL_H_target + +struct ipt_evil_target_info { +u_int8_t mode; +}; + +#define IPT_EVIL_SET 0x1 +#define IPT_EVIL_CLEAR 0x2 + +#endif /*_IPT_EVIL_H_target*/
net/ipv4/netfilter/ipt_EVIL.c +97 -0
97 lines not on this page · raw message
net/ipv4/netfilter/Kconfig +10 -0
@@ -402,6 +412,16 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. +config IP_NF_TARGET_EVIL + tristate "EVIL target support" + depends on IP_NF_MANGLE + help + This option adds a `EVIL' target, which allows you to create rules in + the `mangle' table which alter the Evil bit an IP packet prior to routing. + + If you want to compile it as a module, say M here and read + <file:Documentation/modules.txt>. If unsure, say `N'. + config IP_NF_TARGET_ECN tristate "ECN target support" depends on IP_NF_MANGLE
net/ipv4/netfilter/Makefile +1 -0
@@ -67,6 +68,7 @@ obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o +obj-$(CONFIG_IP_NF_TARGET_EVIL) += ipt_EVIL.o obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
include/linux/netfilter_ipv4/ipt_evil.h +8 -0
@@ -0,0 +1,8 @@ +#ifndef _IPT_EVIL_H +#define _IPT_EVIL_H + +struct ipt_evil_info { +u_int8_t invert; +}; + +#endif /*_IPT_EVIL_H*/
net/ipv4/netfilter/ipt_evil.c +52 -0
52 lines not on this page · raw message
net/ipv4/netfilter/Kconfig +10 -0
@@ -135,6 +135,16 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. +config IP_NF_MATCH_EVIL + tristate "Evil match support" + depends on IP_NF_IPTABLES + help + Evil matching allows you to match packets based on the Evil bit + in the IP packet. + + If you want to compile it as a module, say M here and read + <file:Documentation/modules.txt>. If unsure, say `N'. + config IP_NF_MATCH_ECN tristate "ECN match support" depends on IP_NF_IPTABLES
net/ipv4/netfilter/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o +obj-$(CONFIG_IP_NF_MATCH_EVIL) += ipt_evil.o obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o obj-$(CONFIG_IP_NF_MATCH_DSCP) += ipt_dscp.o obj-$(CONFIG_IP_NF_MATCH_AH_ESP) += ipt_ah.o ipt_esp.o
/* Shared library add-on to iptables to add EVIL target support. */ #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <iptables.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_EVIL.h>
/* Function which prints out usage message. */
static void
help(void)
{
printf(
"EVIL target v%s options:\n"
" --evil-set Set the Evil bit.\n"
" --evil-clear Clear the Evil bit.\n",IPTABLES_VERSION);
}
static struct option opts[] = {
{ "evil-set", 0, 0, '1' },
{ "evil-clear", 0, 0, '2' },
{ 0 }
};/* Initialize the target. */
static voidinit(struct ipt_entry_target *t, unsigned int *nfcache) {
}
/* Function which parses command options; returns true if it
ate an option */
static int
parse(int c, char **argv, int invert, unsigned int *flags,
const struct ipt_entry *entry,
struct ipt_entry_target **target)
{
struct ipt_evil_target_info *evilinfo
= (struct ipt_evil_target_info *)(*target)->data;
switch (c) {
case '1':
if (*flags & IPT_EVIL_SET)
exit_error(PARAMETER_PROBLEM,
"EVIL target: Cant specify --evil-set twice");
*flags |= IPT_EVIL_SET;
evilinfo->mode = IPT_EVIL_SET;
break;
case '2':
if (*flags & IPT_EVIL_CLEAR)
exit_error(PARAMETER_PROBLEM,
"EVIL target: Cant specify --evil-clear twice");
*flags |= IPT_EVIL_CLEAR;
evilinfo->mode = IPT_EVIL_CLEAR;
break;
default:
return 0;
}
return 1;
}static voidfinal_check(unsigned int flags)
{
if (!flags)
exit_error(PARAMETER_PROBLEM,
"EVIL target: Parameter --evil-set or --evil-clear is required");
}/* Prints out the targinfo. */
static void
print(const struct ipt_ip *ip,
const struct ipt_entry_target *target,
int numeric)
{
const struct ipt_evil_target_info *evilinfo =
(const struct ipt_evil_target_info *)target->data;
printf("EVIL ");
if (evilinfo->mode & IPT_EVIL_SET)
printf("set ");
else
printf("clear ");
}/* Saves the union ipt_targinfo in parsable form to stdout. */ static voidsave(const struct ipt_ip *ip, const struct ipt_entry_target *target)
{
const struct ipt_evil_target_info *evilinfo =
(const struct ipt_evil_target_info *)target->data;
if (evilinfo->mode & IPT_EVIL_SET)
printf("--evil-set ");
else
printf("--evil-clear ");
}static
struct iptables_target evil
= { NULL,
"EVIL",
IPTABLES_VERSION,
IPT_ALIGN(sizeof(struct ipt_evil_target_info)),
IPT_ALIGN(sizeof(struct ipt_evil_target_info)),
&help,
&init,
&parse,
&final_check,
&print,
&save,
opts
};void _init(void)
{
register_target(&evil);
}/* Shared library add-on to iptables to add Evil matching support. */ #include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <iptables.h>
#include <linux/netfilter_ipv4/ipt_evil.h>
/* Function which prints out usage message. */
static void
help(void)
{
printf("Evil match v%s options:\n"
"This match doesn't take any options\n",IPTABLES_VERSION);
}
static struct option opts[] = {
{0}
};/* Initialize the match. */
static voidinit(struct ipt_entry_match *m, unsigned int *nfcache)
{
*nfcache |= NFC_UNKNOWN;
}/* Function which parses command options; returns true if it
ate an option */
static int
parse(int c, char **argv, int invert, unsigned int *flags,
const struct ipt_entry *entry,
unsigned int *nfcache,
struct ipt_entry_match **match)
{
struct ipt_evil_info *evilinfo = (struct ipt_evil_info *)(*match)->data;
switch (c) {
case '1':
check_inverse(optarg, &invert, &optind, 0);
if (invert)
evilinfo->invert = 1;
break;
default:
return 0;
}
return 1;
}/* Final check. */
static voidfinal_check(unsigned int flags)
{
}
/* Prints out the matchinfo. */
static void
print(const struct ipt_ip *ip,
const struct ipt_entry_match *match,
int numeric)
{
const struct ipt_evil_info *info = (const struct ipt_evil_info *)match->data;
if (info->invert)
printf("!");
printf("Evil match ");
}/* Saves the union ipt_matchinfo in parsable form to stdout. */ static voidsave(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
const struct ipt_evil_info *info = (const struct ipt_evil_info *)match->data;
if (info->invert)
printf("! ");
}static
struct iptables_match evil
= { NULL,
"evil",
IPTABLES_VERSION,
IPT_ALIGN(sizeof(struct ipt_evil_info)),
IPT_ALIGN(sizeof(struct ipt_evil_info)),
&help,
&init,
&parse,
&final_check,
&print,
&save,
opts
};void _init(void)
{
register_match(&evil);
}Quoted 3 lines
And there's another small problem regarding conntrack... conntrack tries to reassemble all fragments and this doesn't really work with these packets :)
Will you write a suitable conntrack helper? There's still some hours to go :)
In any case: thanks for the laugh!
best regards
Patrick
Quoted 5 lines · Patrick Schaaf
Quoted 3 lines
And there's another small problem regarding conntrack... conntrack tries to reassemble all fragments and this doesn't really work with these packets :)
Will you write a suitable conntrack helper? There's still some hours to go :)
Don't think I'll spend any more time on this extremely useful RFC...
Quoted 1 line
In any case: thanks for the laugh!
Just couldn't help myself :)
Signature · 1 line
/Martin
Quoted 5 lines · Martin Josefsson
Quoted 4 lines · Patrick Schaaf
Quoted 3 lines
And there's another small problem regarding conntrack... conntrack tries to reassemble all fragments and this doesn't really work with these packets :)
Quoted 7 lines
Quoted 1 line
Will you write a suitable conntrack helper? There's still some hours to go :
)
Don't think I'll spend any more time on this extremely useful RFC...Quoted 1 line
In any case: thanks for the laugh!
Just couldn't help myself :)
Perhaps it could be used as demo code ....
Bernd
Signature · 4 lines
Bernd Petrovitsch Email : [email protected] g.a.m.s gmbh Fax : +43 1 205255-900 Prinz-Eugen-Straße 8 A-1040 Vienna/Austria/Europe LUGA : http://www.luga.at
COPS Backend
In reply to Martin JosefssonHello
Has anyone looked into developing a COPS interface for iptables as a means of remote configuration of multiple distributed firewalls ?
---------------------------------
Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.
Re: COPS Backend
Quoted 4 lines · graham g
Hello
Has anyone looked into developing a COPS interface for iptables as a means of remote configuration of multiple distributed firewalls ?
not that the netfilter core team is aware of.
If you are planning to implement something into this direction, please feel free to discuss it on this mailinglist.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Re: COPS Backend
Not directly related to iptables/netfilter as such, but I am currently working on an implementation of the COPS and COPS-PR protocol stack in Java. The idea is that you can use a Policy Based Management tool to define global network security policies. These policies are then distributed to various firewall devices with COPS-PR, where the policies are enforced. Of course, the system could also ship out policies to other network devices, such as COPS enabled routers, IPsec gateways etc.Im working with Linux boxes at the moment and am working on a very simple proto-type that simply calls the iptables user space tool to add / delete firewall rules when policies are shipped to the device. Anyway suggestions, comments or ideas from anyone would be much appreciated . Development is still in the extreme early stages.
Quoted 4 lines · graham g
Hello
Has anyone looked into developing a COPS interface for iptables as a means of remote configuration of multiple distributed firewalls ?
not that the netfilter core team is aware of.
If you are planning to implement something into this direction, please feel free to discuss it on this mailinglist.
Signature · 5 lines
- Harald Welte http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
Quoted 1 line
ATTACHMENT part 2 application/pgp-signature
---------------------------------
Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.