x_tables, take 5 (Final Review)
Subsystems (4)
PATCH 1/1 x_tables, take 5 (Final Review)
Hi!
It's been some time since I last released a version of the x_tables patch. This is mainly due to the reason that 2.6.15 has only been released recently, and x_tables was clearly 2.6.16 work.
I've modified nfsim and the nfsim-testsuite to work with an x_tables kernel, and all tests now pass without any problem (using an old iptables binary that was compiled against a non-xtables kernel). This, in addition to my manual tests, give me enough confidence that I didn't break something significant.
I'm planning to submit x_tables eatly next week, so this is assumed to be the final review phase.
So if you have any issues, please comment now before it's too late :)
Cheers,
Harald
Signature · 5 lines
- Harald Welte <[email protected]> http://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
include/linux/netfilter/nf_conntrack_common.h +3 -0
@@ -154,6 +154,9 @@ struct ip_conntrack_statunsigned int expect_delete; }; +/* call to create an explicit dependency on nf_conntrack. */ +extern void need_conntrack (void ); +#endif /* __KERNEL__ */ #endif /* _NF_CONNTRACK_COMMON_H */
include/linux/netfilter/x_tables.h new file +224 -0
224 lines not on this page · raw message
include/linux/netfilter/xt_CLASSIFY.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _XT_CLASSIFY_H +#define _XT_CLASSIFY_H + +struct xt_classify_target_info { +u_int32_t priority; +}; + +#endif /*_XT_CLASSIFY_H */
include/linux/netfilter/xt_CONNMARK.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _XT_CONNMARK_H_target +#define _XT_CONNMARK_H_target + +/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> +* by Henrik Nordstrom <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +enum { +XT_CONNMARK_SET =0 , +XT_CONNMARK_SAVE , +XT_CONNMARK_RESTORE +}; + +struct xt_connmark_target_info { +unsigned long mark; +unsigned long mask; +u_int8_t mode; +}; + +#endif /*_XT_CONNMARK_H_target*/
include/linux/netfilter/xt_MARK.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef _XT_MARK_H_target +#define _XT_MARK_H_target + +/* Version 0 */ +struct xt_mark_target_info { +unsigned long mark; +}; + +/* Version 1 */ +enum { +XT_MARK_SET =0 , +XT_MARK_AND , +XT_MARK_OR , +}; + +struct xt_mark_target_info_v1 { +unsigned long mark; +u_int8_t mode; +}; + +#endif /*_XT_MARK_H_target */
include/linux/netfilter/xt_NFQUEUE.h new file +16 -0
@@ -0,0 +1,16 @@ +/* iptables module for using NFQUEUE mechanism +* +* (C) 2005 Harald Welte <[email protected]> +* +* This software is distributed under GNU GPL v2, 1991 +* +*/ +#ifndef _XT_NFQ_TARGET_H +#define _XT_NFQ_TARGET_H + +/* target info */ +struct xt_NFQ_info { +u_int16_t queuenum; +}; + +#endif /* _XT_NFQ_TARGET_H */
include/linux/netfilter/xt_comment.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _XT_COMMENT_H +#define _XT_COMMENT_H + +#define XT_MAX_COMMENT_LEN 256 + +struct xt_comment_info { +unsigned char comment[XT_MAX_COMMENT_LEN ]; +}; + +#endif /* XT_COMMENT_H */
include/linux/netfilter/xt_connbytes.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _XT_CONNBYTES_H +#define _XT_CONNBYTES_H + +enum xt_connbytes_what { +XT_CONNBYTES_PKTS , +XT_CONNBYTES_BYTES , +XT_CONNBYTES_AVGPKT , +}; + +enum xt_connbytes_direction { +XT_CONNBYTES_DIR_ORIGINAL , +XT_CONNBYTES_DIR_REPLY , +XT_CONNBYTES_DIR_BOTH , +}; + +struct xt_connbytes_info +{ +struct { +aligned_u64 from;/* count to be matched */ +aligned_u64 to;/* count to be matched */ + } count; +u_int8_t what;/* ipt_connbytes_what */ +u_int8_t direction;/* ipt_connbytes_direction */ +}; +#endif
include/linux/netfilter/xt_connmark.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef _XT_CONNMARK_H +#define _XT_CONNMARK_H + +/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> +* by Henrik Nordstrom <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +struct xt_connmark_info { +unsigned long mark, mask; +u_int8_t invert; +}; + +#endif /*_XT_CONNMARK_H*/
include/linux/netfilter/xt_conntrack.h new file +63 -0
63 lines not on this page · raw message
include/linux/netfilter/xt_dccp.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _XT_DCCP_H_ +#define _XT_DCCP_H_ + +#define XT_DCCP_SRC_PORTS 0x01 +#define XT_DCCP_DEST_PORTS 0x02 +#define XT_DCCP_TYPE 0x04 +#define XT_DCCP_OPTION 0x08 + +#define XT_DCCP_VALID_FLAGS 0x0f + +struct xt_dccp_info { +u_int16_t dpts[2 ];/* Min, Max */ +u_int16_t spts[2 ];/* Min, Max */ + +u_int16_t flags; +u_int16_t invflags; + +u_int16_t typemask; +u_int8_t option; +}; + +#endif /* _XT_DCCP_H_ */ +
include/linux/netfilter/xt_helper.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _XT_HELPER_H +#define _XT_HELPER_H + +struct xt_helper_info { +int invert; +char name[30 ]; +}; +#endif /* _XT_HELPER_H */
include/linux/netfilter/xt_length.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _XT_LENGTH_H +#define _XT_LENGTH_H + +struct xt_length_info { +u_int16_t min, max; +u_int8_t invert; +}; + +#endif /*_XT_LENGTH_H*/
include/linux/netfilter/xt_limit.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef _XT_RATE_H +#define _XT_RATE_H + +/* timings are in milliseconds. */ +#define XT_LIMIT_SCALE 10000 + +/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 +seconds, or one every 59 hours. */ +struct xt_rateinfo { +u_int32_t avg;/* Average secs between packets * scale */ +u_int32_t burst;/* Period multiplier for upper limit. */ + +/* Used internally by the kernel */ +unsigned long prev; +u_int32_t credit; +u_int32_t credit_cap, cost; + +/* Ugly, ugly fucker. */ +struct xt_rateinfo *master; +}; +#endif /*_XT_RATE_H*/
include/linux/netfilter/xt_mac.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _XT_MAC_H +#define _XT_MAC_H + +struct xt_mac_info { +unsigned char srcaddr[ETH_ALEN ]; +int invert; +}; +#endif /*_XT_MAC_H*/
include/linux/netfilter/xt_mark.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _XT_MARK_H +#define _XT_MARK_H + +struct xt_mark_info { +unsigned long mark, mask; +u_int8_t invert; +}; + +#endif /*_XT_MARK_H*/
include/linux/netfilter/xt_owner.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef _XT_OWNER_H +#define _XT_OWNER_H + +/* match and invert flags */ +#define XT_OWNER_UID 0x01 +#define XT_OWNER_GID 0x02 +#define XT_OWNER_PID 0x04 +#define XT_OWNER_SID 0x08 +#define XT_OWNER_COMM 0x10 + +struct xt_owner_info { +uid_t uid; +gid_t gid; +pid_t pid; +pid_t sid; +char comm[16 ]; +u_int8_t match, invert;/* flags */ +}; + +#endif /*_XT_OWNER_H*/
include/linux/netfilter/xt_physdev.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef _XT_PHYSDEV_H +#define _XT_PHYSDEV_H + +#ifdef __KERNEL__ +#include <linux/if.h> +#endif + +#define XT_PHYSDEV_OP_IN 0x01 +#define XT_PHYSDEV_OP_OUT 0x02 +#define XT_PHYSDEV_OP_BRIDGED 0x04 +#define XT_PHYSDEV_OP_ISIN 0x08 +#define XT_PHYSDEV_OP_ISOUT 0x10 +#define XT_PHYSDEV_OP_MASK (0x20 - 1) + +struct xt_physdev_info { +char physindev[IFNAMSIZ ]; +char in_mask[IFNAMSIZ ]; +char physoutdev[IFNAMSIZ ]; +char out_mask[IFNAMSIZ ]; +u_int8_t invert; +u_int8_t bitmask; +}; + +#endif /*_XT_PHYSDEV_H*/
include/linux/netfilter/xt_pkttype.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _XT_PKTTYPE_H +#define _XT_PKTTYPE_H + +struct xt_pkttype_info { +int pkttype; +int invert; +}; +#endif /*_XT_PKTTYPE_H*/
include/linux/netfilter/xt_realm.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _XT_REALM_H +#define _XT_REALM_H + +struct xt_realm_info { +u_int32_t id; +u_int32_t mask; +u_int8_t invert; +}; + +#endif /* _XT_REALM_H */
include/linux/netfilter/xt_sctp.h new file +107 -0
107 lines not on this page · raw message
include/linux/netfilter/xt_state.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _XT_STATE_H +#define _XT_STATE_H + +#define XT_STATE_BIT (ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) +#define XT_STATE_INVALID (1 << 0) + +#define XT_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 1)) + +struct xt_state_info +{ +unsigned int statemask; +}; +#endif /*_XT_STATE_H*/
include/linux/netfilter/xt_string.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef _XT_STRING_H +#define _XT_STRING_H + +#define XT_STRING_MAX_PATTERN_SIZE 128 +#define XT_STRING_MAX_ALGO_NAME_SIZE 16 + +struct xt_string_info +{ +u_int16_t from_offset; +u_int16_t to_offset; +char algo[XT_STRING_MAX_ALGO_NAME_SIZE ]; +char pattern[XT_STRING_MAX_PATTERN_SIZE ]; +u_int8_t patlen; +u_int8_t invert; +struct ts_config __attribute__((aligned (8 ))) *config; +}; + +#endif /*_XT_STRING_H*/
include/linux/netfilter/xt_tcpmss.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _XT_TCPMSS_MATCH_H +#define _XT_TCPMSS_MATCH_H + +struct xt_tcpmss_match_info { +u_int16_t mss_min, mss_max; +u_int8_t invert; +}; + +#endif /*_XT_TCPMSS_MATCH_H*/
include/linux/netfilter/xt_tcpudp.h new file +36 -0
@@ -0,0 +1,36 @@ +#ifndef _XT_TCPUDP_H +#define _XT_TCPUDP_H + +/* TCP matching stuff */ +struct xt_tcp +{ +u_int16_t spts[2 ];/* Source port range. */ +u_int16_t dpts[2 ];/* Destination port range. */ +u_int8_t option;/* TCP Option iff non-zero*/ +u_int8_t flg_mask;/* TCP flags mask byte */ +u_int8_t flg_cmp;/* TCP flags compare byte */ +u_int8_t invflags;/* Inverse flags */ +}; + +/* Values for "inv" field in struct ipt_tcp. */ +#define XT_TCP_INV_SRCPT 0x01/* Invert the sense of source ports. */ +#define XT_TCP_INV_DSTPT 0x02/* Invert the sense of dest ports. */ +#define XT_TCP_INV_FLAGS 0x04/* Invert the sense of TCP flags. */ +#define XT_TCP_INV_OPTION 0x08/* Invert the sense of option test. */ +#define XT_TCP_INV_MASK 0x0F/* All possible flags. */ + +/* UDP matching stuff */ +struct xt_udp +{ +u_int16_t spts[2 ];/* Source port range. */ +u_int16_t dpts[2 ];/* Destination port range. */ +u_int8_t invflags;/* Inverse flags */ +}; + +/* Values for "invflags" field in struct ipt_udp. */ +#define XT_UDP_INV_SRCPT 0x01/* Invert the sense of source ports. */ +#define XT_UDP_INV_DSTPT 0x02/* Invert the sense of dest ports. */ +#define XT_UDP_INV_MASK 0x03/* All possible flags. */ + + +#endif
include/linux/netfilter_arp/arp_tables.h +26 -99
180 lines not on this page · raw message
include/linux/netfilter_ipv4/ip_conntrack.h +0 -3
@@ -199,9 +199,6 @@ ip_conntrack_put(struct ip_conntrack *ctnf_conntrack_put (&ct->ct_general); } -/* call to create an explicit dependency on ip_conntrack. */ -extern void need_ip_conntrack (void ); -extern int invert_tuplepr (struct ip_conntrack_tuple *inverse,const struct ip_conntrack_tuple *orig);
include/linux/netfilter_ipv4/ip_tables.h +52 -175
298 lines not on this page · raw message
include/linux/netfilter_ipv4/ipt_CLASSIFY.h +2 -3
@@ -1,8 +1,7 @@#ifndef _IPT_CLASSIFY_H#define _IPT_CLASSIFY_H -struct ipt_classify_target_info { -u_int32_t priority; -}; +#include <linux/netfilter/xt_CLASSIFY.h> +#define ipt_classify_target_info xt_classify_target_info#endif /*_IPT_CLASSIFY_H */
include/linux/netfilter_ipv4/ipt_CONNMARK.h +5 -11
@@ -9,17 +9,11 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ +#include <linux/netfilter/xt_CONNMARK.h> +#define IPT_CONNMARK_SET XT_CONNMARK_SET +#define IPT_CONNMARK_SAVE XT_CONNMARK_SAVE +#define IPT_CONNMARK_RESTORE XT_CONNMARK_RESTORE -enum { -IPT_CONNMARK_SET =0 , -IPT_CONNMARK_SAVE , -IPT_CONNMARK_RESTORE -}; - -struct ipt_connmark_target_info { -unsigned long mark; -unsigned long mask; -u_int8_t mode; -}; +#define ipt_connmark_target_info xt_connmark_target_info#endif /*_IPT_CONNMARK_H_target*/
include/linux/netfilter_ipv4/ipt_MARK.h +11 -13
@@ -1,20 +1,18 @@#ifndef _IPT_MARK_H_target#define _IPT_MARK_H_target +/* Backwards compatibility for old userspace */ + +#include <linux/netfilter/xt_MARK.h> +/* Version 0 */ -struct ipt_mark_target_info { -unsigned long mark; -}; +#define ipt_mark_target_info xt_mark_target_info/* Version 1 */ -enum { -IPT_MARK_SET =0 , -IPT_MARK_AND , -IPT_MARK_OR -}; - -struct ipt_mark_target_info_v1 { -unsigned long mark; -u_int8_t mode; -}; +#define IPT_MARK_SET XT_MARK_SET +#define IPT_MARK_AND XT_MARK_AND +#define IPT_MARK_OR XT_MARK_OR + +#define ipt_mark_target_info_v1 xt_mark_target_info_v1 +#endif /*_IPT_MARK_H_target*/
include/linux/netfilter_ipv4/ipt_NFQUEUE.h +4 -4
@@ -8,9 +8,9 @@#ifndef _IPT_NFQ_TARGET_H#define _IPT_NFQ_TARGET_H -/* target info */ -struct ipt_NFQ_info { -u_int16_t queuenum; -}; +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_NFQUEUE.h> + +#define ipt_NFQ_info xt_NFQ_info#endif /* _IPT_DSCP_TARGET_H */
include/linux/netfilter_ipv4/ipt_comment.h +4 -4
@@ -1,10 +1,10 @@#ifndef _IPT_COMMENT_H#define _IPT_COMMENT_H -#define IPT_MAX_COMMENT_LEN 256 +#include <linux/netfilter/xt_comment.h> -struct ipt_comment_info { -unsigned char comment[IPT_MAX_COMMENT_LEN ]; -}; +#define IPT_MAX_COMMENT_LEN XT_MAX_COMMENT_LEN + +#define ipt_comment_info xt_comment_info#endif /* _IPT_COMMENT_H */
include/linux/netfilter_ipv4/ipt_connbytes.h +12 -19
@@ -1,25 +1,18 @@#ifndef _IPT_CONNBYTES_H#define _IPT_CONNBYTES_H -enum ipt_connbytes_what { -IPT_CONNBYTES_PKTS , -IPT_CONNBYTES_BYTES , -IPT_CONNBYTES_AVGPKT , -}; +#include <net/netfilter/xt_connbytes.h> +#define ipt_connbytes_what xt_connbytes_what -enum ipt_connbytes_direction { -IPT_CONNBYTES_DIR_ORIGINAL , -IPT_CONNBYTES_DIR_REPLY , -IPT_CONNBYTES_DIR_BOTH , -}; +#define IPT_CONNBYTES_PKTS XT_CONNBYTES_PACKETS +#define IPT_CONNBYTES_BYTES XT_CONNBYTES_BYTES +#define IPT_CONNBYTES_AVGPKT XT_CONNBYTES_AVGPKT + +#define ipt_connbytes_direction xt_connbytes_direction +#define IPT_CONNBYTES_DIR_ORIGINAL XT_CONNBYTES_DIR_ORIGINAL +#define IPT_CONNBYTES_DIR_REPLY XT_CONNBYTES_DIR_REPLY +#define IPT_CONNBYTES_DIR_BOTH XT_CONNBYTES_DIR_BOTH + +#define ipt_connbytes_info xt_connbytes_info -struct ipt_connbytes_info -{ -struct { -aligned_u64 from;/* count to be matched */ -aligned_u64 to;/* count to be matched */ - } count; -u_int8_t what;/* ipt_connbytes_what */ -u_int8_t direction;/* ipt_connbytes_direction */ -};#endif
include/linux/netfilter_ipv4/ipt_connmark.h +2 -13
@@ -1,18 +1,7 @@#ifndef _IPT_CONNMARK_H#define _IPT_CONNMARK_H -/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> -* by Henrik Nordstrom <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -*/ - -struct ipt_connmark_info { -unsigned long mark, mask; -u_int8_t invert; -}; +#include <linux/netfilter/xt_connmark.h> +#define ipt_connmark_info xt_connmark_info#endif /*_IPT_CONNMARK_H*/
include/linux/netfilter_ipv4/ipt_conntrack.h +16 -48
72 lines not on this page · raw message
include/linux/netfilter_ipv4/ipt_dccp.h +7 -15
@@ -1,23 +1,15 @@#ifndef _IPT_DCCP_H_#define _IPT_DCCP_H_ -#define IPT_DCCP_SRC_PORTS 0x01 -#define IPT_DCCP_DEST_PORTS 0x02 -#define IPT_DCCP_TYPE 0x04 -#define IPT_DCCP_OPTION 0x08 +#include <linux/netfilter/xt_dccp.h> +#define IPT_DCCP_SRC_PORTS XT_DCCP_SRC_PORTS +#define IPT_DCCP_DEST_PORTS XT_DCCP_DEST_PORTS +#define IPT_DCCP_TYPE XT_DCCP_TYPE +#define IPT_DCCP_OPTION XT_DCCP_OPTION -#define IPT_DCCP_VALID_FLAGS 0x0f +#define IPT_DCCP_VALID_FLAGS XT_DCCP_VALID_FLAGS -struct ipt_dccp_info { -u_int16_t dpts[2 ];/* Min, Max */ -u_int16_t spts[2 ];/* Min, Max */ - -u_int16_t flags; -u_int16_t invflags; - -u_int16_t typemask; -u_int8_t option; -}; +#define ipt_dccp_info xt_dccp_info#endif /* _IPT_DCCP_H_ */
include/linux/netfilter_ipv4/ipt_helper.h +3 -4
@@ -1,8 +1,7 @@#ifndef _IPT_HELPER_H#define _IPT_HELPER_H -struct ipt_helper_info { -int invert; -char name[30 ]; -}; +#include <linux/netfilter/xt_helper.h> +#define ipt_helper_info xt_helper_info +#endif /* _IPT_HELPER_H */
include/linux/netfilter_ipv4/ipt_length.h +2 -4
@@ -1,9 +1,7 @@#ifndef _IPT_LENGTH_H#define _IPT_LENGTH_H -struct ipt_length_info { -u_int16_t min, max; -u_int8_t invert; -}; +#include <linux/netfilter/xt_length.h> +#define ipt_length_info xt_length_info#endif /*_IPT_LENGTH_H*/
include/linux/netfilter_ipv4/ipt_limit.h +3 -16
@@ -1,21 +1,8 @@#ifndef _IPT_RATE_H#define _IPT_RATE_H -/* timings are in milliseconds. */ -#define IPT_LIMIT_SCALE 10000 +#include <linux/netfilter/xt_limit.h> +#define IPT_LIMIT_SCALE XT_LIMIT_SCALE +#define ipt_rateinfo xt_rateinfo -/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 -seconds, or one every 59 hours. */ -struct ipt_rateinfo { -u_int32_t avg;/* Average secs between packets * scale */ -u_int32_t burst;/* Period multiplier for upper limit. */ - -/* Used internally by the kernel */ -unsigned long prev; -u_int32_t credit; -u_int32_t credit_cap, cost; - -/* Ugly, ugly fucker. */ -struct ipt_rateinfo *master; -};#endif /*_IPT_RATE_H*/
include/linux/netfilter_ipv4/ipt_mac.h +3 -4
@@ -1,8 +1,7 @@#ifndef _IPT_MAC_H#define _IPT_MAC_H -struct ipt_mac_info { -unsigned char srcaddr[ETH_ALEN ]; -int invert; -}; +#include <linux/netfilter/xt_mac.h> +#define ipt_mac_info xt_mac_info +#endif /*_IPT_MAC_H*/
include/linux/netfilter_ipv4/ipt_mark.h +4 -4
@@ -1,9 +1,9 @@#ifndef _IPT_MARK_H#define _IPT_MARK_H -struct ipt_mark_info { -unsigned long mark, mask; -u_int8_t invert; -}; +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_mark.h> + +#define ipt_mark_info xt_mark_info#endif /*_IPT_MARK_H*/
include/linux/netfilter_ipv4/ipt_owner.h +9 -14
@@ -1,20 +1,15 @@#ifndef _IPT_OWNER_H#define _IPT_OWNER_H -/* match and invert flags */ -#define IPT_OWNER_UID 0x01 -#define IPT_OWNER_GID 0x02 -#define IPT_OWNER_PID 0x04 -#define IPT_OWNER_SID 0x08 -#define IPT_OWNER_COMM 0x10 +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_owner.h> -struct ipt_owner_info { -uid_t uid; -gid_t gid; -pid_t pid; -pid_t sid; -char comm[16 ]; -u_int8_t match, invert;/* flags */ -}; +#define IPT_OWNER_UID XT_OWNER_UID +#define IPT_OWNER_GID XT_OWNER_GID +#define IPT_OWNER_PID XT_OWNER_PID +#define IPT_OWNER_SID XT_OWNER_SID +#define IPT_OWNER_COMM XT_OWNER_COMM + +#define ipt_owner_info xt_owner_info#endif /*_IPT_OWNER_H*/
include/linux/netfilter_ipv4/ipt_physdev.h +10 -17
@@ -1,24 +1,17 @@#ifndef _IPT_PHYSDEV_H#define _IPT_PHYSDEV_H -#ifdef __KERNEL__ -#include <linux/if.h> -#endif +/* Backwards compatibility for old userspace */ -#define IPT_PHYSDEV_OP_IN 0x01 -#define IPT_PHYSDEV_OP_OUT 0x02 -#define IPT_PHYSDEV_OP_BRIDGED 0x04 -#define IPT_PHYSDEV_OP_ISIN 0x08 -#define IPT_PHYSDEV_OP_ISOUT 0x10 -#define IPT_PHYSDEV_OP_MASK (0x20 - 1) +#include <linux/netfilter/xt_physdev.h> -struct ipt_physdev_info { -char physindev[IFNAMSIZ ]; -char in_mask[IFNAMSIZ ]; -char physoutdev[IFNAMSIZ ]; -char out_mask[IFNAMSIZ ]; -u_int8_t invert; -u_int8_t bitmask; -}; +#define IPT_PHYSDEV_OP_IN XT_PHYSDEV_OP_IN +#define IPT_PHYSDEV_OP_OUT XT_PHYSDEV_OP_OUT +#define IPT_PHYSDEV_OP_BRIDGED XT_PHYSDEV_OP_BRIDGED +#define IPT_PHYSDEV_OP_ISIN XT_PHYSDEV_OP_ISIN +#define IPT_PHYSDEV_OP_ISOUT XT_PHYSDEV_OP_ISOUT +#define IPT_PHYSDEV_OP_MASK XT_PHYSDEV_OP_MASK + +#define ipt_physdev_info xt_physdev_info#endif /*_IPT_PHYSDEV_H*/
include/linux/netfilter_ipv4/ipt_pkttype.h +3 -4
@@ -1,8 +1,7 @@#ifndef _IPT_PKTTYPE_H#define _IPT_PKTTYPE_H -struct ipt_pkttype_info { -int pkttype; -int invert; -}; +#include <linux/netfilter/xt_pkttype.h> +#define ipt_pkttype_info xt_pkttype_info +#endif /*_IPT_PKTTYPE_H*/
include/linux/netfilter_ipv4/ipt_realm.h +2 -5
@@ -1,10 +1,7 @@#ifndef _IPT_REALM_H#define _IPT_REALM_H -struct ipt_realm_info { -u_int32_t id; -u_int32_t mask; -u_int8_t invert; -}; +#include <linux/netfilter/xt_realm.h> +#define ipt_realm_info xt_realm_info#endif /* _IPT_REALM_H */
include/linux/netfilter_ipv4/ipt_state.h +9 -7
@@ -1,13 +1,15 @@#ifndef _IPT_STATE_H#define _IPT_STATE_H -#define IPT_STATE_BIT (ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) -#define IPT_STATE_INVALID (1 << 0) +/* Backwards compatibility for old userspace */ -#define IPT_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 1)) +#include <linux/netfilter/xt_state.h> + +#define IPT_STATE_BIT XT_STATE_BIT +#define IPT_STATE_INVALID XT_STATE_INVALID + +#define IPT_STATE_UNTRACKED XT_STATE_UNTRACKED + +#define ipt_state_info xt_state_info -struct ipt_state_info -{ -unsigned int statemask; -};#endif /*_IPT_STATE_H*/
include/linux/netfilter_ipv4/ipt_string.h +4 -12
@@ -1,18 +1,10 @@#ifndef _IPT_STRING_H#define _IPT_STRING_H -#define IPT_STRING_MAX_PATTERN_SIZE 128 -#define IPT_STRING_MAX_ALGO_NAME_SIZE 16 +#include <linux/netfilter/xt_string.h> -struct ipt_string_info -{ -u_int16_t from_offset; -u_int16_t to_offset; -char algo[IPT_STRING_MAX_ALGO_NAME_SIZE ]; -char pattern[IPT_STRING_MAX_PATTERN_SIZE ]; -u_int8_t patlen; -u_int8_t invert; -struct ts_config __attribute__((aligned (8 ))) *config; -}; +#define IPT_STRING_MAX_PATTERN_SIZE XT_STRING_MAX_PATTERN_SIZE +#define IPT_STRING_MAX_ALGO_NAME_SIZE XT_STRING_MAX_ALGO_NAME_SIZE +#define ipt_string_info xt_string_info#endif /*_IPT_STRING_H*/
include/linux/netfilter_ipv4/ipt_tcpmss.h +2 -4
@@ -1,9 +1,7 @@#ifndef _IPT_TCPMSS_MATCH_H#define _IPT_TCPMSS_MATCH_H -struct ipt_tcpmss_match_info { -u_int16_t mss_min, mss_max; -u_int8_t invert; -}; +#include <linux/netfilter/xt_tcpmss.h> +#define ipt_tcpmss_match_info xt_tcpmss_match_info#endif /*_IPT_TCPMSS_MATCH_H*/
include/linux/netfilter_ipv6/ip6_tables.h +45 -165
277 lines not on this page · raw message
include/linux/netfilter_ipv6/ip6t_MARK.h +5 -4
@@ -1,8 +1,9 @@#ifndef _IP6T_MARK_H_target#define _IP6T_MARK_H_target -struct ip6t_mark_target_info { -unsigned long mark; -}; +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_MARK.h> -#endif /*_IPT_MARK_H_target*/ +#define ip6t_mark_target_info xt_mark_target_info + +#endif /*_IP6T_MARK_H_target*/
include/linux/netfilter_ipv6/ip6t_length.h +2 -4
@@ -1,10 +1,8 @@#ifndef _IP6T_LENGTH_H#define _IP6T_LENGTH_H -struct ip6t_length_info { -u_int16_t min, max; -u_int8_t invert; -}; +#include <linux/netfilter/xt_length.h> +#define ip6t_length_info xt_length_info#endif /*_IP6T_LENGTH_H*/
include/linux/netfilter_ipv6/ip6t_limit.h +4 -17
@@ -1,21 +1,8 @@#ifndef _IP6T_RATE_H#define _IP6T_RATE_H -/* timings are in milliseconds. */ -#define IP6T_LIMIT_SCALE 10000 +#include <linux/netfilter/xt_limit.h> +#define IP6T_LIMIT_SCALE XT_LIMIT_SCALE +#define ip6t_rateinfo xt_rateinfo -/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 -seconds, or one every 59 hours. */ -struct ip6t_rateinfo { -u_int32_t avg;/* Average secs between packets * scale */ -u_int32_t burst;/* Period multiplier for upper limit. */ - -/* Used internally by the kernel */ -unsigned long prev; -u_int32_t credit; -u_int32_t credit_cap, cost; - -/* Ugly, ugly fucker. */ -struct ip6t_rateinfo *master; -}; -#endif /*_IPT_RATE_H*/ +#endif /*_IP6T_RATE_H*/
include/linux/netfilter_ipv6/ip6t_mac.h +4 -5
@@ -1,8 +1,7 @@#ifndef _IP6T_MAC_H#define _IP6T_MAC_H -struct ip6t_mac_info { -unsigned char srcaddr[ETH_ALEN ]; -int invert; -}; -#endif /*_IPT_MAC_H*/ +#include <linux/netfilter/xt_mac.h> +#define ip6t_mac_info xt_mac_info + +#endif /*_IP6T_MAC_H*/
include/linux/netfilter_ipv6/ip6t_mark.h +4 -4
@@ -1,9 +1,9 @@#ifndef _IP6T_MARK_H#define _IP6T_MARK_H -struct ip6t_mark_info { -unsigned long mark, mask; -u_int8_t invert; -}; +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_mark.h> + +#define ip6t_mark_info xt_mark_info#endif /*_IPT_MARK_H*/
include/linux/netfilter_ipv6/ip6t_owner.h +7 -5
@@ -1,11 +1,13 @@ #ifndef _IP6T_OWNER_H #define _IP6T_OWNER_H -/* match and invert flags */ -#define IP6T_OWNER_UID 0x01 -#define IP6T_OWNER_GID 0x02 -#define IP6T_OWNER_PID 0x04 -#define IP6T_OWNER_SID 0x08 +/* Backwards compatibility for old userspace */ +#include <linux/netfilter/xt_owner.h> + +#define IP6T_OWNER_UID XT_OWNER_UID +#define IP6T_OWNER_GID XT_OWNER_GID +#define IP6T_OWNER_PID XT_OWNER_PID +#define IP6T_OWNER_SID XT_OWNER_SID struct ip6t_owner_info { uid_t uid;
include/linux/netfilter_ipv6/ip6t_physdev.h +10 -17
@@ -1,24 +1,17 @@#ifndef _IP6T_PHYSDEV_H#define _IP6T_PHYSDEV_H -#ifdef __KERNEL__ -#include <linux/if.h> -#endif +/* Backwards compatibility for old userspace */ -#define IP6T_PHYSDEV_OP_IN 0x01 -#define IP6T_PHYSDEV_OP_OUT 0x02 -#define IP6T_PHYSDEV_OP_BRIDGED 0x04 -#define IP6T_PHYSDEV_OP_ISIN 0x08 -#define IP6T_PHYSDEV_OP_ISOUT 0x10 -#define IP6T_PHYSDEV_OP_MASK (0x20 - 1) +#include <linux/netfilter/xt_physdev.h> -struct ip6t_physdev_info { -char physindev[IFNAMSIZ ]; -char in_mask[IFNAMSIZ ]; -char physoutdev[IFNAMSIZ ]; -char out_mask[IFNAMSIZ ]; -u_int8_t invert; -u_int8_t bitmask; -}; +#define IP6T_PHYSDEV_OP_IN XT_PHYSDEV_OP_IN +#define IP6T_PHYSDEV_OP_OUT XT_PHYSDEV_OP_OUT +#define IP6T_PHYSDEV_OP_BRIDGED XT_PHYSDEV_OP_BRIDGED +#define IP6T_PHYSDEV_OP_ISIN XT_PHYSDEV_OP_ISIN +#define IP6T_PHYSDEV_OP_ISOUT XT_PHYSDEV_OP_ISOUT +#define IP6T_PHYSDEV_OP_MASK XT_PHYSDEV_OP_MASK + +#define ip6t_physdev_info xt_physdev_info#endif /*_IP6T_PHYSDEV_H*/
include/net/netfilter/ipv4/nf_conntrack_ipv4.h +0 -3
@@ -37,7 +37,4 @@ struct nf_conntrack_ipv4 {struct sk_buff *nf_ct_ipv4_ct_gather_frags (struct sk_buff *skb); -/* call to create an explicit dependency on nf_conntrack_l3proto_ipv4. */ -extern void need_ip_conntrack (void ); -#endif /*_NF_CONNTRACK_IPV4_H*/
include/net/netfilter/nf_conntrack.h +0 -3
@@ -221,9 +221,6 @@ extern void nf_ct_helper_put(struct nf_cextern struct nf_conntrack_helper *__nf_conntrack_helper_find_byname (const char *name); -/* call to create an explicit dependency on nf_conntrack. */ -extern void need_nf_conntrack (void ); -extern int nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse,const struct nf_conntrack_tuple *orig);
net/bridge/netfilter/ebt_log.c +1 -0
@@ -15,6 +15,7 @@#include <linux/netfilter.h> #include <linux/module.h> #include <linux/ip.h> +#include <linux/in.h> #include <linux/if_arp.h> #include <linux/spinlock.h>
net/ipv4/netfilter/Kconfig +90 -182
392 lines not on this page · raw message
net/ipv4/netfilter/Makefile +0 -21
@@ -47,14 +47,8 @@ obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o # matches obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o -obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o obj-$(CONFIG_IP_NF_MATCH_HASHLIMIT) += ipt_hashlimit.o -obj-$(CONFIG_IP_NF_MATCH_SCTP) += ipt_sctp.o -obj-$(CONFIG_IP_NF_MATCH_DCCP) += ipt_dccp.o -obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o -obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o -obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o 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
@@ -62,39 +56,24 @@ obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_ 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 -obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_length.o obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o -obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o -obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o -obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o -obj-$(CONFIG_IP_NF_MATCH_CONNBYTES) += ipt_connbytes.o -obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o -obj-$(CONFIG_IP_NF_MATCH_REALM) += ipt_realm.o obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o -obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o -obj-$(CONFIG_IP_NF_MATCH_COMMENT) += ipt_comment.o -obj-$(CONFIG_IP_NF_MATCH_STRING) += ipt_string.o # targets obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.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 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o -obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o -obj-$(CONFIG_IP_NF_TARGET_CONNMARK) += ipt_CONNMARK.o obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o -obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o -obj-$(CONFIG_IP_NF_TARGET_NFQUEUE) += ipt_NFQUEUE.o # generic ARP tables obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
net/ipv4/netfilter/arp_tables.c +79 -365
439 lines not on this page · raw message
net/ipv4/netfilter/ip_conntrack_standalone.c +2 -2
Lines of this file are not shown. View the raw message.
net/ipv4/netfilter/ip_tables.c +95 -731
826 lines not on this page · raw message
net/ipv4/netfilter/ipt_CLASSIFY.c deleted +0 -90
90 lines not on this page · raw message
net/ipv4/netfilter/ipt_CONNMARK.c deleted +0 -122
122 lines not on this page · raw message
net/ipv4/netfilter/ipt_MARK.c deleted +0 -172
172 lines not on this page · raw message
net/ipv4/netfilter/ipt_NFQUEUE.c deleted +0 -70
70 lines not on this page · raw message
net/ipv4/netfilter/ipt_NOTRACK.c deleted +0 -76
76 lines not on this page · raw message
net/ipv4/netfilter/ipt_comment.c deleted +0 -59
59 lines not on this page · raw message
net/ipv4/netfilter/ipt_connbytes.c deleted +0 -161
161 lines not on this page · raw message
net/ipv4/netfilter/ipt_connmark.c deleted +0 -88
88 lines not on this page · raw message
net/ipv4/netfilter/ipt_conntrack.c deleted +0 -232
232 lines not on this page · raw message
net/ipv4/netfilter/ipt_dccp.c deleted +0 -176
176 lines not on this page · raw message
net/ipv4/netfilter/ipt_helper.c deleted +0 -168
168 lines not on this page · raw message
net/ipv4/netfilter/ipt_length.c deleted +0 -64
64 lines not on this page · raw message
net/ipv4/netfilter/ipt_limit.c deleted +0 -157
157 lines not on this page · raw message
net/ipv4/netfilter/ipt_mac.c deleted +0 -79
79 lines not on this page · raw message
net/ipv4/netfilter/ipt_mark.c deleted +0 -71
71 lines not on this page · raw message
net/ipv4/netfilter/ipt_physdev.c deleted +0 -135
135 lines not on this page · raw message
net/ipv4/netfilter/ipt_pkttype.c deleted +0 -70
70 lines not on this page · raw message
net/ipv4/netfilter/ipt_realm.c deleted +0 -76
76 lines not on this page · raw message
net/ipv4/netfilter/ipt_sctp.c deleted +0 -203
203 lines not on this page · raw message
net/ipv4/netfilter/ipt_state.c deleted +0 -74
74 lines not on this page · raw message
net/ipv4/netfilter/ipt_string.c deleted +0 -91
91 lines not on this page · raw message
net/ipv4/netfilter/ipt_tcpmss.c deleted +0 -127
127 lines not on this page · raw message
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -6
Lines of this file are not shown. View the raw message.
net/ipv6/netfilter/Kconfig +29 -49
78 lines not on this page · raw message
net/ipv6/netfilter/ip6_tables.c +101 -727
828 lines not on this page · raw message
net/ipv6/netfilter/ip6t_MARK.c deleted +0 -81
81 lines not on this page · raw message
net/ipv6/netfilter/ip6t_NFQUEUE.c deleted +0 -70
70 lines not on this page · raw message
net/ipv6/netfilter/ip6t_length.c deleted +0 -66
66 lines not on this page · raw message
net/ipv6/netfilter/ip6t_limit.c deleted +0 -147
147 lines not on this page · raw message
net/ipv6/netfilter/ip6t_mac.c deleted +0 -80
80 lines not on this page · raw message
net/ipv6/netfilter/ip6t_mark.c deleted +0 -66
66 lines not on this page · raw message
net/ipv6/netfilter/ip6t_physdev.c deleted +0 -135
135 lines not on this page · raw message
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +1 -7
Lines of this file are not shown. View the raw message.
net/ipv6/netfilter/nf_conntrack_reasm.c +16 -29
45 lines not on this page · raw message
net/netfilter/Kconfig +254 -0
254 lines not on this page · raw message
net/netfilter/nf_conntrack_standalone.c +2 -2
Lines of this file are not shown. View the raw message.
net/netfilter/x_tables.c new file +627 -0
627 lines not on this page · raw message
net/netfilter/xt_CLASSIFY.c new file +109 -0
109 lines not on this page · raw message
net/netfilter/xt_CONNMARK.c new file +141 -0
141 lines not on this page · raw message
net/netfilter/xt_MARK.c new file +191 -0
191 lines not on this page · raw message
net/netfilter/xt_NFQUEUE.c new file +107 -0
107 lines not on this page · raw message
net/netfilter/xt_NOTRACK.c new file +92 -0
92 lines not on this page · raw message
net/netfilter/xt_comment.c new file +80 -0
80 lines not on this page · raw message
net/netfilter/xt_connbytes.c new file +180 -0
180 lines not on this page · raw message
net/netfilter/xt_connmark.c new file +109 -0
109 lines not on this page · raw message
net/netfilter/xt_conntrack.c new file +254 -0
254 lines not on this page · raw message
net/netfilter/xt_dccp.c new file +221 -0
221 lines not on this page · raw message
net/netfilter/xt_helper.c new file +180 -0
180 lines not on this page · raw message
net/netfilter/xt_length.c new file +98 -0
98 lines not on this page · raw message
net/netfilter/xt_limit.c new file +175 -0
175 lines not on this page · raw message
net/netfilter/xt_mac.c new file +99 -0
99 lines not on this page · raw message
net/netfilter/xt_mark.c new file +91 -0
91 lines not on this page · raw message
net/netfilter/xt_owner.c new file +115 -0
115 lines not on this page · raw message
net/netfilter/xt_physdev.c new file +155 -0
155 lines not on this page · raw message
net/netfilter/xt_pkttype.c new file +82 -0
82 lines not on this page · raw message
net/netfilter/xt_realm.c new file +79 -0
79 lines not on this page · raw message
net/netfilter/xt_sctp.c new file +250 -0
250 lines not on this page · raw message
net/netfilter/xt_state.c new file +96 -0
96 lines not on this page · raw message
net/netfilter/xt_string.c new file +111 -0
111 lines not on this page · raw message
net/netfilter/xt_tcpmss.c new file +172 -0
172 lines not on this page · raw message
net/netfilter/xt_tcpudp.c new file +333 -0
333 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 12 lines · Harald Welte
Hi!
It's been some time since I last released a version of the
x_tablespatch. This is mainly due to the reason that 2.6.15 has only been released recently, andx_tableswas clearly 2.6.16 work.I've modified nfsim and the nfsim-testsuite to work with an
x_tableskernel, and all tests now pass without any problem (using an old iptables binary that was compiled against a non-xtables kernel). This, in addition to my manual tests, give me enough confidence that I didn't break something significant.
Quoted 4 lines
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
The patch looks great. It clashes with the policy match however, which is already in Dave's net-2.6 tree. I have an updated patch (trivial change) I can send you if you want.
For now just one question, I need some time to read through the patch:
static int
icmp6_checkentry(const char *tablename,
- const struct ip6t_ip6 *ipv6,
+ const void *entry,
Why do you change struct ip6t_ip6 * to void * for IPv6 matches, but keep ipt_ip for IPv4 matches? Shouldn't the old API be unaffected by moving some matches and targets to x_tables?
Quoted 10 lines · Patrick McHardy
For now just one question, I need some time to read through the patch:
static int
icmp6_checkentry(const char *tablename,net/ipv6/netfilter/ip6_tables.c +1
-1- const struct ip6t_ip6 *ipv6, + const void *entry,Why do you change struct
ip6t_ip6* to void * for IPv6 matches, but keepipt_ipfor IPv4 matches? Shouldn't the old API be unaffected by moving some matches and targets tox_tables?
OK, I answered the question myself. I somehow misread and missed that IPv4 matches are changed too and ipt_register_match is just a wrapper for xt_tables. Now I like the patch even better :)
Quoted 4 lines · Harald Welte
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
OK, here are a couple of more comments.
- xt_owner:
Unfortunately I think the owner match can't be converted to x_tables without breaking compatiblity with ip6_tables. The ip6_tables version never supported command and sid matching, so the structures differ in size and layout.
- xt_realm:
IPv6 doesn't use tclassid, so its currently useless for ip6_tables. Maybe keep it as an x_tables match and just don't register for ip6_tables.
- xt_conntrack:
The existing match is unfixable IPv4 specific because of address sizes, NAT support, ..., so it also shouldn't register for IPv6. An IPv6-capable version probably needs to duplicate most of the code, but I'd keep it as x_tables match anyway.
- assertion while adding rules
I get this assertion while adding rules:
ASSERT: CPU #0, filter comefrom(ecbaf05c) = 2
I assume its known because the place responsible for setting comefrom is surrounded by CONFIG_FIXME :) I'm going to look into fixing it.
Quoted 1 line · Patrick McHardy
OK, here are a couple of more comments.
thanks a lot.
Quoted 6 lines
-
xt_owner:Unfortunately I think the owner match can't be converted to
x_tableswithout breaking compatiblity withip6_tables. Theip6_tablesversion never supported command and sid matching, so the structures differ in size and layout.
yes. The xt_owner file is not active and I should have deleted it from the tree. As you might have noticed, ip[6]t_owner.c are still present and active. I arrived at the same conclusion as you, but just never removed the files. done now.
Quoted 5 lines
-
xt_realm:IPv6 doesn't use tclassid, so its currently useless for
ip6_tables. Maybe keep it as anx_tablesmatch and just don't register forip6_tables.
This is actually what it does. only registers for AF_INET.
Quoted 6 lines
-
xt_conntrack:The existing match is unfixable IPv4 specific because of address sizes, NAT support, ..., so it also shouldn't register for IPv6. An IPv6-capable version probably needs to duplicate most of the code, but I'd keep it as
x_tablesmatch anyway.
mh, ok, removed AF_INET registration from my tree.
Quoted 1 line
- assertion while adding rules
oops, somebody is actually still using CONFIG_NETFILTER_DEBUG...
Quoted 5 lines
I get this assertion while adding rules:
ASSERT: CPU #0, filter comefrom(ecbaf05c) = 2I assume its known because the place responsible for setting comefrom is surrounded by
CONFIG_FIXME:) I'm going to look into fixing it.
Well, if you look into that, I'll rather work on something else now. Just send me a patch :)
Signature · 5 lines
- Harald Welte <[email protected]> http://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 5 lines · Harald Welte
net/netfilter/xt_helper.c new file +0
-0
net/netfilter/xt_helper.c line 171
Quoted 9 lines
net/netfilter/xt_helper.c new file +9
-0+static int __init init (void ) +{ +int ret; +need_conntrack (); + + ret =xt_register_match (AF_INET , &helper_match); + ret =xt_register_match (AF_INET6 , &helper6_match); +} +
This function is missing a return. I also just noticed its not in the Makefile and has a typo: MODULE_ALIASS("ipt_helper");
Quoted 2 lines · Patrick McHardy
This function is missing a return. I also just noticed its not in the
Makefileand has a typo:MODULE_ALIASS("ipt_helper");
Thanks, fixed
Signature · 5 lines
- Harald Welte <[email protected]> http://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
Hi,
From: Harald Welte <[email protected]>
Date: Sun, 8 Jan 2006 22:26:20 +0100
Quoted 12 lines
Hi!
It's been some time since I last released a version of the
x_tablespatch. This is mainly due to the reason that 2.6.15 has only been released recently, andx_tableswas clearly 2.6.16 work.I've modified nfsim and the nfsim-testsuite to work with an
x_tableskernel, and all tests now pass without any problem (using an old iptables binary that was compiled against a non-xtables kernel). This, in addition to my manual tests, give me enough confidence that I didn't break something significant.
Quoted 4 lines
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
OK, I'll test it after sending this mail. Before that I have some comments about minor issues.
The dependency on NETFILTER_XTABLES is missing at config of CLASSIFY and NOTRACK. And according to your Kconfig style, the menu item for CLASSIFY should not be shown. Please apply attached patches.
I have one more comment about need_conntrack(). The kernel with x_tables patch doesn't load nf_connrack_ipv4 when user types "iptables -A INPUT -m state...". Then no packets might be untracked after that. One solution is to try load nf_conntrack_{ipv4,ipv6} and to ignore error on load, but I'm not sure that this is the best way.
-- Yasuyuki Kozakai
[NETFILTER] x_tables: CONNMARK and NOTRACK target needs NETFILTER_XTABLES
---
commit f00b6e9542a3c1d3d4cfe736d275c17826cf5d4a
tree 0f210538533e3f60416261849d2eb2a5b4c36142
parent 4f879b6981ff5d21484c20faaf7ff6730a5d494f
author Yasuyuki Kozakai <[email protected]> Mon, 09 Jan 2006 02:38:20 +0900 committer Yasuyuki Kozakai <[email protected]> Mon, 09 Jan 2006 14:37:05 +0900
net/netfilter/Kconfig | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/netfilter/Kconfig +2 -0
@@ -124,6 +124,7 @@ config NETFILTER_XT_TARGET_CLASSIFY config NETFILTER_XT_TARGET_CONNMARK tristate 'CONNMARK target support' + depends on NETFILTER_XTABLES depends on IP_NF_MANGLE || IP6_NF_MANGLE depends on (IP_NF_CONNTRACK && IP_NF_CONNTRACK_MARK) || (NF_CONNTRACK_MARK && NF_CONNTRACK_IPV4) help
@@ -161,6 +162,7 @@ config NETFILTER_XT_TARGET_NFQUEUE config NETFILTER_XT_TARGET_NOTRACK tristate 'NOTRACK target support' + depends on NETFILTER_XTABLES depends on IP_NF_RAW || IP6_NF_RAW depends on IP_NF_CONNTRACK || NF_CONNTRACK help
[NETFILTER] x_tables: don't show menu item for IP_NF_TARGET_CLASSIFY
---
commit 4f879b6981ff5d21484c20faaf7ff6730a5d494f
tree aede2a5367518adfbf84c970272cccb7f539a8b6
parent 91b0e552d6e525e61410205864ff79a00a4807f1
author Yasuyuki Kozakai <[email protected]> Mon, 09 Jan 2006 02:25:05 +0900 committer Yasuyuki Kozakai <[email protected]> Mon, 09 Jan 2006 14:37:04 +0900
net/ipv4/netfilter/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/netfilter/Kconfig +1 -1
@@ -664,7 +664,7 @@ config IP_NF_TARGET_MARK automatically select new xtables match based on the old value config IP_NF_TARGET_CLASSIFY - tristate "CLASSIFY target support" + tristate default n select NETFILTER_XT_TARGET_CLASSIFY help
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Yasuyuki KOZAKAI
OK, I'll test it after sending this mail. Before that I have some comments about minor issues.
thanks a lot.
Quoted 3 lines
The dependency on
NETFILTER_XTABLESis missing at config of CLASSIFY and NOTRACK. And according to yourKconfigstyle, the menu item for CLASSIFY should not be shown. Please apply attached patches.
thanks, I'll update.
Quoted 5 lines
I have one more comment about
need_conntrack(). The kernel withx_tablespatch doesn't loadnf_connrack_ipv4when user types "iptables -A INPUT -m state...". Then no packets might be untracked after that. One solution is to try load nf_conntrack_{ipv4,ipv6} and to ignore error on load, but I'm not sure that this is the best way.
Mh. Can we put this into checkentry()? Probably there are some issues with regard to locking, but it would be the logical place to do it. We [can] know whether it's an iptables or an ip6tables rule, and therefore we know which tracking we want to request.
we should have something like a
"need_conntrack(int pf)" function provided by the conntrack core. Then anyone in the kernel can request something like "need_conntrack(AF_INET)".
Also, my Kconfig magic (originally suggested by Rusty) doesn't seem to work. It does not automatically select the XT matches/targets based on the previous IPT selections :(
Signature · 5 lines
- Harald Welte <[email protected]> http://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
From: Harald Welte <[email protected]>
Date: Mon, 9 Jan 2006 11:35:04 +0100
Quoted 11 lines
Quoted 5 lines
I have one more comment about
need_conntrack(). The kernel withx_tablespatch doesn't loadnf_connrack_ipv4when user types "iptables -A INPUT -m state...". Then no packets might be untracked after that. One solution is to try load nf_conntrack_{ipv4,ipv6} and to ignore error on load, but I'm not sure that this is the best way.Mh. Can we put this into
checkentry()? Probably there are some issues with regard to locking, but it would be the logical place to do it. We [can] know whether it's an iptables or an ip6tables rule, and therefore we know which tracking we want to request.
Quoted 4 lines
we should have something like a
"need_conntrack(int pf)" function provided by the conntrack core. Then anyone in the kernel can request something like "need_conntrack(AF_INET)".
sounds good idea.
Quoted 3 lines
Also, my
Kconfigmagic (originally suggested by Rusty) doesn't seem to work. It does not automatically select the XT matches/targets based on the previous IPT selections :(
How about this ?
- make {IP,IP6,ARP}_NF_IPTABLES select NETFILTER_XTABLES
- make IP_NF_{MATCH,TARGET}_* select NETFILTER_XT_{MATCH,TARGET}_*
- hide the menus for NETFILTER_XTABLES and NETFILTER_XT_{MATCH,TARGET}_*
- show the menus for {IP,IP6,ARP}_NF_{MATCH,TARGET}_*
-- Yasuyuki Kozakai
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 14 lines · Yasuyuki KOZAKAI
From: Harald Welte <[email protected]>
Date: Mon, 9 Jan 2006 11:35:04 +0100Quoted 11 lines
Quoted 5 lines
I have one more comment about
need_conntrack(). The kernel withx_tablespatch doesn't loadnf_connrack_ipv4when user types "iptables -A INPUT -m state...". Then no packets might be untracked after that. One solution is to try load nf_conntrack_{ipv4,ipv6} and to ignore error on load, but I'm not sure that this is the best way.Mh. Can we put this into
checkentry()? Probably there are some issues with regard to locking, but it would be the logical place to do it. We [can] know whether it's an iptables or an ip6tables rule, and therefore we know which tracking we want to request.
Quoted 6 lines
Quoted 4 lines
we should have something like a
"need_conntrack(int pf)" function provided by the conntrack core. Then anyone in the kernel can request something like "need_conntrack(AF_INET)".sounds good idea.
I'll implement this later on. Today I want to finally submit x_tables, even with this minor issue left for an incremental patch.
Quoted 10 lines
Quoted 3 lines
Also, my
Kconfigmagic (originally suggested by Rusty) doesn't seem to work. It does not automatically select the XT matches/targets based on the previous IPT selections :(How about this ?
- make {IP,IP6,ARP}_NF_IPTABLES selectNETFILTER_XTABLES
- make IP_NF_{MATCH,TARGET}_* select NETFILTER_XT_{MATCH,TARGET}_*
- hide the menus forNETFILTER_XTABLESand NETFILTER_XT_{MATCH,TARGET}_*
- show the menus for {IP,IP6,ARP}_NF_{MATCH,TARGET}_*
no, I don't like that idea. It would mean that we'd hide the existance of x_tables in the long term from the user. Rather the opposite direction is the case: less and less {ip,arp,ip6}_tables, and more functionality moving to the core.
Signature · 5 lines
- Harald Welte <[email protected]> http://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 12 lines · Harald Welte
Hi!
It's been some time since I last released a version of the
x_tablespatch. This is mainly due to the reason that 2.6.15 has only been released recently, andx_tableswas clearly 2.6.16 work.I've modified nfsim and the nfsim-testsuite to work with an
x_tableskernel, and all tests now pass without any problem (using an old iptables binary that was compiled against a non-xtables kernel). This, in addition to my manual tests, give me enough confidence that I didn't break something significant.
Quoted 5 lines
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
Hi Harald
Is there any chance we can get rid of the rwlock_t lock in 'struct xt_table' ? (Replacing it by an array of spinlocks)
/* Lock for the curtain */
- rwlock_t lock;
+ spinlock_t *lockp;
Pros :
1) No more cache line ping pongs between cpus. A read_lock_bh(&table->lock)
is still expensive because of that.
2) spinlocks are less expensive (spin_unlock is not an atomic op likeread_unlock_bh()
On a dual processor machine, its quite common that all incoming frames are handled by CPU 0, while CPU 1 is doing the User level stuff and sends network trafic...
Thank you
( I had a patch sent in September which was doing quite the same thing on ipt_tables, but keeping the rwlock_t : Correct me but I think we can just use spinlocks)
Eric
Review
Quoted 9 lines · Eric Dumazet
Hi Harald
Is there any chance we can get rid of the
rwlock_tlock in 'structxt_table' ?
(Replacing it by an array of spinlocks)/* Lock for the curtain */(quoted diff) +1
-1- rwlock_t lock; + spinlock_t *lockp;
should work. But I don't want this to hold back x_tables, which otherwise seems functional. Also, it uses the same mechanism as ip_tables, so there shouldn't be any performance impact.
We can always improve performance with incremental patches later on.
Quoted 3 lines
On a dual processor machine, its quite common that all incoming frames are handled by CPU 0, while CPU 1 is doing the User level stuff and sends network trafic...
depends on how many NIC's you have and how your irq routing is configured.
Quoted 3 lines
( I had a patch sent in September which was doing quite the same thing on
ipt_tables, but keeping therwlock_t: Correct me but I think we can just use spinlocks)
If you want to cook up an x_tables based patch, I'd be happy to give it some testing.
Thanks,
Harald
Signature · 5 lines
- Harald Welte <[email protected]> http://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
PATCH 1/1 x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
In reply to Eric DumazetThis patch helps scalability of x_tables on SMP, especially NUMA machines.
Instead of using a single rwlock_t to protect x_tables, use an array of rwlock_t, one for each possible cpu in the machine.
1) No more cache line ping pongs between cpus. read_lock_bh(&table->lock) / read_unlock_bh(&table->lock) were still expensive because of the very hot central rwlock.
2) get_counters() is more latency friendly than before (we lock each sub table one at a time instead of the full x_tables)
3) When a replace of table must be done, the 'writer' have to write_lock_bh() all the locks of the array. This is 'expensive' but seldom done (underlying vmalloc/copy_from_user costs are more expensive anyway)
This patch was tested on a 4 way Opteron machine, two gigabit links, with rather complex iptables rules (around 200 rules) and gives excellent results so far.
Thank you
Eric Dumazet
linux/netfilter/x_tables.h renamed from include/linux/netfilter/x_tables.h +7 -0
@@ -170,7 +170,13 @@unsigned int valid_hooks;/* Lock for the curtain */ +#ifdef CONFIG_SMP +rwlock_t *lockp; +# define xt_table_lockaddr (X ,cpu) per_cpu_ptr((X)->lockp, cpu) +#else rwlock_t lock; +# define xt_table_lockaddr (X ,cpu) (&(X)->lock) +#endif /* Man behind the curtain... */ //struct ip6t_table_info *private;
@@ -207,6 +213,7 @@extern int xt_register_match (int af,struct xt_match *target);extern void xt_unregister_match (int af,struct xt_match *target); +extern int xt_table_global_init (struct xt_table *table);extern int xt_register_table (struct xt_table *table,struct xt_table_info *bootstrap,struct xt_table_info *newinfo);
ipv4/netfilter/ip_tables.c renamed from net/ipv4/netfilter/ip_tables.c +31 -14
139 lines not on this page · raw message
net/netfilter/x_tables.c +41 -4
74 lines not on this page · raw message
net/ipv4/netfilter/ip_nat_rule.c +0 -1
@@ -93,7 +93,6 @@static struct ipt_table nat_table = { .name ="nat" , .valid_hooks =NAT_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/iptable_mangle.c +0 -1
@@ -107,7 +107,6 @@static struct ipt_table packet_mangler = { .name ="mangle" , .valid_hooks =MANGLE_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/iptable_raw.c +0 -1
@@ -82,7 +82,6 @@static struct ipt_table packet_raw = { .name ="raw" , .valid_hooks =RAW_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/arptable_filter.c +0 -1
@@ -142,7 +142,6 @@static struct arpt_table packet_filter = { .name ="filter" , .valid_hooks =FILTER_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .private =NULL , .me =THIS_MODULE , .af =NF_ARP ,
net/ipv6/netfilter/ip6_tables.c +28 -13
127 lines not on this page · raw message
net/ipv6/netfilter/ip6table_filter.c +0 -1
@@ -95,7 +95,6 @@static struct ip6t_table packet_filter = { .name ="filter" , .valid_hooks =FILTER_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET6 , };
net/ipv6/netfilter/ip6table_raw.c +0 -1
@@ -109,7 +109,6 @@static struct xt_table packet_raw = { .name ="raw" , .valid_hooks =RAW_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET6 , };
Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
Quoted 21 lines · On Fri, 27 Jan 2006 16:16:15 +0100 Eric Dumazet <[email protected]> wrote:
This patch helps scalability of
x_tableson SMP, especially NUMA machines.Instead of using a single
rwlock_tto protectx_tables, use an array ofrwlock_t, one for each possible cpu in the machine.1) No more cache line ping pongs between cpus.
read_lock_bh(&table->lock)/read_unlock_bh(&table->lock)were still expensive because of the very hot central rwlock.2)
get_counters()is more latency friendly than before (we lock each sub table one at a time instead of the fullx_tables)3) When a replace of table must be done, the 'writer' have to
write_lock_bh()all the locks of the array. This is 'expensive' but seldom done (underlying vmalloc/copy_from_user costs are more expensive anyway)This patch was tested on a 4 way Opteron machine, two gigabit links, with rather complex iptables rules (around 200 rules) and gives excellent results so far.
Quoted 5 lines
Thank you
Eric DumazetSigned-off-by Eric Dumazet <[email protected]>
You just reinvented brlock. Figure out how to use atomic operations and/or RCU and you will do even better.
Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Fri, 27 Jan 2006 16:16:15 +0100 Eric Dumazet <[email protected]> wrote:
This patch helps scalability of
x_tableson SMP, especially NUMA machines.Instead of using a single
rwlock_tto protectx_tables, use an array ofrwlock_t, one for each possible cpu in the machine.1) No more cache line ping pongs between cpus.
read_lock_bh(&table->lock)/read_unlock_bh(&table->lock)were still expensive because of the very hot central rwlock.2)
get_counters()is more latency friendly than before (we lock each sub table one at a time instead of the fullx_tables)3) When a replace of table must be done, the 'writer' have to
write_lock_bh()all the locks of the array. This is 'expensive' but seldom done (underlying vmalloc/copy_from_user costs are more expensive anyway)This patch was tested on a 4 way Opteron machine, two gigabit links, with rather complex iptables rules (around 200 rules) and gives excellent results so far.
Quoted 10 lines
Quoted 5 lines
Thank you
Eric DumazetSigned-off-by Eric Dumazet <[email protected]>You just reinvented brlock. Figure out how to use atomic operations and/or RCU and you will do even better.
Thanks Stephen for this very constructive comment.
After RCU being added to ipv4 route cache (by RCU experts, not me), my main servers cannot work anymore reliably.
If somebody can prove me RCU can works on x_tables, I'm open.
Eric
Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
Quoted 8 lines · On Fri, 27 Jan 2006 16:46:05 +0100 Eric Dumazet <[email protected]> wrote:
Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Fri, 27 Jan 2006 16:16:15 +0100 Eric Dumazet <[email protected]> wrote:
This patch helps scalability of
x_tableson SMP, especially NUMA machines.Instead of using a single
rwlock_tto protectx_tables, use an array ofrwlock_t, one for each possible cpu in the machine.
It makes no sense to have a per-cpu lock. Why not just use per-cpu counters and bh_disable()?
Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Fri, 27 Jan 2006 16:46:05 +0100 Eric Dumazet <[email protected]> wrote:
Quoted 3 lines · Stephen Hemminger
On Fri, 27 Jan 2006 16:16:15 +0100
Eric Dumazet <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
This patch helps scalability of
x_tableson SMP, especially NUMA machines.Instead of using a single
rwlock_tto protectx_tables, use an array ofrwlock_t, one for each possible cpu in the machine.It makes no sense to have a per-cpu lock. Why not just use per-cpu counters and
bh_disable()?
If you examin the x_tables code, you'll discover :
A CPU A might enters the code (ipt_do_table()) because a packet is processed : it follows the rules, increment 64 bits packet counts and 64 bits bytes counters of matched rules... Then it leaves the code. For this stage a read_lock_bh() was used to let this cpu does its job (including recursive calls apparently)
Then a CPU B wants to either :
[1] - replace the rules by a new set, atomically keeping all counters values (example : iptables -A INPUT -p tcp)
[2] - Read all the rules and associated counters atomically.
(example : iptables -nvL INPUT)
[...] - Other interesting things like resetting al counters
(example : iptables -Z)
This kind of task uses a write_lock_bh() to be sure CPU A will block in read_lock_bh()
Then a CPU C wants to to a task similar to B (imagine you have a periodic fetch of counters to feed a RRD database) : you want that CPU C doesnt read garbage values when CPU B adds a new rule in a chain, and while CPU A feed more network packets...
You need some kind of exclusion so that CPU B reads sane values, not values currently modified by CPU A. You need some kind of exclusion to let CPU B doing some table exchange (and keeps counters).
counters are already 'per-cpu' (ie each CPU only reads its own copy of rules and change its own counters), and bh_disable() wont permit exclusion between CPUS.
And finally you want to keep compatibility with user programs and existing API...
So using a per-cpu rwlock does make sense...
Eric
Re: [PATCH] x_tables : Use SMP friendly (percpu) rwlock_t to protect x_tables
In reply to Eric DumazetQuoted 10 lines · Eric Dumazet
This patch helps scalability of
x_tableson SMP, especially NUMA machines.Instead of using a single
rwlock_tto protectx_tables, use an array ofrwlock_t, one for each possible cpu in the machine.1) No more cache line ping pongs between cpus.
read_lock_bh(&table->lock)/read_unlock_bh(&table->lock)were still expensive because of the very hot central rwlock.2)
get_counters()is more latency friendly than before (we lock each sub table one at a time instead of the fullx_tables)3) When a replace of table must be done, the 'writer' have to
write_lock_bh()all the locks of the array. This is 'expensive' but seldom done (underlying vmalloc/copy_from_user costs are more expensive anyway)
Quoted 7 lines
This patch was tested on a 4 way Opteron machine, two gigabit links, with rather complex iptables rules (around 200 rules) and gives excellent results so far.
Thank you
Eric DumazetSigned-off-by Eric Dumazet <[email protected]>
Small problem with this patch on UP : _raw_write_lock() and _raw_write_unlock() are not defined. They should be nop.
Eric
linux/netfilter/x_tables.h renamed from include/linux/netfilter/x_tables.h +7 -0
@@ -170,7 +170,13 @@unsigned int valid_hooks;/* Lock for the curtain */ +#ifdef CONFIG_SMP +rwlock_t *lockp; +# define xt_table_lockaddr (X ,cpu) per_cpu_ptr((X)->lockp, cpu) +#else rwlock_t lock; +# define xt_table_lockaddr (X ,cpu) (&(X)->lock) +#endif /* Man behind the curtain... */ //struct ip6t_table_info *private;
@@ -207,6 +213,7 @@extern int xt_register_match (int af,struct xt_match *target);extern void xt_unregister_match (int af,struct xt_match *target); +extern int xt_table_global_init (struct xt_table *table);extern int xt_register_table (struct xt_table *table,struct xt_table_info *bootstrap,struct xt_table_info *newinfo);
ipv4/netfilter/ip_tables.c renamed from net/ipv4/netfilter/ip_tables.c +31 -14
139 lines not on this page · raw message
net/netfilter/x_tables.c +49 -4
82 lines not on this page · raw message
net/ipv4/netfilter/ip_nat_rule.c +0 -1
@@ -93,7 +93,6 @@static struct ipt_table nat_table = { .name ="nat" , .valid_hooks =NAT_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/iptable_mangle.c +0 -1
@@ -107,7 +107,6 @@static struct ipt_table packet_mangler = { .name ="mangle" , .valid_hooks =MANGLE_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/iptable_raw.c +0 -1
@@ -82,7 +82,6 @@static struct ipt_table packet_raw = { .name ="raw" , .valid_hooks =RAW_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET , };
net/ipv4/netfilter/arptable_filter.c +0 -1
@@ -142,7 +142,6 @@static struct arpt_table packet_filter = { .name ="filter" , .valid_hooks =FILTER_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .private =NULL , .me =THIS_MODULE , .af =NF_ARP ,
net/ipv6/netfilter/ip6_tables.c +28 -13
127 lines not on this page · raw message
net/ipv6/netfilter/ip6table_filter.c +0 -1
@@ -95,7 +95,6 @@static struct ip6t_table packet_filter = { .name ="filter" , .valid_hooks =FILTER_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET6 , };
net/ipv6/netfilter/ip6table_raw.c +0 -1
@@ -109,7 +109,6 @@static struct xt_table packet_raw = { .name ="raw" , .valid_hooks =RAW_VALID_HOOKS , - .lock =RW_LOCK_UNLOCKED , .me =THIS_MODULE , .af =AF_INET6 , };
Hi,
From: Harald Welte <[email protected]>
Date: Sun, 8 Jan 2006 22:26:20 +0100
Quoted 4 lines
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
I have some more comments.
- xt_dccp:dccp_find_option() assumes dccp header is just after IPv4 header. Please consider to apply the attached 1st patch.
- xt_length:
The place of IPv4/IPv6 payload length field is different. I think that this feature would be better to be implemented as per layer 3 protocol.
- ip6t_owner:ip6t_owner.h is missing.
- xt_sctp:match_packet() assumes sctp header is just after IPv4 header, too. Please consider to apply the attached 2nd patch.
Regards,
-- Yasuyuki Kozakai
[NETFILTER] x_tables: fix the offset to DCCP header
---
commit 022cb249bcf3fb02a5094257e23674f67b25932a
tree 83bd37d768e4afd1b804f64376a300b01a527e4d
parent 0cd354deca6eda0e4acfe9f98590aabd7285b6a8
author Yasuyuki Kozakai <[email protected]> Tue, 10 Jan 2006 02:03:48 +0900 committer Yasuyuki Kozakai <[email protected]> Tue, 10 Jan 2006 02:03:48 +0900
net/netfilter/xt_dccp.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
net/netfilter/xt_dccp.c +6 -6
@@ -34,6 +34,7 @@ static DEFINE_SPINLOCK(dccp_buflock);static inline int dccp_find_option (u_int8_t option,const struct sk_buff *skb, +unsigned int protoff,const struct dccp_hdr *dh,int *hotdrop) {
@@ -52,9 +53,7 @@ dccp_find_option(u_int8_t option,return 0 ;spin_lock_bh (&dccp_buflock); - op =skb_header_pointer (skb, - skb->nh.iph->ihl*4 + optoff, - optlen, dccp_optbuf); + op =skb_header_pointer (skb, protoff + optoff, optlen, dccp_optbuf);if (op ==NULL ) {/* If we don't have the whole header, drop packet. */ spin_unlock_bh (&dccp_buflock);
@@ -86,10 +85,10 @@ match_types(const struct dccp_hdr *dh, u }static inline int -match_option (u_int8_t option,const struct sk_buff *skb, +match_option (u_int8_t option,const struct sk_buff *skb,unsigned int protoff,const struct dccp_hdr *dh,int *hotdrop) { -return dccp_find_option (option, skb, dh, hotdrop); +return dccp_find_option (option, skb, protoff, dh, hotdrop); } static int
@@ -122,7 +121,8 @@ match(const struct sk_buff *skb, XT_DCCP_DEST_PORTS, info->flags, info->invflags) && DCCHECK(match_types(dh, info->typemask),XT_DCCP_TYPE , info->flags, info->invflags) - &&DCCHECK (match_option (info->option, skb, dh, hotdrop), + &&DCCHECK (match_option (info->option, skb, protoff, dh, + hotdrop),XT_DCCP_OPTION , info->flags, info->invflags); }
net/netfilter/xt_sctp.c +4 -4
@@ -40,15 +40,15 @@ match_flags(const struct xt_sctp_flag_inreturn 1 ; } -static int +static inline int match_packet (const struct sk_buff *skb, +unsigned int offset,const u_int32_t *chunkmap,int chunk_match_type,const struct xt_sctp_flag_info *flag_info,const int flag_count,int *hotdrop) { -int offset;u_int32_t chunkmapcopy[256 /sizeof (u_int32_t)];sctp_chunkhdr_t _sch, *sch;
@@ -60,7 +60,6 @@ match_packet(const struct sk_buff *skb,SCTP_CHUNKMAP_COPY (chunkmapcopy, chunkmap); } - offset = skb->nh.iph->ihl *4 +sizeof (sctp_sctphdr_t); do { sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch); if (sch == NULL) {
@@ -153,7 +152,8 @@ match(const struct sk_buff *skb, &&SCCHECK (((ntohs (sh->dest) >= info->dpts[0 ]) && (ntohs (sh->dest) <= info->dpts[1 ])),XT_SCTP_DEST_PORTS , info->flags, info->invflags) - &&SCCHECK (match_packet (skb, info->chunkmap, info->chunk_match_type, + &&SCCHECK (match_packet (skb, protoff, + info->chunkmap, info->chunk_match_type, info->flag_info, info->flag_count, hotdrop),XT_SCTP_CHUNK_TYPES , info->flags, info->invflags);
A message that is not in the archive (sent off-list or not yet received): [email protected]
Harald Welte
AppliedQuoted 11 lines · Yasuyuki KOZAKAI
Hi,
From: Harald Welte <[email protected]>
Date: Sun, 8 Jan 2006 22:26:20 +0100Quoted 4 lines
I'm planning to submit
x_tableseatly next week, so this is assumed to be the final review phase.So if you have any issues, please comment now before it's too late :)
I have some more comments.
great, thanks.
Quoted 3 lines
-
xt_dccp:dccp_find_option()assumes dccp header is just after IPv4 header. Please consider to apply the attached 1st patch.
ok, applied your fix.
Quoted 3 lines
-
xt_length:
The place of IPv4/IPv6 payload length field is different. I think that this feature would be better to be implemented as per layer 3 protocol.
well, that's why we have two separate 'match' functions for AF_INET and AF_INET6. Having two different modules sounds like overkill for me, considering that we waste one page per module, even if the functionality is only a single line of C code.
Quoted 2 lines
-
ip6t_owner:ip6t_owner.his missing.
oops. re-adding it right now.
Quoted 3 lines
-
xt_sctp:match_packet()assumes sctp header is just after IPv4 header, too. Please consider to apply the attached 2nd patch.
thanks, applied your fix.
Signature · 5 lines
- Harald Welte <[email protected]> http://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