netfilter 00/11: netfilter -next update
Subsystems (4)
Hi Dave,
following is a first netfilter update for net-next-2.6.git, including:
- conntrack accounting fixes
- a new IPv4/IPv6 security table for SELinux
- IPv6 support for ebtables
- ctnetlink cleanups and SCTP support
- removal of ksize "abuse" in ct_extend
- minor queuing cleanups
Please apply, thanks.
include/linux/netfilter/nfnetlink_conntrack.h | 10 ++ include/linux/netfilter_bridge/ebt_ip6.h | 40 ++++++ include/linux/netfilter_bridge/ebt_log.h | 3 +- include/linux/netfilter_ipv4.h | 1 + include/linux/netfilter_ipv6.h | 1 + include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 2 - include/net/netfilter/nf_conntrack.h | 19 +++ include/net/netns/ipv4.h | 1 + include/net/netns/ipv6.h | 1 + net/bridge/netfilter/Kconfig | 9 ++ net/bridge/netfilter/Makefile | 1 + net/bridge/netfilter/ebt_ip6.c | 144 +++++++++++++++++++ net/bridge/netfilter/ebt_log.c | 64 +++++++-- net/ipv4/netfilter/Kconfig | 12 ++ net/ipv4/netfilter/Makefile | 1 + net/ipv4/netfilter/ip_queue.c | 3 - net/ipv4/netfilter/iptable_security.c | 180 ++++++++++++++++++++++++ net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 5 +- net/ipv6/netfilter/Kconfig | 12 ++ net/ipv6/netfilter/Makefile | 1 + net/ipv6/netfilter/ip6_queue.c | 3 - net/ipv6/netfilter/ip6table_security.c | 172 ++++++++++++++++++++++ net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 5 +- net/netfilter/nf_conntrack_core.c | 19 +++ net/netfilter/nf_conntrack_extend.c | 10 +- net/netfilter/nf_conntrack_netlink.c | 30 ++-- net/netfilter/nf_conntrack_proto_dccp.c | 3 +- net/netfilter/nf_conntrack_proto_sctp.c | 80 +++++++++++ net/netfilter/nf_conntrack_proto_tcp.c | 9 +- net/netfilter/nfnetlink_queue.c | 1 - net/netfilter/xt_CONNSECMARK.c | 10 +- net/netfilter/xt_SECMARK.c | 10 +- 32 files changed, 794 insertions(+), 68 deletions(-) create mode 100644 include/linux/netfilter_bridge/ebt_ip6.h create mode 100644 net/bridge/netfilter/ebt_ip6.c create mode 100644 net/ipv4/netfilter/iptable_security.c create mode 100644 net/ipv6/netfilter/ip6table_security.c
Fabian Hugelshofer (2):
netfilter: nf_conntrack: properly account terminating packets
netfilter: ctnetlink: include conntrack status in destroy event message
James Morris (2):
netfilter: ip_tables: add iptables security table for mandatory access control rules
netfilter: ip6_tables: add ip6tables security table
Kuo-lang Tseng (1):
netfilter: ebtables: add IPv6 support
Pablo Neira Ayuso (2):
netfilter: ctnetlink: group errors into logical errno sets
netfilter: ctnetlink: add full support for SCTP to ctnetlink
Patrick McHardy (1):
netfilter: nf_conntrack: add nf_ct_kill()
Pekka Enberg (1):
netfilter: nf_conntrack_extend: use krealloc() in nf_conntrack_extend.c V2
Rami Rosen (2):
netfilter: nf_conntrack: remove unnecessary function declaration
netfilter: {ip,ip6,nfnetlink}_queue: misc cleanups
netfilter 01/11: ebtables: add IPv6 support
netfilter: ebtables: add IPv6 support
It implements matching functions for IPv6 address & traffic class (merged from the patch sent by Jan Engelhardt [[email protected]]
http://marc.info/?l=netfilter-devel&m=120182168424052&w=2), protocol, and layer-4 port id. Corresponding watcher logging function is also added for IPv6.
---
commit b6e858ce9cfbf1779380ba9bb1b3e27b3b4db8b7
tree 19f9efc52596f3aa05ddc75efaddb4c20ba74808
parent 40aecb1b13f50d96616abb612c17e59457f54263
author Kuo-lang Tseng <[email protected]> Fri, 06 Jun 2008 17:08:08 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:08:08 +0200
include/linux/netfilter_bridge/ebt_ip6.h | 40 ++++++++ include/linux/netfilter_bridge/ebt_log.h | 3 - net/bridge/netfilter/Kconfig | 9 ++ net/bridge/netfilter/Makefile | 1 net/bridge/netfilter/ebt_ip6.c | 144 ++++++++++++++++++++++++++++++ net/bridge/netfilter/ebt_log.c | 64 ++++++++++--- 6 files changed, 244 insertions(+), 17 deletions(-)
include/linux/netfilter_bridge/ebt_ip6.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* ebt_ip6 +* +* Authors: +* Kuo-Lang Tseng <[email protected]> +* Manohar Castelino <[email protected]> +* +* Jan 11, 2008 +* +*/ + +#ifndef __LINUX_BRIDGE_EBT_IP6_H +#define __LINUX_BRIDGE_EBT_IP6_H + +#define EBT_IP6_SOURCE 0x01 +#define EBT_IP6_DEST 0x02 +#define EBT_IP6_TCLASS 0x04 +#define EBT_IP6_PROTO 0x08 +#define EBT_IP6_SPORT 0x10 +#define EBT_IP6_DPORT 0x20 +#define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS |\ + EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT) +#define EBT_IP6_MATCH "ip6" + +/* the same values are used for the invflags */ +struct ebt_ip6_info +{ +struct in6_addr saddr; +struct in6_addr daddr; +struct in6_addr smsk; +struct in6_addr dmsk; +uint8_t tclass; +uint8_t protocol; +uint8_t bitmask; +uint8_t invflags; +uint16_t sport[2 ]; +uint16_t dport[2 ]; +}; + +#endif
include/linux/netfilter_bridge/ebt_log.h +2 -1
@@ -4,7 +4,8 @@#define EBT_LOG_IP 0x01/* if the frame is made by ip, log the ip information */ #define EBT_LOG_ARP 0x02#define EBT_LOG_NFLOG 0x04 -#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP) +#define EBT_LOG_IP6 0x08 +#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP | EBT_LOG_IP6)#define EBT_LOG_PREFIX_SIZE 30#define EBT_LOG_WATCHER "log"
net/bridge/netfilter/Kconfig +9 -0
@@ -83,6 +83,15 @@ config BRIDGE_EBT_IP To compile it as a module, choose M here. If unsure, say N. +config BRIDGE_EBT_IP6 + tristate "ebt: IP6 filter support" + depends on BRIDGE_NF_EBTABLES + help + This option adds the IP6 match, which allows basic IPV6 header field + filtering. + + To compile it as a module, choose M here. If unsure, say N. + config BRIDGE_EBT_LIMIT tristate "ebt: limit match support" depends on BRIDGE_NF_EBTABLES
net/bridge/netfilter/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_BRIDGE_EBT_802_3) += ebt_802_3.o obj-$(CONFIG_BRIDGE_EBT_AMONG) += ebt_among.o obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o +obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip6.o obj-$(CONFIG_BRIDGE_EBT_LIMIT) += ebt_limit.o obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o
net/bridge/netfilter/ebt_ip6.c new file +144 -0
144 lines not on this page · raw message
net/bridge/netfilter/ebt_log.c +48 -16
83 lines not on this page · raw message
netfilter 02/11: ctnetlink: group errors into logical errno sets
In reply to Patrick McHardynetfilter: ctnetlink: group errors into logical errno sets
This patch groups ctnetlink errors into three logical sets:
* Malformed messages: if ctnetlink receives a message without some mandatory attribute, then it returns EINVAL.
* Unsupported operations: if userspace tries to perform an unsupported operation, then it returns EOPNOTSUPP.
* Unchangeable: if userspace tries to change some attribute of the conntrack object that can only be set once, then it returns EBUSY.
This patch reduces the number of -EINVAL from 23 to 14 and it results in 5 -EBUSY and 6 -EOPNOTSUPP.
---
commit aed5c546c63f757b44cd55d279b88a118a5cc485
tree 696cc590645bde00e74341241795575c7769b25d
parent b6e858ce9cfbf1779380ba9bb1b3e27b3b4db8b7
author Pablo Neira Ayuso <[email protected]> Fri, 06 Jun 2008 17:08:16 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:08:16 +0200
net/netfilter/nf_conntrack_netlink.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-)
net/netfilter/nf_conntrack_netlink.c +10 -11
@@ -4,7 +4,7 @@* (C) 2001 by Jay Schulist <[email protected]> * (C) 2002-2006 by Harald Welte <[email protected]> * (C) 2003 by Patrick Mchardy <[email protected]> -* (C) 2005-2007 by Pablo Neira Ayuso <[email protected]> +* (C) 2005-2008 by Pablo Neira Ayuso <[email protected]> * * Initial connection tracking via netlink development funded and * generally made possible by Network Robots, Inc. (www.networkrobots.com)
@@ -891,20 +891,19 @@ ctnetlink_change_status(struct nf_conn *ct, struct nlattr *cda[])if (d & (IPS_EXPECTED |IPS_CONFIRMED |IPS_DYING ))/* unchangeable */ -return -EINVAL ; +return -EBUSY ;if (d &IPS_SEEN_REPLY && !(status &IPS_SEEN_REPLY ))/* SEEN_REPLY bit can only be set */ -return -EINVAL ; - +return -EBUSY ;if (d &IPS_ASSURED && !(status &IPS_ASSURED ))/* ASSURED bit can only be set */ -return -EINVAL ; +return -EBUSY ;if (cda[CTA_NAT_SRC ] || cda[CTA_NAT_DST ]) {#ifndef CONFIG_NF_NAT_NEEDED -return -EINVAL ; +return -EOPNOTSUPP ;#else struct nf_nat_range range;
@@ -945,7 +944,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[])/* don't change helper of sibling connections */ if (ct->master) -return -EINVAL ; +return -EBUSY ; err =ctnetlink_parse_help (cda[CTA_HELP ], &helpname);if (err <0 )
@@ -963,7 +962,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[]) helper =__nf_conntrack_helper_find_byname (helpname);if (helper ==NULL ) -return -EINVAL ; +return -EOPNOTSUPP ;if (help) {if (help->helper == helper)
@@ -1258,12 +1257,12 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (!(nlh->nlmsg_flags &NLM_F_EXCL )) {/* we only allow nat config for new conntracks */ if (cda[CTA_NAT_SRC ] || cda[CTA_NAT_DST ]) { - err = -EINVAL ; + err = -EOPNOTSUPP ; goto out_unlock; }/* can't link an existing conntrack to a master */ if (cda[CTA_TUPLE_MASTER ]) { - err = -EINVAL ; + err = -EOPNOTSUPP ; goto out_unlock; } err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h),
@@ -1608,7 +1607,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb, h =__nf_conntrack_helper_find_byname (name);if (!h) {spin_unlock_bh (&nf_conntrack_lock); -return -EINVAL ; +return -EOPNOTSUPP ; }for (i =0 ; i < nf_ct_expect_hsize; i++) { hlist_for_each_entry_safe(exp, n, next,
netfilter 03/11: ctnetlink: add full support for SCTP to ctnetlink
In reply to Patrick McHardynetfilter: ctnetlink: add full support for SCTP to ctnetlink
This patch adds full support for SCTP to ctnetlink. This includes three new attributes: state, original vtag and reply vtag.
---
commit f3cca975999eb8009c2e912cd11948e0208a2de7
tree 4cbc50244dd073e8230d078817cccedc833181e2
parent aed5c546c63f757b44cd55d279b88a118a5cc485
author Pablo Neira Ayuso <[email protected]> Fri, 06 Jun 2008 17:08:24 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:08:24 +0200
include/linux/netfilter/nfnetlink_conntrack.h | 10 +++ net/netfilter/nf_conntrack_proto_sctp.c | 80 +++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 0 deletions(-)
include/linux/netfilter/nfnetlink_conntrack.h +10 -0
@@ -81,6 +81,7 @@ enum ctattr_protoinfo {CTA_PROTOINFO_UNSPEC ,CTA_PROTOINFO_TCP ,CTA_PROTOINFO_DCCP , +CTA_PROTOINFO_SCTP , __CTA_PROTOINFO_MAX };#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
@@ -103,6 +104,15 @@ enum ctattr_protoinfo_dccp { };#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1) +enum ctattr_protoinfo_sctp { +CTA_PROTOINFO_SCTP_UNSPEC , +CTA_PROTOINFO_SCTP_STATE , +CTA_PROTOINFO_SCTP_VTAG_ORIGINAL , +CTA_PROTOINFO_SCTP_VTAG_REPLY , + __CTA_PROTOINFO_SCTP_MAX +}; +#define CTA_PROTOINFO_SCTP_MAX (__CTA_PROTOINFO_SCTP_MAX - 1) +enum ctattr_counters {CTA_COUNTERS_UNSPEC ,CTA_COUNTERS_PACKETS ,/* old 64bit counters */
net/netfilter/nf_conntrack_proto_sctp.c +80 -0
98 lines not on this page · raw message
netfilter 04/11: ip_tables: add iptables security table for mandatory access control rules
In reply to Patrick McHardynetfilter: ip_tables: add iptables security table for mandatory access control rules
The following patch implements a new "security" table for iptables, so that MAC (SELinux etc.) networking rules can be managed separately to standard DAC rules.
This is to help with distro integration of the new secmark-based network controls, per various previous discussions.
The need for a separate table arises from the fact that existing tools and usage of iptables will likely clash with centralized MAC policy management.
The SECMARK and CONNSECMARK targets will still be valid in the mangle table to prevent breakage of existing users.
---
commit 9ca9e6f29c9a45b477de6f6ec63bc39331c384a2
tree 8cf9e0db3c50b215b470494ba3a3f11c86fb8f4b
parent f3cca975999eb8009c2e912cd11948e0208a2de7
author James Morris <[email protected]> Fri, 06 Jun 2008 17:10:43 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:10:43 +0200
include/linux/netfilter_ipv4.h | 1 include/net/netns/ipv4.h | 1 net/ipv4/netfilter/Kconfig | 12 ++ net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/iptable_security.c | 180 +++++++++++++++++++++++++++++++++ net/netfilter/xt_CONNSECMARK.c | 10 +- net/netfilter/xt_SECMARK.c | 10 +- 7 files changed, 209 insertions(+), 6 deletions(-)
include/linux/netfilter_ipv4.h +1 -0
@@ -60,6 +60,7 @@ enum nf_ip_hook_priorities {NF_IP_PRI_MANGLE =-150 ,NF_IP_PRI_NAT_DST =-100 ,NF_IP_PRI_FILTER =0 , +NF_IP_PRI_SECURITY =50 ,NF_IP_PRI_NAT_SRC =100 ,NF_IP_PRI_SELINUX_LAST =225 , NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX,
include/net/netns/ipv4.h +1 -0
@@ -36,6 +36,7 @@ struct netns_ipv4 {struct xt_table *iptable_mangle;struct xt_table *iptable_raw;struct xt_table *arptable_filter; +struct xt_table *iptable_security;#endif int sysctl_icmp_echo_ignore_all;
net/ipv4/netfilter/Kconfig +12 -0
@@ -365,6 +365,18 @@ config IP_NF_RAW If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. +# security table for MAC policy +config IP_NF_SECURITY + tristate "Security table" + depends on IP_NF_IPTABLES + depends on SECURITY + default m if NETFILTER_ADVANCED=n + help + This option adds a `security' table to iptables, for use + with Mandatory Access Control (MAC) policy. + + If unsure, say N. + # ARP tables config IP_NF_ARPTABLES tristate "ARP tables support"
net/ipv4/netfilter/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o obj-$(CONFIG_NF_NAT) += iptable_nat.o obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o +obj-$(CONFIG_IP_NF_SECURITY) += iptable_security.o # matches obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o
net/ipv4/netfilter/iptable_security.c new file +180 -0
180 lines not on this page · raw message
net/netfilter/xt_CONNSECMARK.c +7 -3
@@ -8,7 +8,7 @@* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> * by Henrik Nordstrom <[email protected]> * -* (C) 2006 Red Hat, Inc., James Morris <[email protected]> +* (C) 2006,2008 Red Hat, Inc., James Morris <[email protected]> * * 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
@@ -94,6 +94,12 @@ connsecmark_tg_check(const char *tablename, const void *entry, {const struct xt_connsecmark_target_info *info = targinfo; +if (strcmp (tablename,"mangle" ) &&strcmp (tablename,"security" )) { + printk(KERN_INFO PFX "target only valid in the \'mangle\' " + "or \'security\' tables, not \'%s\'.\n", tablename); +return false; + } +switch (info->mode) {case CONNSECMARK_SAVE :case CONNSECMARK_RESTORE :
@@ -126,7 +132,6 @@ static struct xt_target connsecmark_tg_reg[] __read_mostly = { .destroy = connsecmark_tg_destroy, .target = connsecmark_tg, .targetsize = sizeof(struct xt_connsecmark_target_info), - .table = "mangle", .me = THIS_MODULE, }, {
@@ -136,7 +141,6 @@ static struct xt_target connsecmark_tg_reg[] __read_mostly = { .destroy = connsecmark_tg_destroy, .target = connsecmark_tg, .targetsize = sizeof(struct xt_connsecmark_target_info), - .table = "mangle", .me = THIS_MODULE, }, };
net/netfilter/xt_SECMARK.c +7 -3
@@ -5,7 +5,7 @@* Based on the nfmark match by: * (C) 1999-2001 Marc Boucher <[email protected]> * -* (C) 2006 Red Hat, Inc., James Morris <[email protected]> +* (C) 2006,2008 Red Hat, Inc., James Morris <[email protected]> * * 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
@@ -89,6 +89,12 @@ secmark_tg_check(const char *tablename, const void *entry, {struct xt_secmark_target_info *info = targinfo; +if (strcmp (tablename,"mangle" ) &&strcmp (tablename,"security" )) { + printk(KERN_INFO PFX "target only valid in the \'mangle\' " + "or \'security\' tables, not \'%s\'.\n", tablename); +return false; + } +if (mode && mode != info->mode) { printk(KERN_INFO PFX "mode already set to %hu cannot mix with " "rules for mode %hu\n", mode, info->mode);
@@ -127,7 +133,6 @@ static struct xt_target secmark_tg_reg[] __read_mostly = { .destroy = secmark_tg_destroy, .target = secmark_tg, .targetsize = sizeof(struct xt_secmark_target_info), - .table = "mangle", .me = THIS_MODULE, }, {
@@ -137,7 +142,6 @@ static struct xt_target secmark_tg_reg[] __read_mostly = { .destroy = secmark_tg_destroy, .target = secmark_tg, .targetsize = sizeof(struct xt_secmark_target_info), - .table = "mangle", .me = THIS_MODULE, }, };
netfilter 05/11: ip6_tables: add ip6tables security table
In reply to Patrick McHardynetfilter: ip6_tables: add ip6tables security table
This is a port of the IPv4 security table for IPv6.
---
commit 90faf09757063e4e45aba7124977ef5b82cd5223
tree a7e7a39d81e48803d3fdd4007cd9bafbd425e770
parent 9ca9e6f29c9a45b477de6f6ec63bc39331c384a2
author James Morris <[email protected]> Fri, 06 Jun 2008 17:11:00 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:00 +0200
include/linux/netfilter_ipv6.h | 1 include/net/netns/ipv6.h | 1 net/ipv6/netfilter/Kconfig | 12 ++ net/ipv6/netfilter/Makefile | 1 net/ipv6/netfilter/ip6table_security.c | 172 ++++++++++++++++++++++++++++++++ 5 files changed, 187 insertions(+), 0 deletions(-)
include/linux/netfilter_ipv6.h +1 -0
@@ -64,6 +64,7 @@ enum nf_ip6_hook_priorities {NF_IP6_PRI_MANGLE =-150 ,NF_IP6_PRI_NAT_DST =-100 ,NF_IP6_PRI_FILTER =0 , +NF_IP6_PRI_SECURITY =50 ,NF_IP6_PRI_NAT_SRC =100 ,NF_IP6_PRI_SELINUX_LAST =225 , NF_IP6_PRI_LAST = INT_MAX,
include/net/netns/ipv6.h +1 -0
@@ -35,6 +35,7 @@ struct netns_ipv6 {struct xt_table *ip6table_filter;struct xt_table *ip6table_mangle;struct xt_table *ip6table_raw; +struct xt_table *ip6table_security;#endif struct rt6_info *ip6_null_entry;struct rt6_statistics *rt6_stats;
net/ipv6/netfilter/Kconfig +12 -0
@@ -208,5 +208,17 @@ config IP6_NF_RAW If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. +# security table for MAC policy +config IP6_NF_SECURITY + tristate "Security table" + depends on IP6_NF_IPTABLES + depends on SECURITY + default m if NETFILTER_ADVANCED=n + help + This option adds a `security' table to iptables, for use + with Mandatory Access Control (MAC) policy. + + If unsure, say N. + endmenu
net/ipv6/netfilter/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o +obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o # objects for l3 independent conntrack nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o
net/ipv6/netfilter/ip6table_security.c new file +172 -0
172 lines not on this page · raw message
netfilter 06/11: nf_conntrack_extend: use krealloc() in nf_conntrack_extend.c V2
In reply to Patrick McHardynetfilter: nf_conntrack_extend: use krealloc() in nf_conntrack_extend.c V2
The ksize() API is going away because it is being abused and it doesn't even work consistenly across different allocators. Therefore, convert net/netfilter/nf_conntrack_extend.c to use krealloc().
---
commit c6bf7199df1514a3f82c2c6a3d925c5966798141
tree 64365998231e0ae71aa95ff478bd185ea22af3d5
parent 90faf09757063e4e45aba7124977ef5b82cd5223
author Pekka Enberg <[email protected]> Fri, 06 Jun 2008 17:11:04 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:04 +0200
net/netfilter/nf_conntrack_extend.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_extend.c +4 -6
@@ -88,13 +88,11 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp) newlen = newoff + t->len;rcu_read_unlock (); -if (newlen >=ksize (ct->ext)) { - new =kmalloc (newlen, gfp); -if (!new) -return NULL ; - -memcpy (new, ct->ext, ct->ext->len); + new =krealloc (ct->ext, newlen, gfp); +if (!new) +return NULL ; +if (new != ct->ext) {for (i =0 ; i <NF_CT_EXT_NUM ; i++) {if (!nf_ct_ext_exist (ct, i))continue ;
netfilter 07/11: nf_conntrack: add nf_ct_kill()
In reply to Patrick McHardynetfilter: nf_conntrack: add nf_ct_kill()
Encapsulate the common
if (del_timer(&ct->timeout)) ct->timeout.function((unsigned long)ct)
sequence in a new function.
---
commit 0c160731721ea46fa0496d32b9e3816a149d7420
tree 57775bffc393305f930acf792493e21ec8914091
parent c6bf7199df1514a3f82c2c6a3d925c5966798141
author Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200
include/net/netfilter/nf_conntrack.h | 2 ++ net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 5 ++--- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 5 ++--- net/netfilter/nf_conntrack_core.c | 7 +++++++ net/netfilter/nf_conntrack_netlink.c | 3 +-- net/netfilter/nf_conntrack_proto_dccp.c | 3 +-- net/netfilter/nf_conntrack_proto_tcp.c | 9 +++------ 7 files changed, 18 insertions(+), 16 deletions(-)
include/net/netfilter/nf_conntrack.h +2 -0
@@ -223,6 +223,8 @@ static inline void nf_ct_refresh(struct nf_conn *ct,__nf_ct_refresh_acct (ct,0 , skb, extra_jiffies,0 ); } +extern void nf_ct_kill (struct nf_conn *ct); +/* These are for NAT. Icky. */ /* Update TCP window tracking data when NAT mangles the packet */ extern void nf_conntrack_tcp_update(const struct sk_buff *skb,
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +2 -3
@@ -87,9 +87,8 @@ static int icmp_packet(struct nf_conn *ct,means this will only run once even if count hits zero twice (theoretically possible with SMP) */ if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) { -if (atomic_dec_and_test (&ct->proto.icmp.count) - &&del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +if (atomic_dec_and_test (&ct->proto.icmp.count)) +nf_ct_kill (ct); }else {atomic_inc (&ct->proto.icmp.count);nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb);
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +2 -3
@@ -89,9 +89,8 @@ static int icmpv6_packet(struct nf_conn *ct,means this will only run once even if count hits zero twice (theoretically possible with SMP) */ if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) { -if (atomic_dec_and_test (&ct->proto.icmp.count) - &&del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +if (atomic_dec_and_test (&ct->proto.icmp.count)) +nf_ct_kill (ct); }else {atomic_inc (&ct->proto.icmp.count);nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb);
net/netfilter/nf_conntrack_core.c +7 -0
@@ -848,6 +848,13 @@ acct: }EXPORT_SYMBOL_GPL (__nf_ct_refresh_acct); +void nf_ct_kill (struct nf_conn *ct) +{ +if (del_timer (&ct->timeout)) + ct->timeout.function ((unsigned long )ct); +} +EXPORT_SYMBOL_GPL (nf_ct_kill); +#if defined(CONFIG_NF_CT_NETLINK ) || defined(CONFIG_NF_CT_NETLINK_MODULE )#include <linux/netfilter/nfnetlink.h>
net/netfilter/nf_conntrack_netlink.c +1 -2
@@ -812,9 +812,8 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,return -ENOENT ; } } -if (del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +nf_ct_kill (ct);nf_ct_put (ct);return 0 ;
net/netfilter/nf_conntrack_proto_dccp.c +1 -2
@@ -475,8 +475,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,if (type ==DCCP_PKT_RESET && !test_bit (IPS_SEEN_REPLY_BIT , &ct->status)) {/* Tear down connection immediately if only reply is a RESET */ -if (del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +nf_ct_kill (ct);return NF_ACCEPT ; }
net/netfilter/nf_conntrack_proto_tcp.c +3 -6
@@ -843,8 +843,7 @@ static int tcp_packet(struct nf_conn *ct,/* Attempt to reopen a closed/aborted connection. * Delete this connection and look up again. */ write_unlock_bh (&tcp_lock); -if (del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +nf_ct_kill (ct);return -NF_REPEAT ; }/* Fall through */
@@ -877,8 +876,7 @@ static int tcp_packet(struct nf_conn *ct,if (LOG_INVALID (IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: killing out of sync session " ); -if (del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +nf_ct_kill (ct);return -NF_DROP ; } ct->proto.tcp.last_index = index;
@@ -961,8 +959,7 @@ static int tcp_packet(struct nf_conn *ct,problem case, so we can delete the conntrack immediately. --RR */ if (th->rst) { -if (del_timer (&ct->timeout)) - ct->timeout.function ((unsigned long )ct); +nf_ct_kill (ct);return NF_ACCEPT ; } } else if (!test_bit(IPS_ASSURED_BIT, &ct->status)
netfilter 08/11: nf_conntrack: properly account terminating packets
In reply to Patrick McHardynetfilter: nf_conntrack: properly account terminating packets
Currently the last packet of a connection isn't accounted when its causing abnormal termination.
Introduces nf_ct_kill_acct() which increments the accounting counters on conntrack kill. The new function was necessary, because there are calls to nf_ct_kill() which don't need accounting:
nf_conntrack_proto_tcp.c line ~847:
Kills ct and returns NF_REPEAT. We don't want to count twice.
nf_conntrack_proto_tcp.c line ~880:
Kills ct and returns NF_DROP. I think we don't want to count dropped packets.
nf_conntrack_netlink.c line ~824:
As far as I can see ctnetlink_del_conntrack() is used to destroy a conntrack on behalf of the user. There is an sk_buff, but I don't think this is an actual packet. Incrementing counters here is therefore not desired.
---
commit 1b6e77c24870f9932eacedb0e59a3182711b1980
tree 1984675860a2c0a6be95cc2a30b07d84c1f4571c
parent 0c160731721ea46fa0496d32b9e3816a149d7420
author Fabian Hugelshofer <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200
include/net/netfilter/nf_conntrack.h | 19 ++++++++++++++++++- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 2 +- net/netfilter/nf_conntrack_core.c | 16 ++++++++++++++-- net/netfilter/nf_conntrack_proto_dccp.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-)
include/net/netfilter/nf_conntrack.h +18 -1
@@ -223,7 +223,24 @@ static inline void nf_ct_refresh(struct nf_conn *ct,__nf_ct_refresh_acct (ct,0 , skb, extra_jiffies,0 ); } -extern void nf_ct_kill (struct nf_conn *ct); +extern void __nf_ct_kill_acct (struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +const struct sk_buff *skb, +int do_acct); + +/* kill conntrack and do accounting */ +static inline void nf_ct_kill_acct (struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +const struct sk_buff *skb) +{ +__nf_ct_kill_acct (ct, ctinfo, skb,1 ); +} + +/* kill conntrack without accounting */ +static inline void nf_ct_kill (struct nf_conn *ct) +{ +__nf_ct_kill_acct (ct,0 ,NULL ,0 ); +}/* These are for NAT. Icky. */ /* Update TCP window tracking data when NAT mangles the packet */
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -88,7 +88,7 @@ static int icmp_packet(struct nf_conn *ct,(theoretically possible with SMP) */ if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) {if (atomic_dec_and_test (&ct->proto.icmp.count)) -nf_ct_kill (ct); +nf_ct_kill_acct (ct, ctinfo, skb); }else {atomic_inc (&ct->proto.icmp.count);nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb);
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -90,7 +90,7 @@ static int icmpv6_packet(struct nf_conn *ct,(theoretically possible with SMP) */ if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) {if (atomic_dec_and_test (&ct->proto.icmp.count)) -nf_ct_kill (ct); +nf_ct_kill_acct (ct, ctinfo, skb); }else {atomic_inc (&ct->proto.icmp.count);nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb);
net/netfilter/nf_conntrack_core.c +14 -2
@@ -848,12 +848,24 @@ acct: }EXPORT_SYMBOL_GPL (__nf_ct_refresh_acct); -void nf_ct_kill (struct nf_conn *ct) +void __nf_ct_kill_acct (struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +const struct sk_buff *skb, +int do_acct) { +#ifdef CONFIG_NF_CT_ACCT +if (do_acct) { +spin_lock_bh (&nf_conntrack_lock); + ct->counters[CTINFO2DIR (ctinfo)].packets++; + ct->counters[CTINFO2DIR (ctinfo)].bytes += + skb->len -skb_network_offset (skb); +spin_unlock_bh (&nf_conntrack_lock); + } +#endif if (del_timer (&ct->timeout)) ct->timeout.function ((unsigned long )ct); } -EXPORT_SYMBOL_GPL (nf_ct_kill); +EXPORT_SYMBOL_GPL (__nf_ct_kill_acct);#if defined(CONFIG_NF_CT_NETLINK ) || defined(CONFIG_NF_CT_NETLINK_MODULE )
net/netfilter/nf_conntrack_proto_dccp.c +1 -1
@@ -475,7 +475,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,if (type ==DCCP_PKT_RESET && !test_bit (IPS_SEEN_REPLY_BIT , &ct->status)) {/* Tear down connection immediately if only reply is a RESET */ -nf_ct_kill (ct); +nf_ct_kill_acct (ct, ctinfo, skb);return NF_ACCEPT ; }
net/netfilter/nf_conntrack_proto_tcp.c +1 -1
@@ -959,7 +959,7 @@ static int tcp_packet(struct nf_conn *ct,problem case, so we can delete the conntrack immediately. --RR */ if (th->rst) { -nf_ct_kill (ct); +nf_ct_kill_acct (ct, ctinfo, skb);return NF_ACCEPT ; } } else if (!test_bit(IPS_ASSURED_BIT, &ct->status)
netfilter 09/11: ctnetlink: include conntrack status in destroy event message
In reply to Patrick McHardynetfilter: ctnetlink: include conntrack status in destroy event message
When a conntrack is destroyed, the connection status does not get exported to netlink. I don't see a reason for not doing so. This patch exports the status on all conntrack events.
---
commit ddafe2d8dec88f9fb0c9de1f9eea0dd994d97a95
tree 671e33e68095744e53d9592395c0f3b4d5cf9692
parent 1b6e77c24870f9932eacedb0e59a3182711b1980
author Fabian Hugelshofer <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200
net/netfilter/nf_conntrack_netlink.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_netlink.c +3 -3
@@ -475,14 +475,14 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,if (ctnetlink_dump_id (skb, ct) <0 ) goto nla_put_failure; +if (ctnetlink_dump_status (skb, ct) <0 ) + goto nla_put_failure; +if (events &IPCT_DESTROY ) {if (ctnetlink_dump_counters (skb, ct,IP_CT_DIR_ORIGINAL ) <0 ||ctnetlink_dump_counters (skb, ct,IP_CT_DIR_REPLY ) <0 ) goto nla_put_failure; }else { -if (ctnetlink_dump_status (skb, ct) <0 ) - goto nla_put_failure; -if (ctnetlink_dump_timeout (skb, ct) <0 ) goto nla_put_failure;
netfilter 10/11: nf_conntrack: remove unnecessary function declaration
In reply to Patrick McHardynetfilter: nf_conntrack: remove unnecessary function declaration
This patch removes nf_ct_ipv4_ct_gather_frags() method declaration from include/net/netfilter/ipv4/nf_conntrack_ipv4.h, since it is unused in the Linux kernel.
---
commit e0f7130611c678e99a237ecdfb065daae1e677bf
tree 53fdf07e06b6742d03b53d0be0b3aeb5a0f81228
parent ddafe2d8dec88f9fb0c9de1f9eea0dd994d97a95
author Rami Rosen <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200
include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
include/net/netfilter/ipv4/nf_conntrack_ipv4.h +0 -2
@@ -9,8 +9,6 @@#ifndef _NF_CONNTRACK_IPV4_H#define _NF_CONNTRACK_IPV4_H -/* Returns new sk_buff, or NULL */ -struct sk_buff *nf_ct_ipv4_ct_gather_frags (struct sk_buff *skb);extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
netfilter 11/11: {ip,ip6,nfnetlink}_queue: misc cleanups
In reply to Patrick McHardynetfilter: {ip,ip6,nfnetlink}_queue: misc cleanups
- No need to perform data_len = 0 in the switch command, since data_len is initialized to 0 in the beginning of the ipq_build_packet_message() method.
- {ip,ip6}_queue: We can reach nlmsg_failure only from one place; skb is sure to be NULL when getting there; since skb is NULL, there is no need to check this fact and call kfree_skb().
---
commit fd84cffdd4024f74affc3ae7ee4026d754713c36
tree ffd5c770634c694435c555408d3a14c929a7614d
parent e0f7130611c678e99a237ecdfb065daae1e677bf
author Rami Rosen <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200 committer Patrick McHardy <[email protected]> Fri, 06 Jun 2008 17:11:05 +0200
net/ipv4/netfilter/ip_queue.c | 3 --- net/ipv6/netfilter/ip6_queue.c | 3 --- net/netfilter/nfnetlink_queue.c | 1 - 3 files changed, 0 insertions(+), 7 deletions(-)
net/ipv4/netfilter/ip_queue.c +0 -3
@@ -156,7 +156,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)case IPQ_COPY_META :case IPQ_COPY_NONE : size =NLMSG_SPACE (sizeof (*pmsg)); - data_len =0 ;break ;case IPQ_COPY_PACKET :
@@ -224,8 +223,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)return skb; nlmsg_failure: -if (skb) -kfree_skb (skb); *errp = -EINVAL ;printk (KERN_ERR "ip_queue: error creating packet message\n" );return NULL ;
net/ipv6/netfilter/ip6_queue.c +0 -3
@@ -159,7 +159,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)case IPQ_COPY_META :case IPQ_COPY_NONE : size =NLMSG_SPACE (sizeof (*pmsg)); - data_len =0 ;break ;case IPQ_COPY_PACKET :
@@ -226,8 +225,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)return skb; nlmsg_failure: -if (skb) -kfree_skb (skb); *errp = -EINVAL ;printk (KERN_ERR "ip6_queue: error creating packet message\n" );return NULL ;
net/netfilter/nfnetlink_queue.c +0 -1
@@ -243,7 +243,6 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,switch ((enum nfqnl_config_mode )queue->copy_mode) {case NFQNL_COPY_META :case NFQNL_COPY_NONE : - data_len =0 ;break ;case NFQNL_COPY_PACKET :
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Fri, 6 Jun 2008 17:17:40 +0200 (MEST)
Quoted 4 lines
Hi Dave,
following is a first netfilter update for net-next-2.6.git, including:
Quoted 8 lines
- conntrack accounting fixes
- a new IPv4/IPv6 security table for SELinux
- IPv6 support for ebtables
- ctnetlink cleanups and SCTP support
- removal of ksize "abuse" inct_extend
- minor queuing cleanupsPlease apply, thanks.
All applied and pushed out to net-next-2.6, thanks!