aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/Makefile4
-rw-r--r--net/ipv4/netfilter.c10
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_generic.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_icmp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_sctp.c18
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c20
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_udp.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c26
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_pptp.c81
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_gre.c38
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_icmp.c34
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_tcp.c36
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_udp.c36
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_unknown.c16
-rw-r--r--net/ipv4/netfilter/ipt_mac.c5
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c2
16 files changed, 76 insertions, 258 deletions
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index c54edd76de..35e5f59990 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -9,7 +9,7 @@ obj-y := route.o inetpeer.o protocol.o \
9 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ 9 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
10 tcp_minisocks.o tcp_cong.o \ 10 tcp_minisocks.o tcp_cong.o \
11 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ 11 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
12 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o netfilter.o 12 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o
13 13
14obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o 14obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
15obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o 15obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
@@ -28,7 +28,7 @@ obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o
28obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o 28obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o
29obj-$(CONFIG_IP_ROUTE_MULTIPATH_WRANDOM) += multipath_wrandom.o 29obj-$(CONFIG_IP_ROUTE_MULTIPATH_WRANDOM) += multipath_wrandom.o
30obj-$(CONFIG_IP_ROUTE_MULTIPATH_DRR) += multipath_drr.o 30obj-$(CONFIG_IP_ROUTE_MULTIPATH_DRR) += multipath_drr.o
31obj-$(CONFIG_NETFILTER) += netfilter/ 31obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/
32obj-$(CONFIG_IP_VS) += ipvs/ 32obj-$(CONFIG_IP_VS) += ipvs/
33obj-$(CONFIG_INET_DIAG) += inet_diag.o 33obj-$(CONFIG_INET_DIAG) += inet_diag.o
34obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o 34obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index 3321092b09..52a3d7c579 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -1,16 +1,8 @@
1/* IPv4 specific functions of netfilter core */ 1/* IPv4 specific functions of netfilter core */
2
3#include <linux/config.h>
4#ifdef CONFIG_NETFILTER
5
6#include <linux/kernel.h> 2#include <linux/kernel.h>
7#include <linux/netfilter.h> 3#include <linux/netfilter.h>
8#include <linux/netfilter_ipv4.h> 4#include <linux/netfilter_ipv4.h>
9
10#include <linux/ip.h> 5#include <linux/ip.h>
11#include <linux/tcp.h>
12#include <linux/udp.h>
13#include <linux/icmp.h>
14#include <net/route.h> 6#include <net/route.h>
15#include <net/xfrm.h> 7#include <net/xfrm.h>
16#include <net/ip.h> 8#include <net/ip.h>
@@ -146,5 +138,3 @@ static void fini(void)
146 138
147module_init(init); 139module_init(init);
148module_exit(fini); 140module_exit(fini);
149
150#endif /* CONFIG_NETFILTER */
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_generic.c b/net/ipv4/netfilter/ip_conntrack_proto_generic.c
index 88c3712bd2..f891308b5e 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_generic.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_generic.c
@@ -12,7 +12,7 @@
12#include <linux/netfilter.h> 12#include <linux/netfilter.h>
13#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 13#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
14 14
15unsigned long ip_ct_generic_timeout = 600*HZ; 15unsigned int ip_ct_generic_timeout = 600*HZ;
16 16
17static int generic_pkt_to_tuple(const struct sk_buff *skb, 17static int generic_pkt_to_tuple(const struct sk_buff *skb,
18 unsigned int dataoff, 18 unsigned int dataoff,
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index 30fc21d616..f2a90e2743 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -22,7 +22,7 @@
22#include <linux/netfilter_ipv4/ip_conntrack_core.h> 22#include <linux/netfilter_ipv4/ip_conntrack_core.h>
23#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 23#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
24 24
25unsigned long ip_ct_icmp_timeout = 30*HZ; 25unsigned int ip_ct_icmp_timeout = 30*HZ;
26 26
27#if 0 27#if 0
28#define DEBUGP printk 28#define DEBUGP printk
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
index 0b25050981..be602e8aea 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -58,15 +58,15 @@ static const char *sctp_conntrack_names[] = {
58#define HOURS * 60 MINS 58#define HOURS * 60 MINS
59#define DAYS * 24 HOURS 59#define DAYS * 24 HOURS
60 60
61static unsigned long ip_ct_sctp_timeout_closed = 10 SECS; 61static unsigned int ip_ct_sctp_timeout_closed = 10 SECS;
62static unsigned long ip_ct_sctp_timeout_cookie_wait = 3 SECS; 62static unsigned int ip_ct_sctp_timeout_cookie_wait = 3 SECS;
63static unsigned long ip_ct_sctp_timeout_cookie_echoed = 3 SECS; 63static unsigned int ip_ct_sctp_timeout_cookie_echoed = 3 SECS;
64static unsigned long ip_ct_sctp_timeout_established = 5 DAYS; 64static unsigned int ip_ct_sctp_timeout_established = 5 DAYS;
65static unsigned long ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000; 65static unsigned int ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000;
66static unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; 66static unsigned int ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000;
67static unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; 67static unsigned int ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS;
68 68
69static const unsigned long * sctp_timeouts[] 69static const unsigned int * sctp_timeouts[]
70= { NULL, /* SCTP_CONNTRACK_NONE */ 70= { NULL, /* SCTP_CONNTRACK_NONE */
71 &ip_ct_sctp_timeout_closed, /* SCTP_CONNTRACK_CLOSED */ 71 &ip_ct_sctp_timeout_closed, /* SCTP_CONNTRACK_CLOSED */
72 &ip_ct_sctp_timeout_cookie_wait, /* SCTP_CONNTRACK_COOKIE_WAIT */ 72 &ip_ct_sctp_timeout_cookie_wait, /* SCTP_CONNTRACK_COOKIE_WAIT */
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 77f304680d..ea2b39c180 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -85,21 +85,21 @@ static const char *tcp_conntrack_names[] = {
85#define HOURS * 60 MINS 85#define HOURS * 60 MINS
86#define DAYS * 24 HOURS 86#define DAYS * 24 HOURS
87 87
88unsigned long ip_ct_tcp_timeout_syn_sent = 2 MINS; 88unsigned int ip_ct_tcp_timeout_syn_sent = 2 MINS;
89unsigned long ip_ct_tcp_timeout_syn_recv = 60 SECS; 89unsigned int ip_ct_tcp_timeout_syn_recv = 60 SECS;
90unsigned long ip_ct_tcp_timeout_established = 5 DAYS; 90unsigned int ip_ct_tcp_timeout_established = 5 DAYS;
91unsigned long ip_ct_tcp_timeout_fin_wait = 2 MINS; 91unsigned int ip_ct_tcp_timeout_fin_wait = 2 MINS;
92unsigned long ip_ct_tcp_timeout_close_wait = 60 SECS; 92unsigned int ip_ct_tcp_timeout_close_wait = 60 SECS;
93unsigned long ip_ct_tcp_timeout_last_ack = 30 SECS; 93unsigned int ip_ct_tcp_timeout_last_ack = 30 SECS;
94unsigned long ip_ct_tcp_timeout_time_wait = 2 MINS; 94unsigned int ip_ct_tcp_timeout_time_wait = 2 MINS;
95unsigned long ip_ct_tcp_timeout_close = 10 SECS; 95unsigned int ip_ct_tcp_timeout_close = 10 SECS;
96 96
97/* RFC1122 says the R2 limit should be at least 100 seconds. 97/* RFC1122 says the R2 limit should be at least 100 seconds.
98 Linux uses 15 packets as limit, which corresponds 98 Linux uses 15 packets as limit, which corresponds
99 to ~13-30min depending on RTO. */ 99 to ~13-30min depending on RTO. */
100unsigned long ip_ct_tcp_timeout_max_retrans = 5 MINS; 100unsigned int ip_ct_tcp_timeout_max_retrans = 5 MINS;
101 101
102static const unsigned long * tcp_timeouts[] 102static const unsigned int * tcp_timeouts[]
103= { NULL, /* TCP_CONNTRACK_NONE */ 103= { NULL, /* TCP_CONNTRACK_NONE */
104 &ip_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */ 104 &ip_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */
105 &ip_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */ 105 &ip_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
index 46becbe4fe..004003fd61 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
@@ -19,8 +19,8 @@
19#include <linux/netfilter_ipv4.h> 19#include <linux/netfilter_ipv4.h>
20#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 20#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
21 21
22unsigned long ip_ct_udp_timeout = 30*HZ; 22unsigned int ip_ct_udp_timeout = 30*HZ;
23unsigned long ip_ct_udp_timeout_stream = 180*HZ; 23unsigned int ip_ct_udp_timeout_stream = 180*HZ;
24 24
25static int udp_pkt_to_tuple(const struct sk_buff *skb, 25static int udp_pkt_to_tuple(const struct sk_buff *skb,
26 unsigned int dataoff, 26 unsigned int dataoff,
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 7ba97783e7..9dec1293f6 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -544,28 +544,28 @@ extern int ip_conntrack_max;
544extern unsigned int ip_conntrack_htable_size; 544extern unsigned int ip_conntrack_htable_size;
545 545
546/* From ip_conntrack_proto_tcp.c */ 546/* From ip_conntrack_proto_tcp.c */
547extern unsigned long ip_ct_tcp_timeout_syn_sent; 547extern unsigned int ip_ct_tcp_timeout_syn_sent;
548extern unsigned long ip_ct_tcp_timeout_syn_recv; 548extern unsigned int ip_ct_tcp_timeout_syn_recv;
549extern unsigned long ip_ct_tcp_timeout_established; 549extern unsigned int ip_ct_tcp_timeout_established;
550extern unsigned long ip_ct_tcp_timeout_fin_wait; 550extern unsigned int ip_ct_tcp_timeout_fin_wait;
551extern unsigned long ip_ct_tcp_timeout_close_wait; 551extern unsigned int ip_ct_tcp_timeout_close_wait;
552extern unsigned long ip_ct_tcp_timeout_last_ack; 552extern unsigned int ip_ct_tcp_timeout_last_ack;
553extern unsigned long ip_ct_tcp_timeout_time_wait; 553extern unsigned int ip_ct_tcp_timeout_time_wait;
554extern unsigned long ip_ct_tcp_timeout_close; 554extern unsigned int ip_ct_tcp_timeout_close;
555extern unsigned long ip_ct_tcp_timeout_max_retrans; 555extern unsigned int ip_ct_tcp_timeout_max_retrans;
556extern int ip_ct_tcp_loose; 556extern int ip_ct_tcp_loose;
557extern int ip_ct_tcp_be_liberal; 557extern int ip_ct_tcp_be_liberal;
558extern int ip_ct_tcp_max_retrans; 558extern int ip_ct_tcp_max_retrans;
559 559
560/* From ip_conntrack_proto_udp.c */ 560/* From ip_conntrack_proto_udp.c */
561extern unsigned long ip_ct_udp_timeout; 561extern unsigned int ip_ct_udp_timeout;
562extern unsigned long ip_ct_udp_timeout_stream; 562extern unsigned int ip_ct_udp_timeout_stream;
563 563
564/* From ip_conntrack_proto_icmp.c */ 564/* From ip_conntrack_proto_icmp.c */
565extern unsigned long ip_ct_icmp_timeout; 565extern unsigned int ip_ct_icmp_timeout;
566 566
567/* From ip_conntrack_proto_icmp.c */ 567/* From ip_conntrack_proto_icmp.c */
568extern unsigned long ip_ct_generic_timeout; 568extern unsigned int ip_ct_generic_timeout;
569 569
570/* Log invalid packets of a given protocol */ 570/* Log invalid packets of a given protocol */
571static int log_invalid_proto_min = 0; 571static int log_invalid_proto_min = 0;
diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c
index e546203f56..ac00489578 100644
--- a/net/ipv4/netfilter/ip_nat_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c
@@ -148,14 +148,14 @@ pptp_outbound_pkt(struct sk_buff **pskb,
148{ 148{
149 struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info; 149 struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info;
150 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; 150 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
151 151 u_int16_t msg, new_callid;
152 u_int16_t msg, *cid = NULL, new_callid; 152 unsigned int cid_off;
153 153
154 new_callid = htons(ct_pptp_info->pns_call_id); 154 new_callid = htons(ct_pptp_info->pns_call_id);
155 155
156 switch (msg = ntohs(ctlh->messageType)) { 156 switch (msg = ntohs(ctlh->messageType)) {
157 case PPTP_OUT_CALL_REQUEST: 157 case PPTP_OUT_CALL_REQUEST:
158 cid = &pptpReq->ocreq.callID; 158 cid_off = offsetof(union pptp_ctrl_union, ocreq.callID);
159 /* FIXME: ideally we would want to reserve a call ID 159 /* FIXME: ideally we would want to reserve a call ID
160 * here. current netfilter NAT core is not able to do 160 * here. current netfilter NAT core is not able to do
161 * this :( For now we use TCP source port. This breaks 161 * this :( For now we use TCP source port. This breaks
@@ -172,10 +172,10 @@ pptp_outbound_pkt(struct sk_buff **pskb,
172 ct_pptp_info->pns_call_id = ntohs(new_callid); 172 ct_pptp_info->pns_call_id = ntohs(new_callid);
173 break; 173 break;
174 case PPTP_IN_CALL_REPLY: 174 case PPTP_IN_CALL_REPLY:
175 cid = &pptpReq->icreq.callID; 175 cid_off = offsetof(union pptp_ctrl_union, icreq.callID);
176 break; 176 break;
177 case PPTP_CALL_CLEAR_REQUEST: 177 case PPTP_CALL_CLEAR_REQUEST:
178 cid = &pptpReq->clrreq.callID; 178 cid_off = offsetof(union pptp_ctrl_union, clrreq.callID);
179 break; 179 break;
180 default: 180 default:
181 DEBUGP("unknown outbound packet 0x%04x:%s\n", msg, 181 DEBUGP("unknown outbound packet 0x%04x:%s\n", msg,
@@ -197,18 +197,15 @@ pptp_outbound_pkt(struct sk_buff **pskb,
197 197
198 /* only OUT_CALL_REQUEST, IN_CALL_REPLY, CALL_CLEAR_REQUEST pass 198 /* only OUT_CALL_REQUEST, IN_CALL_REPLY, CALL_CLEAR_REQUEST pass
199 * down to here */ 199 * down to here */
200
201 IP_NF_ASSERT(cid);
202
203 DEBUGP("altering call id from 0x%04x to 0x%04x\n", 200 DEBUGP("altering call id from 0x%04x to 0x%04x\n",
204 ntohs(*cid), ntohs(new_callid)); 201 ntohs(*(u_int16_t *)pptpReq + cid_off), ntohs(new_callid));
205 202
206 /* mangle packet */ 203 /* mangle packet */
207 if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, 204 if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
208 (void *)cid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)), 205 cid_off + sizeof(struct pptp_pkt_hdr) +
209 sizeof(new_callid), 206 sizeof(struct PptpControlHeader),
210 (char *)&new_callid, 207 sizeof(new_callid), (char *)&new_callid,
211 sizeof(new_callid)) == 0) 208 sizeof(new_callid)) == 0)
212 return NF_DROP; 209 return NF_DROP;
213 210
214 return NF_ACCEPT; 211 return NF_ACCEPT;
@@ -299,31 +296,30 @@ pptp_inbound_pkt(struct sk_buff **pskb,
299 union pptp_ctrl_union *pptpReq) 296 union pptp_ctrl_union *pptpReq)
300{ 297{
301 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; 298 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
302 u_int16_t msg, new_cid = 0, new_pcid, *pcid = NULL, *cid = NULL; 299 u_int16_t msg, new_cid = 0, new_pcid;
303 300 unsigned int pcid_off, cid_off = 0;
304 int ret = NF_ACCEPT, rv;
305 301
306 new_pcid = htons(nat_pptp_info->pns_call_id); 302 new_pcid = htons(nat_pptp_info->pns_call_id);
307 303
308 switch (msg = ntohs(ctlh->messageType)) { 304 switch (msg = ntohs(ctlh->messageType)) {
309 case PPTP_OUT_CALL_REPLY: 305 case PPTP_OUT_CALL_REPLY:
310 pcid = &pptpReq->ocack.peersCallID; 306 pcid_off = offsetof(union pptp_ctrl_union, ocack.peersCallID);
311 cid = &pptpReq->ocack.callID; 307 cid_off = offsetof(union pptp_ctrl_union, ocack.callID);
312 break; 308 break;
313 case PPTP_IN_CALL_CONNECT: 309 case PPTP_IN_CALL_CONNECT:
314 pcid = &pptpReq->iccon.peersCallID; 310 pcid_off = offsetof(union pptp_ctrl_union, iccon.peersCallID);
315 break; 311 break;
316 case PPTP_IN_CALL_REQUEST: 312 case PPTP_IN_CALL_REQUEST:
317 /* only need to nat in case PAC is behind NAT box */ 313 /* only need to nat in case PAC is behind NAT box */
318 break; 314 return NF_ACCEPT;
319 case PPTP_WAN_ERROR_NOTIFY: 315 case PPTP_WAN_ERROR_NOTIFY:
320 pcid = &pptpReq->wanerr.peersCallID; 316 pcid_off = offsetof(union pptp_ctrl_union, wanerr.peersCallID);
321 break; 317 break;
322 case PPTP_CALL_DISCONNECT_NOTIFY: 318 case PPTP_CALL_DISCONNECT_NOTIFY:
323 pcid = &pptpReq->disc.callID; 319 pcid_off = offsetof(union pptp_ctrl_union, disc.callID);
324 break; 320 break;
325 case PPTP_SET_LINK_INFO: 321 case PPTP_SET_LINK_INFO:
326 pcid = &pptpReq->setlink.peersCallID; 322 pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);
327 break; 323 break;
328 324
329 default: 325 default:
@@ -345,35 +341,26 @@ pptp_inbound_pkt(struct sk_buff **pskb,
345 * WAN_ERROR_NOTIFY, CALL_DISCONNECT_NOTIFY pass down here */ 341 * WAN_ERROR_NOTIFY, CALL_DISCONNECT_NOTIFY pass down here */
346 342
347 /* mangle packet */ 343 /* mangle packet */
348 IP_NF_ASSERT(pcid);
349 DEBUGP("altering peer call id from 0x%04x to 0x%04x\n", 344 DEBUGP("altering peer call id from 0x%04x to 0x%04x\n",
350 ntohs(*pcid), ntohs(new_pcid)); 345 ntohs(*(u_int16_t *)pptpReq + pcid_off), ntohs(new_pcid));
351 346
352 rv = ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, 347 if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
353 (void *)pcid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)), 348 pcid_off + sizeof(struct pptp_pkt_hdr) +
354 sizeof(new_pcid), (char *)&new_pcid, 349 sizeof(struct PptpControlHeader),
355 sizeof(new_pcid)); 350 sizeof(new_pcid), (char *)&new_pcid,
356 if (rv != NF_ACCEPT) 351 sizeof(new_pcid)) == 0)
357 return rv; 352 return NF_DROP;
358 353
359 if (new_cid) { 354 if (new_cid) {
360 IP_NF_ASSERT(cid);
361 DEBUGP("altering call id from 0x%04x to 0x%04x\n", 355 DEBUGP("altering call id from 0x%04x to 0x%04x\n",
362 ntohs(*cid), ntohs(new_cid)); 356 ntohs(*(u_int16_t *)pptpReq + cid_off), ntohs(new_cid));
363 rv = ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, 357 if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
364 (void *)cid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)), 358 cid_off + sizeof(struct pptp_pkt_hdr) +
365 sizeof(new_cid), 359 sizeof(struct PptpControlHeader),
366 (char *)&new_cid, 360 sizeof(new_cid), (char *)&new_cid,
367 sizeof(new_cid)); 361 sizeof(new_cid)) == 0)
368 if (rv != NF_ACCEPT) 362 return NF_DROP;
369 return rv;
370 } 363 }
371
372 /* check for earlier return value of 'switch' above */
373 if (ret != NF_ACCEPT)
374 return ret;
375
376 /* great, at least we don't need to resize packets */
377 return NF_ACCEPT; 364 return NF_ACCEPT;
378} 365}
379 366
diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c
index f7cad7cf1a..6c4899d804 100644
--- a/net/ipv4/netfilter/ip_nat_proto_gre.c
+++ b/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -151,42 +151,6 @@ gre_manip_pkt(struct sk_buff **pskb,
151 return 1; 151 return 1;
152} 152}
153 153
154/* print out a nat tuple */
155static unsigned int
156gre_print(char *buffer,
157 const struct ip_conntrack_tuple *match,
158 const struct ip_conntrack_tuple *mask)
159{
160 unsigned int len = 0;
161
162 if (mask->src.u.gre.key)
163 len += sprintf(buffer + len, "srckey=0x%x ",
164 ntohl(match->src.u.gre.key));
165
166 if (mask->dst.u.gre.key)
167 len += sprintf(buffer + len, "dstkey=0x%x ",
168 ntohl(match->src.u.gre.key));
169
170 return len;
171}
172
173/* print a range of keys */
174static unsigned int
175gre_print_range(char *buffer, const struct ip_nat_range *range)
176{
177 if (range->min.gre.key != 0
178 || range->max.gre.key != 0xFFFF) {
179 if (range->min.gre.key == range->max.gre.key)
180 return sprintf(buffer, "key 0x%x ",
181 ntohl(range->min.gre.key));
182 else
183 return sprintf(buffer, "keys 0x%u-0x%u ",
184 ntohl(range->min.gre.key),
185 ntohl(range->max.gre.key));
186 } else
187 return 0;
188}
189
190/* nat helper struct */ 154/* nat helper struct */
191static struct ip_nat_protocol gre = { 155static struct ip_nat_protocol gre = {
192 .name = "GRE", 156 .name = "GRE",
@@ -194,8 +158,6 @@ static struct ip_nat_protocol gre = {
194 .manip_pkt = gre_manip_pkt, 158 .manip_pkt = gre_manip_pkt,
195 .in_range = gre_in_range, 159 .in_range = gre_in_range,
196 .unique_tuple = gre_unique_tuple, 160 .unique_tuple = gre_unique_tuple,
197 .print = gre_print,
198 .print_range = gre_print_range,
199#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 161#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
200 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 162 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
201 .range_to_nfattr = ip_nat_port_range_to_nfattr, 163 .range_to_nfattr = ip_nat_port_range_to_nfattr,
diff --git a/net/ipv4/netfilter/ip_nat_proto_icmp.c b/net/ipv4/netfilter/ip_nat_proto_icmp.c
index 9387190439..31a3f4ccb9 100644
--- a/net/ipv4/netfilter/ip_nat_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_icmp.c
@@ -74,38 +74,6 @@ icmp_manip_pkt(struct sk_buff **pskb,
74 return 1; 74 return 1;
75} 75}
76 76
77static unsigned int
78icmp_print(char *buffer,
79 const struct ip_conntrack_tuple *match,
80 const struct ip_conntrack_tuple *mask)
81{
82 unsigned int len = 0;
83
84 if (mask->src.u.icmp.id)
85 len += sprintf(buffer + len, "id=%u ",
86 ntohs(match->src.u.icmp.id));
87
88 if (mask->dst.u.icmp.type)
89 len += sprintf(buffer + len, "type=%u ",
90 ntohs(match->dst.u.icmp.type));
91
92 if (mask->dst.u.icmp.code)
93 len += sprintf(buffer + len, "code=%u ",
94 ntohs(match->dst.u.icmp.code));
95
96 return len;
97}
98
99static unsigned int
100icmp_print_range(char *buffer, const struct ip_nat_range *range)
101{
102 if (range->min.icmp.id != 0 || range->max.icmp.id != 0xFFFF)
103 return sprintf(buffer, "id %u-%u ",
104 ntohs(range->min.icmp.id),
105 ntohs(range->max.icmp.id));
106 else return 0;
107}
108
109struct ip_nat_protocol ip_nat_protocol_icmp = { 77struct ip_nat_protocol ip_nat_protocol_icmp = {
110 .name = "ICMP", 78 .name = "ICMP",
111 .protonum = IPPROTO_ICMP, 79 .protonum = IPPROTO_ICMP,
@@ -113,8 +81,6 @@ struct ip_nat_protocol ip_nat_protocol_icmp = {
113 .manip_pkt = icmp_manip_pkt, 81 .manip_pkt = icmp_manip_pkt,
114 .in_range = icmp_in_range, 82 .in_range = icmp_in_range,
115 .unique_tuple = icmp_unique_tuple, 83 .unique_tuple = icmp_unique_tuple,
116 .print = icmp_print,
117 .print_range = icmp_print_range,
118#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 84#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
119 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 85 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
120 .range_to_nfattr = ip_nat_port_range_to_nfattr, 86 .range_to_nfattr = ip_nat_port_range_to_nfattr,
diff --git a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c
index 1d381bf685..a3d14079eb 100644
--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c
@@ -136,40 +136,6 @@ tcp_manip_pkt(struct sk_buff **pskb,
136 return 1; 136 return 1;
137} 137}
138 138
139static unsigned int
140tcp_print(char *buffer,
141 const struct ip_conntrack_tuple *match,
142 const struct ip_conntrack_tuple *mask)
143{
144 unsigned int len = 0;
145
146 if (mask->src.u.tcp.port)
147 len += sprintf(buffer + len, "srcpt=%u ",
148 ntohs(match->src.u.tcp.port));
149
150
151 if (mask->dst.u.tcp.port)
152 len += sprintf(buffer + len, "dstpt=%u ",
153 ntohs(match->dst.u.tcp.port));
154
155 return len;
156}
157
158static unsigned int
159tcp_print_range(char *buffer, const struct ip_nat_range *range)
160{
161 if (range->min.tcp.port != 0 || range->max.tcp.port != 0xFFFF) {
162 if (range->min.tcp.port == range->max.tcp.port)
163 return sprintf(buffer, "port %u ",
164 ntohs(range->min.tcp.port));
165 else
166 return sprintf(buffer, "ports %u-%u ",
167 ntohs(range->min.tcp.port),
168 ntohs(range->max.tcp.port));
169 }
170 else return 0;
171}
172
173struct ip_nat_protocol ip_nat_protocol_tcp = { 139struct ip_nat_protocol ip_nat_protocol_tcp = {
174 .name = "TCP", 140 .name = "TCP",
175 .protonum = IPPROTO_TCP, 141 .protonum = IPPROTO_TCP,
@@ -177,8 +143,6 @@ struct ip_nat_protocol ip_nat_protocol_tcp = {
177 .manip_pkt = tcp_manip_pkt, 143 .manip_pkt = tcp_manip_pkt,
178 .in_range = tcp_in_range, 144 .in_range = tcp_in_range,
179 .unique_tuple = tcp_unique_tuple, 145 .unique_tuple = tcp_unique_tuple,
180 .print = tcp_print,
181 .print_range = tcp_print_range,
182#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 146#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
183 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 147 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
184 .range_to_nfattr = ip_nat_port_range_to_nfattr, 148 .range_to_nfattr = ip_nat_port_range_to_nfattr,
diff --git a/net/ipv4/netfilter/ip_nat_proto_udp.c b/net/ipv4/netfilter/ip_nat_proto_udp.c
index c4906e1aa2..ec6053fdc8 100644
--- a/net/ipv4/netfilter/ip_nat_proto_udp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_udp.c
@@ -122,40 +122,6 @@ udp_manip_pkt(struct sk_buff **pskb,
122 return 1; 122 return 1;
123} 123}
124 124
125static unsigned int
126udp_print(char *buffer,
127 const struct ip_conntrack_tuple *match,
128 const struct ip_conntrack_tuple *mask)
129{
130 unsigned int len = 0;
131
132 if (mask->src.u.udp.port)
133 len += sprintf(buffer + len, "srcpt=%u ",
134 ntohs(match->src.u.udp.port));
135
136
137 if (mask->dst.u.udp.port)
138 len += sprintf(buffer + len, "dstpt=%u ",
139 ntohs(match->dst.u.udp.port));
140
141 return len;
142}
143
144static unsigned int
145udp_print_range(char *buffer, const struct ip_nat_range *range)
146{
147 if (range->min.udp.port != 0 || range->max.udp.port != 0xFFFF) {
148 if (range->min.udp.port == range->max.udp.port)
149 return sprintf(buffer, "port %u ",
150 ntohs(range->min.udp.port));
151 else
152 return sprintf(buffer, "ports %u-%u ",
153 ntohs(range->min.udp.port),
154 ntohs(range->max.udp.port));
155 }
156 else return 0;
157}
158
159struct ip_nat_protocol ip_nat_protocol_udp = { 125struct ip_nat_protocol ip_nat_protocol_udp = {
160 .name = "UDP", 126 .name = "UDP",
161 .protonum = IPPROTO_UDP, 127 .protonum = IPPROTO_UDP,
@@ -163,8 +129,6 @@ struct ip_nat_protocol ip_nat_protocol_udp = {
163 .manip_pkt = udp_manip_pkt, 129 .manip_pkt = udp_manip_pkt,
164 .in_range = udp_in_range, 130 .in_range = udp_in_range,
165 .unique_tuple = udp_unique_tuple, 131 .unique_tuple = udp_unique_tuple,
166 .print = udp_print,
167 .print_range = udp_print_range,
168#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 132#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
169 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 133 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
170 .range_to_nfattr = ip_nat_port_range_to_nfattr, 134 .range_to_nfattr = ip_nat_port_range_to_nfattr,
diff --git a/net/ipv4/netfilter/ip_nat_proto_unknown.c b/net/ipv4/netfilter/ip_nat_proto_unknown.c
index f0099a646a..3bf0495172 100644
--- a/net/ipv4/netfilter/ip_nat_proto_unknown.c
+++ b/net/ipv4/netfilter/ip_nat_proto_unknown.c
@@ -46,26 +46,10 @@ unknown_manip_pkt(struct sk_buff **pskb,
46 return 1; 46 return 1;
47} 47}
48 48
49static unsigned int
50unknown_print(char *buffer,
51 const struct ip_conntrack_tuple *match,
52 const struct ip_conntrack_tuple *mask)
53{
54 return 0;
55}
56
57static unsigned int
58unknown_print_range(char *buffer, const struct ip_nat_range *range)
59{
60 return 0;
61}
62
63struct ip_nat_protocol ip_nat_unknown_protocol = { 49struct ip_nat_protocol ip_nat_unknown_protocol = {
64 .name = "unknown", 50 .name = "unknown",
65 /* .me isn't set: getting a ref to this cannot fail. */ 51 /* .me isn't set: getting a ref to this cannot fail. */
66 .manip_pkt = unknown_manip_pkt, 52 .manip_pkt = unknown_manip_pkt,
67 .in_range = unknown_in_range, 53 .in_range = unknown_in_range,
68 .unique_tuple = unknown_unique_tuple, 54 .unique_tuple = unknown_unique_tuple,
69 .print = unknown_print,
70 .print_range = unknown_print_range
71}; 55};
diff --git a/net/ipv4/netfilter/ipt_mac.c b/net/ipv4/netfilter/ipt_mac.c
index 11a459e33f..1b9bb4559f 100644
--- a/net/ipv4/netfilter/ipt_mac.c
+++ b/net/ipv4/netfilter/ipt_mac.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/if_ether.h> 13#include <linux/if_ether.h>
14#include <linux/etherdevice.h>
14 15
15#include <linux/netfilter_ipv4/ipt_mac.h> 16#include <linux/netfilter_ipv4/ipt_mac.h>
16#include <linux/netfilter_ipv4/ip_tables.h> 17#include <linux/netfilter_ipv4/ip_tables.h>
@@ -33,8 +34,8 @@ match(const struct sk_buff *skb,
33 return (skb->mac.raw >= skb->head 34 return (skb->mac.raw >= skb->head
34 && (skb->mac.raw + ETH_HLEN) <= skb->data 35 && (skb->mac.raw + ETH_HLEN) <= skb->data
35 /* If so, compare... */ 36 /* If so, compare... */
36 && ((memcmp(eth_hdr(skb)->h_source, info->srcaddr, ETH_ALEN) 37 && ((!compare_ether_addr(eth_hdr(skb)->h_source, info->srcaddr))
37 == 0) ^ info->invert)); 38 ^ info->invert));
38} 39}
39 40
40static int 41static int
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 9bdbb77939..0c56c52a38 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -277,7 +277,7 @@ static struct nf_hook_ops ipv4_conntrack_local_in_ops = {
277 277
278#ifdef CONFIG_SYSCTL 278#ifdef CONFIG_SYSCTL
279/* From nf_conntrack_proto_icmp.c */ 279/* From nf_conntrack_proto_icmp.c */
280extern unsigned long nf_ct_icmp_timeout; 280extern unsigned int nf_ct_icmp_timeout;
281static struct ctl_table_header *nf_ct_ipv4_sysctl_header; 281static struct ctl_table_header *nf_ct_ipv4_sysctl_header;
282 282
283static ctl_table nf_ct_sysctl_table[] = { 283static ctl_table nf_ct_sysctl_table[] = {