Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
2351392f
Commit
2351392f
authored
Sep 02, 2004
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://kernel.bkbits.net/davem/net-2.6
into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents
83d6ea2d
7cd101a5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
71 deletions
+25
-71
include/linux/netfilter_ipv4/ip_conntrack_ftp.h
include/linux/netfilter_ipv4/ip_conntrack_ftp.h
+0
-5
include/linux/netfilter_ipv4/ip_conntrack_irc.h
include/linux/netfilter_ipv4/ip_conntrack_irc.h
+0
-5
net/ipv4/netfilter/ip_conntrack_ftp.c
net/ipv4/netfilter/ip_conntrack_ftp.c
+1
-2
net/ipv4/netfilter/ip_conntrack_irc.c
net/ipv4/netfilter/ip_conntrack_irc.c
+3
-4
net/ipv4/netfilter/ip_nat_ftp.c
net/ipv4/netfilter/ip_nat_ftp.c
+12
-30
net/ipv4/netfilter/ip_nat_irc.c
net/ipv4/netfilter/ip_nat_irc.c
+9
-25
No files found.
include/linux/netfilter_ipv4/ip_conntrack_ftp.h
View file @
2351392f
...
...
@@ -4,11 +4,6 @@
#ifdef __KERNEL__
#include <linux/netfilter_ipv4/lockhelp.h>
/* Protects ftp part of conntracks */
DECLARE_LOCK_EXTERN
(
ip_ftp_lock
);
#define FTP_PORT 21
#endif
/* __KERNEL__ */
...
...
include/linux/netfilter_ipv4/ip_conntrack_irc.h
View file @
2351392f
...
...
@@ -33,13 +33,8 @@ struct ip_ct_irc_master {
#ifdef __KERNEL__
#include <linux/netfilter_ipv4/lockhelp.h>
#define IRC_PORT 6667
/* Protects irc part of conntracks */
DECLARE_LOCK_EXTERN
(
ip_irc_lock
);
#endif
/* __KERNEL__ */
#endif
/* _IP_CONNTRACK_IRC_H */
net/ipv4/netfilter/ip_conntrack_ftp.c
View file @
2351392f
...
...
@@ -28,7 +28,7 @@ MODULE_DESCRIPTION("ftp connection tracking helper");
/* This is slow, but it's simple. --RR */
static
char
ftp_buffer
[
65536
];
DECLARE_LOCK
(
ip_ftp_lock
);
static
DECLARE_LOCK
(
ip_ftp_lock
);
struct
module
*
ip_conntrack_ftp
=
THIS_MODULE
;
#define MAX_PORTS 8
...
...
@@ -460,7 +460,6 @@ static int __init init(void)
}
PROVIDES_CONNTRACK
(
ftp
);
EXPORT_SYMBOL
(
ip_ftp_lock
);
module_init
(
init
);
module_exit
(
fini
);
net/ipv4/netfilter/ip_conntrack_irc.c
View file @
2351392f
...
...
@@ -41,6 +41,7 @@ static int max_dcc_channels = 8;
static
unsigned
int
dcc_timeout
=
300
;
/* This is slow, but it's simple. --RR */
static
char
irc_buffer
[
65536
];
static
DECLARE_LOCK
(
irc_buffer_lock
);
MODULE_AUTHOR
(
"Harald Welte <laforge@netfilter.org>"
);
MODULE_DESCRIPTION
(
"IRC (DCC) connection tracking helper"
);
...
...
@@ -55,7 +56,6 @@ MODULE_PARM_DESC(dcc_timeout, "timeout on for unestablished DCC channels");
static
char
*
dccprotos
[]
=
{
"SEND "
,
"CHAT "
,
"MOVE "
,
"TSEND "
,
"SCHAT "
};
#define MINMATCHLEN 5
DECLARE_LOCK
(
ip_irc_lock
);
struct
module
*
ip_conntrack_irc
=
THIS_MODULE
;
#if 0
...
...
@@ -137,7 +137,7 @@ static int help(struct sk_buff *skb,
if
(
dataoff
>=
skb
->
len
)
return
NF_ACCEPT
;
LOCK_BH
(
&
i
p_irc
_lock
);
LOCK_BH
(
&
i
rc_buffer
_lock
);
ib_ptr
=
skb_header_pointer
(
skb
,
dataoff
,
skb
->
len
-
dataoff
,
irc_buffer
);
BUG_ON
(
ib_ptr
==
NULL
);
...
...
@@ -232,7 +232,7 @@ static int help(struct sk_buff *skb,
}
/* while data < ... */
out:
UNLOCK_BH
(
&
i
p_irc
_lock
);
UNLOCK_BH
(
&
i
rc_buffer
_lock
);
return
NF_ACCEPT
;
}
...
...
@@ -306,7 +306,6 @@ static void fini(void)
}
PROVIDES_CONNTRACK
(
irc
);
EXPORT_SYMBOL
(
ip_irc_lock
);
module_init
(
init
);
module_exit
(
fini
);
net/ipv4/netfilter/ip_nat_ftp.c
View file @
2351392f
...
...
@@ -36,8 +36,6 @@ static int ports_c;
module_param_array
(
ports
,
int
,
ports_c
,
0400
);
DECLARE_LOCK_EXTERN
(
ip_ftp_lock
);
/* FIXME: Time out? --RR */
static
unsigned
int
...
...
@@ -60,8 +58,6 @@ ftp_nat_expected(struct sk_buff **pskb,
DEBUGP
(
"nat_expected: We have a connection!
\n
"
);
exp_ftp_info
=
&
ct
->
master
->
help
.
exp_ftp_info
;
LOCK_BH
(
&
ip_ftp_lock
);
if
(
exp_ftp_info
->
ftptype
==
IP_CT_FTP_PORT
||
exp_ftp_info
->
ftptype
==
IP_CT_FTP_EPRT
)
{
/* PORT command: make connection go to the client. */
...
...
@@ -76,7 +72,6 @@ ftp_nat_expected(struct sk_buff **pskb,
DEBUGP
(
"nat_expected: PASV cmd. %u.%u.%u.%u->%u.%u.%u.%u
\n
"
,
NIPQUAD
(
newsrcip
),
NIPQUAD
(
newdstip
));
}
UNLOCK_BH
(
&
ip_ftp_lock
);
if
(
HOOK2MANIP
(
hooknum
)
==
IP_NAT_MANIP_SRC
)
newip
=
newsrcip
;
...
...
@@ -112,8 +107,6 @@ mangle_rfc959_packet(struct sk_buff **pskb,
{
char
buffer
[
sizeof
(
"nnn,nnn,nnn,nnn,nnn,nnn"
)];
MUST_BE_LOCKED
(
&
ip_ftp_lock
);
sprintf
(
buffer
,
"%u,%u,%u,%u,%u,%u"
,
NIPQUAD
(
newip
),
port
>>
8
,
port
&
0xFF
);
...
...
@@ -135,8 +128,6 @@ mangle_eprt_packet(struct sk_buff **pskb,
{
char
buffer
[
sizeof
(
"|1|255.255.255.255|65535|"
)];
MUST_BE_LOCKED
(
&
ip_ftp_lock
);
sprintf
(
buffer
,
"|1|%u.%u.%u.%u|%u|"
,
NIPQUAD
(
newip
),
port
);
DEBUGP
(
"calling ip_nat_mangle_tcp_packet
\n
"
);
...
...
@@ -157,8 +148,6 @@ mangle_epsv_packet(struct sk_buff **pskb,
{
char
buffer
[
sizeof
(
"|||65535|"
)];
MUST_BE_LOCKED
(
&
ip_ftp_lock
);
sprintf
(
buffer
,
"|||%u|"
,
port
);
DEBUGP
(
"calling ip_nat_mangle_tcp_packet
\n
"
);
...
...
@@ -178,7 +167,7 @@ static int (*mangle[])(struct sk_buff **, u_int32_t, u_int16_t,
[
IP_CT_FTP_EPSV
]
=
mangle_epsv_packet
};
static
int
ftp_data_fixup
(
const
struct
ip_ct_ftp_expect
*
ct
_ftp_info
,
static
int
ftp_data_fixup
(
const
struct
ip_ct_ftp_expect
*
exp
_ftp_info
,
struct
ip_conntrack
*
ct
,
struct
sk_buff
**
pskb
,
enum
ip_conntrack_info
ctinfo
,
...
...
@@ -190,15 +179,14 @@ static int ftp_data_fixup(const struct ip_ct_ftp_expect *ct_ftp_info,
u_int16_t
port
;
struct
ip_conntrack_tuple
newtuple
;
MUST_BE_LOCKED
(
&
ip_ftp_lock
);
DEBUGP
(
"FTP_NAT: seq %u + %u in %u
\n
"
,
expect
->
seq
,
ct
_ftp_info
->
len
,
expect
->
seq
,
exp
_ftp_info
->
len
,
ntohl
(
tcph
->
seq
));
/* Change address inside packet to match way we're mapping
this connection. */
if
(
ct
_ftp_info
->
ftptype
==
IP_CT_FTP_PASV
||
ct
_ftp_info
->
ftptype
==
IP_CT_FTP_EPSV
)
{
if
(
exp
_ftp_info
->
ftptype
==
IP_CT_FTP_PASV
||
exp
_ftp_info
->
ftptype
==
IP_CT_FTP_EPSV
)
{
/* PASV/EPSV response: must be where client thinks server
is */
newip
=
ct
->
tuplehash
[
IP_CT_DIR_ORIGINAL
].
tuple
.
dst
.
ip
;
...
...
@@ -220,7 +208,7 @@ static int ftp_data_fixup(const struct ip_ct_ftp_expect *ct_ftp_info,
newtuple
.
src
.
u
.
tcp
.
port
=
expect
->
tuple
.
src
.
u
.
tcp
.
port
;
/* Try to get same port: if not, try to change it. */
for
(
port
=
ct
_ftp_info
->
port
;
port
!=
0
;
port
++
)
{
for
(
port
=
exp
_ftp_info
->
port
;
port
!=
0
;
port
++
)
{
newtuple
.
dst
.
u
.
tcp
.
port
=
htons
(
port
);
if
(
ip_conntrack_change_expect
(
expect
,
&
newtuple
)
==
0
)
...
...
@@ -229,9 +217,9 @@ static int ftp_data_fixup(const struct ip_ct_ftp_expect *ct_ftp_info,
if
(
port
==
0
)
return
0
;
if
(
!
mangle
[
ct
_ftp_info
->
ftptype
](
pskb
,
newip
,
port
,
if
(
!
mangle
[
exp
_ftp_info
->
ftptype
](
pskb
,
newip
,
port
,
expect
->
seq
-
ntohl
(
tcph
->
seq
),
ct
_ftp_info
->
len
,
ct
,
ctinfo
))
exp
_ftp_info
->
len
,
ct
,
ctinfo
))
return
0
;
return
1
;
...
...
@@ -248,12 +236,12 @@ static unsigned int help(struct ip_conntrack *ct,
struct
tcphdr
*
tcph
=
(
void
*
)
iph
+
iph
->
ihl
*
4
;
unsigned
int
datalen
;
int
dir
;
struct
ip_ct_ftp_expect
*
ct
_ftp_info
;
struct
ip_ct_ftp_expect
*
exp
_ftp_info
;
if
(
!
exp
)
DEBUGP
(
"ip_nat_ftp: no exp!!"
);
ct
_ftp_info
=
&
exp
->
help
.
exp_ftp_info
;
exp
_ftp_info
=
&
exp
->
help
.
exp_ftp_info
;
/* Only mangle things once: original direction in POST_ROUTING
and reply direction on PRE_ROUTING. */
...
...
@@ -269,29 +257,23 @@ static unsigned int help(struct ip_conntrack *ct,
}
datalen
=
(
*
pskb
)
->
len
-
iph
->
ihl
*
4
-
tcph
->
doff
*
4
;
LOCK_BH
(
&
ip_ftp_lock
);
/* If it's in the right range... */
if
(
between
(
exp
->
seq
+
ct
_ftp_info
->
len
,
if
(
between
(
exp
->
seq
+
exp
_ftp_info
->
len
,
ntohl
(
tcph
->
seq
),
ntohl
(
tcph
->
seq
)
+
datalen
))
{
if
(
!
ftp_data_fixup
(
ct_ftp_info
,
ct
,
pskb
,
ctinfo
,
exp
))
{
UNLOCK_BH
(
&
ip_ftp_lock
);
if
(
!
ftp_data_fixup
(
exp_ftp_info
,
ct
,
pskb
,
ctinfo
,
exp
))
return
NF_DROP
;
}
}
else
{
/* Half a match? This means a partial retransmisison.
It's a cracker being funky. */
if
(
net_ratelimit
())
{
printk
(
"FTP_NAT: partial packet %u/%u in %u/%u
\n
"
,
exp
->
seq
,
ct
_ftp_info
->
len
,
exp
->
seq
,
exp
_ftp_info
->
len
,
ntohl
(
tcph
->
seq
),
ntohl
(
tcph
->
seq
)
+
datalen
);
}
UNLOCK_BH
(
&
ip_ftp_lock
);
return
NF_DROP
;
}
UNLOCK_BH
(
&
ip_ftp_lock
);
return
NF_ACCEPT
;
}
...
...
net/ipv4/netfilter/ip_nat_irc.c
View file @
2351392f
...
...
@@ -45,9 +45,6 @@ MODULE_LICENSE("GPL");
module_param_array
(
ports
,
int
,
ports_c
,
0400
);
MODULE_PARM_DESC
(
ports
,
"port numbers of IRC servers"
);
/* protects irc part of conntracks */
DECLARE_LOCK_EXTERN
(
ip_irc_lock
);
/* FIXME: Time out? --RR */
static
unsigned
int
...
...
@@ -88,7 +85,7 @@ irc_nat_expected(struct sk_buff **pskb,
return
ip_nat_setup_info
(
ct
,
&
mr
,
hooknum
);
}
static
int
irc_data_fixup
(
const
struct
ip_ct_irc_expect
*
ct
_irc_info
,
static
int
irc_data_fixup
(
const
struct
ip_ct_irc_expect
*
exp
_irc_info
,
struct
ip_conntrack
*
ct
,
struct
sk_buff
**
pskb
,
enum
ip_conntrack_info
ctinfo
,
...
...
@@ -103,23 +100,16 @@ static int irc_data_fixup(const struct ip_ct_irc_expect *ct_irc_info,
/* "4294967296 65635 " */
char
buffer
[
18
];
MUST_BE_LOCKED
(
&
ip_irc_lock
);
DEBUGP
(
"IRC_NAT: info (seq %u + %u) in %u
\n
"
,
expect
->
seq
,
ct
_irc_info
->
len
,
expect
->
seq
,
exp
_irc_info
->
len
,
ntohl
(
tcph
->
seq
));
newip
=
ct
->
tuplehash
[
IP_CT_DIR_REPLY
].
tuple
.
dst
.
ip
;
/* Alter conntrack's expectations. */
/* We can read expect here without conntrack lock, since it's
only set in ip_conntrack_irc, with ip_irc_lock held
writable */
t
=
expect
->
tuple
;
t
.
dst
.
ip
=
newip
;
for
(
port
=
ct
_irc_info
->
port
;
port
!=
0
;
port
++
)
{
for
(
port
=
exp
_irc_info
->
port
;
port
!=
0
;
port
++
)
{
t
.
dst
.
u
.
tcp
.
port
=
htons
(
port
);
if
(
ip_conntrack_change_expect
(
expect
,
&
t
)
==
0
)
{
DEBUGP
(
"using port %d"
,
port
);
...
...
@@ -149,7 +139,7 @@ static int irc_data_fixup(const struct ip_ct_irc_expect *ct_irc_info,
return
ip_nat_mangle_tcp_packet
(
pskb
,
ct
,
ctinfo
,
expect
->
seq
-
ntohl
(
tcph
->
seq
),
ct
_irc_info
->
len
,
buffer
,
exp
_irc_info
->
len
,
buffer
,
strlen
(
buffer
));
}
...
...
@@ -164,12 +154,12 @@ static unsigned int help(struct ip_conntrack *ct,
struct
tcphdr
*
tcph
=
(
void
*
)
iph
+
iph
->
ihl
*
4
;
unsigned
int
datalen
;
int
dir
;
struct
ip_ct_irc_expect
*
ct
_irc_info
;
struct
ip_ct_irc_expect
*
exp
_irc_info
;
if
(
!
exp
)
DEBUGP
(
"ip_nat_irc: no exp!!"
);
ct
_irc_info
=
&
exp
->
help
.
exp_irc_info
;
exp
_irc_info
=
&
exp
->
help
.
exp_irc_info
;
/* Only mangle things once: original direction in POST_ROUTING
and reply direction on PRE_ROUTING. */
...
...
@@ -186,30 +176,24 @@ static unsigned int help(struct ip_conntrack *ct,
DEBUGP
(
"got beyond not touching
\n
"
);
datalen
=
(
*
pskb
)
->
len
-
iph
->
ihl
*
4
-
tcph
->
doff
*
4
;
LOCK_BH
(
&
ip_irc_lock
);
/* Check whether the whole IP/address pattern is carried in the payload */
if
(
between
(
exp
->
seq
+
ct
_irc_info
->
len
,
if
(
between
(
exp
->
seq
+
exp
_irc_info
->
len
,
ntohl
(
tcph
->
seq
),
ntohl
(
tcph
->
seq
)
+
datalen
))
{
if
(
!
irc_data_fixup
(
ct_irc_info
,
ct
,
pskb
,
ctinfo
,
exp
))
{
UNLOCK_BH
(
&
ip_irc_lock
);
if
(
!
irc_data_fixup
(
exp_irc_info
,
ct
,
pskb
,
ctinfo
,
exp
))
return
NF_DROP
;
}
}
else
{
/* Half a match? This means a partial retransmisison.
It's a cracker being funky. */
if
(
net_ratelimit
())
{
printk
(
"IRC_NAT: partial packet %u/%u in %u/%u
\n
"
,
exp
->
seq
,
ct
_irc_info
->
len
,
exp
->
seq
,
exp
_irc_info
->
len
,
ntohl
(
tcph
->
seq
),
ntohl
(
tcph
->
seq
)
+
datalen
);
}
UNLOCK_BH
(
&
ip_irc_lock
);
return
NF_DROP
;
}
UNLOCK_BH
(
&
ip_irc_lock
);
return
NF_ACCEPT
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment