-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NETFILTER]: Add "nfnetlink_queue" netfilter queue handler over nfnet…
…link - Add new nfnetlink_queue module - Add new ipt_NFQUEUE and ip6t_NFQUEUE modules to access queue numbers 1-65535 - Mark ip_queue and ip6_queue Kconfig options as OBSOLETE - Update feature-removal-schedule to remove ip[6]_queue in December Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Harald Welte
authored and
David S. Miller
committed
Aug 29, 2005
1 parent
0ab43f8
commit 7af4cc3
Showing
12 changed files
with
1,153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef _NFNETLINK_QUEUE_H | ||
#define _NFNETLINK_QUEUE_H | ||
|
||
#include <linux/netfilter/nfnetlink.h> | ||
|
||
enum nfqnl_msg_types { | ||
NFQNL_MSG_PACKET, /* packet from kernel to userspace */ | ||
NFQNL_MSG_VERDICT, /* verdict from userspace to kernel */ | ||
NFQNL_MSG_CONFIG, /* connect to a particular queue */ | ||
|
||
NFQNL_MSG_MAX | ||
}; | ||
|
||
struct nfqnl_msg_packet_hdr { | ||
u_int32_t packet_id; /* unique ID of packet in queue */ | ||
u_int16_t hw_protocol; /* hw protocol (network order) */ | ||
u_int8_t hook; /* netfilter hook */ | ||
} __attribute__ ((packed)); | ||
|
||
struct nfqnl_msg_packet_hw { | ||
u_int16_t hw_addrlen; | ||
u_int16_t _pad; | ||
u_int8_t hw_addr[8]; | ||
} __attribute__ ((packed)); | ||
|
||
struct nfqnl_msg_packet_timestamp { | ||
u_int64_t sec; | ||
u_int64_t usec; | ||
} __attribute__ ((packed)); | ||
|
||
enum nfqnl_attr_type { | ||
NFQA_UNSPEC, | ||
NFQA_PACKET_HDR, | ||
NFQA_VERDICT_HDR, /* nfqnl_msg_verdict_hrd */ | ||
NFQA_MARK, /* u_int32_t nfmark */ | ||
NFQA_TIMESTAMP, /* nfqnl_msg_packet_timestamp */ | ||
NFQA_IFINDEX_INDEV, /* u_int32_t ifindex */ | ||
NFQA_IFINDEX_OUTDEV, /* u_int32_t ifindex */ | ||
NFQA_HWADDR, /* nfqnl_msg_packet_hw */ | ||
NFQA_PAYLOAD, /* opaque data payload */ | ||
|
||
__NFQA_MAX | ||
}; | ||
#define NFQA_MAX (__NFQA_MAX - 1) | ||
|
||
struct nfqnl_msg_verdict_hdr { | ||
u_int32_t verdict; | ||
u_int32_t id; | ||
} __attribute__ ((packed)); | ||
|
||
|
||
enum nfqnl_msg_config_cmds { | ||
NFQNL_CFG_CMD_NONE, | ||
NFQNL_CFG_CMD_BIND, | ||
NFQNL_CFG_CMD_UNBIND, | ||
NFQNL_CFG_CMD_PF_BIND, | ||
NFQNL_CFG_CMD_PF_UNBIND, | ||
}; | ||
|
||
struct nfqnl_msg_config_cmd { | ||
u_int8_t command; /* nfqnl_msg_config_cmds */ | ||
u_int8_t _pad; | ||
u_int16_t pf; /* AF_xxx for PF_[UN]BIND */ | ||
} __attribute__ ((packed)); | ||
|
||
enum nfqnl_config_mode { | ||
NFQNL_COPY_NONE, | ||
NFQNL_COPY_META, | ||
NFQNL_COPY_PACKET, | ||
}; | ||
|
||
struct nfqnl_msg_config_params { | ||
u_int32_t copy_range; | ||
u_int8_t copy_mode; /* enum nfqnl_config_mode */ | ||
} __attribute__ ((packed)); | ||
|
||
|
||
enum nfqnl_attr_config { | ||
NFQA_CFG_UNSPEC, | ||
NFQA_CFG_CMD, /* nfqnl_msg_config_cmd */ | ||
NFQA_CFG_PARAMS, /* nfqnl_msg_config_params */ | ||
__NFQA_CFG_MAX | ||
}; | ||
|
||
#endif /* _NFNETLINK_QUEUE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* iptables module for using NFQUEUE mechanism | ||
* | ||
* (C) 2005 Harald Welte <laforge@netfilter.org> | ||
* | ||
* This software is distributed under GNU GPL v2, 1991 | ||
* | ||
*/ | ||
#ifndef _IPT_NFQ_TARGET_H | ||
#define _IPT_NFQ_TARGET_H | ||
|
||
/* target info */ | ||
struct ipt_NFQ_info { | ||
u_int16_t queuenum; | ||
}; | ||
|
||
#endif /* _IPT_DSCP_TARGET_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* iptables module for using new netfilter netlink queue | ||
* | ||
* (C) 2005 by Harald Welte <laforge@netfilter.org> | ||
* | ||
* 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/netfilter.h> | ||
#include <linux/netfilter_ipv4/ip_tables.h> | ||
#include <linux/netfilter_ipv4/ipt_NFQUEUE.h> | ||
|
||
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); | ||
MODULE_DESCRIPTION("iptables NFQUEUE target"); | ||
MODULE_LICENSE("GPL"); | ||
|
||
static unsigned int | ||
target(struct sk_buff **pskb, | ||
const struct net_device *in, | ||
const struct net_device *out, | ||
unsigned int hooknum, | ||
const void *targinfo, | ||
void *userinfo) | ||
{ | ||
const struct ipt_NFQ_info *tinfo = targinfo; | ||
|
||
return NF_QUEUE_NR(tinfo->queuenum); | ||
} | ||
|
||
static int | ||
checkentry(const char *tablename, | ||
const struct ipt_entry *e, | ||
void *targinfo, | ||
unsigned int targinfosize, | ||
unsigned int hook_mask) | ||
{ | ||
if (targinfosize != IPT_ALIGN(sizeof(struct ipt_NFQ_info))) { | ||
printk(KERN_WARNING "NFQUEUE: targinfosize %u != %Zu\n", | ||
targinfosize, | ||
IPT_ALIGN(sizeof(struct ipt_NFQ_info))); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
static struct ipt_target ipt_NFQ_reg = { | ||
.name = "NFQUEUE", | ||
.target = target, | ||
.checkentry = checkentry, | ||
.me = THIS_MODULE, | ||
}; | ||
|
||
static int __init init(void) | ||
{ | ||
return ipt_register_target(&ipt_NFQ_reg); | ||
} | ||
|
||
static void __exit fini(void) | ||
{ | ||
ipt_unregister_target(&ipt_NFQ_reg); | ||
} | ||
|
||
module_init(init); | ||
module_exit(fini); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* ip6tables module for using new netfilter netlink queue | ||
* | ||
* (C) 2005 by Harald Welte <laforge@netfilter.org> | ||
* | ||
* 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/netfilter.h> | ||
#include <linux/netfilter_ipv6/ip6_tables.h> | ||
#include <linux/netfilter_ipv4/ipt_NFQUEUE.h> | ||
|
||
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); | ||
MODULE_DESCRIPTION("ip6tables NFQUEUE target"); | ||
MODULE_LICENSE("GPL"); | ||
|
||
static unsigned int | ||
target(struct sk_buff **pskb, | ||
const struct net_device *in, | ||
const struct net_device *out, | ||
unsigned int hooknum, | ||
const void *targinfo, | ||
void *userinfo) | ||
{ | ||
const struct ipt_NFQ_info *tinfo = targinfo; | ||
|
||
return NF_QUEUE_NR(tinfo->queuenum); | ||
} | ||
|
||
static int | ||
checkentry(const char *tablename, | ||
const struct ip6t_entry *e, | ||
void *targinfo, | ||
unsigned int targinfosize, | ||
unsigned int hook_mask) | ||
{ | ||
if (targinfosize != IP6T_ALIGN(sizeof(struct ipt_NFQ_info))) { | ||
printk(KERN_WARNING "NFQUEUE: targinfosize %u != %Zu\n", | ||
targinfosize, | ||
IP6T_ALIGN(sizeof(struct ipt_NFQ_info))); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
static struct ip6t_target ipt_NFQ_reg = { | ||
.name = "NFQUEUE", | ||
.target = target, | ||
.checkentry = checkentry, | ||
.me = THIS_MODULE, | ||
}; | ||
|
||
static int __init init(void) | ||
{ | ||
return ip6t_register_target(&ipt_NFQ_reg); | ||
} | ||
|
||
static void __exit fini(void) | ||
{ | ||
ip6t_unregister_target(&ipt_NFQ_reg); | ||
} | ||
|
||
module_init(init); | ||
module_exit(fini); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o | ||
obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o |
Oops, something went wrong.