: net/ipv[46]/netfilter.c cleanups
Subsystems (2)
PATCH 1/5 : net/ipv[46]/netfilter.c cleanups
Hi Dave,
following are a couple of netfilter fixes and cleanup patches. The first two PPTP patches fix critical bugs, I'm going to push them to -stable as well.
[NETFILTER]: net/ipv[46]/netfilter.c cleanups
Don't wrap entire file in #ifdef CONFIG_NETFILTER, remove a few unneccessary includes.
---
commit 9d179ec0f5dc92411afd56e51010bbb57fa17b57
tree a99790588288e9d04ce1247d9fc64fa133b69eb8
parent 16e6d946e635f88097c2e9303b9fde04e3b6e754
author Patrick McHardy <[email protected]> Sat, 07 Jan 2006 07:48:28 +0100 committer Patrick McHardy <[email protected]> Sat, 07 Jan 2006 07:48:28 +0100
include/linux/netfilter_ipv6.h | 5 +++++ net/ipv4/Makefile | 4 ++-- net/ipv4/netfilter.c | 10 ---------- net/ipv6/Makefile | 5 ++--- net/ipv6/netfilter.c | 19 ++----------------- 5 files changed, 11 insertions(+), 32 deletions(-)
include/linux/netfilter_ipv6.h +5 -0
@@ -72,7 +72,12 @@ enum nf_ip6_hook_priorities { NF_IP6_PRI_LAST = INT_MAX, }; +#ifdef CONFIG_NETFILTER extern int ipv6_netfilter_init (void );extern void ipv6_netfilter_fini (void ); +#else /* CONFIG_NETFILTER */ +static inline int ipv6_netfilter_init (void ) {return 0 ; } +static inline void ipv6_netfilter_fini (void ) {return ; } +#endif /* CONFIG_NETFILTER */ #endif /*__LINUX_IP6_NETFILTER_H*/
net/ipv4/Makefile +2 -2
@@ -9,7 +9,7 @@ obj-y := route.o inetpeer.o protocol tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ tcp_minisocks.o tcp_cong.o \ datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ - sysctl_net_ipv4.o fib_frontend.o fib_semantics.o netfilter.o + sysctl_net_ipv4.o fib_frontend.o fib_semantics.o obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
@@ -28,7 +28,7 @@ obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += m obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_WRANDOM) += multipath_wrandom.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_DRR) += multipath_drr.o -obj-$(CONFIG_NETFILTER) += netfilter/ +obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/ obj-$(CONFIG_IP_VS) += ipvs/ obj-$(CONFIG_INET_DIAG) += inet_diag.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o
net/ipv4/netfilter.c +0 -10
@@ -1,16 +1,8 @@/* IPv4 specific functions of netfilter core */ - -#include <linux/config.h> -#ifdef CONFIG_NETFILTER -#include <linux/kernel.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> -#include <linux/ip.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#include <linux/icmp.h> #include <net/route.h> #include <net/xfrm.h> #include <net/ip.h>
@@ -146,5 +138,3 @@ static void fini(void)module_init (init);module_exit (fini); - -#endif /* CONFIG_NETFILTER */
net/ipv6/Makefile +2 -3
@@ -8,8 +8,7 @@ ipv6-objs := af_inet6.o anycast.o ip6_ou route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \ protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ - ip6_flowlabel.o ipv6_syms.o netfilter.o \ - inet6_connection_sock.o + ip6_flowlabel.o ipv6_syms.o inet6_connection_sock.o ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \ xfrm6_output.o
@@ -19,7 +18,7 @@ obj-$(CONFIG_INET6_AH) += ah6.o obj-$(CONFIG_INET6_ESP) += esp6.o obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o obj-$(CONFIG_INET6_TUNNEL) += xfrm6_tunnel.o -obj-$(CONFIG_NETFILTER) += netfilter/ +obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/ obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
net/ipv6/netfilter.c +2 -17
@@ -1,9 +1,5 @@ -#include <linux/config.h> -#include <linux/init.h> - -#ifdef CONFIG_NETFILTER -#include <linux/kernel.h> +#include <linux/init.h> #include <linux/ipv6.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv6.h>
@@ -94,18 +90,7 @@ int __init ipv6_netfilter_init(void)return nf_register_queue_rerouter (PF_INET6 , &ip6_reroute); } -void ipv6_netfilter_fini (void ) +void __exit ipv6_netfilter_fini(void) {nf_unregister_queue_rerouter (PF_INET6 ); } - -#else /* CONFIG_NETFILTER */ -int __init ipv6_netfilter_init (void ) -{ -return 0 ; -} - -void ipv6_netfilter_fini (void ) -{ -} -#endif /* CONFIG_NETFILTER */
PATCH 2/5 : Fix crash in ip_nat_pptp
[NETFILTER]: Fix crash in ip_nat_pptp
When an inbound PPTP_IN_CALL_REQUEST packet is received the PPTP NAT helper uses a NULL pointer in pointer arithmentic to calculate the offset in the packet which needs to be mangled and corrupts random memory or crashes.
---
commit 6c97b3d460f11d5223f16d02d5369f278a621866
tree dd785c80d0fcc79e2f665686a61f33d06c6e365a
parent 9d179ec0f5dc92411afd56e51010bbb57fa17b57
author Patrick McHardy <[email protected]> Sat, 07 Jan 2006 20:59:45 +0100 committer Patrick McHardy <[email protected]> Sat, 07 Jan 2006 20:59:45 +0100
net/ipv4/netfilter/ip_nat_helper_pptp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/netfilter/ip_nat_helper_pptp.c +1 -1
@@ -315,7 +315,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,break ;case PPTP_IN_CALL_REQUEST :/* only need to nat in case PAC is behind NAT box */ -break ; +return NF_ACCEPT ;case PPTP_WAN_ERROR_NOTIFY : pcid = &pptpReq->wanerr.peersCallID;break ;
PATCH 3/5 : Fix another crash in ip_nat_pptp
In reply to Patrick McHardy[NETFILTER]: Fix another crash in ip_nat_pptp
The PPTP NAT helper calculates the offset at which the packet needs to be mangled as difference between two pointers to the header. With non-linear skbs however the pointers may point to two seperate buffers on the stack and the calculation results in a wrong offset beeing used.
---
commit dd180da32f914c0a56e3d75f84b898db7e2910c3
tree dc2a60841e76a0843b17782ac355f54b5fa80c96
parent 6c97b3d460f11d5223f16d02d5369f278a621866
author Patrick McHardy <[email protected]> Sat, 07 Jan 2006 21:00:03 +0100 committer Patrick McHardy <[email protected]> Sat, 07 Jan 2006 21:00:03 +0100
net/ipv4/netfilter/ip_nat_helper_pptp.c | 57 +++++++++++++++---------------- 1 files changed, 27 insertions(+), 30 deletions(-)
net/ipv4/netfilter/ip_nat_helper_pptp.c +27 -30
@@ -148,14 +148,14 @@ pptp_outbound_pkt(struct sk_buff **pskb, {struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info;struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; - -u_int16_t msg, *cid =NULL , new_callid; +u_int16_t msg, new_callid; +unsigned int cid_off; new_callid =htons (ct_pptp_info->pns_call_id);switch (msg =ntohs (ctlh->messageType)) {case PPTP_OUT_CALL_REQUEST : - cid = &pptpReq->ocreq.callID; + cid_off = offsetof(union pptp_ctrl_union, ocreq.callID);/* FIXME: ideally we would want to reserve a call ID * here. current netfilter NAT core is not able to do * this :( For now we use TCP source port. This breaks
@@ -172,10 +172,10 @@ pptp_outbound_pkt(struct sk_buff **pskb, ct_pptp_info->pns_call_id =ntohs (new_callid);break ;case PPTP_IN_CALL_REPLY : - cid = &pptpReq->icreq.callID; + cid_off = offsetof(union pptp_ctrl_union, icreq.callID);break ;case PPTP_CALL_CLEAR_REQUEST : - cid = &pptpReq->clrreq.callID; + cid_off = offsetof(union pptp_ctrl_union, clrreq.callID);break ;default : DEBUGP("unknown outbound packet 0x%04x:%s\n", msg,
@@ -197,18 +197,15 @@ pptp_outbound_pkt(struct sk_buff **pskb,/* only OUT_CALL_REQUEST, IN_CALL_REPLY, CALL_CLEAR_REQUEST pass * down to here */ - -IP_NF_ASSERT (cid); -DEBUGP ("altering call id from 0x%04x to 0x%04x\n" , -ntohs (*cid),ntohs (new_callid)); +ntohs (*(u_int16_t *)pptpReq + cid_off),ntohs (new_callid));/* mangle packet */ if (ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, - (void *)cid - ((void *)ctlh -sizeof (struct pptp_pkt_hdr )), -sizeof (new_callid), - (char *)&new_callid, -sizeof (new_callid)) ==0 ) + cid_off +sizeof (struct pptp_pkt_hdr ) + +sizeof (struct PptpControlHeader ), +sizeof (new_callid), (char *)&new_callid, +sizeof (new_callid)) ==0 )return NF_DROP ;return NF_ACCEPT ;
@@ -299,7 +296,8 @@ pptp_inbound_pkt(struct sk_buff **pskb, union pptp_ctrl_union *pptpReq) {struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; -u_int16_t msg, new_cid =0 , new_pcid, *pcid =NULL , *cid =NULL ; +u_int16_t msg, new_cid =0 , new_pcid; +unsigned int pcid_off, cid_off =0 ;int ret =NF_ACCEPT , rv;
@@ -307,23 +305,23 @@ pptp_inbound_pkt(struct sk_buff **pskb,switch (msg =ntohs (ctlh->messageType)) {case PPTP_OUT_CALL_REPLY : - pcid = &pptpReq->ocack.peersCallID; - cid = &pptpReq->ocack.callID; + pcid_off = offsetof(union pptp_ctrl_union, ocack.peersCallID); + cid_off = offsetof(union pptp_ctrl_union, ocack.callID);break ;case PPTP_IN_CALL_CONNECT : - pcid = &pptpReq->iccon.peersCallID; + pcid_off = offsetof(union pptp_ctrl_union, iccon.peersCallID);break ;case PPTP_IN_CALL_REQUEST :/* only need to nat in case PAC is behind NAT box */ return NF_ACCEPT ;case PPTP_WAN_ERROR_NOTIFY : - pcid = &pptpReq->wanerr.peersCallID; + pcid_off = offsetof(union pptp_ctrl_union, wanerr.peersCallID);break ;case PPTP_CALL_DISCONNECT_NOTIFY : - pcid = &pptpReq->disc.callID; + pcid_off = offsetof(union pptp_ctrl_union, disc.callID);break ;case PPTP_SET_LINK_INFO : - pcid = &pptpReq->setlink.peersCallID; + pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);break ;default :
@@ -345,25 +343,24 @@ pptp_inbound_pkt(struct sk_buff **pskb,* WAN_ERROR_NOTIFY, CALL_DISCONNECT_NOTIFY pass down here */ /* mangle packet */ -IP_NF_ASSERT (pcid);DEBUGP ("altering peer call id from 0x%04x to 0x%04x\n" , -ntohs (*pcid),ntohs (new_pcid)); +ntohs (*(u_int16_t *)pptpReq + pcid_off),ntohs (new_pcid)); - rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, - (void *)pcid - ((void *)ctlh -sizeof (struct pptp_pkt_hdr )), + rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, + pcid_off +sizeof (struct pptp_pkt_hdr ) + +sizeof (struct PptpControlHeader ),sizeof (new_pcid), (char *)&new_pcid,sizeof (new_pcid));if (rv !=NF_ACCEPT )return rv;if (new_cid) { -IP_NF_ASSERT (cid);DEBUGP ("altering call id from 0x%04x to 0x%04x\n" , -ntohs (*cid),ntohs (new_cid)); - rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, - (void *)cid - ((void *)ctlh -sizeof (struct pptp_pkt_hdr )), -sizeof (new_cid), - (char *)&new_cid, +ntohs (*(u_int16_t *)pptpReq + cid_off),ntohs (new_cid)); + rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, + cid_off +sizeof (struct pptp_pkt_hdr ) + +sizeof (struct PptpControlHeader ), +sizeof (new_cid), (char *)&new_cid,sizeof (new_cid));if (rv !=NF_ACCEPT )return rv;
PATCH 4/5 : Fix return value confusion in PPTP NAT helper
In reply to Patrick McHardy[NETFILTER]: Fix return value confusion in PPTP NAT helper
ip_nat_mangle_tcp_packet doesn't return NF_* values but 0/1 for failure/success.
---
commit 1aefffdcf7bb75a1b98b961b25c5a45f12a357a3
tree 49e70e9d824c331414e69ae2abfc481db867de50
parent dd180da32f914c0a56e3d75f84b898db7e2910c3
author Patrick McHardy <[email protected]> Sat, 07 Jan 2006 21:11:35 +0100 committer Patrick McHardy <[email protected]> Sat, 07 Jan 2006 21:11:35 +0100
net/ipv4/netfilter/ip_nat_helper_pptp.c | 36 +++++++++++-------------------- 1 files changed, 13 insertions(+), 23 deletions(-)
net/ipv4/netfilter/ip_nat_helper_pptp.c +13 -23
@@ -299,8 +299,6 @@ pptp_inbound_pkt(struct sk_buff **pskb,u_int16_t msg, new_cid =0 , new_pcid;unsigned int pcid_off, cid_off =0 ; -int ret =NF_ACCEPT , rv; - new_pcid =htons (nat_pptp_info->pns_call_id);switch (msg =ntohs (ctlh->messageType)) {
@@ -345,32 +343,24 @@ pptp_inbound_pkt(struct sk_buff **pskb,/* mangle packet */ DEBUGP ("altering peer call id from 0x%04x to 0x%04x\n" ,ntohs (*(u_int16_t *)pptpReq + pcid_off),ntohs (new_pcid)); - - rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, - pcid_off +sizeof (struct pptp_pkt_hdr ) + -sizeof (struct PptpControlHeader ), -sizeof (new_pcid), (char *)&new_pcid, -sizeof (new_pcid)); -if (rv !=NF_ACCEPT ) -return rv; + +if (ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, + pcid_off +sizeof (struct pptp_pkt_hdr ) + +sizeof (struct PptpControlHeader ), +sizeof (new_pcid), (char *)&new_pcid, +sizeof (new_pcid)) ==0 ) +return NF_DROP ;if (new_cid) {DEBUGP ("altering call id from 0x%04x to 0x%04x\n" ,ntohs (*(u_int16_t *)pptpReq + cid_off),ntohs (new_cid)); - rv =ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, - cid_off +sizeof (struct pptp_pkt_hdr ) + -sizeof (struct PptpControlHeader ), -sizeof (new_cid), (char *)&new_cid, -sizeof (new_cid)); -if (rv !=NF_ACCEPT ) -return rv; +if (ip_nat_mangle_tcp_packet (pskb, ct, ctinfo, + cid_off +sizeof (struct pptp_pkt_hdr ) + +sizeof (struct PptpControlHeader ), +sizeof (new_cid), (char *)&new_cid, +sizeof (new_cid)) ==0 ) +return NF_DROP ; } - -/* check for earlier return value of 'switch' above */ -if (ret !=NF_ACCEPT ) -return ret; - -/* great, at least we don't need to resize packets */ return NF_ACCEPT ; }
PATCH 5/5 : Remove unused function from NAT protocol helpers
In reply to Patrick McHardy[NETFILTER]: Remove unused function from NAT protocol helpers
->print and ->print_range are not used (and apparently never were).
---
commit 2d7be102c6e62236562415d7beacd790cc6504f4
tree e77e60cd6294f94e1ad3bd7f99aafcee18b28750
parent 80996cd784ba8851c0cf72ace29f410446d079e0
author Patrick McHardy <[email protected]> Sun, 08 Jan 2006 06:42:07 +0100 committer Patrick McHardy <[email protected]> Sun, 08 Jan 2006 06:42:07 +0100
include/linux/netfilter_ipv4/ip_nat_protocol.h | 7 ---- net/ipv4/netfilter/ip_nat_proto_gre.c | 38 ------------------------ net/ipv4/netfilter/ip_nat_proto_icmp.c | 34 --------------------- net/ipv4/netfilter/ip_nat_proto_tcp.c | 36 ----------------------- net/ipv4/netfilter/ip_nat_proto_udp.c | 36 ----------------------- net/ipv4/netfilter/ip_nat_proto_unknown.c | 16 ---------- 6 files changed, 0 insertions(+), 167 deletions(-)
include/linux/netfilter_ipv4/ip_nat_protocol.h +0 -7
@@ -42,13 +42,6 @@ struct ip_nat_protocolenum ip_nat_manip_type maniptype, const struct ip_conntrack *conntrack); -unsigned int (*print)(char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask); - -unsigned int (*print_range)(char *buffer, -const struct ip_nat_range *range); -int (*range_to_nfattr)(struct sk_buff *skb,const struct ip_nat_range *range);
net/ipv4/netfilter/ip_nat_proto_gre.c +0 -38
@@ -151,42 +151,6 @@ gre_manip_pkt(struct sk_buff **pskb,return 1 ; } -/* print out a nat tuple */ -static unsigned int -gre_print (char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask) -{ -unsigned int len =0 ; - -if (mask->src.u.gre.key) - len +=sprintf (buffer + len,"srckey=0x%x " , -ntohl (match->src.u.gre.key)); - -if (mask->dst.u.gre.key) - len +=sprintf (buffer + len,"dstkey=0x%x " , -ntohl (match->src.u.gre.key)); - -return len; -} - -/* print a range of keys */ -static unsigned int -gre_print_range (char *buffer,const struct ip_nat_range *range) -{ -if (range->min.gre.key !=0 - || range->max.gre.key !=0xFFFF ) { -if (range->min.gre.key == range->max.gre.key) -return sprintf (buffer,"key 0x%x " , -ntohl (range->min.gre.key)); -else -return sprintf (buffer,"keys 0x%u-0x%u " , -ntohl (range->min.gre.key), -ntohl (range->max.gre.key)); - }else -return 0 ; -} -/* nat helper struct */ static struct ip_nat_protocol gre = { .name ="GRE" ,
@@ -194,8 +158,6 @@ static struct ip_nat_protocol gre = { .manip_pkt = gre_manip_pkt, .in_range = gre_in_range, .unique_tuple = gre_unique_tuple, - .print = gre_print, - .print_range = gre_print_range,#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK ) || \ defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE ) .range_to_nfattr = ip_nat_port_range_to_nfattr,
net/ipv4/netfilter/ip_nat_proto_icmp.c +0 -34
@@ -74,38 +74,6 @@ icmp_manip_pkt(struct sk_buff **pskb,return 1 ; } -static unsigned int -icmp_print (char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask) -{ -unsigned int len =0 ; - -if (mask->src.u.icmp.id) - len +=sprintf (buffer + len,"id=%u " , -ntohs (match->src.u.icmp.id)); - -if (mask->dst.u.icmp.type) - len +=sprintf (buffer + len,"type=%u " , -ntohs (match->dst.u.icmp.type)); - -if (mask->dst.u.icmp.code) - len +=sprintf (buffer + len,"code=%u " , -ntohs (match->dst.u.icmp.code)); - -return len; -} - -static unsigned int -icmp_print_range (char *buffer,const struct ip_nat_range *range) -{ -if (range->min.icmp.id !=0 || range->max.icmp.id !=0xFFFF ) -return sprintf (buffer,"id %u-%u " , -ntohs (range->min.icmp.id), -ntohs (range->max.icmp.id)); -else return 0 ; -} -struct ip_nat_protocol ip_nat_protocol_icmp = { .name ="ICMP" , .protonum =IPPROTO_ICMP ,
@@ -113,8 +81,6 @@ struct ip_nat_protocol ip_nat_protocol_i .manip_pkt = icmp_manip_pkt, .in_range = icmp_in_range, .unique_tuple = icmp_unique_tuple, - .print = icmp_print, - .print_range = icmp_print_range,#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK ) || \ defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE ) .range_to_nfattr = ip_nat_port_range_to_nfattr,
net/ipv4/netfilter/ip_nat_proto_tcp.c +0 -36
@@ -136,40 +136,6 @@ tcp_manip_pkt(struct sk_buff **pskb,return 1 ; } -static unsigned int -tcp_print (char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask) -{ -unsigned int len =0 ; - -if (mask->src.u.tcp.port) - len +=sprintf (buffer + len,"srcpt=%u " , -ntohs (match->src.u.tcp.port)); - - -if (mask->dst.u.tcp.port) - len +=sprintf (buffer + len,"dstpt=%u " , -ntohs (match->dst.u.tcp.port)); - -return len; -} - -static unsigned int -tcp_print_range (char *buffer,const struct ip_nat_range *range) -{ -if (range->min.tcp.port !=0 || range->max.tcp.port !=0xFFFF ) { -if (range->min.tcp.port == range->max.tcp.port) -return sprintf (buffer,"port %u " , -ntohs (range->min.tcp.port)); -else -return sprintf (buffer,"ports %u-%u " , -ntohs (range->min.tcp.port), -ntohs (range->max.tcp.port)); - } -else return 0 ; -} -struct ip_nat_protocol ip_nat_protocol_tcp = { .name ="TCP" , .protonum =IPPROTO_TCP ,
@@ -177,8 +143,6 @@ struct ip_nat_protocol ip_nat_protocol_t .manip_pkt = tcp_manip_pkt, .in_range = tcp_in_range, .unique_tuple = tcp_unique_tuple, - .print = tcp_print, - .print_range = tcp_print_range,#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK ) || \ defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE ) .range_to_nfattr = ip_nat_port_range_to_nfattr,
net/ipv4/netfilter/ip_nat_proto_udp.c +0 -36
@@ -122,40 +122,6 @@ udp_manip_pkt(struct sk_buff **pskb,return 1 ; } -static unsigned int -udp_print (char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask) -{ -unsigned int len =0 ; - -if (mask->src.u.udp.port) - len +=sprintf (buffer + len,"srcpt=%u " , -ntohs (match->src.u.udp.port)); - - -if (mask->dst.u.udp.port) - len +=sprintf (buffer + len,"dstpt=%u " , -ntohs (match->dst.u.udp.port)); - -return len; -} - -static unsigned int -udp_print_range (char *buffer,const struct ip_nat_range *range) -{ -if (range->min.udp.port !=0 || range->max.udp.port !=0xFFFF ) { -if (range->min.udp.port == range->max.udp.port) -return sprintf (buffer,"port %u " , -ntohs (range->min.udp.port)); -else -return sprintf (buffer,"ports %u-%u " , -ntohs (range->min.udp.port), -ntohs (range->max.udp.port)); - } -else return 0 ; -} -struct ip_nat_protocol ip_nat_protocol_udp = { .name ="UDP" , .protonum =IPPROTO_UDP ,
@@ -163,8 +129,6 @@ struct ip_nat_protocol ip_nat_protocol_u .manip_pkt = udp_manip_pkt, .in_range = udp_in_range, .unique_tuple = udp_unique_tuple, - .print = udp_print, - .print_range = udp_print_range,#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK ) || \ defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE ) .range_to_nfattr = ip_nat_port_range_to_nfattr,
net/ipv4/netfilter/ip_nat_proto_unknown.c +0 -16
@@ -46,26 +46,10 @@ unknown_manip_pkt(struct sk_buff **pskb,return 1 ; } -static unsigned int -unknown_print (char *buffer, -const struct ip_conntrack_tuple *match, -const struct ip_conntrack_tuple *mask) -{ -return 0 ; -} - -static unsigned int -unknown_print_range (char *buffer,const struct ip_nat_range *range) -{ -return 0 ; -} -struct ip_nat_protocol ip_nat_unknown_protocol = { .name ="unknown" ,/* .me isn't set: getting a ref to this cannot fail. */ .manip_pkt = unknown_manip_pkt, .in_range = unknown_in_range, .unique_tuple = unknown_unique_tuple, - .print = unknown_print, - .print_range = unknown_print_range };
David S. Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Tue, 10 Jan 2006 01:38:38 +0100
Quoted 2 lines
following are a couple of netfilter fixes and cleanup patches. The first two PPTP patches fix critical bugs, I'm going to push them to -stable as well.
All applied, thanks Patrick.
Quoted 10 lines · David S. Miller
From: Patrick McHardy <[email protected]>
Date: Tue, 10 Jan 2006 01:38:38 +0100Quoted 2 lines
following are a couple of netfilter fixes and cleanup patches. The first two PPTP patches fix critical bugs, I'm going to push them to -stable as well.
All applied, thanks Patrick.
Oops, missed one :)
[NETFILTER]: Fix timeout sysctls on big-endian 64bit architectures
The connection tracking timeout variables are unsigned long, but proc_dointvec_jiffies is used with sizeof(unsigned int) in the sysctl tables. Since there is no proc_doulongvec_jiffies function, change the timeout variables to unsigned int.
---
commit 16e6d946e635f88097c2e9303b9fde04e3b6e754
tree aeda640c98f827c1b205f9b9a2f15d0e57448236
parent 77b5a9142e3a53b375c6c21ec80fdbe890a8403c
author Patrick McHardy <[email protected]> Sat, 07 Jan 2006 07:21:58 +0100 committer Patrick McHardy <[email protected]> Sat, 07 Jan 2006 07:21:58 +0100
net/ipv4/netfilter/ip_conntrack_proto_generic.c | 2 +- net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 2 +- net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 16 +++++++------- net/ipv4/netfilter/ip_conntrack_proto_tcp.c | 20 +++++++++--------- net/ipv4/netfilter/ip_conntrack_proto_udp.c | 4 ++-- net/ipv4/netfilter/ip_conntrack_standalone.c | 26 ++++++++++++----------- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 2 +- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 4 ++-- net/netfilter/nf_conntrack_proto_generic.c | 2 +- net/netfilter/nf_conntrack_proto_sctp.c | 16 +++++++------- net/netfilter/nf_conntrack_proto_tcp.c | 20 +++++++++--------- net/netfilter/nf_conntrack_proto_udp.c | 4 ++-- net/netfilter/nf_conntrack_standalone.c | 24 +++++++++++---------- 13 files changed, 71 insertions(+), 71 deletions(-)
net/ipv4/netfilter/ip_conntrack_proto_generic.c +1 -1
@@ -12,7 +12,7 @@#include <linux/netfilter.h> #include <linux/netfilter_ipv4/ip_conntrack_protocol.h> -unsigned long ip_ct_generic_timeout =600 *HZ ; +unsigned int ip_ct_generic_timeout =600 *HZ ; static int generic_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
net/ipv4/netfilter/ip_conntrack_proto_icmp.c +1 -1
@@ -22,7 +22,7 @@#include <linux/netfilter_ipv4/ip_conntrack_core.h> #include <linux/netfilter_ipv4/ip_conntrack_protocol.h> -unsigned long ip_ct_icmp_timeout =30 *HZ ; +unsigned int ip_ct_icmp_timeout =30 *HZ ;#if 0 #define DEBUGP printk
net/ipv4/netfilter/ip_conntrack_proto_sctp.c +8 -8
@@ -57,15 +57,15 @@ static const char *sctp_conntrack_names[#define HOURS * 60 MINS#define DAYS * 24 HOURS -static unsigned long ip_ct_sctp_timeout_closed = 10 SECS; -static unsigned long ip_ct_sctp_timeout_cookie_wait = 3 SECS; -static unsigned long ip_ct_sctp_timeout_cookie_echoed = 3 SECS; -static unsigned long ip_ct_sctp_timeout_established = 5 DAYS; -static unsigned long ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; -static unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; -static unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; +static unsigned int ip_ct_sctp_timeout_closed = 10 SECS; +static unsigned int ip_ct_sctp_timeout_cookie_wait = 3 SECS; +static unsigned int ip_ct_sctp_timeout_cookie_echoed = 3 SECS; +static unsigned int ip_ct_sctp_timeout_established = 5 DAYS; +static unsigned int ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; +static unsigned int ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; +static unsigned int ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; -static const unsigned long * sctp_timeouts[] +static const unsigned int * sctp_timeouts[] = {NULL ,/* SCTP_CONNTRACK_NONE */ &ip_ct_sctp_timeout_closed,/* SCTP_CONNTRACK_CLOSED */ &ip_ct_sctp_timeout_cookie_wait,/* SCTP_CONNTRACK_COOKIE_WAIT */
net/ipv4/netfilter/ip_conntrack_proto_tcp.c +10 -10
@@ -85,21 +85,21 @@ static const char *tcp_conntrack_names[]#define HOURS * 60 MINS#define DAYS * 24 HOURS -unsigned long ip_ct_tcp_timeout_syn_sent = 2 MINS; -unsigned long ip_ct_tcp_timeout_syn_recv = 60 SECS; -unsigned long ip_ct_tcp_timeout_established = 5 DAYS; -unsigned long ip_ct_tcp_timeout_fin_wait = 2 MINS; -unsigned long ip_ct_tcp_timeout_close_wait = 60 SECS; -unsigned long ip_ct_tcp_timeout_last_ack = 30 SECS; -unsigned long ip_ct_tcp_timeout_time_wait = 2 MINS; -unsigned long ip_ct_tcp_timeout_close = 10 SECS; +unsigned int ip_ct_tcp_timeout_syn_sent = 2 MINS; +unsigned int ip_ct_tcp_timeout_syn_recv = 60 SECS; +unsigned int ip_ct_tcp_timeout_established = 5 DAYS; +unsigned int ip_ct_tcp_timeout_fin_wait = 2 MINS; +unsigned int ip_ct_tcp_timeout_close_wait = 60 SECS; +unsigned int ip_ct_tcp_timeout_last_ack = 30 SECS; +unsigned int ip_ct_tcp_timeout_time_wait = 2 MINS; +unsigned int ip_ct_tcp_timeout_close = 10 SECS;/* RFC1122 says the R2 limit should be at least 100 seconds. Linux uses 15 packets as limit, which corresponds to ~13-30min depending on RTO. */ -unsigned long ip_ct_tcp_timeout_max_retrans = 5 MINS; +unsigned int ip_ct_tcp_timeout_max_retrans = 5 MINS; -static const unsigned long * tcp_timeouts[] +static const unsigned int * tcp_timeouts[] = {NULL ,/* TCP_CONNTRACK_NONE */ &ip_ct_tcp_timeout_syn_sent,/* TCP_CONNTRACK_SYN_SENT, */ &ip_ct_tcp_timeout_syn_recv,/* TCP_CONNTRACK_SYN_RECV, */
net/ipv4/netfilter/ip_conntrack_proto_udp.c +2 -2
@@ -19,8 +19,8 @@#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4/ip_conntrack_protocol.h> -unsigned long ip_ct_udp_timeout =30 *HZ ; -unsigned long ip_ct_udp_timeout_stream =180 *HZ ; +unsigned int ip_ct_udp_timeout =30 *HZ ; +unsigned int ip_ct_udp_timeout_stream =180 *HZ ; static int udp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
net/ipv4/netfilter/ip_conntrack_standalone.c +13 -13
@@ -544,28 +544,28 @@ extern int ip_conntrack_max;extern unsigned int ip_conntrack_htable_size;/* From ip_conntrack_proto_tcp.c */ -extern unsigned long ip_ct_tcp_timeout_syn_sent; -extern unsigned long ip_ct_tcp_timeout_syn_recv; -extern unsigned long ip_ct_tcp_timeout_established; -extern unsigned long ip_ct_tcp_timeout_fin_wait; -extern unsigned long ip_ct_tcp_timeout_close_wait; -extern unsigned long ip_ct_tcp_timeout_last_ack; -extern unsigned long ip_ct_tcp_timeout_time_wait; -extern unsigned long ip_ct_tcp_timeout_close; -extern unsigned long ip_ct_tcp_timeout_max_retrans; +extern unsigned int ip_ct_tcp_timeout_syn_sent; +extern unsigned int ip_ct_tcp_timeout_syn_recv; +extern unsigned int ip_ct_tcp_timeout_established; +extern unsigned int ip_ct_tcp_timeout_fin_wait; +extern unsigned int ip_ct_tcp_timeout_close_wait; +extern unsigned int ip_ct_tcp_timeout_last_ack; +extern unsigned int ip_ct_tcp_timeout_time_wait; +extern unsigned int ip_ct_tcp_timeout_close; +extern unsigned int ip_ct_tcp_timeout_max_retrans;extern int ip_ct_tcp_loose;extern int ip_ct_tcp_be_liberal;extern int ip_ct_tcp_max_retrans;/* From ip_conntrack_proto_udp.c */ -extern unsigned long ip_ct_udp_timeout; -extern unsigned long ip_ct_udp_timeout_stream; +extern unsigned int ip_ct_udp_timeout; +extern unsigned int ip_ct_udp_timeout_stream;/* From ip_conntrack_proto_icmp.c */ -extern unsigned long ip_ct_icmp_timeout; +extern unsigned int ip_ct_icmp_timeout;/* From ip_conntrack_proto_icmp.c */ -extern unsigned long ip_ct_generic_timeout; +extern unsigned int ip_ct_generic_timeout;/* Log invalid packets of a given protocol */ static int log_invalid_proto_min =0 ;
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
@@ -277,7 +277,7 @@ static struct nf_hook_ops ipv4_conntrack#ifdef CONFIG_SYSCTL /* From nf_conntrack_proto_icmp.c */ -extern unsigned long nf_ct_icmp_timeout; +extern unsigned int nf_ct_icmp_timeout;static struct ctl_table_header *nf_ct_ipv4_sysctl_header; static ctl_table nf_ct_sysctl_table[] = {
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +2 -2
@@ -335,10 +335,10 @@ static struct nf_hook_ops ipv6_conntrack#ifdef CONFIG_SYSCTL /* From nf_conntrack_proto_icmpv6.c */ -extern unsigned long nf_ct_icmpv6_timeout; +extern unsigned int nf_ct_icmpv6_timeout;/* From nf_conntrack_frag6.c */ -extern unsigned long nf_ct_frag6_timeout; +extern unsigned int nf_ct_frag6_timeout;extern unsigned int nf_ct_frag6_low_thresh;extern unsigned int nf_ct_frag6_high_thresh;
net/netfilter/nf_conntrack_proto_generic.c +1 -1
@@ -17,7 +17,7 @@#include <linux/netfilter.h> #include <net/netfilter/nf_conntrack_protocol.h> -unsigned long nf_ct_generic_timeout =600 *HZ ; +unsigned int nf_ct_generic_timeout =600 *HZ ; static int generic_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
net/netfilter/nf_conntrack_proto_sctp.c +8 -8
@@ -62,15 +62,15 @@ static const char *sctp_conntrack_names[#define HOURS * 60 MINS#define DAYS * 24 HOURS -static unsigned long nf_ct_sctp_timeout_closed = 10 SECS; -static unsigned long nf_ct_sctp_timeout_cookie_wait = 3 SECS; -static unsigned long nf_ct_sctp_timeout_cookie_echoed = 3 SECS; -static unsigned long nf_ct_sctp_timeout_established = 5 DAYS; -static unsigned long nf_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; -static unsigned long nf_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; -static unsigned long nf_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; +static unsigned int nf_ct_sctp_timeout_closed = 10 SECS; +static unsigned int nf_ct_sctp_timeout_cookie_wait = 3 SECS; +static unsigned int nf_ct_sctp_timeout_cookie_echoed = 3 SECS; +static unsigned int nf_ct_sctp_timeout_established = 5 DAYS; +static unsigned int nf_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; +static unsigned int nf_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; +static unsigned int nf_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; -static unsigned long * sctp_timeouts[] +static unsigned int * sctp_timeouts[] = {NULL ,/* SCTP_CONNTRACK_NONE */ &nf_ct_sctp_timeout_closed,/* SCTP_CONNTRACK_CLOSED */ &nf_ct_sctp_timeout_cookie_wait,/* SCTP_CONNTRACK_COOKIE_WAIT */
net/netfilter/nf_conntrack_proto_tcp.c +10 -10
@@ -93,21 +93,21 @@ static const char *tcp_conntrack_names[]#define HOURS * 60 MINS#define DAYS * 24 HOURS -unsigned long nf_ct_tcp_timeout_syn_sent = 2 MINS; -unsigned long nf_ct_tcp_timeout_syn_recv = 60 SECS; -unsigned long nf_ct_tcp_timeout_established = 5 DAYS; -unsigned long nf_ct_tcp_timeout_fin_wait = 2 MINS; -unsigned long nf_ct_tcp_timeout_close_wait = 60 SECS; -unsigned long nf_ct_tcp_timeout_last_ack = 30 SECS; -unsigned long nf_ct_tcp_timeout_time_wait = 2 MINS; -unsigned long nf_ct_tcp_timeout_close = 10 SECS; +unsigned int nf_ct_tcp_timeout_syn_sent = 2 MINS; +unsigned int nf_ct_tcp_timeout_syn_recv = 60 SECS; +unsigned int nf_ct_tcp_timeout_established = 5 DAYS; +unsigned int nf_ct_tcp_timeout_fin_wait = 2 MINS; +unsigned int nf_ct_tcp_timeout_close_wait = 60 SECS; +unsigned int nf_ct_tcp_timeout_last_ack = 30 SECS; +unsigned int nf_ct_tcp_timeout_time_wait = 2 MINS; +unsigned int nf_ct_tcp_timeout_close = 10 SECS;/* RFC1122 says the R2 limit should be at least 100 seconds. Linux uses 15 packets as limit, which corresponds to ~13-30min depending on RTO. */ -unsigned long nf_ct_tcp_timeout_max_retrans = 5 MINS; +unsigned int nf_ct_tcp_timeout_max_retrans = 5 MINS; -static unsigned long * tcp_timeouts[] +static unsigned int * tcp_timeouts[] = {NULL ,/* TCP_CONNTRACK_NONE */ &nf_ct_tcp_timeout_syn_sent,/* TCP_CONNTRACK_SYN_SENT, */ &nf_ct_tcp_timeout_syn_recv,/* TCP_CONNTRACK_SYN_RECV, */
net/netfilter/nf_conntrack_proto_udp.c +2 -2
@@ -27,8 +27,8 @@#include <linux/netfilter_ipv6.h> #include <net/netfilter/nf_conntrack_protocol.h> -unsigned long nf_ct_udp_timeout =30 *HZ ; -unsigned long nf_ct_udp_timeout_stream =180 *HZ ; +unsigned int nf_ct_udp_timeout =30 *HZ ; +unsigned int nf_ct_udp_timeout_stream =180 *HZ ; static int udp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
net/netfilter/nf_conntrack_standalone.c +12 -12
@@ -431,25 +431,25 @@ extern int nf_conntrack_max;extern unsigned int nf_conntrack_htable_size;/* From nf_conntrack_proto_tcp.c */ -extern unsigned long nf_ct_tcp_timeout_syn_sent; -extern unsigned long nf_ct_tcp_timeout_syn_recv; -extern unsigned long nf_ct_tcp_timeout_established; -extern unsigned long nf_ct_tcp_timeout_fin_wait; -extern unsigned long nf_ct_tcp_timeout_close_wait; -extern unsigned long nf_ct_tcp_timeout_last_ack; -extern unsigned long nf_ct_tcp_timeout_time_wait; -extern unsigned long nf_ct_tcp_timeout_close; -extern unsigned long nf_ct_tcp_timeout_max_retrans; +extern unsigned int nf_ct_tcp_timeout_syn_sent; +extern unsigned int nf_ct_tcp_timeout_syn_recv; +extern unsigned int nf_ct_tcp_timeout_established; +extern unsigned int nf_ct_tcp_timeout_fin_wait; +extern unsigned int nf_ct_tcp_timeout_close_wait; +extern unsigned int nf_ct_tcp_timeout_last_ack; +extern unsigned int nf_ct_tcp_timeout_time_wait; +extern unsigned int nf_ct_tcp_timeout_close; +extern unsigned int nf_ct_tcp_timeout_max_retrans;extern int nf_ct_tcp_loose;extern int nf_ct_tcp_be_liberal;extern int nf_ct_tcp_max_retrans;/* From nf_conntrack_proto_udp.c */ -extern unsigned long nf_ct_udp_timeout; -extern unsigned long nf_ct_udp_timeout_stream; +extern unsigned int nf_ct_udp_timeout; +extern unsigned int nf_ct_udp_timeout_stream;/* From nf_conntrack_proto_generic.c */ -extern unsigned long nf_ct_generic_timeout; +extern unsigned int nf_ct_generic_timeout;/* Log invalid packets of a given protocol */ static int log_invalid_proto_min =0 ;
From: Patrick McHardy <[email protected]>
Date: Tue, 10 Jan 2006 01:50:56 +0100
Quoted 1 line
Oops, missed one :)
Applied, thanks.