ebtables: Clone xt_AUDIT to ebt_audit to return EBT_CONTINUE
Subsystems (3)
PATCH 1/1 ebtables: Clone xt_AUDIT to ebt_audit to return EBT_CONTINUE
Even though ebtables uses xtables it still requires targets to return EBT_CONTINUE instead of XT_CONTINUE. This prevented xt_AUDIT to work as ebt module.
net/bridge/netfilter/Kconfig +9 -0
@@ -144,6 +144,15 @@ config BRIDGE_EBT_ARPREPLY To compile it as a module, choose M here. If unsure, say N. +config BRIDGE_EBT_AUDIT + tristate "ebt: audit target support" + depends on AUDIT + help + This option adds a 'AUDIT' target, which can be used to create + audit records for packets dropped/accepted. + + To compile it as a module, choose M here. If unsure, say N. + config BRIDGE_EBT_DNAT tristate "ebt: dnat target support" help
net/bridge/netfilter/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o # targets obj-$(CONFIG_BRIDGE_EBT_ARPREPLY) += ebt_arpreply.o +obj-$(CONFIG_BRIDGE_EBT_AUDIT) += ebt_audit.o obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o obj-$(CONFIG_BRIDGE_EBT_DNAT) += ebt_dnat.o obj-$(CONFIG_BRIDGE_EBT_REDIRECT) += ebt_redirect.o
net/bridge/netfilter/ebt_audit.c new file +201 -0
201 lines not on this page · raw message
net/netfilter/xt_AUDIT.c +0 -1
@@ -27,7 +27,6 @@ MODULE_AUTHOR("Thomas Graf <[email protected]>");MODULE_DESCRIPTION ("Xtables: creates audit records for dropped/accepted packets" );MODULE_ALIAS ("ipt_AUDIT" );MODULE_ALIAS ("ip6t_AUDIT" ); -MODULE_ALIAS ("ebt_AUDIT" );MODULE_ALIAS ("arpt_AUDIT" ); static void audit_proto(struct audit_buffer *ab, struct sk_buff *skb,
Quoted 3 lines · Thomas Graf
Even though ebtables uses xtables it still requires targets to return
EBT_CONTINUEinstead ofXT_CONTINUE. This preventedxt_AUDITto work as ebt module.
Something that just came to mind is that you could probably do to keep the code at a minimum:
static unsigned int ebt_audit(struct xt_target_param *par)
{
unsigned int ret = xt_audit_tg(par);
if (ret == XT_CONTINUE)
return EBT_CONTINUE;
...
}static struct xt_target audit_tg_reg[] = {
{
.name = "AUDIT",
.family = NFPROTO_UNSPEC,
.target = xt_audit_tg,
},
{
.name = "AUDIT",
.family = NFPROTO_BRIDGE,
.target = ebt_audit_tg,
},
};Am 16.03.2011 01:43, schrieb Jan Engelhardt:
Quoted 10 lines · Thomas Graf
Quoted 4 lines
Even though ebtables uses xtables it still requires targets to return
EBT_CONTINUEinstead ofXT_CONTINUE. This preventedxt_AUDITto work as ebt module.Something that just came to mind is that you could probably do to keep the code at a minimum:
Quoted 8 lines
static unsigned int
ebt_audit(struct xt_target_param *par){ unsigned int ret = xt_audit_tg(par); if (ret == XT_CONTINUE) return EBT_CONTINUE; ... }
Seems like a good idea to me. If more modules need this (f.i. MARK) we could also consider doing the mapping based on a target flag in ebtables itself.
However please see Dave's mail about net-next, until the merge window is over and -rc1 released only bugfixes will be accepted.
Quoted 19 lines · Patrick McHardy
Am 16.03.2011 01:43, schrieb Jan Engelhardt:
Quoted 18 lines · Thomas Graf
Quoted 4 lines
Even though ebtables uses xtables it still requires targets to return
EBT_CONTINUEinstead ofXT_CONTINUE. This preventedxt_AUDITto work as ebt module.Something that just came to mind is that you could probably do to keep the code at a minimum:
static unsigned int
ebt_audit(struct xt_target_param *par){ unsigned int ret = xt_audit_tg(par); if (ret == XT_CONTINUE) return EBT_CONTINUE; ... }
That's a good idea, thanks Jan!
Quoted 6 lines
Seems like a good idea to me. If more modules need this (f.i. MARK) we could also consider doing the mapping based on a target flag in ebtables itself.
However please see Dave's mail about net-next, until the merge window is over and -rc1 released only bugfixes will be accepted.
I was considering this a bugfix because the module as-is can be loaded with ebtables, will create audit records but won't allow for the next rule to drop/reject the packet.
Would you consider Jan's approach a bugfix or should I wait?
Quoted 27 lines · Thomas Graf
Quoted 19 lines · Patrick McHardy
Am 16.03.2011 01:43, schrieb Jan Engelhardt:
Quoted 18 lines · Thomas Graf
Quoted 4 lines
Even though ebtables uses xtables it still requires targets to return
EBT_CONTINUEinstead ofXT_CONTINUE. This preventedxt_AUDITto work as ebt module.Something that just came to mind is that you could probably do to keep the code at a minimum:
static unsigned int
ebt_audit(struct xt_target_param *par){ unsigned int ret = xt_audit_tg(par); if (ret == XT_CONTINUE) return EBT_CONTINUE; ... }That's a good idea, thanks Jan!
Quoted 4 lines
Seems like a good idea to me. If more modules need this (f.i. MARK) we could also consider doing the mapping based on a target flag in ebtables itself.
Quoted 8 lines
Quoted 2 lines
However please see Dave's mail about net-next, until the merge window is over and -rc1 released only bugfixes will be accepted.
I was considering this a bugfix because the module as-is can be loaded with ebtables, will create audit records but won't allow for the next rule to drop/reject the packet.
Would you consider Jan's approach a bugfix or should I wait?
Yes, this qualifies as a bugfix in my opinion since we're returning invalid verdicts to ebtables. I'll apply your patch later today.
PATCH 1/1 ebtables: Fix xt_AUDIT to work with ebtables, return EBT_CONTINUE if NFPROTO_BRIDGE
In reply to Jan EngelhardtEven though ebtables uses xtables it still requires targets to return EBT_CONTINUE instead of XT_CONTINUE. This prevented xt_AUDIT to work as ebt module.
Upon Jan's suggestion, use a separate struct xt_target for NFPROTO_BRIDGE having its own target callback returning EBT_CONTINUE instead of cloning the module.
net/netfilter/xt_AUDIT.c +27 -9
@@ -19,6 +19,7 @@#include <linux/if_arp.h> #include <linux/netfilter/x_tables.h> #include <linux/netfilter/xt_AUDIT.h> +#include <linux/netfilter_bridge/ebtables.h> #include <net/ipv6.h> #include <net/ip.h>
@@ -168,6 +169,13 @@ errout:return XT_CONTINUE ; } +static unsigned int +audit_tg_ebt (struct sk_buff *skb,const struct xt_action_param *par) +{ +audit_tg (skb, par); +return EBT_CONTINUE ; +} +static int audit_tg_check (const struct xt_tgchk_param *par) {const struct xt_audit_info *info = par->targinfo;
@@ -181,23 +189,33 @@ static int audit_tg_check(const struct xt_tgchk_param *par)return 0 ; } -static struct xt_target audit_tg_reg__read_mostly = { - .name ="AUDIT" , - .family =NFPROTO_UNSPEC , - .target = audit_tg, - .targetsize =sizeof (struct xt_audit_info ), - .checkentry = audit_tg_check, - .me =THIS_MODULE , +static struct xt_target audit_tg_reg[]__read_mostly = { + { + .name ="AUDIT" , + .family =NFPROTO_UNSPEC , + .target = audit_tg, + .targetsize =sizeof (struct xt_audit_info ), + .checkentry = audit_tg_check, + .me =THIS_MODULE , + }, + { + .name ="AUDIT" , + .family =NFPROTO_BRIDGE , + .target = audit_tg_ebt, + .targetsize =sizeof (struct xt_audit_info ), + .checkentry = audit_tg_check, + .me =THIS_MODULE , + }, };static int __init audit_tg_init (void ) { -return xt_register_target (&audit_tg_reg); +return xt_register_targets (audit_tg_reg,ARRAY_SIZE (audit_tg_reg)); } static void __exit audit_tg_exit(void) { -xt_unregister_target (&audit_tg_reg); +xt_unregister_targets (audit_tg_reg,ARRAY_SIZE (audit_tg_reg)); }module_init (audit_tg_init);
Patrick McHardy
AppliedRe: [PATCH] ebtables: Fix xt_AUDIT to work with ebtables, return EBT_CONTINUE if NFPROTO_BRIDGE
Quoted 8 lines · Thomas Graf
Even though ebtables uses xtables it still requires targets to return
EBT_CONTINUEinstead ofXT_CONTINUE. This preventedxt_AUDITto work as ebt module.Upon Jan's suggestion, use a separate struct
xt_targetforNFPROTO_BRIDGEhaving its own target callback returningEBT_CONTINUEinstead of cloning the module.
Applied, thanks Thomas.