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
b42597e2
Commit
b42597e2
authored
Jul 11, 2012
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipv4: Add ipv4_redirect() and ipv4_sk_redirect() helper functions.
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parent
e47a185b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
include/net/route.h
include/net/route.h
+3
-0
net/ipv4/route.c
net/ipv4/route.c
+28
-0
No files found.
include/net/route.h
View file @
b42597e2
...
...
@@ -180,6 +180,9 @@ static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 s
extern
void
ipv4_update_pmtu
(
struct
sk_buff
*
skb
,
struct
net
*
net
,
u32
mtu
,
int
oif
,
u32
mark
,
u8
protocol
,
int
flow_flags
);
extern
void
ipv4_sk_update_pmtu
(
struct
sk_buff
*
skb
,
struct
sock
*
sk
,
u32
mtu
);
extern
void
ipv4_redirect
(
struct
sk_buff
*
skb
,
struct
net
*
net
,
int
oif
,
u32
mark
,
u8
protocol
,
int
flow_flags
);
extern
void
ipv4_sk_redirect
(
struct
sk_buff
*
skb
,
struct
sock
*
sk
);
extern
void
ip_rt_send_redirect
(
struct
sk_buff
*
skb
);
extern
unsigned
int
inet_addr_type
(
struct
net
*
net
,
__be32
addr
);
...
...
net/ipv4/route.c
View file @
b42597e2
...
...
@@ -1590,6 +1590,34 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu)
}
EXPORT_SYMBOL_GPL
(
ipv4_sk_update_pmtu
);
void
ipv4_redirect
(
struct
sk_buff
*
skb
,
struct
net
*
net
,
int
oif
,
u32
mark
,
u8
protocol
,
int
flow_flags
)
{
const
struct
iphdr
*
iph
=
(
const
struct
iphdr
*
)
skb
->
data
;
struct
flowi4
fl4
;
struct
rtable
*
rt
;
flowi4_init_output
(
&
fl4
,
oif
,
mark
,
RT_TOS
(
iph
->
tos
),
RT_SCOPE_UNIVERSE
,
protocol
,
flow_flags
,
iph
->
daddr
,
iph
->
saddr
,
0
,
0
);
rt
=
__ip_route_output_key
(
net
,
&
fl4
);
if
(
!
IS_ERR
(
rt
))
{
ip_do_redirect
(
&
rt
->
dst
,
skb
);
ip_rt_put
(
rt
);
}
}
EXPORT_SYMBOL_GPL
(
ipv4_redirect
);
void
ipv4_sk_redirect
(
struct
sk_buff
*
skb
,
struct
sock
*
sk
)
{
const
struct
inet_sock
*
inet
=
inet_sk
(
sk
);
return
ipv4_redirect
(
skb
,
sock_net
(
sk
),
sk
->
sk_bound_dev_if
,
sk
->
sk_mark
,
inet
->
hdrincl
?
IPPROTO_RAW
:
sk
->
sk_protocol
,
inet_sk_flowi_flags
(
sk
));
}
EXPORT_SYMBOL_GPL
(
ipv4_sk_redirect
);
static
struct
dst_entry
*
ipv4_dst_check
(
struct
dst_entry
*
dst
,
u32
cookie
)
{
struct
rtable
*
rt
=
(
struct
rtable
*
)
dst
;
...
...
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