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
Kirill Smelkov
linux
Commits
2dd7b159
Commit
2dd7b159
authored
May 17, 2003
by
Rusty Russell
Committed by
David S. Miller
May 17, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NETFILTER]: Move skb_ip_make_writable to netfilter.c.
parent
f868da7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
65 deletions
+69
-65
include/linux/netfilter_ipv4.h
include/linux/netfilter_ipv4.h
+6
-0
include/linux/netfilter_ipv4/ip_nat_core.h
include/linux/netfilter_ipv4/ip_nat_core.h
+0
-6
net/core/netfilter.c
net/core/netfilter.c
+63
-0
net/ipv4/netfilter/ip_nat_core.c
net/ipv4/netfilter/ip_nat_core.c
+0
-59
No files found.
include/linux/netfilter_ipv4.h
View file @
2dd7b159
...
...
@@ -75,6 +75,12 @@ void nf_debug_ip_finish_output2(struct sk_buff *skb);
#endif
/*CONFIG_NETFILTER_DEBUG*/
extern
int
ip_route_me_harder
(
struct
sk_buff
**
pskb
);
/* Call this before modifying an existing IP packet: ensures it is
modifiable and linear to the point you care about (writable_len).
Returns true or false. */
extern
int
skb_ip_make_writable
(
struct
sk_buff
**
pskb
,
unsigned
int
writable_len
);
#endif
/*__KERNEL__*/
#endif
/*__LINUX_IP_NETFILTER_H*/
include/linux/netfilter_ipv4/ip_nat_core.h
View file @
2dd7b159
...
...
@@ -30,10 +30,4 @@ extern void place_in_hashes(struct ip_conntrack *conntrack,
extern
struct
ip_nat_protocol
ip_nat_protocol_tcp
;
extern
struct
ip_nat_protocol
ip_nat_protocol_udp
;
extern
struct
ip_nat_protocol
ip_nat_protocol_icmp
;
/* Call this before modifying an existing IP packet: ensures it is
modifiable and linear to the point you care about (writable_len).
Returns true or false. */
extern
int
skb_ip_make_writable
(
struct
sk_buff
**
pskb
,
unsigned
int
writable_len
);
#endif
/* _IP_NAT_CORE_H */
net/core/netfilter.c
View file @
2dd7b159
...
...
@@ -20,6 +20,9 @@
#include <linux/if.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/icmp.h>
#include <net/sock.h>
#include <net/route.h>
#include <linux/ip.h>
...
...
@@ -683,8 +686,68 @@ int ip_route_me_harder(struct sk_buff **pskb)
return
err
;
}
int
skb_ip_make_writable
(
struct
sk_buff
**
pskb
,
unsigned
int
writable_len
)
{
struct
sk_buff
*
nskb
;
unsigned
int
iplen
;
if
(
writable_len
>
(
*
pskb
)
->
len
)
return
0
;
/* Not exclusive use of packet? Must copy. */
if
(
skb_shared
(
*
pskb
)
||
skb_cloned
(
*
pskb
))
goto
copy_skb
;
/* Alexey says IP hdr is always modifiable and linear, so ok. */
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
)
return
1
;
iplen
=
writable_len
-
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
;
/* DaveM says protocol headers are also modifiable. */
switch
((
*
pskb
)
->
nh
.
iph
->
protocol
)
{
case
IPPROTO_TCP
:
{
struct
tcphdr
hdr
;
if
(
skb_copy_bits
(
*
pskb
,
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
,
&
hdr
,
sizeof
(
hdr
))
!=
0
)
goto
copy_skb
;
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
hdr
.
doff
*
4
)
goto
pull_skb
;
goto
copy_skb
;
}
case
IPPROTO_UDP
:
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
sizeof
(
struct
udphdr
))
goto
pull_skb
;
goto
copy_skb
;
case
IPPROTO_ICMP
:
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
sizeof
(
struct
icmphdr
))
goto
pull_skb
;
goto
copy_skb
;
/* Insert other cases here as desired */
}
copy_skb:
nskb
=
skb_copy
(
*
pskb
,
GFP_ATOMIC
);
if
(
!
nskb
)
return
0
;
BUG_ON
(
skb_is_nonlinear
(
nskb
));
/* Rest of kernel will get very unhappy if we pass it a
suddenly-orphaned skbuff */
if
((
*
pskb
)
->
sk
)
skb_set_owner_w
(
nskb
,
(
*
pskb
)
->
sk
);
kfree_skb
(
*
pskb
);
*
pskb
=
nskb
;
return
1
;
pull_skb:
return
pskb_may_pull
(
*
pskb
,
writable_len
);
}
#endif
/*CONFIG_INET*/
/* This does not belong here, but ipt_REJECT needs it if connection
tracking in use: without this, connection may not be in hash table,
and hence manufactured ICMP or RST packets will not be associated
...
...
net/ipv4/netfilter/ip_nat_core.c
View file @
2dd7b159
...
...
@@ -969,65 +969,6 @@ icmp_reply_translation(struct sk_buff **pskb,
return
0
;
}
int
skb_ip_make_writable
(
struct
sk_buff
**
pskb
,
unsigned
int
writable_len
)
{
struct
sk_buff
*
nskb
;
unsigned
int
iplen
;
if
(
writable_len
>
(
*
pskb
)
->
len
)
return
0
;
/* Not exclusive use of packet? Must copy. */
if
(
skb_shared
(
*
pskb
)
||
skb_cloned
(
*
pskb
))
goto
copy_skb
;
/* Alexey says IP hdr is always modifiable and linear, so ok. */
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
)
return
1
;
iplen
=
writable_len
-
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
;
/* DaveM says protocol headers are also modifiable. */
switch
((
*
pskb
)
->
nh
.
iph
->
protocol
)
{
case
IPPROTO_TCP
:
{
struct
tcphdr
hdr
;
if
(
skb_copy_bits
(
*
pskb
,
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
,
&
hdr
,
sizeof
(
hdr
))
!=
0
)
goto
copy_skb
;
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
hdr
.
doff
*
4
)
goto
pull_skb
;
goto
copy_skb
;
}
case
IPPROTO_UDP
:
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
sizeof
(
struct
udphdr
))
goto
pull_skb
;
goto
copy_skb
;
case
IPPROTO_ICMP
:
if
(
writable_len
<=
(
*
pskb
)
->
nh
.
iph
->
ihl
*
4
+
sizeof
(
struct
icmphdr
))
goto
pull_skb
;
goto
copy_skb
;
/* Insert other cases here as desired */
}
copy_skb:
nskb
=
skb_copy
(
*
pskb
,
GFP_ATOMIC
);
if
(
!
nskb
)
return
0
;
BUG_ON
(
skb_is_nonlinear
(
nskb
));
/* Rest of kernel will get very unhappy if we pass it a
suddenly-orphaned skbuff */
if
((
*
pskb
)
->
sk
)
skb_set_owner_w
(
nskb
,
(
*
pskb
)
->
sk
);
kfree_skb
(
*
pskb
);
*
pskb
=
nskb
;
return
1
;
pull_skb:
return
pskb_may_pull
(
*
pskb
,
writable_len
);
}
int
__init
ip_nat_init
(
void
)
{
size_t
i
;
...
...
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