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
0d51db7b
Commit
0d51db7b
authored
Jun 19, 2004
by
Hideaki Yoshifuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IPV6] XFRM: support (uncompressed) tunnel mode ipcomp6 using xfrm6_tunnel infrastructure.
parent
b4c8b9eb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
719 additions
and
14 deletions
+719
-14
include/net/xfrm.h
include/net/xfrm.h
+14
-4
net/ipv6/Makefile
net/ipv6/Makefile
+2
-1
net/ipv6/ip6_tunnel.c
net/ipv6/ip6_tunnel.c
+9
-9
net/ipv6/ipcomp6.c
net/ipv6/ipcomp6.c
+69
-0
net/ipv6/xfrm6_policy.c
net/ipv6/xfrm6_policy.c
+2
-0
net/ipv6/xfrm6_tunnel.c
net/ipv6/xfrm6_tunnel.c
+623
-0
No files found.
include/net/xfrm.h
View file @
0d51db7b
...
...
@@ -497,10 +497,6 @@ xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
return
0
;
}
/* placeholder until xfrm6_tunnel.c is written */
static
inline
int
xfrm6_tunnel_check_size
(
struct
sk_buff
*
skb
)
{
return
0
;
}
/* A struct encoding bundle of transformations to apply to some set of flow.
*
* dst->child points to the next element of bundle.
...
...
@@ -783,6 +779,12 @@ struct xfrm_tunnel {
void
(
*
err_handler
)(
struct
sk_buff
*
skb
,
void
*
info
);
};
struct
xfrm6_tunnel
{
int
(
*
handler
)(
struct
sk_buff
**
pskb
,
unsigned
int
*
nhoffp
);
void
(
*
err_handler
)(
struct
sk_buff
*
skb
,
struct
inet6_skb_parm
*
opt
,
int
type
,
int
code
,
int
offset
,
__u32
info
);
};
extern
void
xfrm_init
(
void
);
extern
void
xfrm4_init
(
void
);
extern
void
xfrm4_fini
(
void
);
...
...
@@ -793,6 +795,8 @@ extern void xfrm4_state_init(void);
extern
void
xfrm4_state_fini
(
void
);
extern
void
xfrm6_state_init
(
void
);
extern
void
xfrm6_state_fini
(
void
);
extern
void
xfrm6_tunnel_init
(
void
);
extern
void
xfrm6_tunnel_fini
(
void
);
extern
int
xfrm_state_walk
(
u8
proto
,
int
(
*
func
)(
struct
xfrm_state
*
,
int
,
void
*
),
void
*
);
extern
struct
xfrm_state
*
xfrm_state_alloc
(
void
);
...
...
@@ -818,6 +822,12 @@ extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler);
extern
int
xfrm4_tunnel_deregister
(
struct
xfrm_tunnel
*
handler
);
extern
int
xfrm4_tunnel_check_size
(
struct
sk_buff
*
skb
);
extern
int
xfrm6_rcv
(
struct
sk_buff
**
pskb
,
unsigned
int
*
nhoffp
);
extern
int
xfrm6_tunnel_register
(
struct
xfrm6_tunnel
*
handler
);
extern
int
xfrm6_tunnel_deregister
(
struct
xfrm6_tunnel
*
handler
);
extern
int
xfrm6_tunnel_check_size
(
struct
sk_buff
*
skb
);
extern
u32
xfrm6_tunnel_alloc_spi
(
xfrm_address_t
*
saddr
);
extern
void
xfrm6_tunnel_free_spi
(
xfrm_address_t
*
saddr
);
extern
u32
xfrm6_tunnel_spi_lookup
(
xfrm_address_t
*
saddr
);
#ifdef CONFIG_XFRM
extern
int
xfrm4_rcv_encap
(
struct
sk_buff
*
skb
,
__u16
encap_type
);
...
...
net/ipv6/Makefile
View file @
0d51db7b
...
...
@@ -10,7 +10,8 @@ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \
exthdrs.o sysctl_net_ipv6.o datagram.o proc.o
\
ip6_flowlabel.o ipv6_syms.o
ipv6-$(CONFIG_XFRM)
+=
xfrm6_policy.o xfrm6_state.o xfrm6_input.o
ipv6-$(CONFIG_XFRM)
+=
xfrm6_policy.o xfrm6_state.o xfrm6_input.o
\
xfrm6_tunnel.o
ipv6-objs
+=
$
(
ipv6-y
)
obj-$(CONFIG_INET6_AH)
+=
ah6.o
...
...
net/ipv6/ip6_tunnel.c
View file @
0d51db7b
...
...
@@ -540,8 +540,7 @@ ip6ip6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
read_unlock
(
&
ip6ip6_lock
);
icmpv6_send
(
skb
,
ICMPV6_DEST_UNREACH
,
ICMPV6_ADDR_UNREACH
,
0
,
skb
->
dev
);
discard:
kfree_skb
(
skb
);
return
0
;
return
1
;
}
static
inline
struct
ipv6_txoptions
*
create_tel
(
__u8
encap_limit
)
...
...
@@ -1097,10 +1096,9 @@ ip6ip6_fb_tnl_dev_init(struct net_device *dev)
return
0
;
}
static
struct
inet6_protocol
ip6ip6_protocol
=
{
static
struct
xfrm6_tunnel
ip6ip6_handler
=
{
.
handler
=
ip6ip6_rcv
,
.
err_handler
=
ip6ip6_err
,
.
flags
=
INET6_PROTO_FINAL
};
/**
...
...
@@ -1113,9 +1111,9 @@ static int __init ip6_tunnel_init(void)
{
int
err
;
if
(
(
err
=
inet6_add_protocol
(
&
ip6ip6_protocol
,
IPPROTO_IPV6
)
)
<
0
)
{
printk
(
KERN_ERR
"
Failed to register IPv6 protoco
l
\n
"
);
return
err
;
if
(
xfrm6_tunnel_register
(
&
ip6ip6_handler
)
<
0
)
{
printk
(
KERN_ERR
"
ip6ip6 init: can't register tunne
l
\n
"
);
return
-
EAGAIN
;
}
ip6ip6_fb_tnl_dev
=
alloc_netdev
(
sizeof
(
struct
ip6_tnl
),
"ip6tnl0"
,
ip6ip6_tnl_dev_setup
);
...
...
@@ -1132,7 +1130,7 @@ static int __init ip6_tunnel_init(void)
}
return
0
;
fail:
inet6_del_protocol
(
&
ip6ip6_protocol
,
IPPROTO_IPV6
);
xfrm6_tunnel_deregister
(
&
ip6ip6_handler
);
return
err
;
}
...
...
@@ -1142,8 +1140,10 @@ static int __init ip6_tunnel_init(void)
static
void
__exit
ip6_tunnel_cleanup
(
void
)
{
if
(
xfrm6_tunnel_deregister
(
&
ip6ip6_handler
)
<
0
)
printk
(
KERN_INFO
"ip6ip6 close: can't deregister tunnel
\n
"
);
unregister_netdev
(
ip6ip6_fb_tnl_dev
);
inet6_del_protocol
(
&
ip6ip6_protocol
,
IPPROTO_IPV6
);
}
module_init
(
ip6_tunnel_init
);
...
...
net/ipv6/ipcomp6.c
View file @
0d51db7b
...
...
@@ -258,6 +258,66 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
xfrm_state_put
(
x
);
}
static
struct
xfrm_state
*
ipcomp6_tunnel_create
(
struct
xfrm_state
*
x
)
{
struct
xfrm_state
*
t
=
NULL
;
t
=
xfrm_state_alloc
();
if
(
!
t
)
goto
out
;
t
->
id
.
proto
=
IPPROTO_IPV6
;
t
->
id
.
spi
=
xfrm6_tunnel_alloc_spi
((
xfrm_address_t
*
)
&
x
->
props
.
saddr
);
memcpy
(
t
->
id
.
daddr
.
a6
,
x
->
id
.
daddr
.
a6
,
sizeof
(
struct
in6_addr
));
memcpy
(
&
t
->
sel
,
&
x
->
sel
,
sizeof
(
t
->
sel
));
t
->
props
.
family
=
AF_INET6
;
t
->
props
.
mode
=
1
;
memcpy
(
t
->
props
.
saddr
.
a6
,
x
->
props
.
saddr
.
a6
,
sizeof
(
struct
in6_addr
));
t
->
type
=
xfrm_get_type
(
IPPROTO_IPV6
,
t
->
props
.
family
);
if
(
t
->
type
==
NULL
)
goto
error
;
if
(
t
->
type
->
init_state
(
t
,
NULL
))
goto
error
;
t
->
km
.
state
=
XFRM_STATE_VALID
;
atomic_set
(
&
t
->
tunnel_users
,
1
);
out:
return
t
;
error:
xfrm_state_put
(
t
);
goto
out
;
}
static
int
ipcomp6_tunnel_attach
(
struct
xfrm_state
*
x
)
{
int
err
=
0
;
struct
xfrm_state
*
t
=
NULL
;
u32
spi
;
spi
=
xfrm6_tunnel_spi_lookup
((
xfrm_address_t
*
)
&
x
->
props
.
saddr
);
if
(
spi
)
t
=
xfrm_state_lookup
((
xfrm_address_t
*
)
&
x
->
id
.
daddr
,
spi
,
IPPROTO_IPV6
,
AF_INET6
);
if
(
!
t
)
{
t
=
ipcomp6_tunnel_create
(
x
);
if
(
!
t
)
{
err
=
-
EINVAL
;
goto
out
;
}
xfrm_state_insert
(
t
);
xfrm_state_hold
(
t
);
}
x
->
tunnel
=
t
;
atomic_inc
(
&
t
->
tunnel_users
);
out:
return
err
;
}
static
void
ipcomp6_free_data
(
struct
ipcomp_data
*
ipcd
)
{
if
(
ipcd
->
tfm
)
...
...
@@ -271,8 +331,11 @@ static void ipcomp6_destroy(struct xfrm_state *x)
struct
ipcomp_data
*
ipcd
=
x
->
data
;
if
(
!
ipcd
)
return
;
xfrm_state_delete_tunnel
(
x
);
ipcomp6_free_data
(
ipcd
);
kfree
(
ipcd
);
xfrm6_tunnel_free_spi
((
xfrm_address_t
*
)
&
x
->
props
.
saddr
);
}
static
int
ipcomp6_init_state
(
struct
xfrm_state
*
x
,
void
*
args
)
...
...
@@ -303,6 +366,12 @@ static int ipcomp6_init_state(struct xfrm_state *x, void *args)
if
(
!
ipcd
->
tfm
)
goto
error
;
if
(
x
->
props
.
mode
)
{
err
=
ipcomp6_tunnel_attach
(
x
);
if
(
err
)
goto
error
;
}
calg_desc
=
xfrm_calg_get_byname
(
x
->
calg
->
alg_name
);
BUG_ON
(
!
calg_desc
);
ipcd
->
threshold
=
calg_desc
->
uinfo
.
comp
.
threshold
;
...
...
net/ipv6/xfrm6_policy.c
View file @
0d51db7b
...
...
@@ -277,10 +277,12 @@ void __init xfrm6_init(void)
{
xfrm6_policy_init
();
xfrm6_state_init
();
xfrm6_tunnel_init
();
}
void
__exit
xfrm6_fini
(
void
)
{
xfrm6_tunnel_fini
();
//xfrm6_input_fini();
xfrm6_policy_fini
();
xfrm6_state_fini
();
...
...
net/ipv6/xfrm6_tunnel.c
0 → 100644
View file @
0d51db7b
This diff is collapsed.
Click to expand it.
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