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
cc68945e
Commit
cc68945e
authored
Apr 02, 2003
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPSEC]: Store xfrm_encap_tmpl directly in xfrm_state.
parent
2348a17b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
22 deletions
+21
-22
include/net/xfrm.h
include/net/xfrm.h
+3
-1
net/ipv4/esp.c
net/ipv4/esp.c
+7
-8
net/key/af_key.c
net/key/af_key.c
+9
-11
net/xfrm/xfrm_state.c
net/xfrm/xfrm_state.c
+2
-2
No files found.
include/net/xfrm.h
View file @
cc68945e
...
...
@@ -118,7 +118,9 @@ struct xfrm_state
struct
xfrm_algo
*
aalg
;
struct
xfrm_algo
*
ealg
;
struct
xfrm_algo
*
calg
;
struct
xfrm_algo
*
encap_alg
;
/* Data for encapsulator */
struct
xfrm_encap_tmpl
*
encap
;
/* State for replay detection */
struct
xfrm_replay_state
replay
;
...
...
net/ipv4/esp.c
View file @
cc68945e
...
...
@@ -85,8 +85,7 @@ int esp_output(struct sk_buff *skb)
*
(
u8
*
)(
trailer
->
tail
+
clen
-
skb
->
len
-
2
)
=
(
clen
-
skb
->
len
)
-
2
;
pskb_put
(
skb
,
trailer
,
clen
-
skb
->
len
);
if
(
x
->
encap_alg
)
encap
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
);
encap
=
x
->
encap
;
iph
=
skb
->
nh
.
iph
;
if
(
x
->
props
.
mode
)
{
...
...
@@ -285,7 +284,7 @@ int esp_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_bu
/* ... check padding bits here. Silly. :-) */
if
(
x
->
encap
_alg
&&
decap
&&
decap
->
decap_type
)
{
if
(
x
->
encap
&&
decap
&&
decap
->
decap_type
)
{
struct
esp_encap_data
*
encap_data
;
struct
udphdr
*
uh
=
(
struct
udphdr
*
)
(
iph
+
1
);
...
...
@@ -337,11 +336,11 @@ int esp_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_bu
int
esp_post_input
(
struct
xfrm_state
*
x
,
struct
xfrm_decap_state
*
decap
,
struct
sk_buff
*
skb
)
{
if
(
x
->
encap
_alg
)
{
if
(
x
->
encap
)
{
struct
xfrm_encap_tmpl
*
encap
;
struct
esp_encap_data
*
decap_data
;
encap
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
)
;
encap
=
x
->
encap
;
decap_data
=
(
struct
esp_encap_data
*
)(
decap
->
decap_data
);
/* first, make sure that the decap type == the encap type */
...
...
@@ -517,9 +516,9 @@ int esp_init_state(struct xfrm_state *x, void *args)
x
->
props
.
header_len
=
sizeof
(
struct
ip_esp_hdr
)
+
esp
->
conf
.
ivlen
;
if
(
x
->
props
.
mode
)
x
->
props
.
header_len
+=
sizeof
(
struct
iphdr
);
if
(
x
->
encap
_alg
)
{
struct
xfrm_encap_tmpl
*
encap
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
);
if
(
x
->
encap
)
{
struct
xfrm_encap_tmpl
*
encap
=
x
->
encap
;
if
(
encap
->
encap_type
)
{
switch
(
encap
->
encap_type
)
{
case
UDP_ENCAP_ESPINUDP
:
...
...
net/key/af_key.c
View file @
cc68945e
...
...
@@ -646,8 +646,8 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
size
+=
sizeof
(
struct
sadb_key
)
+
encrypt_key_size
;
}
}
if
(
x
->
encap
_alg
)
natt
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
)
;
if
(
x
->
encap
)
natt
=
x
->
encap
;
if
(
natt
&&
natt
->
encap_type
)
{
size
+=
sizeof
(
struct
sadb_x_nat_t_type
);
...
...
@@ -1064,14 +1064,12 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
if
(
ext_hdrs
[
SADB_X_EXT_NAT_T_TYPE
-
1
])
{
struct
sadb_x_nat_t_type
*
n_type
;
struct
xfrm_encap_tmpl
*
natt
;
int
obits
=
(
sizeof
*
natt
);
x
->
encap
_alg
=
kmalloc
(
sizeof
(
*
x
->
encap_alg
)
+
obits
,
GFP_KERNEL
);
if
(
!
x
->
encap
_alg
)
x
->
encap
=
kmalloc
(
sizeof
(
*
x
->
encap
)
,
GFP_KERNEL
);
if
(
!
x
->
encap
)
goto
out
;
strcpy
(
x
->
encap_alg
->
alg_name
,
"NAT-T"
);
natt
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
);
natt
=
x
->
encap
;
n_type
=
ext_hdrs
[
SADB_X_EXT_NAT_T_TYPE
-
1
];
natt
->
encap_type
=
n_type
->
sadb_x_nat_t_type_type
;
...
...
@@ -1103,8 +1101,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
kfree
(
x
->
ealg
);
if
(
x
->
calg
)
kfree
(
x
->
calg
);
if
(
x
->
encap
_alg
)
kfree
(
x
->
encap
_alg
);
if
(
x
->
encap
)
kfree
(
x
->
encap
);
kfree
(
x
);
return
ERR_PTR
(
-
ENOBUFS
);
}
...
...
@@ -2561,10 +2559,10 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
if
(
!
satype
)
return
-
EINVAL
;
if
(
!
x
->
encap
_alg
)
if
(
!
x
->
encap
)
return
-
EINVAL
;
natt
=
(
struct
xfrm_encap_tmpl
*
)
(
x
->
encap_alg
->
alg_key
)
;
natt
=
x
->
encap
;
/* Build an SADB_X_NAT_T_NEW_MAPPING message:
*
...
...
net/xfrm/xfrm_state.c
View file @
cc68945e
...
...
@@ -157,8 +157,8 @@ void __xfrm_state_destroy(struct xfrm_state *x)
kfree
(
x
->
ealg
);
if
(
x
->
calg
)
kfree
(
x
->
calg
);
if
(
x
->
encap
_alg
)
kfree
(
x
->
encap
_alg
);
if
(
x
->
encap
)
kfree
(
x
->
encap
);
if
(
x
->
type
)
xfrm_put_type
(
x
->
type
);
kfree
(
x
);
...
...
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