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
e3305626
Commit
e3305626
authored
Nov 09, 2005
by
Christoph Hellwig
Committed by
Jeff Garzik
Nov 09, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ieee80211: cleanup crypto list handling, other minor cleanups.
parent
c2a8fad4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
111 deletions
+42
-111
include/net/ieee80211_crypt.h
include/net/ieee80211_crypt.h
+1
-0
net/ieee80211/ieee80211_crypt.c
net/ieee80211/ieee80211_crypt.c
+41
-111
No files found.
include/net/ieee80211_crypt.h
View file @
e3305626
...
@@ -31,6 +31,7 @@ enum {
...
@@ -31,6 +31,7 @@ enum {
struct
ieee80211_crypto_ops
{
struct
ieee80211_crypto_ops
{
const
char
*
name
;
const
char
*
name
;
struct
list_head
list
;
/* init new crypto context (e.g., allocate private data space,
/* init new crypto context (e.g., allocate private data space,
* select IV, etc.); returns NULL on failure or pointer to allocated
* select IV, etc.); returns NULL on failure or pointer to allocated
...
...
net/ieee80211/ieee80211_crypt.c
View file @
e3305626
...
@@ -11,15 +11,14 @@
...
@@ -11,15 +11,14 @@
*
*
*/
*/
#include <linux/
config
.h>
#include <linux/
errno
.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <asm/string.h>
#include <linux/string.h>
#include <asm/errno.h>
#include <net/ieee80211.h>
#include <net/ieee80211.h>
MODULE_AUTHOR
(
"Jouni Malinen"
);
MODULE_AUTHOR
(
"Jouni Malinen"
);
MODULE_DESCRIPTION
(
"HostAP crypto"
);
MODULE_DESCRIPTION
(
"HostAP crypto"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
...
@@ -29,32 +28,20 @@ struct ieee80211_crypto_alg {
...
@@ -29,32 +28,20 @@ struct ieee80211_crypto_alg {
struct
ieee80211_crypto_ops
*
ops
;
struct
ieee80211_crypto_ops
*
ops
;
};
};
struct
ieee80211_crypto
{
static
LIST_HEAD
(
ieee80211_crypto_algs
);
struct
list_head
algs
;
static
DEFINE_SPINLOCK
(
ieee80211_crypto_lock
);
spinlock_t
lock
;
};
static
struct
ieee80211_crypto
*
hcrypt
;
void
ieee80211_crypt_deinit_entries
(
struct
ieee80211_device
*
ieee
,
int
force
)
void
ieee80211_crypt_deinit_entries
(
struct
ieee80211_device
*
ieee
,
int
force
)
{
{
struct
list_head
*
ptr
,
*
n
;
struct
ieee80211_crypt_data
*
entry
,
*
next
;
struct
ieee80211_crypt_data
*
entry
;
unsigned
long
flags
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
ieee
->
lock
,
flags
);
spin_lock_irqsave
(
&
ieee
->
lock
,
flags
);
list_for_each_entry_safe
(
entry
,
next
,
&
ieee
->
crypt_deinit_list
,
list
)
{
if
(
list_empty
(
&
ieee
->
crypt_deinit_list
))
goto
unlock
;
for
(
ptr
=
ieee
->
crypt_deinit_list
.
next
,
n
=
ptr
->
next
;
ptr
!=
&
ieee
->
crypt_deinit_list
;
ptr
=
n
,
n
=
ptr
->
next
)
{
entry
=
list_entry
(
ptr
,
struct
ieee80211_crypt_data
,
list
);
if
(
atomic_read
(
&
entry
->
refcnt
)
!=
0
&&
!
force
)
if
(
atomic_read
(
&
entry
->
refcnt
)
!=
0
&&
!
force
)
continue
;
continue
;
list_del
(
ptr
);
list_del
(
&
entry
->
list
);
if
(
entry
->
ops
)
{
if
(
entry
->
ops
)
{
entry
->
ops
->
deinit
(
entry
->
priv
);
entry
->
ops
->
deinit
(
entry
->
priv
);
...
@@ -62,7 +49,6 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force)
...
@@ -62,7 +49,6 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force)
}
}
kfree
(
entry
);
kfree
(
entry
);
}
}
unlock:
spin_unlock_irqrestore
(
&
ieee
->
lock
,
flags
);
spin_unlock_irqrestore
(
&
ieee
->
lock
,
flags
);
}
}
...
@@ -125,9 +111,6 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
...
@@ -125,9 +111,6 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
unsigned
long
flags
;
unsigned
long
flags
;
struct
ieee80211_crypto_alg
*
alg
;
struct
ieee80211_crypto_alg
*
alg
;
if
(
hcrypt
==
NULL
)
return
-
1
;
alg
=
kmalloc
(
sizeof
(
*
alg
),
GFP_KERNEL
);
alg
=
kmalloc
(
sizeof
(
*
alg
),
GFP_KERNEL
);
if
(
alg
==
NULL
)
if
(
alg
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -135,9 +118,9 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
...
@@ -135,9 +118,9 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
memset
(
alg
,
0
,
sizeof
(
*
alg
));
memset
(
alg
,
0
,
sizeof
(
*
alg
));
alg
->
ops
=
ops
;
alg
->
ops
=
ops
;
spin_lock_irqsave
(
&
hcrypt
->
lock
,
flags
);
spin_lock_irqsave
(
&
ieee80211_crypto_
lock
,
flags
);
list_add
(
&
alg
->
list
,
&
hcrypt
->
algs
);
list_add
(
&
alg
->
list
,
&
ieee80211_crypto_
algs
);
spin_unlock_irqrestore
(
&
hcrypt
->
lock
,
flags
);
spin_unlock_irqrestore
(
&
ieee80211_crypto_
lock
,
flags
);
printk
(
KERN_DEBUG
"ieee80211_crypt: registered algorithm '%s'
\n
"
,
printk
(
KERN_DEBUG
"ieee80211_crypt: registered algorithm '%s'
\n
"
,
ops
->
name
);
ops
->
name
);
...
@@ -147,64 +130,49 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
...
@@ -147,64 +130,49 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
int
ieee80211_unregister_crypto_ops
(
struct
ieee80211_crypto_ops
*
ops
)
int
ieee80211_unregister_crypto_ops
(
struct
ieee80211_crypto_ops
*
ops
)
{
{
struct
ieee80211_crypto_alg
*
alg
;
unsigned
long
flags
;
unsigned
long
flags
;
struct
list_head
*
ptr
;
struct
ieee80211_crypto_alg
*
del_alg
=
NULL
;
if
(
hcrypt
==
NULL
)
return
-
1
;
spin_lock_irqsave
(
&
hcrypt
->
lock
,
flags
);
for
(
ptr
=
hcrypt
->
algs
.
next
;
ptr
!=
&
hcrypt
->
algs
;
ptr
=
ptr
->
next
)
{
struct
ieee80211_crypto_alg
*
alg
=
(
struct
ieee80211_crypto_alg
*
)
ptr
;
if
(
alg
->
ops
==
ops
)
{
list_del
(
&
alg
->
list
);
del_alg
=
alg
;
break
;
}
}
spin_unlock_irqrestore
(
&
hcrypt
->
lock
,
flags
);
if
(
del_alg
)
{
spin_lock_irqsave
(
&
ieee80211_crypto_lock
,
flags
);
printk
(
KERN_DEBUG
"ieee80211_crypt: unregistered algorithm "
list_for_each_entry
(
alg
,
&
ieee80211_crypto_algs
,
list
)
{
"'%s'
\n
"
,
ops
->
name
);
if
(
alg
->
ops
==
ops
)
kfree
(
del_alg
)
;
goto
found
;
}
}
spin_unlock_irqrestore
(
&
ieee80211_crypto_lock
,
flags
);
return
del_alg
?
0
:
-
1
;
return
-
EINVAL
;
found:
printk
(
KERN_DEBUG
"ieee80211_crypt: unregistered algorithm "
"'%s'
\n
"
,
ops
->
name
);
list_del
(
&
alg
->
list
);
spin_unlock_irqrestore
(
&
ieee80211_crypto_lock
,
flags
);
kfree
(
alg
);
return
0
;
}
}
struct
ieee80211_crypto_ops
*
ieee80211_get_crypto_ops
(
const
char
*
name
)
struct
ieee80211_crypto_ops
*
ieee80211_get_crypto_ops
(
const
char
*
name
)
{
{
struct
ieee80211_crypto_alg
*
alg
;
unsigned
long
flags
;
unsigned
long
flags
;
struct
list_head
*
ptr
;
struct
ieee80211_crypto_alg
*
found_alg
=
NULL
;
spin_lock_irqsave
(
&
ieee80211_crypto_lock
,
flags
);
list_for_each_entry
(
alg
,
&
ieee80211_crypto_algs
,
list
)
{
if
(
hcrypt
==
NULL
)
if
(
strcmp
(
alg
->
ops
->
name
,
name
)
==
0
)
return
NULL
;
goto
found
;
spin_lock_irqsave
(
&
hcrypt
->
lock
,
flags
);
for
(
ptr
=
hcrypt
->
algs
.
next
;
ptr
!=
&
hcrypt
->
algs
;
ptr
=
ptr
->
next
)
{
struct
ieee80211_crypto_alg
*
alg
=
(
struct
ieee80211_crypto_alg
*
)
ptr
;
if
(
strcmp
(
alg
->
ops
->
name
,
name
)
==
0
)
{
found_alg
=
alg
;
break
;
}
}
}
spin_unlock_irqrestore
(
&
hcrypt
->
lock
,
flags
);
spin_unlock_irqrestore
(
&
ieee80211_crypto_lock
,
flags
);
return
NULL
;
if
(
found_alg
)
found:
return
found_alg
->
ops
;
spin_unlock_irqrestore
(
&
ieee80211_crypto_lock
,
flags
);
else
return
alg
->
ops
;
return
NULL
;
}
}
static
void
*
ieee80211_crypt_null_init
(
int
keyidx
)
static
void
*
ieee80211_crypt_null_init
(
int
keyidx
)
{
{
return
(
void
*
)
1
;
return
(
void
*
)
1
;
}
}
static
void
ieee80211_crypt_null_deinit
(
void
*
priv
)
static
void
ieee80211_crypt_null_deinit
(
void
*
priv
)
{
{
}
}
...
@@ -213,56 +181,18 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = {
...
@@ -213,56 +181,18 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = {
.
name
=
"NULL"
,
.
name
=
"NULL"
,
.
init
=
ieee80211_crypt_null_init
,
.
init
=
ieee80211_crypt_null_init
,
.
deinit
=
ieee80211_crypt_null_deinit
,
.
deinit
=
ieee80211_crypt_null_deinit
,
.
encrypt_mpdu
=
NULL
,
.
decrypt_mpdu
=
NULL
,
.
encrypt_msdu
=
NULL
,
.
decrypt_msdu
=
NULL
,
.
set_key
=
NULL
,
.
get_key
=
NULL
,
.
extra_mpdu_prefix_len
=
0
,
.
extra_mpdu_postfix_len
=
0
,
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
};
};
static
int
__init
ieee80211_crypto_init
(
void
)
static
int
__init
ieee80211_crypto_init
(
void
)
{
{
int
ret
=
-
ENOMEM
;
return
ieee80211_register_crypto_ops
(
&
ieee80211_crypt_null
);
hcrypt
=
kmalloc
(
sizeof
(
*
hcrypt
),
GFP_KERNEL
);
if
(
!
hcrypt
)
goto
out
;
memset
(
hcrypt
,
0
,
sizeof
(
*
hcrypt
));
INIT_LIST_HEAD
(
&
hcrypt
->
algs
);
spin_lock_init
(
&
hcrypt
->
lock
);
ret
=
ieee80211_register_crypto_ops
(
&
ieee80211_crypt_null
);
if
(
ret
<
0
)
{
kfree
(
hcrypt
);
hcrypt
=
NULL
;
}
out:
return
ret
;
}
}
static
void
__exit
ieee80211_crypto_deinit
(
void
)
static
void
__exit
ieee80211_crypto_deinit
(
void
)
{
{
struct
list_head
*
ptr
,
*
n
;
ieee80211_unregister_crypto_ops
(
&
ieee80211_crypt_null
);
BUG_ON
(
!
list_empty
(
&
ieee80211_crypto_algs
));
if
(
hcrypt
==
NULL
)
return
;
for
(
ptr
=
hcrypt
->
algs
.
next
,
n
=
ptr
->
next
;
ptr
!=
&
hcrypt
->
algs
;
ptr
=
n
,
n
=
ptr
->
next
)
{
struct
ieee80211_crypto_alg
*
alg
=
(
struct
ieee80211_crypto_alg
*
)
ptr
;
list_del
(
ptr
);
printk
(
KERN_DEBUG
"ieee80211_crypt: unregistered algorithm "
"'%s' (deinit)
\n
"
,
alg
->
ops
->
name
);
kfree
(
alg
);
}
kfree
(
hcrypt
);
}
}
EXPORT_SYMBOL
(
ieee80211_crypt_deinit_entries
);
EXPORT_SYMBOL
(
ieee80211_crypt_deinit_entries
);
...
...
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