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
0b8cf496
Commit
0b8cf496
authored
Aug 18, 2004
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge nuts.davemloft.net:/disk1/BK/xfrm-icmp-2.6
into nuts.davemloft.net:/disk1/BK/net-2.6
parents
af597aa6
1f68baf8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
157 additions
and
4 deletions
+157
-4
include/net/xfrm.h
include/net/xfrm.h
+42
-4
net/ipv4/raw.c
net/ipv4/raw.c
+48
-0
net/ipv4/xfrm4_policy.c
net/ipv4/xfrm4_policy.c
+9
-0
net/ipv6/raw.c
net/ipv6/raw.c
+48
-0
net/ipv6/xfrm6_policy.c
net/ipv6/xfrm6_policy.c
+10
-0
No files found.
include/net/xfrm.h
View file @
0b8cf496
...
@@ -421,13 +421,51 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
...
@@ -421,13 +421,51 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
return
1
;
return
1
;
}
}
static
__inline__
u16
xfrm_flowi_sport
(
struct
flowi
*
fl
)
{
u16
port
;
switch
(
fl
->
proto
)
{
case
IPPROTO_TCP
:
case
IPPROTO_UDP
:
port
=
fl
->
fl_ip_sport
;
break
;
case
IPPROTO_ICMP
:
case
IPPROTO_ICMPV6
:
port
=
htons
(
fl
->
fl_icmp_type
);
break
;
default:
port
=
0
;
/*XXX*/
}
return
port
;
}
static
__inline__
u16
xfrm_flowi_dport
(
struct
flowi
*
fl
)
{
u16
port
;
switch
(
fl
->
proto
)
{
case
IPPROTO_TCP
:
case
IPPROTO_UDP
:
port
=
fl
->
fl_ip_dport
;
break
;
case
IPPROTO_ICMP
:
case
IPPROTO_ICMPV6
:
port
=
htons
(
fl
->
fl_icmp_code
);
break
;
default:
port
=
0
;
/*XXX*/
}
return
port
;
}
static
inline
int
static
inline
int
__xfrm4_selector_match
(
struct
xfrm_selector
*
sel
,
struct
flowi
*
fl
)
__xfrm4_selector_match
(
struct
xfrm_selector
*
sel
,
struct
flowi
*
fl
)
{
{
return
addr_match
(
&
fl
->
fl4_dst
,
&
sel
->
daddr
,
sel
->
prefixlen_d
)
&&
return
addr_match
(
&
fl
->
fl4_dst
,
&
sel
->
daddr
,
sel
->
prefixlen_d
)
&&
addr_match
(
&
fl
->
fl4_src
,
&
sel
->
saddr
,
sel
->
prefixlen_s
)
&&
addr_match
(
&
fl
->
fl4_src
,
&
sel
->
saddr
,
sel
->
prefixlen_s
)
&&
!
((
fl
->
fl_ip_dport
^
sel
->
dport
)
&
sel
->
dport_mask
)
&&
!
((
xfrm_flowi_dport
(
fl
)
^
sel
->
dport
)
&
sel
->
dport_mask
)
&&
!
((
fl
->
fl_ip_sport
^
sel
->
sport
)
&
sel
->
sport_mask
)
&&
!
((
xfrm_flowi_sport
(
fl
)
^
sel
->
sport
)
&
sel
->
sport_mask
)
&&
(
fl
->
proto
==
sel
->
proto
||
!
sel
->
proto
)
&&
(
fl
->
proto
==
sel
->
proto
||
!
sel
->
proto
)
&&
(
fl
->
oif
==
sel
->
ifindex
||
!
sel
->
ifindex
);
(
fl
->
oif
==
sel
->
ifindex
||
!
sel
->
ifindex
);
}
}
...
@@ -437,8 +475,8 @@ __xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
...
@@ -437,8 +475,8 @@ __xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
{
{
return
addr_match
(
&
fl
->
fl6_dst
,
&
sel
->
daddr
,
sel
->
prefixlen_d
)
&&
return
addr_match
(
&
fl
->
fl6_dst
,
&
sel
->
daddr
,
sel
->
prefixlen_d
)
&&
addr_match
(
&
fl
->
fl6_src
,
&
sel
->
saddr
,
sel
->
prefixlen_s
)
&&
addr_match
(
&
fl
->
fl6_src
,
&
sel
->
saddr
,
sel
->
prefixlen_s
)
&&
!
((
fl
->
fl_ip_dport
^
sel
->
dport
)
&
sel
->
dport_mask
)
&&
!
((
xfrm_flowi_dport
(
fl
)
^
sel
->
dport
)
&
sel
->
dport_mask
)
&&
!
((
fl
->
fl_ip_sport
^
sel
->
sport
)
&
sel
->
sport_mask
)
&&
!
((
xfrm_flowi_sport
(
fl
)
^
sel
->
sport
)
&
sel
->
sport_mask
)
&&
(
fl
->
proto
==
sel
->
proto
||
!
sel
->
proto
)
&&
(
fl
->
proto
==
sel
->
proto
||
!
sel
->
proto
)
&&
(
fl
->
oif
==
sel
->
ifindex
||
!
sel
->
ifindex
);
(
fl
->
oif
==
sel
->
ifindex
||
!
sel
->
ifindex
);
}
}
...
...
net/ipv4/raw.c
View file @
0b8cf496
...
@@ -323,6 +323,51 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length,
...
@@ -323,6 +323,51 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length,
return
err
;
return
err
;
}
}
static
void
raw_probe_proto_opt
(
struct
flowi
*
fl
,
struct
msghdr
*
msg
)
{
struct
iovec
*
iov
;
u8
*
type
=
NULL
;
u8
*
code
=
NULL
;
int
probed
=
0
;
int
i
;
if
(
!
msg
->
msg_iov
)
return
;
for
(
i
=
0
;
i
<
msg
->
msg_iovlen
;
i
++
)
{
iov
=
&
msg
->
msg_iov
[
i
];
if
(
!
iov
)
continue
;
switch
(
fl
->
proto
)
{
case
IPPROTO_ICMP
:
/* check if one-byte field is readable or not. */
if
(
iov
->
iov_base
&&
iov
->
iov_len
<
1
)
break
;
if
(
!
type
)
{
type
=
iov
->
iov_base
;
/* check if code field is readable or not. */
if
(
iov
->
iov_len
>
1
)
code
=
type
+
1
;
}
else
if
(
!
code
)
code
=
iov
->
iov_base
;
if
(
type
&&
code
)
{
fl
->
fl_icmp_type
=
*
type
;
fl
->
fl_icmp_code
=
*
code
;
probed
=
1
;
}
break
;
default:
probed
=
1
;
break
;
}
if
(
probed
)
break
;
}
}
static
int
raw_sendmsg
(
struct
kiocb
*
iocb
,
struct
sock
*
sk
,
struct
msghdr
*
msg
,
static
int
raw_sendmsg
(
struct
kiocb
*
iocb
,
struct
sock
*
sk
,
struct
msghdr
*
msg
,
size_t
len
)
size_t
len
)
{
{
...
@@ -429,6 +474,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
...
@@ -429,6 +474,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.
proto
=
inet
->
hdrincl
?
IPPROTO_RAW
:
.
proto
=
inet
->
hdrincl
?
IPPROTO_RAW
:
sk
->
sk_protocol
,
sk
->
sk_protocol
,
};
};
if
(
!
inet
->
hdrincl
)
raw_probe_proto_opt
(
&
fl
,
msg
);
err
=
ip_route_output_flow
(
&
rt
,
&
fl
,
sk
,
!
(
msg
->
msg_flags
&
MSG_DONTWAIT
));
err
=
ip_route_output_flow
(
&
rt
,
&
fl
,
sk
,
!
(
msg
->
msg_flags
&
MSG_DONTWAIT
));
}
}
if
(
err
)
if
(
err
)
...
...
net/ipv4/xfrm4_policy.c
View file @
0b8cf496
...
@@ -183,6 +183,15 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
...
@@ -183,6 +183,15 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
}
}
break
;
break
;
case
IPPROTO_ICMP
:
if
(
pskb_may_pull
(
skb
,
xprth
+
2
-
skb
->
data
))
{
u8
*
icmp
=
xprth
;
fl
->
fl_icmp_type
=
icmp
[
0
];
fl
->
fl_icmp_code
=
icmp
[
1
];
}
break
;
case
IPPROTO_ESP
:
case
IPPROTO_ESP
:
if
(
pskb_may_pull
(
skb
,
xprth
+
4
-
skb
->
data
))
{
if
(
pskb_may_pull
(
skb
,
xprth
+
4
-
skb
->
data
))
{
u32
*
ehdr
=
(
u32
*
)
xprth
;
u32
*
ehdr
=
(
u32
*
)
xprth
;
...
...
net/ipv6/raw.c
View file @
0b8cf496
...
@@ -555,6 +555,52 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
...
@@ -555,6 +555,52 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
IP6_INC_STATS
(
IPSTATS_MIB_OUTDISCARDS
);
IP6_INC_STATS
(
IPSTATS_MIB_OUTDISCARDS
);
return
err
;
return
err
;
}
}
static
void
rawv6_probe_proto_opt
(
struct
flowi
*
fl
,
struct
msghdr
*
msg
)
{
struct
iovec
*
iov
;
u8
*
type
=
NULL
;
u8
*
code
=
NULL
;
int
probed
=
0
;
int
i
;
if
(
!
msg
->
msg_iov
)
return
;
for
(
i
=
0
;
i
<
msg
->
msg_iovlen
;
i
++
)
{
iov
=
&
msg
->
msg_iov
[
i
];
if
(
!
iov
)
continue
;
switch
(
fl
->
proto
)
{
case
IPPROTO_ICMPV6
:
/* check if one-byte field is readable or not. */
if
(
iov
->
iov_base
&&
iov
->
iov_len
<
1
)
break
;
if
(
!
type
)
{
type
=
iov
->
iov_base
;
/* check if code field is readable or not. */
if
(
iov
->
iov_len
>
1
)
code
=
type
+
1
;
}
else
if
(
!
code
)
code
=
iov
->
iov_base
;
if
(
type
&&
code
)
{
fl
->
fl_icmp_type
=
*
type
;
fl
->
fl_icmp_code
=
*
code
;
probed
=
1
;
}
break
;
default:
probed
=
1
;
break
;
}
if
(
probed
)
break
;
}
}
static
int
rawv6_sendmsg
(
struct
kiocb
*
iocb
,
struct
sock
*
sk
,
static
int
rawv6_sendmsg
(
struct
kiocb
*
iocb
,
struct
sock
*
sk
,
struct
msghdr
*
msg
,
size_t
len
)
struct
msghdr
*
msg
,
size_t
len
)
{
{
...
@@ -674,6 +720,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
...
@@ -674,6 +720,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
opt
=
fl6_merge_options
(
&
opt_space
,
flowlabel
,
opt
);
opt
=
fl6_merge_options
(
&
opt_space
,
flowlabel
,
opt
);
fl
.
proto
=
proto
;
fl
.
proto
=
proto
;
rawv6_probe_proto_opt
(
&
fl
,
msg
);
ipv6_addr_copy
(
&
fl
.
fl6_dst
,
daddr
);
ipv6_addr_copy
(
&
fl
.
fl6_dst
,
daddr
);
if
(
ipv6_addr_any
(
&
fl
.
fl6_src
)
&&
!
ipv6_addr_any
(
&
np
->
saddr
))
if
(
ipv6_addr_any
(
&
fl
.
fl6_src
)
&&
!
ipv6_addr_any
(
&
np
->
saddr
))
ipv6_addr_copy
(
&
fl
.
fl6_src
,
&
np
->
saddr
);
ipv6_addr_copy
(
&
fl
.
fl6_src
,
&
np
->
saddr
);
...
...
net/ipv6/xfrm6_policy.c
View file @
0b8cf496
...
@@ -213,6 +213,16 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
...
@@ -213,6 +213,16 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
fl
->
proto
=
nexthdr
;
fl
->
proto
=
nexthdr
;
return
;
return
;
case
IPPROTO_ICMPV6
:
if
(
pskb_may_pull
(
skb
,
skb
->
nh
.
raw
+
offset
+
2
-
skb
->
data
))
{
u8
*
icmp
=
(
u8
*
)
exthdr
;
fl
->
fl_icmp_type
=
icmp
[
0
];
fl
->
fl_icmp_code
=
icmp
[
1
];
}
fl
->
proto
=
nexthdr
;
return
;
/* XXX Why are there these headers? */
/* XXX Why are there these headers? */
case
IPPROTO_AH
:
case
IPPROTO_AH
:
case
IPPROTO_ESP
:
case
IPPROTO_ESP
:
...
...
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