diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-11-01 21:17:38 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-11-01 21:17:38 +0000 |
| commit | 3c3feed41a52b5692575275541bce39a83146644 (patch) | |
| tree | d7eefbc43ae961805537882e088a954e7b9cf530 /tools | |
| parent | d8ed03efe5a7e8cc83f204393b6a083915bf9c22 (diff) | |
| parent | bb3d23fd35c00a652a92e4249477e5240f3a4180 (diff) | |
Notes
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/bsdbox/Makefile.base | 2 | ||||
| -rw-r--r-- | tools/build/mk/OptionalObsoleteFiles.inc | 35 | ||||
| -rw-r--r-- | tools/build/options/WITHOUT_DEBUG_FILES | 3 | ||||
| -rw-r--r-- | tools/regression/net80211/ccmp/test_ccmp.c | 64 | ||||
| -rw-r--r-- | tools/regression/net80211/tkip/test_tkip.c | 69 | ||||
| -rw-r--r-- | tools/regression/net80211/wep/test_wep.c | 69 | ||||
| -rw-r--r-- | tools/regression/security/open_to_operation/Makefile | 2 | ||||
| -rw-r--r-- | tools/regression/security/open_to_operation/open_to_operation.c | 27 | ||||
| -rw-r--r-- | tools/test/README | 16 | ||||
| -rw-r--r-- | tools/test/net/Makefile | 9 | ||||
| -rw-r--r-- | tools/test/net/connect.c | 86 | ||||
| -rw-r--r-- | tools/test/net/listen.c | 106 | ||||
| -rw-r--r-- | tools/tools/ioat/Makefile | 1 | ||||
| -rw-r--r-- | tools/tools/ioat/ioatcontrol.8 | 105 | ||||
| -rw-r--r-- | tools/tools/ioat/ioatcontrol.c | 173 |
15 files changed, 651 insertions, 116 deletions
diff --git a/tools/bsdbox/Makefile.base b/tools/bsdbox/Makefile.base index 4eb70562454b..be900981f9b3 100644 --- a/tools/bsdbox/Makefile.base +++ b/tools/bsdbox/Makefile.base @@ -6,7 +6,7 @@ # CRUNCH_PROGS_sbin+= dmesg sysctl init reboot CRUNCH_PROGS_bin+= ls cat dd df cp hostname kill mkdir sleep ps -CRUNCH_PROGS_bin+= ln rm hostname kenv mv expr +CRUNCH_PROGS_bin+= ln rm kenv mv expr CRUNCH_PROGS_usr.bin+= true false hexdump tail nc w head uname tset CRUNCH_PROGS_usr.sbin+= gpioctl CRUNCH_ALIAS_w= uptime diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index bbecadd2b71f..7f5534704722 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -173,6 +173,10 @@ OLD_DIRS+=etc/autofs .endif .if ${MK_BHYVE} == no +OLD_FILES+=usr/lib/libvmmapi.a +OLD_FILES+=usr/lib/libvmmapi.so +OLD_LIBS+=usr/lib/libvmmapi.so.5 +OLD_FILES+=usr/include/vmmapi.h OLD_FILES+=usr/sbin/bhyve OLD_FILES+=usr/sbin/bhyvectl OLD_FILES+=usr/sbin/bhyveload @@ -3964,9 +3968,34 @@ OLD_FILES+=usr/share/man/man5/keymap.5.gz OLD_FILES+=usr/share/man/man8/moused.8.gz .endif -#.if ${MK_LIB32} == no -# to be filled in -#.endif +.if ${MK_LIB32} == no +OLD_FILES+=etc/mtree/BSD.lib32.dist +OLD_FILES+=libexec/ld-elf32.so.1 +. if exists(${DESTDIR}/usr/lib32) +LIB32_DIRS!=find ${DESTDIR}/usr/lib32 -type d \ + | sed -e 's,^${DESTDIR}/,,'; echo +LIB32_FILES!=find ${DESTDIR}/usr/lib32 \! -type d \ + \! -name "lib*.so*" | sed -e 's,^${DESTDIR}/,,'; echo +LIB32_LIBS!=find ${DESTDIR}/usr/lib32 \! -type d \ + -name "lib*.so*" | sed -e 's,^${DESTDIR}/,,'; echo +OLD_DIRS+=${LIB32_DIRS} +OLD_FILES+=${LIB32_FILES} +OLD_LIBS+=${LIB32_LIBS} +. endif +. if ${MK_DEBUG_FILES} == no +. if exists(${DESTDIR}/usr/lib/debug/usr/lib32) +DEBUG_LIB32_DIRS!=find ${DESTDIR}/usr/lib/debug/usr/lib32 -type d \ + | sed -e 's,^${DESTDIR}/,,'; echo +DEBUG_LIB32_FILES!=find ${DESTDIR}/usr/lib/debug/usr/lib32 \! -type d \ + \! -name "lib*.so*" | sed -e 's,^${DESTDIR}/,,'; echo +DEBUG_LIB32_LIBS!=find ${DESTDIR}/usr/lib/debug/usr/lib32 \! -type d \ + -name "lib*.so*" | sed -e 's,^${DESTDIR}/,,'; echo +OLD_DIRS+=${DEBUG_LIB32_DIRS} +OLD_FILES+=${DEBUG_LIB32_FILES} +OLD_LIBS+=${DEBUG_LIB32_LIBS} +. endif +. endif +.endif .if ${MK_LIBCPLUSPLUS} == no OLD_LIBS+=lib/libcxxrt.so.1 diff --git a/tools/build/options/WITHOUT_DEBUG_FILES b/tools/build/options/WITHOUT_DEBUG_FILES new file mode 100644 index 000000000000..2938f3008e9a --- /dev/null +++ b/tools/build/options/WITHOUT_DEBUG_FILES @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to avoid building or installing standalone debug files for each +executable binary and shared library. diff --git a/tools/regression/net80211/ccmp/test_ccmp.c b/tools/regression/net80211/ccmp/test_ccmp.c index 058e7289a0ac..ffe4b7caf70a 100644 --- a/tools/regression/net80211/ccmp/test_ccmp.c +++ b/tools/regression/net80211/ccmp/test_ccmp.c @@ -53,6 +53,7 @@ #include <sys/socket.h> #include <net/if.h> +#include <net/if_var.h> #include <net/if_media.h> #include <net80211/ieee80211_var.h> @@ -591,32 +592,32 @@ printtest(const struct ciphertest *t) } static int -runtest(struct ieee80211com *ic, struct ciphertest *t) +runtest(struct ieee80211vap *vap, struct ciphertest *t) { - struct ieee80211_key key; + struct ieee80211_key *key = &vap->iv_nw_keys[t->keyix]; struct mbuf *m = NULL; const struct ieee80211_cipher *cip; - u_int8_t mac[IEEE80211_ADDR_LEN]; + int hdrlen; printf("%s: ", t->name); /* * Setup key. */ - memset(&key, 0, sizeof(key)); - key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; - key.wk_cipher = &ieee80211_cipher_none; - if (!ieee80211_crypto_newkey(ic, t->cipher, - IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) { + memset(key, 0, sizeof(*key)); + key->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; + key->wk_cipher = &ieee80211_cipher_none; + if (!ieee80211_crypto_newkey(vap, t->cipher, + IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, key)) { printf("FAIL: ieee80211_crypto_newkey failed\n"); goto bad; } - memcpy(key.wk_key, t->key, t->key_len); - key.wk_keylen = t->key_len; - key.wk_keyrsc = 0; - key.wk_keytsc = t->pn-1; /* PN-1 since we do encap */ - if (!ieee80211_crypto_setkey(ic, &key, mac)) { + memcpy(key->wk_key, t->key, t->key_len); + key->wk_keylen = t->key_len; + memset(key->wk_keyrsc, 0, sizeof(key->wk_keyrsc)); + key->wk_keytsc = t->pn-1; /* PN-1 since we do encap */ + if (!ieee80211_crypto_setkey(vap, key)) { printf("FAIL: ieee80211_crypto_setkey failed\n"); goto bad; } @@ -624,17 +625,18 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Craft frame from plaintext data. */ - cip = key.wk_cipher; + cip = key->wk_cipher; m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR); m->m_data += cip->ic_header; memcpy(mtod(m, void *), t->plaintext, t->plaintext_len); m->m_len = t->plaintext_len; m->m_pkthdr.len = m->m_len; + hdrlen = ieee80211_anyhdrsize(mtod(m, void *)); /* * Encrypt frame w/ MIC. */ - if (!cip->ic_encap(&key, m, t->keyix<<6)) { + if (!cip->ic_encap(key, m)) { printtest(t); printf("FAIL: ccmp encap failed\n"); goto bad; @@ -660,7 +662,7 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Decrypt frame; strip MIC. */ - if (!cip->ic_decap(&key, m)) { + if (!cip->ic_decap(key, m, hdrlen)) { printf("FAIL: ccmp decap failed\n"); printtest(t); cmpfail(mtod(m, const void *), m->m_len, @@ -680,17 +682,17 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) printf("FAIL: decap botch; data does not compare\n"); printtest(t); cmpfail(mtod(m, const void *), m->m_pkthdr.len, - t->plaintext, t_plaintext_len); + t->plaintext, t->plaintext_len); goto bad; } m_freem(m); - ieee80211_crypto_delkey(ic, &key); + ieee80211_crypto_delkey(vap, key); printf("PASS\n"); return 1; bad: if (m != NULL) m_freem(m); - ieee80211_crypto_delkey(ic, &key); + ieee80211_crypto_delkey(vap, key); return 0; } @@ -704,26 +706,38 @@ static int debug = 0; static int init_crypto_ccmp_test(void) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct ieee80211com ic; + struct ieee80211vap vap; + struct ifnet ifp; int i, pass, total; memset(&ic, 0, sizeof(ic)); - if (debug) - ic.ic_debug = IEEE80211_MSG_CRYPTO; + memset(&vap, 0, sizeof(vap)); + memset(&ifp, 0, sizeof(ifp)); + ieee80211_crypto_attach(&ic); + /* some minimal initialization */ + strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname)); + vap.iv_ic = ⁣ + vap.iv_ifp = &ifp; + if (debug) + vap.iv_debug = IEEE80211_MSG_CRYPTO; + ieee80211_crypto_vattach(&vap); + pass = 0; total = 0; - for (i = 0; i < N(ccmptests); i++) + for (i = 0; i < nitems(ccmptests); i++) if (tests & (1<<i)) { total++; - pass += runtest(&ic, &ccmptests[i]); + pass += runtest(&vap, &ccmptests[i]); } printf("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total); + + ieee80211_crypto_vdetach(&vap); ieee80211_crypto_detach(&ic); + return (pass == total ? 0 : -1); -#undef N } static int diff --git a/tools/regression/net80211/tkip/test_tkip.c b/tools/regression/net80211/tkip/test_tkip.c index 5a6397852a3f..70d2e385407d 100644 --- a/tools/regression/net80211/tkip/test_tkip.c +++ b/tools/regression/net80211/tkip/test_tkip.c @@ -43,6 +43,7 @@ #include <sys/socket.h> #include <net/if.h> +#include <net/if_var.h> #include <net/if_media.h> #include <net80211/ieee80211_var.h> @@ -141,7 +142,6 @@ struct tkip_ctx { struct ieee80211com *tc_ic; /* for diagnostics */ uint16_t tx_ttak[5]; - int tx_phase1_done; uint8_t tx_rc4key[16]; uint16_t rx_ttak[5]; @@ -179,34 +179,34 @@ cmpfail(const void *gen, size_t genlen, const void *ref, size_t reflen) } static int -runtest(struct ieee80211com *ic, struct ciphertest *t) +runtest(struct ieee80211vap *vap, struct ciphertest *t) { struct tkip_ctx *ctx; - struct ieee80211_key key; + struct ieee80211_key *key = &vap->iv_nw_keys[t->keyix]; struct mbuf *m = NULL; const struct ieee80211_cipher *cip; - u_int8_t mac[IEEE80211_ADDR_LEN]; u_int len; + int hdrlen; printf("%s: ", t->name); /* * Setup key. */ - memset(&key, 0, sizeof(key)); - key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; - key.wk_cipher = &ieee80211_cipher_none; - if (!ieee80211_crypto_newkey(ic, IEEE80211_CIPHER_TKIP, - IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) { + memset(key, 0, sizeof(*key)); + key->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; + key->wk_cipher = &ieee80211_cipher_none; + if (!ieee80211_crypto_newkey(vap, t->cipher, + IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, key)) { printf("FAIL: ieee80211_crypto_newkey failed\n"); goto bad; } - memcpy(key.wk_key, t->key, t->key_len); - key.wk_keylen = 128/NBBY; - key.wk_keyrsc = 0; - key.wk_keytsc = t->pn; - if (!ieee80211_crypto_setkey(ic, &key, mac)) { + memcpy(key->wk_key, t->key, t->key_len); + key->wk_keylen = 128/NBBY; + memset(key->wk_keyrsc, 0, sizeof(key->wk_keyrsc)); + key->wk_keytsc = t->pn; + if (!ieee80211_crypto_setkey(vap, key)) { printf("FAIL: ieee80211_crypto_setkey failed\n"); goto bad; } @@ -214,18 +214,19 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Craft frame from plaintext data. */ - cip = key.wk_cipher; + cip = key->wk_cipher; m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR); m->m_data += cip->ic_header; len = t->plaintext_len - IEEE80211_WEP_MICLEN; memcpy(mtod(m, void *), t->plaintext, len); m->m_len = len; m->m_pkthdr.len = m->m_len; + hdrlen = ieee80211_anyhdrsize(mtod(m, void *)); /* * Add MIC. */ - if (!ieee80211_crypto_enmic(ic, &key, m)) { + if (!ieee80211_crypto_enmic(vap, key, m, 1)) { printf("FAIL: tkip enmic failed\n"); goto bad; } @@ -247,14 +248,14 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Encrypt frame w/ MIC. */ - if (!cip->ic_encap(&key, m, t->keyix<<6)) { + if (!cip->ic_encap(key, m)) { printf("FAIL: tkip encap failed\n"); goto bad; } /* * Verify: phase1, phase2, frame length, frame contents. */ - ctx = key.wk_private; + ctx = key->wk_private; if (memcmp(ctx->tx_ttak, t->phase1, t->phase1_len)) { printf("FAIL: encrypt phase1 botch\n"); cmpfail(ctx->tx_ttak, sizeof(ctx->tx_ttak), @@ -281,7 +282,7 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Decrypt frame. */ - if (!cip->ic_decap(&key, m)) { + if (!cip->ic_decap(key, m, hdrlen)) { printf("tkip decap failed\n"); /* * Check reason for failure: phase1, phase2, frame data (ICV). @@ -319,17 +320,19 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * De-MIC decrypted frame. */ - if (!ieee80211_crypto_demic(ic, &key, m)) { + if (!ieee80211_crypto_demic(vap, key, m, 1)) { printf("FAIL: tkip demic failed\n"); goto bad; } /* XXX check frame length and contents... */ + m_freem(m); + ieee80211_crypto_delkey(vap, key); printf("PASS\n"); return 1; bad: if (m != NULL) m_freem(m); - ieee80211_crypto_delkey(ic, &key); + ieee80211_crypto_delkey(vap, key); return 0; } @@ -343,26 +346,38 @@ static int tests = -1; static int init_crypto_tkip_test(void) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct ieee80211com ic; + struct ieee80211vap vap; + struct ifnet ifp; int i, pass, total; memset(&ic, 0, sizeof(ic)); - if (debug) - ic.ic_debug = IEEE80211_MSG_CRYPTO; + memset(&vap, 0, sizeof(vap)); + memset(&ifp, 0, sizeof(ifp)); + ieee80211_crypto_attach(&ic); + /* some minimal initialization */ + strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname)); + vap.iv_ic = ⁣ + vap.iv_ifp = &ifp; + if (debug) + vap.iv_debug = IEEE80211_MSG_CRYPTO; + ieee80211_crypto_vattach(&vap); + pass = 0; total = 0; - for (i = 0; i < N(tkiptests); i++) + for (i = 0; i < nitems(tkiptests); i++) if (tests & (1<<i)) { total++; - pass += runtest(&ic, &tkiptests[i]); + pass += runtest(&vap, &tkiptests[i]); } printf("%u of %u 802.11i TKIP test vectors passed\n", pass, total); + + ieee80211_crypto_vdetach(&vap); ieee80211_crypto_detach(&ic); + return (pass == total ? 0 : -1); -#undef N } static int diff --git a/tools/regression/net80211/wep/test_wep.c b/tools/regression/net80211/wep/test_wep.c index ba6cd46d6895..c156863e668c 100644 --- a/tools/regression/net80211/wep/test_wep.c +++ b/tools/regression/net80211/wep/test_wep.c @@ -53,6 +53,7 @@ #include <sys/socket.h> #include <net/if.h> +#include <net/if_var.h> #include <net/if_media.h> #include <net80211/ieee80211_var.h> @@ -178,54 +179,55 @@ cmpfail(const void *gen, size_t genlen, const void *ref, size_t reflen) } struct wep_ctx_hw { /* for use with h/w support */ - struct ieee80211com *wc_ic; /* for diagnostics */ - u_int32_t wc_iv; /* initial vector for crypto */ + struct ieee80211vap *wc_vap; /* for diagnostics+statistics */ + struct ieee80211com *wc_ic; + uint32_t wc_iv; /* initial vector for crypto */ }; static int -runtest(struct ieee80211com *ic, struct ciphertest *t) +runtest(struct ieee80211vap *vap, struct ciphertest *t) { - struct ieee80211_key key; + struct ieee80211_key *key = &vap->iv_nw_keys[t->keyix]; struct mbuf *m = NULL; const struct ieee80211_cipher *cip; - u_int8_t mac[IEEE80211_ADDR_LEN]; struct wep_ctx_hw *ctx; + int hdrlen; printf("%s: ", t->name); /* * Setup key. */ - memset(&key, 0, sizeof(key)); - key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; - key.wk_cipher = &ieee80211_cipher_none; - if (!ieee80211_crypto_newkey(ic, t->cipher, - IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) { + memset(key, 0, sizeof(*key)); + key->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV; + key->wk_cipher = &ieee80211_cipher_none; + if (!ieee80211_crypto_newkey(vap, t->cipher, + IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, key)) { printf("FAIL: ieee80211_crypto_newkey failed\n"); goto bad; } - memcpy(key.wk_key, t->key, t->key_len); - key.wk_keylen = t->key_len; - if (!ieee80211_crypto_setkey(ic, &key, mac)) { + memcpy(key->wk_key, t->key, t->key_len); + key->wk_keylen = t->key_len; + if (!ieee80211_crypto_setkey(vap, key)) { printf("FAIL: ieee80211_crypto_setkey failed\n"); goto bad; } - cip = key.wk_cipher; /* * Craft frame from plaintext data. */ - cip = key.wk_cipher; + cip = key->wk_cipher; m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR); memcpy(mtod(m, void *), t->encrypted, t->encrypted_len); m->m_len = t->encrypted_len; m->m_pkthdr.len = m->m_len; + hdrlen = ieee80211_anyhdrsize(mtod(m, void *)); /* * Decrypt frame. */ - if (!cip->ic_decap(&key, m)) { + if (!cip->ic_decap(key, m, hdrlen)) { printf("FAIL: wep decap failed\n"); cmpfail(mtod(m, const void *), m->m_pkthdr.len, t->plaintext, t->plaintext_len); @@ -249,9 +251,11 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) /* * Encrypt frame. */ - ctx = (struct wep_ctx_hw *) key.wk_private; + ctx = (struct wep_ctx_hw *) key->wk_private; + ctx->wc_vap = vap; + ctx->wc_ic = vap->iv_ic; memcpy(&ctx->wc_iv, t->iv, sizeof(t->iv)); /* for encap/encrypt */ - if (!cip->ic_encap(&key, m, t->keyix<<6)) { + if (!cip->ic_encap(key, m)) { printf("FAIL: wep encap failed\n"); goto bad; } @@ -271,13 +275,13 @@ runtest(struct ieee80211com *ic, struct ciphertest *t) goto bad; } m_freem(m); - ieee80211_crypto_delkey(ic, &key); + ieee80211_crypto_delkey(vap, key); printf("PASS\n"); return 1; bad: if (m != NULL) m_freem(m); - ieee80211_crypto_delkey(ic, &key); + ieee80211_crypto_delkey(vap, key); return 0; } @@ -291,25 +295,38 @@ static int debug = 0; static int init_crypto_wep_test(void) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct ieee80211com ic; + struct ieee80211vap vap; + struct ifnet ifp; int i, pass, total; memset(&ic, 0, sizeof(ic)); - if (debug) - ic.ic_debug = IEEE80211_MSG_CRYPTO; + memset(&vap, 0, sizeof(vap)); + memset(&ifp, 0, sizeof(ifp)); + ieee80211_crypto_attach(&ic); + + /* some minimal initialization */ + strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname)); + vap.iv_ic = ⁣ + vap.iv_ifp = &ifp; + if (debug) + vap.iv_debug = IEEE80211_MSG_CRYPTO; + ieee80211_crypto_vattach(&vap); + pass = 0; total = 0; - for (i = 0; i < N(weptests); i++) + for (i = 0; i < nitems(weptests); i++) if (tests & (1<<i)) { total++; - pass += runtest(&ic, &weptests[i]); + pass += runtest(&vap, &weptests[i]); } printf("%u of %u 802.11i WEP test vectors passed\n", pass, total); + + ieee80211_crypto_vdetach(&vap); ieee80211_crypto_detach(&ic); + return (pass == total ? 0 : -1); -#undef N } static int diff --git a/tools/regression/security/open_to_operation/Makefile b/tools/regression/security/open_to_operation/Makefile index 462626f0cb0e..fbc0dc7c12b8 100644 --- a/tools/regression/security/open_to_operation/Makefile +++ b/tools/regression/security/open_to_operation/Makefile @@ -2,6 +2,6 @@ PROG= open_to_operation MAN= -#WARNS= 3 +WARNS?= 3 .include <bsd.prog.mk> diff --git a/tools/regression/security/open_to_operation/open_to_operation.c b/tools/regression/security/open_to_operation/open_to_operation.c index 38af3c674efd..0c65019a629a 100644 --- a/tools/regression/security/open_to_operation/open_to_operation.c +++ b/tools/regression/security/open_to_operation/open_to_operation.c @@ -169,9 +169,9 @@ try_directory_open(const char *testname, const char *directory, ok_mode(testname, NULL, mode); close(dfd); } else { - if (expected_errno && expected_errno == expected_errno) + if (expected_errno && expected_errno == errno) ok_mode(testname, NULL, mode); - else if (expected_errno) + else if (expected_errno != 0) notok_mode(testname, "wrong errno", mode); else notok_mode(testname, "failed", mode); @@ -753,7 +753,8 @@ pwritev_wrapper(int d, const void *buf, size_t nbytes) static ssize_t aio_write_wrapper(int d, const void *buf, size_t nbytes) { - struct aiocb aiocb, *aiocb_array[1]; + struct aiocb aiocb; + struct aiocb const *aiocb_array[] = { &aiocb }; bzero(&aiocb, sizeof(aiocb)); aiocb.aio_fildes = d; @@ -839,7 +840,8 @@ preadv_wrapper(int d, void *buf, size_t nbytes) static ssize_t aio_read_wrapper(int d, void *buf, size_t nbytes) { - struct aiocb aiocb, *aiocb_array[1]; + struct aiocb aiocb; + struct aiocb const *aiocb_array[] = { &aiocb }; bzero(&aiocb, sizeof(aiocb)); aiocb.aio_fildes = d; @@ -847,7 +849,6 @@ aio_read_wrapper(int d, void *buf, size_t nbytes) aiocb.aio_nbytes = nbytes; if (aio_read(&aiocb) < 0) return (-1); - aiocb_array[0] = &aiocb; if (aio_suspend(aiocb_array, 1, NULL) < 0) return (-1); return (aio_return(&aiocb)); @@ -1009,12 +1010,8 @@ check_mmap_exec(const char *testname, const char *path, int isdir, if (isdir) notok_mode(testname, "mmap dir succeeded", mode); - else if ((mode & O_ACCMODE) == O_RDONLY || - (mode & O_ACCMODE) == O_RDWR) - ok_mode(testname, "mmap file succeeded", - mode); else - notok_mode(testname, "mmap file succeeded", + ok_mode(testname, "mmap file succeeded", mode); (void)munmap(addr, getpagesize()); } @@ -1069,7 +1066,7 @@ check_mmap_write_private(const char *testname, const char *path, int isdir, } int -main(int argc, char *argv[]) +main(void) { char dir_path[PATH_MAX], file_path[PATH_MAX]; int dummy, fd; @@ -1084,25 +1081,25 @@ main(int argc, char *argv[]) strlcpy(dir_path, "/tmp/open-dir.XXXXXXXXXXX", sizeof(dir_path)); if (mkdtemp(dir_path) == NULL) - err(-1, "mkdtemp"); + err(1, "mkdtemp"); if (chmod(dir_path, PERM_DIR) < 0) { warn("chmod %s", dir_path); (void)rmdir(dir_path); - exit(-1); + exit(1); } strlcpy(file_path, "/tmp/open-file.XXXXXXXXXXX", sizeof(file_path)); fd = mkstemp(file_path); if (fd < 0) { warn("mkstemp"); (void)rmdir(dir_path); - exit(-1); + exit(1); } close(fd); if (chmod(file_path, PERM_FILE) < 0) { warn("chmod %s", file_path); (void)unlink(file_path); (void)rmdir(dir_path); - exit(-1); + exit(1); } check_directory_open_modes(dir_path, file_modes, file_modes_count); diff --git a/tools/test/README b/tools/test/README index 22e8e74d258f..1e4aef85253e 100644 --- a/tools/test/README +++ b/tools/test/README @@ -1,14 +1,24 @@ $FreeBSD$ -This directory is for test programs. +This directory is for standalone test programs. For the FreeBSD +Test Suite, which uses Kyua, please see /usr/src/tests/ -A test program is one that will exercise a particular bit of the system -and try to break it and/or measuring performance on it. +A test program is one that exercises a particular bit of the system +and either tries to break it or measures its performance. Please make a subdir per program, and add a brief description to this file. +auxinfo Return information on page sizes, CPUs, and OS release date. devrandom Programs to test /dev/*random. +hwpmc Automatically trigger every event in hwpmc(4). +iconv Character set conversion tests. malloc A program to test and benchmark malloc(). +net A set of generic test programs for networking. netfibs Programs to test multi-FIB network stacks. posixshm A program to test POSIX shared memory. +ppsapi Test 1 Pulse Per Second (1PPS) input for time control. +pthread_vfork Check that vfork and pthreads work together. +ptrace Verify that ptrace works with syscalls, vfork etc. +sort Tests for the sort command, including a full regression. testfloat Programs to test floating-point implementations +upsdl Test of mmap functionality. diff --git a/tools/test/net/Makefile b/tools/test/net/Makefile new file mode 100644 index 000000000000..e4c525920d8c --- /dev/null +++ b/tools/test/net/Makefile @@ -0,0 +1,9 @@ +# $FreeBSD$ + +PROGS= listen connect +MAN= +WARNS?= 6 + +test: ${PROGS} + +.include <bsd.prog.mk> diff --git a/tools/test/net/connect.c b/tools/test/net/connect.c new file mode 100644 index 000000000000..a1245f1e8b3a --- /dev/null +++ b/tools/test/net/connect.c @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2015 George V. Neville-Neil + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <strings.h> +#include <sysexits.h> +#include <unistd.h> + +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> + +#define PORT 6969 /* Default port */ +#define RECV_LIMIT 64 /* When do we move listen to 0? */ + +void usage(void); + +void usage() +{ + err(EX_USAGE, "connect [-p port]\n"); +} + +int main(int argc, char **argv) +{ + + int ch, cli_sock, count = 0; + int port = PORT; + struct sockaddr_in remoteaddr; + + while ((ch = getopt(argc, argv, "p:")) != -1) { + switch (ch) { + case 'p': + port = atoi(optarg); + break; + case 'h': + default: + usage(); + } + } + + bzero(&remoteaddr, sizeof(remoteaddr)); + remoteaddr.sin_len = sizeof(remoteaddr); + remoteaddr.sin_family = AF_INET; + remoteaddr.sin_port = htons(port); + remoteaddr.sin_addr.s_addr = INADDR_ANY; + + cli_sock = socket(AF_INET, SOCK_STREAM, 0); + + while ((cli_sock = connect(cli_sock, (struct sockaddr *)&remoteaddr, + sizeof(remoteaddr))) >= 0) { + count++; + close(cli_sock); + cli_sock = socket(AF_INET, SOCK_STREAM, 0); + } + + printf("Exiting at %d with errno %d\n", count, errno); + +} diff --git a/tools/test/net/listen.c b/tools/test/net/listen.c new file mode 100644 index 000000000000..2c09bb699b76 --- /dev/null +++ b/tools/test/net/listen.c @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2015 George V. Neville-Neil + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <strings.h> +#include <sysexits.h> +#include <unistd.h> + +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in.h> + +#define PORT 6969 /* Default port */ +#define LISTEN 5 /* Default backlog */ +#define RECV_LIMIT 64 /* When do we move listen to 0? */ + +void usage(void); + +void usage() +{ + err(EX_USAGE, "listen [-p port] [-l limit]\n"); +} + +int main(int argc, char **argv) +{ + + int ch, srv_sock, cli_sock, recvd = 0; + int port = PORT; + int limit = LISTEN; + struct sockaddr_in localaddr; + + while ((ch = getopt(argc, argv, "p:l:")) != -1) { + switch (ch) { + case 'p': + port = atoi(optarg); + break; + case 'l': + limit = atoi(optarg); + break; + case 'h': + default: + usage(); + } + } + + bzero(&localaddr, sizeof(localaddr)); + localaddr.sin_len = sizeof(localaddr); + localaddr.sin_family = AF_INET; + localaddr.sin_port = htons(port); + localaddr.sin_addr.s_addr = INADDR_ANY; + + srv_sock = socket(AF_INET, SOCK_STREAM, 0); + + if (bind(srv_sock, (struct sockaddr *)&localaddr, + sizeof(struct sockaddr_in)) < 0) + err(EX_OSERR, "Could not bind to INADDR_ANY:%d", port); + + if (listen(srv_sock, limit) < 0) + err(EX_OSERR, "Failed to listen with depth of %d\n", limit); + + while (((cli_sock = accept(srv_sock, NULL, NULL)) >= 0) + && (recvd < RECV_LIMIT)) { + close(cli_sock); + recvd++; + } + + listen(srv_sock, 0); + + while (((cli_sock = accept(srv_sock, NULL, NULL)) >= 0) + && (recvd <= (RECV_LIMIT + limit + 1))) { + close(cli_sock); + recvd++; + } + + if (accept(srv_sock, NULL, NULL) >= 0) + printf ("Late connection at %d\n", recvd); + else + printf("recvd %d\n", recvd); +} diff --git a/tools/tools/ioat/Makefile b/tools/tools/ioat/Makefile index a3f496892145..7ea3e6e99de9 100644 --- a/tools/tools/ioat/Makefile +++ b/tools/tools/ioat/Makefile @@ -4,5 +4,6 @@ PROG= ioatcontrol MAN= ioatcontrol.8 CFLAGS+= -I${.CURDIR:H:H:H}/sys/dev/ioat WARNS?= 6 +LIBADD= util .include <bsd.prog.mk> diff --git a/tools/tools/ioat/ioatcontrol.8 b/tools/tools/ioat/ioatcontrol.8 index 762ce14fc830..2306d3876a36 100644 --- a/tools/tools/ioat/ioatcontrol.8 +++ b/tools/tools/ioat/ioatcontrol.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2015 +.Dd October 28, 2015 .Dt IOATCONTROL 8 .Os .Sh NAME @@ -33,18 +33,101 @@ .Xr ioat 4 .Sh SYNOPSIS .Nm +.Op Fl f +.Op Fl V .Ar channel_number -.Ar num_loops +.Ar num_txns +.Ar [ bufsize +.Ar [ chain-len +.Ar [ duration ] ] ] +.Nm +.Fl r +.Op Fl v +.Op Fl V +.Op Fl w +.Ar channel_number +.Ar address +.Ar [ bufsize ] .Sh DESCRIPTION .Nm allows one to issue some number of test operations to the .Xr ioat 4 driver on a specific hardware channel. +The arguments are as follows: +.Bl -tag -width Ds +.It Fl f +Test block fill (by default, +.Nm +tests copy) +.It Fl V +Verify copies/fills for accuracy +.El +.Pp +Alternatively one can use +.Nm +.Fl r +to issue DMA to or from a specific +.Ar address . +The arguments in "raw" mode are: +.Bl -tag -width Ds +.It Fl v +.Ar address +is a kernel virtual address (by default, +.Ar address +is assumed to be a physical address) +.It Fl V +Dump the resulting hex to syslog +.It Fl w +Write to the specified +.Ar address +(by default, +.Nm +.Fl r +reads) +.El +.Pp +.Nm +operates in one of two modes; if the +.Ar duration +argument is passed, +.Nm +tries to estimate the copy rate in bytes per second by running +.Ar num_txns +repeatedly in loop. +If +.Ar duration +is not passed, +.Nm +only runs through +.Ar num_txns +once and prints the total bytes copied, as well as error information. .Pp -Each loop will allocate two chunks of memory, write data patterns to them, -submit a DMA request to copy one buffer to the other, and compare the contents -in the callback. -If the contents are not as expected, an error is reported. +The +.Ar bufsize +argument determines the size of buffers to use for each +.Fn ioat_copy +invocation. +The default is 256 KB. +In raw mode, the default is 4 KB. +.Pp +The +.Ar chain-len +argument determines the number of copies to chain together in a single DMA +transaction. +The default is 1, and the maximum is currently 4. +.Pp +The +.Ar duration +argument specifies an approximate time limit for the test, in milliseconds. +.Pp +The test will allocate two chunks of memory for each component of each +transaction's chain. +It will initialize them with specific data patterns. +During the test, it submits DMA requests to copy between pairs of buffers. +If the +.Fl V +flag was specified, it will compare the contents in the callback for a copy +error. .Sh FILES .Pa /dev/ioat_test .Pp @@ -52,9 +135,14 @@ The interface between .Nm and .Xr ioat 4 . -.Nm +.Xr ioat 4 exposes it with .Cd hw.ioat.enable_ioat_test=1 . +.Sh DIAGNOSTICS +The wait channel +.Va test_submit +indicates that the test code has enqueued all requested transactions and is +waiting on the IOAT hardware to complete one before issuing another operation. .Sh SEE ALSO .Xr ioat 4 .Sh HISTORY @@ -69,7 +157,8 @@ driver and .Nm tool were developed by .An \&Jim Harris Aq Mt jimharris@FreeBSD.org , +.An \&Carl Delsey Aq Mt carl.r.delsey@intel.com , and -.An \&Carl Delsey Aq Mt carl.r.delsey@intel.com . +.An \&Conrad Meyer Aq Mt cem@FreeBSD.org . This manual page was written by .An \&Conrad Meyer Aq Mt cem@FreeBSD.org . diff --git a/tools/tools/ioat/ioatcontrol.c b/tools/tools/ioat/ioatcontrol.c index 7cfb816f4346..90255e7c7d25 100644 --- a/tools/tools/ioat/ioatcontrol.c +++ b/tools/tools/ioat/ioatcontrol.c @@ -28,34 +28,154 @@ __FBSDID("$FreeBSD$"); #include <sys/ioctl.h> +#include <sys/queue.h> #include <fcntl.h> +#include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <sysexits.h> #include <unistd.h> +#include <libutil.h> + #include "ioat_test.h" +static int prettyprint(struct ioat_test *); + +static void +usage(void) +{ + + printf("Usage: %s [-fV] <channel #> <txns> [<bufsize> " + "[<chain-len> [duration]]]\n", getprogname()); + printf(" %s -r [-vV] <channel #> <addr> [<bufsize>]\n", + getprogname()); + exit(EX_USAGE); +} + +static void +main_raw(struct ioat_test *t, int argc, char **argv) +{ + int fd; + + /* Raw DMA defaults */ + t->testkind = IOAT_TEST_RAW_DMA; + t->transactions = 1; + t->chain_depth = 1; + t->buffer_size = 4 * 1024; + + t->raw_target = strtoull(argv[1], NULL, 0); + if (t->raw_target == 0) { + printf("Target shoudln't be NULL\n"); + exit(EX_USAGE); + } + + if (argc >= 3) { + t->buffer_size = atoi(argv[2]); + if (t->buffer_size == 0) { + printf("Buffer size must be greater than zero\n"); + exit(EX_USAGE); + } + } + + fd = open("/dev/ioat_test", O_RDWR); + if (fd < 0) { + printf("Cannot open /dev/ioat_test\n"); + exit(EX_UNAVAILABLE); + } + + (void)ioctl(fd, IOAT_DMATEST, t); + close(fd); + + exit(prettyprint(t)); +} + int main(int argc, char **argv) { struct ioat_test t; - int fd; + int fd, ch; + bool fflag, rflag; - if (argc < 3) { - printf("Usage: %s <channel #> <num_loops>\n", argv[0]); - return (EX_USAGE); + while ((ch = getopt(argc, argv, "rfvVw")) != -1) { + switch (ch) { + case 'f': + fflag = true; + break; + case 'r': + rflag = true; + break; + case 'v': + t.raw_is_virtual = true; + break; + case 'V': + t.verify = true; + break; + case 'w': + t.raw_write = true; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc < 2) + usage(); + + if (rflag && fflag) { + printf("Invalid: -r and -f\n"); + usage(); } - t.channel_index = atoi(argv[1]); + /* Defaults for optional args */ + t.buffer_size = 256 * 1024; + t.chain_depth = 2; + t.duration = 0; + t.testkind = IOAT_TEST_DMA; + + if (fflag) + t.testkind = IOAT_TEST_FILL; + + t.channel_index = atoi(argv[0]); if (t.channel_index > 8) { printf("Channel number must be between 0 and 7.\n"); return (EX_USAGE); } - t.num_loops = atoi(argv[2]); + if (rflag) { + main_raw(&t, argc, argv); + return (EX_OK); + } + + t.transactions = atoi(argv[1]); + + if (argc >= 3) { + t.buffer_size = atoi(argv[2]); + if (t.buffer_size == 0) { + printf("Buffer size must be greater than zero\n"); + return (EX_USAGE); + } + } + + if (argc >= 4) { + t.chain_depth = atoi(argv[3]); + if (t.chain_depth < 1) { + printf("Chain length must be greater than zero\n"); + return (EX_USAGE); + } + } + + if (argc >= 5) { + t.duration = atoi(argv[4]); + if (t.duration < 1) { + printf("Duration must be greater than zero\n"); + return (EX_USAGE); + } + } fd = open("/dev/ioat_test", O_RDWR); if (fd < 0) { @@ -66,5 +186,44 @@ main(int argc, char **argv) (void)ioctl(fd, IOAT_DMATEST, &t); close(fd); - return (t.status); + return (prettyprint(&t)); +} + +static int +prettyprint(struct ioat_test *t) +{ + char bps[10], bytesh[10]; + uintmax_t bytes; + + if (t->status[IOAT_TEST_NO_DMA_ENGINE] != 0 || + t->status[IOAT_TEST_NO_MEMORY] != 0 || + t->status[IOAT_TEST_MISCOMPARE] != 0) { + printf("Errors:\n"); + if (t->status[IOAT_TEST_NO_DMA_ENGINE] != 0) + printf("\tNo DMA engine present: %u\n", + (unsigned)t->status[IOAT_TEST_NO_DMA_ENGINE]); + if (t->status[IOAT_TEST_NO_MEMORY] != 0) + printf("\tOut of memory: %u\n", + (unsigned)t->status[IOAT_TEST_NO_MEMORY]); + if (t->status[IOAT_TEST_MISCOMPARE] != 0) + printf("\tMiscompares: %u\n", + (unsigned)t->status[IOAT_TEST_MISCOMPARE]); + } + + printf("Processed %u txns\n", (unsigned)t->status[IOAT_TEST_OK] / + t->chain_depth); + bytes = (uintmax_t)t->buffer_size * t->status[IOAT_TEST_OK]; + + humanize_number(bytesh, sizeof(bytesh), (int64_t)bytes, "B", + HN_AUTOSCALE, HN_DECIMAL); + if (t->duration) { + humanize_number(bps, sizeof(bps), + (int64_t)1000 * bytes / t->duration, "B/s", HN_AUTOSCALE, + HN_DECIMAL); + printf("%ju (%s) copied in %u ms (%s)\n", bytes, bytesh, + (unsigned)t->duration, bps); + } else + printf("%ju (%s) copied\n", bytes, bytesh); + + return (EX_OK); } |
