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
7c4d1c43
Commit
7c4d1c43
authored
Jun 28, 2003
by
Herbert Xu
Committed by
Hideaki Yoshifuji
Jun 28, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[XFRM] Set port/proto in acquire messages.
Also append policy spec to acquire message.
parent
31e6d03a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
27 deletions
+46
-27
include/linux/xfrm.h
include/linux/xfrm.h
+1
-0
net/xfrm/xfrm_user.c
net/xfrm/xfrm_user.c
+45
-27
No files found.
include/linux/xfrm.h
View file @
7c4d1c43
...
@@ -203,6 +203,7 @@ struct xfrm_userpolicy_id {
...
@@ -203,6 +203,7 @@ struct xfrm_userpolicy_id {
struct
xfrm_user_acquire
{
struct
xfrm_user_acquire
{
struct
xfrm_id
id
;
struct
xfrm_id
id
;
xfrm_address_t
saddr
;
xfrm_address_t
saddr
;
struct
xfrm_selector
sel
;
struct
xfrm_userpolicy_info
policy
;
struct
xfrm_userpolicy_info
policy
;
__u32
aalgos
;
__u32
aalgos
;
__u32
ealgos
;
__u32
ealgos
;
...
...
net/xfrm/xfrm_user.c
View file @
7c4d1c43
...
@@ -560,7 +560,7 @@ static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut,
...
@@ -560,7 +560,7 @@ static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut,
}
}
}
}
static
int
copy_user_tmpl
(
struct
xfrm_policy
*
pol
,
struct
rtattr
**
xfrma
)
static
int
copy_
from_
user_tmpl
(
struct
xfrm_policy
*
pol
,
struct
rtattr
**
xfrma
)
{
{
struct
rtattr
*
rt
=
xfrma
[
XFRMA_TMPL
-
1
];
struct
rtattr
*
rt
=
xfrma
[
XFRMA_TMPL
-
1
];
struct
xfrm_user_tmpl
*
utmpl
;
struct
xfrm_user_tmpl
*
utmpl
;
...
@@ -616,7 +616,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p,
...
@@ -616,7 +616,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p,
}
}
copy_from_user_policy
(
xp
,
p
);
copy_from_user_policy
(
xp
,
p
);
err
=
copy_user_tmpl
(
xp
,
xfrma
);
err
=
copy_
from_
user_tmpl
(
xp
,
xfrma
);
if
(
err
)
{
if
(
err
)
{
*
errp
=
err
;
*
errp
=
err
;
kfree
(
xp
);
kfree
(
xp
);
...
@@ -653,30 +653,14 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
...
@@ -653,30 +653,14 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
return
0
;
return
0
;
}
}
static
int
dump_one_policy
(
struct
xfrm_policy
*
xp
,
int
dir
,
int
count
,
void
*
ptr
)
static
int
copy_to_user_tmpl
(
struct
xfrm_policy
*
xp
,
struct
sk_buff
*
skb
)
{
{
struct
xfrm_dump_info
*
sp
=
ptr
;
struct
xfrm_userpolicy_info
*
p
;
struct
sk_buff
*
in_skb
=
sp
->
in_skb
;
struct
sk_buff
*
skb
=
sp
->
out_skb
;
struct
nlmsghdr
*
nlh
;
unsigned
char
*
b
=
skb
->
tail
;
if
(
sp
->
this_idx
<
sp
->
start_idx
)
goto
out
;
nlh
=
NLMSG_PUT
(
skb
,
NETLINK_CB
(
in_skb
).
pid
,
sp
->
nlmsg_seq
,
XFRM_MSG_NEWPOLICY
,
sizeof
(
*
p
));
p
=
NLMSG_DATA
(
nlh
);
nlh
->
nlmsg_flags
=
0
;
copy_to_user_policy
(
xp
,
p
,
dir
);
if
(
xp
->
xfrm_nr
)
{
struct
xfrm_user_tmpl
vec
[
XFRM_MAX_DEPTH
];
struct
xfrm_user_tmpl
vec
[
XFRM_MAX_DEPTH
];
int
i
;
int
i
;
if
(
xp
->
xfrm_nr
==
0
)
return
0
;
for
(
i
=
0
;
i
<
xp
->
xfrm_nr
;
i
++
)
{
for
(
i
=
0
;
i
<
xp
->
xfrm_nr
;
i
++
)
{
struct
xfrm_user_tmpl
*
up
=
&
vec
[
i
];
struct
xfrm_user_tmpl
*
up
=
&
vec
[
i
];
struct
xfrm_tmpl
*
kp
=
&
xp
->
xfrm_vec
[
i
];
struct
xfrm_tmpl
*
kp
=
&
xp
->
xfrm_vec
[
i
];
...
@@ -694,7 +678,34 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
...
@@ -694,7 +678,34 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
RTA_PUT
(
skb
,
XFRMA_TMPL
,
RTA_PUT
(
skb
,
XFRMA_TMPL
,
(
sizeof
(
struct
xfrm_user_tmpl
)
*
xp
->
xfrm_nr
),
(
sizeof
(
struct
xfrm_user_tmpl
)
*
xp
->
xfrm_nr
),
vec
);
vec
);
}
return
0
;
rtattr_failure:
return
-
1
;
}
static
int
dump_one_policy
(
struct
xfrm_policy
*
xp
,
int
dir
,
int
count
,
void
*
ptr
)
{
struct
xfrm_dump_info
*
sp
=
ptr
;
struct
xfrm_userpolicy_info
*
p
;
struct
sk_buff
*
in_skb
=
sp
->
in_skb
;
struct
sk_buff
*
skb
=
sp
->
out_skb
;
struct
nlmsghdr
*
nlh
;
unsigned
char
*
b
=
skb
->
tail
;
if
(
sp
->
this_idx
<
sp
->
start_idx
)
goto
out
;
nlh
=
NLMSG_PUT
(
skb
,
NETLINK_CB
(
in_skb
).
pid
,
sp
->
nlmsg_seq
,
XFRM_MSG_NEWPOLICY
,
sizeof
(
*
p
));
p
=
NLMSG_DATA
(
nlh
);
nlh
->
nlmsg_flags
=
0
;
copy_to_user_policy
(
xp
,
p
,
dir
);
if
(
copy_to_user_tmpl
(
xp
,
skb
)
<
0
)
goto
nlmsg_failure
;
nlh
->
nlmsg_len
=
skb
->
tail
-
b
;
nlh
->
nlmsg_len
=
skb
->
tail
-
b
;
out:
out:
...
@@ -702,7 +713,6 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
...
@@ -702,7 +713,6 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
return
0
;
return
0
;
nlmsg_failure:
nlmsg_failure:
rtattr_failure:
skb_trim
(
skb
,
b
-
skb
->
data
);
skb_trim
(
skb
,
b
-
skb
->
data
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1011,12 +1021,16 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
...
@@ -1011,12 +1021,16 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
memcpy
(
&
ua
->
id
,
&
x
->
id
,
sizeof
(
ua
->
id
));
memcpy
(
&
ua
->
id
,
&
x
->
id
,
sizeof
(
ua
->
id
));
memcpy
(
&
ua
->
saddr
,
&
x
->
props
.
saddr
,
sizeof
(
ua
->
saddr
));
memcpy
(
&
ua
->
saddr
,
&
x
->
props
.
saddr
,
sizeof
(
ua
->
saddr
));
memcpy
(
&
ua
->
sel
,
&
x
->
sel
,
sizeof
(
ua
->
sel
));
copy_to_user_policy
(
xp
,
&
ua
->
policy
,
dir
);
copy_to_user_policy
(
xp
,
&
ua
->
policy
,
dir
);
ua
->
aalgos
=
xt
->
aalgos
;
ua
->
aalgos
=
xt
->
aalgos
;
ua
->
ealgos
=
xt
->
ealgos
;
ua
->
ealgos
=
xt
->
ealgos
;
ua
->
calgos
=
xt
->
calgos
;
ua
->
calgos
=
xt
->
calgos
;
ua
->
seq
=
x
->
km
.
seq
=
seq
;
ua
->
seq
=
x
->
km
.
seq
=
seq
;
if
(
copy_to_user_tmpl
(
xp
,
skb
)
<
0
)
goto
nlmsg_failure
;
nlh
->
nlmsg_len
=
skb
->
tail
-
b
;
nlh
->
nlmsg_len
=
skb
->
tail
-
b
;
return
skb
->
len
;
return
skb
->
len
;
...
@@ -1029,8 +1043,12 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
...
@@ -1029,8 +1043,12 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
struct
xfrm_policy
*
xp
,
int
dir
)
struct
xfrm_policy
*
xp
,
int
dir
)
{
{
struct
sk_buff
*
skb
;
struct
sk_buff
*
skb
;
size_t
len
;
skb
=
alloc_skb
(
sizeof
(
struct
xfrm_user_acquire
)
+
16
,
GFP_ATOMIC
);
len
=
RTA_LENGTH
(
sizeof
(
struct
xfrm_user_tmpl
)
*
xp
->
xfrm_nr
);
len
=
RTA_ALIGN
(
len
);
len
+=
NLMSG_ALIGN
(
NLMSG_LENGTH
(
sizeof
(
struct
xfrm_user_acquire
)));
skb
=
alloc_skb
(
len
,
GFP_ATOMIC
);
if
(
skb
==
NULL
)
if
(
skb
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
...
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