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
e1be85a7
Commit
e1be85a7
authored
Feb 12, 2003
by
Tom Lendacky
Committed by
David S. Miller
Feb 12, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPSEC] Make sure SADB_X_SPDADD messages have proper spid.
parent
8f8703a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
net/key/af_key.c
net/key/af_key.c
+23
-19
No files found.
net/key/af_key.c
View file @
e1be85a7
...
...
@@ -1394,24 +1394,23 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol)
return
0
;
}
static
struct
sk_buff
*
pfkey_xfrm_policy2msg
(
struct
xfrm_policy
*
xp
,
int
dir
)
static
int
pfkey_xfrm_policy2msg_size
(
struct
xfrm_policy
*
xp
)
{
return
sizeof
(
struct
sadb_msg
)
+
(
sizeof
(
struct
sadb_lifetime
)
*
3
)
+
(
sizeof
(
struct
sadb_address
)
*
2
)
+
(
sizeof
(
struct
sockaddr_in
)
*
2
)
+
/* XXX */
sizeof
(
struct
sadb_x_policy
)
+
(
xp
->
xfrm_nr
*
(
sizeof
(
struct
sadb_x_ipsecrequest
)
+
(
sizeof
(
struct
sockaddr_in
)
*
2
)));
}
static
struct
sk_buff
*
pfkey_xfrm_policy2msg_prep
(
struct
xfrm_policy
*
xp
)
{
struct
sk_buff
*
skb
;
struct
sadb_msg
*
hdr
;
struct
sadb_address
*
addr
;
struct
sadb_lifetime
*
lifetime
;
struct
sadb_x_policy
*
pol
;
struct
sockaddr_in
*
sin
;
int
i
;
int
size
;
size
=
sizeof
(
struct
sadb_msg
)
+
sizeof
(
struct
sadb_lifetime
)
*
3
+
sizeof
(
struct
sadb_address
)
*
2
+
sizeof
(
struct
sockaddr_in
)
*
2
+
/* XXX */
sizeof
(
struct
sadb_x_policy
)
+
xp
->
xfrm_nr
*
(
sizeof
(
struct
sadb_x_ipsecrequest
)
+
sizeof
(
struct
sockaddr_in
)
*
2
);
size
=
pfkey_xfrm_policy2msg_size
(
xp
);
skb
=
alloc_skb
(
size
+
16
,
GFP_ATOMIC
);
if
(
skb
==
NULL
)
...
...
@@ -1533,7 +1532,6 @@ static struct sk_buff * pfkey_xfrm_policy2msg(struct xfrm_policy *xp, int dir)
}
hdr
->
sadb_msg_len
=
size
/
sizeof
(
uint64_t
);
hdr
->
sadb_msg_reserved
=
atomic_read
(
&
xp
->
refcnt
);
return
skb
;
}
static
int
pfkey_spdadd
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
,
struct
sadb_msg
*
hdr
,
void
**
ext_hdrs
)
...
...
@@ -1606,7 +1604,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
(
err
=
parse_ipsecrequests
(
xp
,
pol
))
<
0
)
goto
out
;
out_skb
=
pfkey_xfrm_policy2msg
(
xp
,
pol
->
sadb_x_policy_dir
-
1
);
out_skb
=
pfkey_xfrm_policy2msg
_prep
(
xp
);
if
(
IS_ERR
(
out_skb
))
{
err
=
PTR_ERR
(
out_skb
);
goto
out
;
...
...
@@ -1619,6 +1617,8 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
goto
out
;
}
pfkey_xfrm_policy2msg
(
out_skb
,
xp
,
pol
->
sadb_x_policy_dir
-
1
);
xfrm_pol_put
(
xp
);
out_hdr
=
(
struct
sadb_msg
*
)
out_skb
->
data
;
...
...
@@ -1679,11 +1679,12 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
err
=
0
;
out_skb
=
pfkey_xfrm_policy2msg
(
xp
,
pol
->
sadb_x_policy_dir
-
1
);
out_skb
=
pfkey_xfrm_policy2msg
_prep
(
xp
);
if
(
IS_ERR
(
out_skb
))
{
err
=
PTR_ERR
(
out_skb
);
goto
out
;
}
pfkey_xfrm_policy2msg
(
out_skb
,
xp
,
pol
->
sadb_x_policy_dir
-
1
);
out_hdr
=
(
struct
sadb_msg
*
)
out_skb
->
data
;
out_hdr
->
sadb_msg_version
=
hdr
->
sadb_msg_version
;
...
...
@@ -1721,11 +1722,12 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
err
=
0
;
out_skb
=
pfkey_xfrm_policy2msg
(
xp
,
pol
->
sadb_x_policy_dir
-
1
);
out_skb
=
pfkey_xfrm_policy2msg
_prep
(
xp
);
if
(
IS_ERR
(
out_skb
))
{
err
=
PTR_ERR
(
out_skb
);
goto
out
;
}
pfkey_xfrm_policy2msg
(
out_skb
,
xp
,
pol
->
sadb_x_policy_dir
-
1
);
out_hdr
=
(
struct
sadb_msg
*
)
out_skb
->
data
;
out_hdr
->
sadb_msg_version
=
hdr
->
sadb_msg_version
;
...
...
@@ -1752,10 +1754,12 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
struct
sk_buff
*
out_skb
;
struct
sadb_msg
*
out_hdr
;
out_skb
=
pfkey_xfrm_policy2msg
(
xp
,
dir
);
out_skb
=
pfkey_xfrm_policy2msg
_prep
(
xp
);
if
(
IS_ERR
(
out_skb
))
return
PTR_ERR
(
out_skb
);
pfkey_xfrm_policy2msg
(
out_skb
,
xp
,
dir
);
out_hdr
=
(
struct
sadb_msg
*
)
out_skb
->
data
;
out_hdr
->
sadb_msg_version
=
data
->
hdr
->
sadb_msg_version
;
out_hdr
->
sadb_msg_type
=
SADB_X_SPDDUMP
;
...
...
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