summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-08-13 22:06:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-08-13 22:06:49 +0000
commit541b122edb7e2c5c5ef95ed8f7ce2a1ad381af99 (patch)
tree2df9515e581b045a5aa42011adb08c9ed5122a4a /sys/dev
parent6311f0afe8773fb3b358bb6f6b72d09f23fff25c (diff)
fix session code
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/ubsec.c47
-rw-r--r--sys/dev/pci/ubsecreg.h4
-rw-r--r--sys/dev/pci/ubsecvar.h6
3 files changed, 27 insertions, 30 deletions
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c
index 0e569c43e3e..2e35673fb17 100644
--- a/sys/dev/pci/ubsec.c
+++ b/sys/dev/pci/ubsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsec.c,v 1.23 2000/08/13 22:03:09 deraadt Exp $ */
+/* $OpenBSD: ubsec.c,v 1.24 2000/08/13 22:06:47 deraadt Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -284,8 +284,8 @@ ubsec_feed(sc)
void *v, *mcr2;
npkts = sc->sc_nqueue;
- if (npkts > 20)
- npkts = 20;
+ if (npkts > 5)
+ npkts = 5;
if (npkts < 2)
goto feed1;
@@ -366,10 +366,10 @@ ubsec_newsession(sidp, cri)
{
struct cryptoini *c, *encini = NULL, *macini = NULL;
struct ubsec_softc *sc = NULL;
- struct ubsec_session *ses;
+ struct ubsec_session *ses = NULL;
MD5_CTX md5ctx;
SHA1_CTX sha1ctx;
- int i;
+ int i, sesn;
if (sidp == NULL || cri == NULL)
return (EINVAL);
@@ -401,34 +401,32 @@ ubsec_newsession(sidp, cri)
if (sc->sc_sessions == NULL) {
ses = sc->sc_sessions = (struct ubsec_session *)malloc(
- sizeof(struct ubsec_session), M_DEVBUF, M_NOWAIT);
+ sizeof(struct ubsec_session), M_DEVBUF, M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
- i = 0;
+ sesn = 0;
sc->sc_nsessions = 1;
} else {
- for (i = 0; i < sc->sc_nsessions; i++) {
- if (sc->sc_sessions[i].ses_used == 0) {
- ses = &sc->sc_sessions[i];
+ for (sesn = 0; sesn < sc->sc_nsessions; sesn++) {
+ if (sc->sc_sessions[sesn].ses_used == 0) {
+ ses = &sc->sc_sessions[sesn];
break;
}
}
if (ses == NULL) {
- ses = (struct ubsec_session *)malloc(
- (sc->sc_nsessions + 1) *
+ sesn = sc->sc_nsessions;
+ ses = (struct ubsec_session *)malloc((sesn + 1) *
sizeof(struct ubsec_session), M_DEVBUF, M_NOWAIT);
if (ses == NULL)
return (ENOMEM);
- for (i = 0; i < sc->sc_nsessions; i++) {
- bcopy(&sc->sc_sessions[i], &ses[i],
- sizeof(struct ubsec_session));
- bzero(&sc->sc_sessions[i],
- sizeof(struct ubsec_session));
- }
+ bcopy(sc->sc_sessions, ses, (sesn + 1) *
+ sizeof(struct ubsec_session));
+ bzero(sc->sc_sessions, sesn *
+ sizeof(struct ubsec_session));
free(sc->sc_sessions, M_DEVBUF);
sc->sc_sessions = ses;
- ses = &sc->sc_sessions[sc->sc_nsessions];
+ ses = &sc->sc_sessions[sesn];
sc->sc_nsessions++;
}
}
@@ -444,8 +442,7 @@ ubsec_newsession(sidp, cri)
bcopy(encini->cri_key, &ses->ses_deskey[0], 8);
bcopy(encini->cri_key, &ses->ses_deskey[2], 8);
bcopy(encini->cri_key, &ses->ses_deskey[4], 8);
- }
- else
+ } else
bcopy(encini->cri_key, &ses->ses_deskey[0], 24);
SWAP32(ses->ses_deskey[0]);
SWAP32(ses->ses_deskey[1]);
@@ -498,8 +495,7 @@ ubsec_newsession(sidp, cri)
macini->cri_key[i] ^= HMAC_OPAD_VAL;
}
- *sidp = UBSEC_SID(sc->sc_dv.dv_unit, i);
-
+ *sidp = UBSEC_SID(sc->sc_dv.dv_unit, sesn);
return (0);
}
@@ -562,7 +558,8 @@ ubsec_process(crp)
}
bzero(q, sizeof(struct ubsec_q));
- ses = q->q_ses = &sc->sc_sessions[UBSEC_SESSION(crp->crp_sid)];
+ q->q_sesn = UBSEC_SESSION(crp->crp_sid);
+ ses = &sc->sc_sessions[q->q_sesn];
q->q_mcr = (struct ubsec_mcr *)malloc(sizeof(struct ubsec_mcr),
M_DEVBUF, M_NOWAIT);
@@ -924,7 +921,7 @@ ubsec_callback(q)
continue;
m_copydata((struct mbuf *)crp->crp_buf,
crd->crd_skip + crd->crd_len - 8, 8,
- (u_int8_t *)q->q_ses->ses_iv);
+ (u_int8_t *)q->q_sc->sc_sessions[q->q_sesn].ses_iv);
break;
}
}
diff --git a/sys/dev/pci/ubsecreg.h b/sys/dev/pci/ubsecreg.h
index ba06c25298f..b4b042c1620 100644
--- a/sys/dev/pci/ubsecreg.h
+++ b/sys/dev/pci/ubsecreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsecreg.h,v 1.6 2000/08/13 22:03:09 deraadt Exp $ */
+/* $OpenBSD: ubsecreg.h,v 1.7 2000/08/13 22:06:48 deraadt Exp $ */
/*
* Copyright (c) 2000 Theo de Raadt
@@ -71,7 +71,7 @@
#define UBSEC_CARD(sid) (((sid) & 0xf0000000) >> 28)
#define UBSEC_SESSION(sid) ( (sid) & 0x0fffffff)
-#define UBSEC_SID(crd,ses) (((crd) << 28) | ((ses) & 0x0fffffff))
+#define UBSEC_SID(crd, sesn) (((crd) << 28) | ((sesn) & 0x0fffffff))
#define MAX_SCATTER 64
struct ubsec_pktctx {
diff --git a/sys/dev/pci/ubsecvar.h b/sys/dev/pci/ubsecvar.h
index e4e22e6a8e0..412c5ab7ab1 100644
--- a/sys/dev/pci/ubsecvar.h
+++ b/sys/dev/pci/ubsecvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsecvar.h,v 1.8 2000/08/13 22:03:09 deraadt Exp $ */
+/* $OpenBSD: ubsecvar.h,v 1.9 2000/08/13 22:06:48 deraadt Exp $ */
/*
* Copyright (c) 2000 Theo de Raadt
@@ -61,7 +61,7 @@ struct ubsec_q {
int q_dst_packl[MAX_SCATTER];
int q_dst_npa, q_dst_l;
u_int32_t q_macbuf[5];
- struct ubsec_session * q_ses;
+ int q_sesn;
};
struct ubsec_session {
@@ -74,5 +74,5 @@ struct ubsec_session {
/* Maximum queue length */
#ifndef UBS_MAX_NQUEUE
-#define UBS_MAX_NQUEUE 24
+#define UBS_MAX_NQUEUE 60
#endif