Use kmem_* instead of malloc/free and use interrupt versions as the code can be called from interrupt.diff -r1.18 -r1.19 src/sys/net80211/ieee80211_crypto_ccmp.c
(mlelstv)
--- src/sys/net80211/ieee80211_crypto_ccmp.c 2020/07/28 15:41:26 1.18
+++ src/sys/net80211/ieee80211_crypto_ccmp.c 2020/11/03 15:06:50 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ieee80211_crypto_ccmp.c,v 1.18 2020/07/28 15:41:26 riastradh Exp $ */ | 1 | /* $NetBSD: ieee80211_crypto_ccmp.c,v 1.19 2020/11/03 15:06:50 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | 4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | #ifdef __FreeBSD__ | 35 | #ifdef __FreeBSD__ | |
36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_ccmp.c,v 1.7 2005/07/11 03:06:23 sam Exp $"); | 36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_ccmp.c,v 1.7 2005/07/11 03:06:23 sam Exp $"); | |
37 | #endif | 37 | #endif | |
38 | #ifdef __NetBSD__ | 38 | #ifdef __NetBSD__ | |
39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_ccmp.c,v 1.18 2020/07/28 15:41:26 riastradh Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_ccmp.c,v 1.19 2020/11/03 15:06:50 mlelstv Exp $"); | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | /* | 42 | /* | |
43 | * IEEE 802.11i AES-CCMP crypto support. | 43 | * IEEE 802.11i AES-CCMP crypto support. | |
44 | * | 44 | * | |
45 | * Part of this module is derived from similar code in the Host | 45 | * Part of this module is derived from similar code in the Host | |
46 | * AP driver. The code is used with the consent of the author and | 46 | * AP driver. The code is used with the consent of the author and | |
47 | * its license is included below. | 47 | * its license is included below. | |
48 | */ | 48 | */ | |
49 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
50 | #include <sys/kernel.h> | 50 | #include <sys/kernel.h> | |
51 | #include <sys/kmem.h> | 51 | #include <sys/kmem.h> | |
52 | #include <sys/mbuf.h> | 52 | #include <sys/mbuf.h> | |
@@ -96,41 +96,41 @@ const struct ieee80211_cipher ieee80211_ | @@ -96,41 +96,41 @@ const struct ieee80211_cipher ieee80211_ | |||
96 | }; | 96 | }; | |
97 | 97 | |||
98 | #define ccmp ieee80211_cipher_ccmp | 98 | #define ccmp ieee80211_cipher_ccmp | |
99 | 99 | |||
100 | static int ccmp_encrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | 100 | static int ccmp_encrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | |
101 | static int ccmp_decrypt(struct ieee80211_key *, u_int64_t pn, | 101 | static int ccmp_decrypt(struct ieee80211_key *, u_int64_t pn, | |
102 | struct mbuf *, int hdrlen); | 102 | struct mbuf *, int hdrlen); | |
103 | 103 | |||
104 | static void * | 104 | static void * | |
105 | ccmp_attach(struct ieee80211com *ic, struct ieee80211_key *k) | 105 | ccmp_attach(struct ieee80211com *ic, struct ieee80211_key *k) | |
106 | { | 106 | { | |
107 | struct ccmp_ctx *ctx; | 107 | struct ccmp_ctx *ctx; | |
108 | 108 | |||
109 | ctx = kmem_zalloc(sizeof(*ctx), KM_NOSLEEP); | 109 | ctx = kmem_intr_zalloc(sizeof(*ctx), KM_NOSLEEP); | |
110 | if (ctx == NULL) { | 110 | if (ctx == NULL) { | |
111 | ic->ic_stats.is_crypto_nomem++; | 111 | ic->ic_stats.is_crypto_nomem++; | |
112 | return NULL; | 112 | return NULL; | |
113 | } | 113 | } | |
114 | ctx->cc_ic = ic; | 114 | ctx->cc_ic = ic; | |
115 | return ctx; | 115 | return ctx; | |
116 | } | 116 | } | |
117 | 117 | |||
118 | static void | 118 | static void | |
119 | ccmp_detach(struct ieee80211_key *k) | 119 | ccmp_detach(struct ieee80211_key *k) | |
120 | { | 120 | { | |
121 | struct ccmp_ctx *ctx = k->wk_private; | 121 | struct ccmp_ctx *ctx = k->wk_private; | |
122 | 122 | |||
123 | kmem_free(ctx, sizeof(*ctx)); | 123 | kmem_intr_free(ctx, sizeof(*ctx)); | |
124 | } | 124 | } | |
125 | 125 | |||
126 | static int | 126 | static int | |
127 | ccmp_setkey(struct ieee80211_key *k) | 127 | ccmp_setkey(struct ieee80211_key *k) | |
128 | { | 128 | { | |
129 | struct ccmp_ctx *ctx = k->wk_private; | 129 | struct ccmp_ctx *ctx = k->wk_private; | |
130 | 130 | |||
131 | if (k->wk_keylen != (128/NBBY)) { | 131 | if (k->wk_keylen != (128/NBBY)) { | |
132 | IEEE80211_DPRINTF(ctx->cc_ic, IEEE80211_MSG_CRYPTO, | 132 | IEEE80211_DPRINTF(ctx->cc_ic, IEEE80211_MSG_CRYPTO, | |
133 | "%s: Invalid key length %u, expecting %u\n", | 133 | "%s: Invalid key length %u, expecting %u\n", | |
134 | __func__, k->wk_keylen, 128/NBBY); | 134 | __func__, k->wk_keylen, 128/NBBY); | |
135 | return 0; | 135 | return 0; | |
136 | } | 136 | } |
--- src/sys/net80211/ieee80211_crypto_tkip.c 2019/12/19 16:29:50 1.16
+++ src/sys/net80211/ieee80211_crypto_tkip.c 2020/11/03 15:06:50 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ieee80211_crypto_tkip.c,v 1.16 2019/12/19 16:29:50 kamil Exp $ */ | 1 | /* $NetBSD: ieee80211_crypto_tkip.c,v 1.17 2020/11/03 15:06:50 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | 4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -26,40 +26,40 @@ | @@ -26,40 +26,40 @@ | |||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | #ifdef __FreeBSD__ | 35 | #ifdef __FreeBSD__ | |
36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_tkip.c,v 1.10 2005/08/08 18:46:35 sam Exp $"); | 36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_tkip.c,v 1.10 2005/08/08 18:46:35 sam Exp $"); | |
37 | #endif | 37 | #endif | |
38 | #ifdef __NetBSD__ | 38 | #ifdef __NetBSD__ | |
39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_tkip.c,v 1.16 2019/12/19 16:29:50 kamil Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_tkip.c,v 1.17 2020/11/03 15:06:50 mlelstv Exp $"); | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | /* | 42 | /* | |
43 | * IEEE 802.11i TKIP crypto support. | 43 | * IEEE 802.11i TKIP crypto support. | |
44 | * | 44 | * | |
45 | * Part of this module is derived from similar code in the Host | 45 | * Part of this module is derived from similar code in the Host | |
46 | * AP driver. The code is used with the consent of the author and | 46 | * AP driver. The code is used with the consent of the author and | |
47 | * its license is included below. | 47 | * its license is included below. | |
48 | */ | 48 | */ | |
49 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
50 | #include <sys/systm.h> | 50 | #include <sys/systm.h> | |
51 | #include <sys/mbuf.h> | 51 | #include <sys/mbuf.h> | |
52 | #include <sys/malloc.h> | 52 | #include <sys/kmem.h> | |
53 | #include <sys/kernel.h> | 53 | #include <sys/kernel.h> | |
54 | #include <sys/endian.h> | 54 | #include <sys/endian.h> | |
55 | 55 | |||
56 | #include <sys/socket.h> | 56 | #include <sys/socket.h> | |
57 | 57 | |||
58 | #include <net/if.h> | 58 | #include <net/if.h> | |
59 | #include <net/if_ether.h> | 59 | #include <net/if_ether.h> | |
60 | #include <net/if_media.h> | 60 | #include <net/if_media.h> | |
61 | 61 | |||
62 | #include <net80211/ieee80211_var.h> | 62 | #include <net80211/ieee80211_var.h> | |
63 | 63 | |||
64 | static void *tkip_attach(struct ieee80211com *, struct ieee80211_key *); | 64 | static void *tkip_attach(struct ieee80211com *, struct ieee80211_key *); | |
65 | static void tkip_detach(struct ieee80211_key *); | 65 | static void tkip_detach(struct ieee80211_key *); | |
@@ -108,42 +108,42 @@ struct tkip_ctx { | @@ -108,42 +108,42 @@ struct tkip_ctx { | |||
108 | static void michael_mic(struct tkip_ctx *, const u8 *key, | 108 | static void michael_mic(struct tkip_ctx *, const u8 *key, | |
109 | struct mbuf *m, u_int off, size_t data_len, | 109 | struct mbuf *m, u_int off, size_t data_len, | |
110 | u8 mic[IEEE80211_WEP_MICLEN]); | 110 | u8 mic[IEEE80211_WEP_MICLEN]); | |
111 | static int tkip_encrypt(struct tkip_ctx *, struct ieee80211_key *, | 111 | static int tkip_encrypt(struct tkip_ctx *, struct ieee80211_key *, | |
112 | struct mbuf *, int hdr_len); | 112 | struct mbuf *, int hdr_len); | |
113 | static int tkip_decrypt(struct tkip_ctx *, struct ieee80211_key *, | 113 | static int tkip_decrypt(struct tkip_ctx *, struct ieee80211_key *, | |
114 | struct mbuf *, int hdr_len); | 114 | struct mbuf *, int hdr_len); | |
115 | 115 | |||
116 | static void * | 116 | static void * | |
117 | tkip_attach(struct ieee80211com *ic, struct ieee80211_key *k) | 117 | tkip_attach(struct ieee80211com *ic, struct ieee80211_key *k) | |
118 | { | 118 | { | |
119 | struct tkip_ctx *ctx; | 119 | struct tkip_ctx *ctx; | |
120 | 120 | |||
121 | ctx = malloc(sizeof(struct tkip_ctx), M_DEVBUF, M_NOWAIT | M_ZERO); | 121 | ctx = kmem_intr_zalloc(sizeof(struct tkip_ctx), KM_NOSLEEP); | |
122 | if (ctx == NULL) { | 122 | if (ctx == NULL) { | |
123 | ic->ic_stats.is_crypto_nomem++; | 123 | ic->ic_stats.is_crypto_nomem++; | |
124 | return NULL; | 124 | return NULL; | |
125 | } | 125 | } | |
126 | 126 | |||
127 | ctx->tc_ic = ic; | 127 | ctx->tc_ic = ic; | |
128 | return ctx; | 128 | return ctx; | |
129 | } | 129 | } | |
130 | 130 | |||
131 | static void | 131 | static void | |
132 | tkip_detach(struct ieee80211_key *k) | 132 | tkip_detach(struct ieee80211_key *k) | |
133 | { | 133 | { | |
134 | struct tkip_ctx *ctx = k->wk_private; | 134 | struct tkip_ctx *ctx = k->wk_private; | |
135 | 135 | |||
136 | free(ctx, M_DEVBUF); | 136 | kmem_intr_free(ctx, sizeof(struct tkip_ctx)); | |
137 | } | 137 | } | |
138 | 138 | |||
139 | static int | 139 | static int | |
140 | tkip_setkey(struct ieee80211_key *k) | 140 | tkip_setkey(struct ieee80211_key *k) | |
141 | { | 141 | { | |
142 | struct tkip_ctx *ctx = k->wk_private; | 142 | struct tkip_ctx *ctx = k->wk_private; | |
143 | 143 | |||
144 | if (k->wk_keylen != (128/NBBY)) { | 144 | if (k->wk_keylen != (128/NBBY)) { | |
145 | (void) ctx; /* XXX */ | 145 | (void) ctx; /* XXX */ | |
146 | IEEE80211_DPRINTF(ctx->tc_ic, IEEE80211_MSG_CRYPTO, | 146 | IEEE80211_DPRINTF(ctx->tc_ic, IEEE80211_MSG_CRYPTO, | |
147 | "%s: Invalid key length %u, expecting %u\n", | 147 | "%s: Invalid key length %u, expecting %u\n", | |
148 | __func__, k->wk_keylen, 128/NBBY); | 148 | __func__, k->wk_keylen, 128/NBBY); | |
149 | return 0; | 149 | return 0; |
--- src/sys/net80211/ieee80211_crypto_wep.c 2018/05/03 17:14:37 1.12
+++ src/sys/net80211/ieee80211_crypto_wep.c 2020/11/03 15:06:50 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ieee80211_crypto_wep.c,v 1.12 2018/05/03 17:14:37 maxv Exp $ */ | 1 | /* $NetBSD: ieee80211_crypto_wep.c,v 1.13 2020/11/03 15:06:50 mlelstv Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | 4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -26,36 +26,36 @@ | @@ -26,36 +26,36 @@ | |||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | #ifdef __FreeBSD__ | 35 | #ifdef __FreeBSD__ | |
36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_wep.c,v 1.7 2005/06/10 16:11:24 sam Exp $"); | 36 | __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_wep.c,v 1.7 2005/06/10 16:11:24 sam Exp $"); | |
37 | #endif | 37 | #endif | |
38 | #ifdef __NetBSD__ | 38 | #ifdef __NetBSD__ | |
39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_wep.c,v 1.12 2018/05/03 17:14:37 maxv Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_wep.c,v 1.13 2020/11/03 15:06:50 mlelstv Exp $"); | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | /* | 42 | /* | |
43 | * IEEE 802.11 WEP crypto support. | 43 | * IEEE 802.11 WEP crypto support. | |
44 | */ | 44 | */ | |
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/mbuf.h> | 47 | #include <sys/mbuf.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/kmem.h> | |
49 | #include <sys/kernel.h> | 49 | #include <sys/kernel.h> | |
50 | #include <sys/endian.h> | 50 | #include <sys/endian.h> | |
51 | 51 | |||
52 | #include <sys/socket.h> | 52 | #include <sys/socket.h> | |
53 | 53 | |||
54 | #include <net/if.h> | 54 | #include <net/if.h> | |
55 | #include <net/if_ether.h> | 55 | #include <net/if_ether.h> | |
56 | #include <net/if_media.h> | 56 | #include <net/if_media.h> | |
57 | 57 | |||
58 | #include <net80211/ieee80211_var.h> | 58 | #include <net80211/ieee80211_var.h> | |
59 | 59 | |||
60 | static void *wep_attach(struct ieee80211com *, struct ieee80211_key *); | 60 | static void *wep_attach(struct ieee80211com *, struct ieee80211_key *); | |
61 | static void wep_detach(struct ieee80211_key *); | 61 | static void wep_detach(struct ieee80211_key *); | |
@@ -85,43 +85,43 @@ const struct ieee80211_cipher ieee80211_ | @@ -85,43 +85,43 @@ const struct ieee80211_cipher ieee80211_ | |||
85 | static int wep_encrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | 85 | static int wep_encrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | |
86 | static int wep_decrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | 86 | static int wep_decrypt(struct ieee80211_key *, struct mbuf *, int hdrlen); | |
87 | 87 | |||
88 | struct wep_ctx { | 88 | struct wep_ctx { | |
89 | struct ieee80211com *wc_ic; /* for diagnostics */ | 89 | struct ieee80211com *wc_ic; /* for diagnostics */ | |
90 | u_int32_t wc_iv; /* initial vector for crypto */ | 90 | u_int32_t wc_iv; /* initial vector for crypto */ | |
91 | }; | 91 | }; | |
92 | 92 | |||
93 | static void * | 93 | static void * | |
94 | wep_attach(struct ieee80211com *ic, struct ieee80211_key *k) | 94 | wep_attach(struct ieee80211com *ic, struct ieee80211_key *k) | |
95 | { | 95 | { | |
96 | struct wep_ctx *ctx; | 96 | struct wep_ctx *ctx; | |
97 | 97 | |||
98 | ctx = malloc(sizeof(struct wep_ctx), M_DEVBUF, M_NOWAIT | M_ZERO); | 98 | ctx = kmem_intr_zalloc(sizeof(struct wep_ctx), KM_NOSLEEP); | |
99 | if (ctx == NULL) { | 99 | if (ctx == NULL) { | |
100 | ic->ic_stats.is_crypto_nomem++; | 100 | ic->ic_stats.is_crypto_nomem++; | |
101 | return NULL; | 101 | return NULL; | |
102 | } | 102 | } | |
103 | 103 | |||
104 | ctx->wc_ic = ic; | 104 | ctx->wc_ic = ic; | |
105 | get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); | 105 | get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); | |
106 | return ctx; | 106 | return ctx; | |
107 | } | 107 | } | |
108 | 108 | |||
109 | static void | 109 | static void | |
110 | wep_detach(struct ieee80211_key *k) | 110 | wep_detach(struct ieee80211_key *k) | |
111 | { | 111 | { | |
112 | struct wep_ctx *ctx = k->wk_private; | 112 | struct wep_ctx *ctx = k->wk_private; | |
113 | 113 | |||
114 | free(ctx, M_DEVBUF); | 114 | kmem_intr_free(ctx, sizeof(struct wep_ctx)); | |
115 | } | 115 | } | |
116 | 116 | |||
117 | static int | 117 | static int | |
118 | wep_setkey(struct ieee80211_key *k) | 118 | wep_setkey(struct ieee80211_key *k) | |
119 | { | 119 | { | |
120 | return k->wk_keylen >= 40/NBBY; | 120 | return k->wk_keylen >= 40/NBBY; | |
121 | } | 121 | } | |
122 | 122 | |||
123 | /* | 123 | /* | |
124 | * Add privacy headers appropriate for the specified key. | 124 | * Add privacy headers appropriate for the specified key. | |
125 | */ | 125 | */ | |
126 | static int | 126 | static int | |
127 | wep_encap(struct ieee80211_key *k, struct mbuf *m, u_int8_t keyid) | 127 | wep_encap(struct ieee80211_key *k, struct mbuf *m, u_int8_t keyid) |