mg: add bounce matching for [] and {}
Hi tech -- Diff below adds the bounce matching for [] and {} in mg like it does for (). I miss having that from GNU Emacs, anyone else? OK? ~Brian Index: keymap.c === RCS file: /cvs/src/usr.bin/mg/keymap.c,v retrieving revision 1.51 diff -u -p -r1.51 keymap.c --- keymap.c22 May 2013 19:23:45 -1.51 +++ keymap.c13 Aug 2014 22:49:08 - @@ -388,16 +388,16 @@ static PF fund_del[] = { }; static PF fund_cb[] = { -showmatch/* ) */ +showmatch/* ) ] } */ }; #ifndefFUND_XMAPS #define NFUND_XMAPS0/* extra map sections after normal ones */ #endif -static struct KEYMAPE (6 + NFUND_XMAPS + IMAPEXT) fundmap = { -6 + NFUND_XMAPS, -6 + NFUND_XMAPS + IMAPEXT, +static struct KEYMAPE (8 + NFUND_XMAPS + IMAPEXT) fundmap = { +8 + NFUND_XMAPS, +8 + NFUND_XMAPS + IMAPEXT, selfinsert, { { @@ -414,6 +414,12 @@ static struct KEYMAPE (6 + NFUND_XMAPS + }, { ')', ')', fund_cb, NULL +}, +{ +']', ']', fund_cb, NULL +}, +{ +'}', '}', fund_cb, NULL }, { CCHR('?'), CCHR('?'), fund_del, NULL
Re: ssh man page additions for unix domain socket forwarding
On Wed, 13 Aug 2014 00:46:25 -0400, Jared Yanovich wrote: > It might be desired to change some of the usage strings as well. The actual usage is too convoluted to describe in the SYNOPSIS. What you have is OK but I think what is really needed is a subsection devoted to port forwarding. - todd
Re: ksh history bug
On Wed, Aug 13, 2014 at 07:41:08PM +0100, Jason McIntyre wrote: > hi! > > notice how ksh's history command (fc -l) does not list the last typed history > command: > > $ ls > $ date > Wed Aug 13 19:29:59 BST 2014 > $ history > 1 ls > 2 date > > the only thing i have to compare it with is bash: > > bash-4.3$ ls > bash-4.3$ date > Wed Aug 13 19:31:47 BST 2014 > bash-4.3$ history > 1 ls > 2 date > 3 history zsh has the same behaviour as ksh: remi@mistral:~% ls -d . . remi@mistral:~% date Wed Aug 13 21:32:51 CEST 2014 remi@mistral:~% history 1 rm .zhistfile 2 ls -d . 3 date remi@mistral:~% > > i think ksh's behaviour is wrong, but i'm unable to find anything that says > how it > should behave. note that commands like (in vi editing mode) "2k" in the > example above > will bring up "date", which is correct but confusing in ksh's case (since > looking at > the output of "history" you'd expect "ls"). > > anyone? > > note i have "a fix", included below, but it was produced using the theory > about > an infinite number of monkeys with an infinite amount of time. i definitely > do not profer > it in seriousness. > > jmc > > Index: history.c > === > RCS file: /cvs/src/bin/ksh/history.c,v > retrieving revision 1.39 > diff -u -r1.39 history.c > --- history.c 19 May 2010 17:36:08 - 1.39 > +++ history.c 13 Aug 2014 18:38:16 - > @@ -190,7 +190,7 @@ > const char *nfmt = nflag ? "\t" : "%d\t"; > > for (hp = rflag ? hlast : hfirst; > - hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { > + hp >= hfirst && hp <= hlast + 1; hp += rflag ? -1 : 1) { > shf_fprintf(shl_stdout, nfmt, > hist_source->line - (int) (histptr - hp)); > /* print multi-line commands correctly */ >
Re: autonetd, Wi-Fi automated configuration
Hi, Since you did ask for input. On Wed, Aug 13, 2014 at 07:06:23PM +0400, Vadim Zhukov wrote: > Hello all. > > I won't describe the problem, you all new it: when you switch between > hotspots, your network interface doesn't follow you. Also, you > probably want to have some sort of fallback configuration. > > Maybe you have a bunch of shell scripts, or whatever, - all this stuff > that rely on ifconfig(8) output, and thus tend to break on crazy I did when I worked for a company and my laptop went to work and came back home. They were simple scripts, did not do any auto-anything. I would simply do: $ sh workwifi.sh# at employer $ sh homewifi.sh# at home $ sh momdadwifi.sh # at my parents' home You can get fancier than this if you really need to be. All the necessary tools exist on the base OS. > network names. Sometimes you probably asked yourself, why there is no > NetworkManager analog in OpenBSD? - So here is a try of constructing > an answer to ths question. No, never. In fact, the opposite. Every time I come across a daemon/"manager" I wonder "is this really necessary?" To me, the elegance of OpenBSD has always been in its simplicity. It provides all necessary tools to its users. The users are free to build the more sophisticated tools (e.g., ones found in ports/packages). This leaves OpenBSD uncluttered. Unlike some other OSes, e.g., MacOS X, inundated with countless processes, busy doing ... something, I'm sure. And what and why in the world are "those two" sending and receiving over my network? Every time I take a look at the process list on my MBP I get this depressed, grossed-out, disgusted feeling. And on that high note... --patrick p.s., My plea: Please not for the base OS. > The internal logic is simple: scan networks, find known one and try to > run ifconfig(8) (and, probably, dhclient(8) and/or route(8)) on it. I > tried to avoid creating another rich parser syntax - all of the lines > you set up in configuration file became command-line arguments of > corresponding utilities. > > I invite you to look at the current source code here: > > cvs -d anon...@anoncvs.ohvost.ru:/cvs checkout autonetd > > Maybe this will evolve into backend of some GUI, or whatever. Maybe > not. But at least it works much better than what I've had before. > > Any input is highly appreciated. Thank you for your time! > > -- > WBR, > Vadim Zhukov >
ksh history bug
hi! notice how ksh's history command (fc -l) does not list the last typed history command: $ ls $ date Wed Aug 13 19:29:59 BST 2014 $ history 1 ls 2 date the only thing i have to compare it with is bash: bash-4.3$ ls bash-4.3$ date Wed Aug 13 19:31:47 BST 2014 bash-4.3$ history 1 ls 2 date 3 history i think ksh's behaviour is wrong, but i'm unable to find anything that says how it should behave. note that commands like (in vi editing mode) "2k" in the example above will bring up "date", which is correct but confusing in ksh's case (since looking at the output of "history" you'd expect "ls"). anyone? note i have "a fix", included below, but it was produced using the theory about an infinite number of monkeys with an infinite amount of time. i definitely do not profer it in seriousness. jmc Index: history.c === RCS file: /cvs/src/bin/ksh/history.c,v retrieving revision 1.39 diff -u -r1.39 history.c --- history.c 19 May 2010 17:36:08 - 1.39 +++ history.c 13 Aug 2014 18:38:16 - @@ -190,7 +190,7 @@ const char *nfmt = nflag ? "\t" : "%d\t"; for (hp = rflag ? hlast : hfirst; - hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { + hp >= hfirst && hp <= hlast + 1; hp += rflag ? -1 : 1) { shf_fprintf(shl_stdout, nfmt, hist_source->line - (int) (histptr - hp)); /* print multi-line commands correctly */
[regress] convert enc (3des) test from /dev/crypto
this one with a bit of cheating however (manual cbc implementation). OK? diff --git regress/sys/crypto/enc/Makefile regress/sys/crypto/enc/Makefile index cc29b32..8725f0c 100644 --- regress/sys/crypto/enc/Makefile +++ regress/sys/crypto/enc/Makefile @@ -1,12 +1,21 @@ # $OpenBSD: Makefile,v 1.5 2010/10/15 10:39:12 jsg Exp $ +DIR= ${.CURDIR}/../../../../sys + +CFLAGS+= -I${DIR} + PROG= des3 +SRCS= des3.c LDADD=-lcrypto DPADD=${LIBCRYPTO} REGRESS_ROOT_TARGETS= run-regress-${PROG} +.PATH: ${DIR}/crypto +SRCS+= cast.c ecb_enc.c ecb3_enc.c gmac.c rijndael.c set_key.c +SRCS+= xform.c + run-regress-${PROG}: ${PROG} - ${SUDO} ./${PROG} + ./${PROG} .include diff --git regress/sys/crypto/enc/des3.c regress/sys/crypto/enc/des3.c index 024418d..fe67872 100644 --- regress/sys/crypto/enc/des3.c +++ regress/sys/crypto/enc/des3.c @@ -22,105 +22,73 @@ * 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. */ -#include #include -#include -#include -#include #include #include #include #include #include #include #include -static int -syscrypt(const unsigned char *key, size_t klen, const unsigned char *iv, -const unsigned char *in, unsigned char *out, size_t len, int encrypt) -{ - struct session_op session; - struct crypt_op cryp; - int cryptodev_fd = -1, fd = -1; - - if ((cryptodev_fd = open("/dev/crypto", O_RDWR, 0)) < 0) { - warn("/dev/crypto"); - goto err; - } - if (ioctl(cryptodev_fd, CRIOGET, &fd) == -1) { - warn("CRIOGET failed"); - goto err; - } - memset(&session, 0, sizeof(session)); - session.cipher = CRYPTO_3DES_CBC; - session.key = (caddr_t) key; - session.keylen = klen; - if (ioctl(fd, CIOCGSESSION, &session) == -1) { - warn("CIOCGSESSION"); - goto err; - } - memset(&cryp, 0, sizeof(cryp)); - cryp.ses = session.ses; - cryp.op = encrypt ? COP_ENCRYPT : COP_DECRYPT; - cryp.flags = 0; - cryp.len = len; - cryp.src = (caddr_t) in; - cryp.dst = (caddr_t) out; - cryp.iv = (caddr_t) iv; - cryp.mac = 0; - if (ioctl(fd, CIOCCRYPT, &cryp) == -1) { - warn("CIOCCRYPT"); - goto err; - } - if (ioctl(fd, CIOCFSESSION, &session.ses) == -1) { - warn("CIOCFSESSION"); - goto err; - } - close(fd); - close(cryptodev_fd); - return (0); +/* Stubs */ -err: - if (fd != -1) - close(fd); - if (cryptodev_fd != -1) - close(cryptodev_fd); - return (-1); -} +u_int32_t deflate_global(u_int8_t *, u_int32_t, int, u_int8_t **); -static int -getallowsoft(void) +u_int32_t +deflate_global(u_int8_t *data, u_int32_t size, int comp, u_int8_t **out) { - int mib[2], old; - size_t olen; - - olen = sizeof(old); - - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; - if (sysctl(mib, 2, &old, &olen, NULL, 0) < 0) - err(1, "sysctl failed"); - - return old; + return 0; } -static void -setallowsoft(int new) +void explicit_bzero(void *, size_t); + +void +explicit_bzero(void *b, size_t len) { - int mib[2], old; - size_t olen, nlen; + bzero(b, len); +} - olen = nlen = sizeof(new); - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; +/* Simulate CBC mode */ - if (sysctl(mib, 2, &old, &olen, &new, nlen) < 0) - err(1, "sysctl failed"); +static int +docrypt(const unsigned char *key, size_t klen, const unsigned char *iv0, +const unsigned char *in, unsigned char *out, size_t len, int encrypt) +{ + u_int8_t block[8], iv[8], iv2[8], *ivp = iv, *nivp; + u_int8_t ctx[384]; + int i, j, error = 0; + + memcpy(iv, iv0, 8); + memset(ctx, 0, sizeof(ctx)); + error = des3_setkey(ctx, key, klen); + if (error) + return -1; + for (i = 0; i < len / 8; i ++) { + bcopy(in, block, 8); + in += 8; + if (encrypt) { + for (j = 0; j < 8; j++) + block[j] ^= ivp[j]; + des3_encrypt(ctx, block); + memcpy(ivp, block, 8); + } else { + nivp = ivp == iv ? iv2 : iv; + memcpy(nivp, block, 8); + des3_decrypt(ctx, block); + for (j = 0; j < 8; j++) + block[j] ^= ivp[j]; + ivp = nivp; + } + bcopy(block, out, 8); + out += 8; + } + return 0; } static int match(unsigned ch
autonetd, Wi-Fi automated configuration
Hello all. I won't describe the problem, you all new it: when you switch between hotspots, your network interface doesn't follow you. Also, you probably want to have some sort of fallback configuration. Maybe you have a bunch of shell scripts, or whatever, - all this stuff that rely on ifconfig(8) output, and thus tend to break on crazy network names. Sometimes you probably asked yourself, why there is no NetworkManager analog in OpenBSD? - So here is a try of constructing an answer to ths question. The internal logic is simple: scan networks, find known one and try to run ifconfig(8) (and, probably, dhclient(8) and/or route(8)) on it. I tried to avoid creating another rich parser syntax - all of the lines you set up in configuration file became command-line arguments of corresponding utilities. I invite you to look at the current source code here: cvs -d anon...@anoncvs.ohvost.ru:/cvs checkout autonetd Maybe this will evolve into backend of some GUI, or whatever. Maybe not. But at least it works much better than what I've had before. Any input is highly appreciated. Thank you for your time! -- WBR, Vadim Zhukov
[regress] convert aes-ctr test from /dev/crypto
this test is converted the same way jsing@ has recently converted an xts test by pulling in xform.c code. OK? diff --git regress/sys/crypto/aesctr/Makefile regress/sys/crypto/aesctr/Makefile index 31ae500..7310dbc 100644 --- regress/sys/crypto/aesctr/Makefile +++ regress/sys/crypto/aesctr/Makefile @@ -1,10 +1,29 @@ # $OpenBSD: Makefile,v 1.1 2005/05/25 05:47:53 markus Exp $ +DIR= ${.CURDIR}/../../../../sys + +CFLAGS+= -I${DIR} + PROG= aesctr +SRCS= aesctr.c + +CDIAGFLAGS=-Wall +CDIAGFLAGS+= -Werror +CDIAGFLAGS+= -Wpointer-arith +CDIAGFLAGS+= -Wno-uninitialized +CDIAGFLAGS+= -Wstrict-prototypes +CDIAGFLAGS+= -Wmissing-prototypes +CDIAGFLAGS+= -Wunused +CDIAGFLAGS+= -Wsign-compare +CDIAGFLAGS+= -Wshadow REGRESS_ROOT_TARGETS= run-regress-${PROG} +.PATH: ${DIR}/crypto +SRCS+= cast.c ecb_enc.c ecb3_enc.c gmac.c rijndael.c set_key.c +SRCS+= xform.c + run-regress-${PROG}: ${PROG} - ${SUDO} ./${PROG} + ./${PROG} .include diff --git regress/sys/crypto/aesctr/aesctr.c regress/sys/crypto/aesctr/aesctr.c index 4cc1a6e..3a0b4d1 100644 --- regress/sys/crypto/aesctr/aesctr.c +++ regress/sys/crypto/aesctr/aesctr.c @@ -14,17 +14,13 @@ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include -#include -#include -#include +#include #include -#include #include #include #include #include #include @@ -128,92 +124,67 @@ struct { "B4 07 DF 86 65 69 FD 07 F4 8C C0 B5 83 D6 07 1F" /*"1E C0 E6 B8"*/, }, }; -static int -syscrypt(const unsigned char *key, size_t klen, const unsigned char *iv, -const unsigned char *in, unsigned char *out, size_t len, int encrypt) -{ - struct session_op session; - struct crypt_op cryp; - int cryptodev_fd = -1, fd = -1; +/* Stubs */ - if ((cryptodev_fd = open("/dev/crypto", O_RDWR, 0)) < 0) { - warn("/dev/crypto"); - goto err; - } - if (ioctl(cryptodev_fd, CRIOGET, &fd) == -1) { - warn("CRIOGET failed"); - goto err; - } - memset(&session, 0, sizeof(session)); - session.cipher = CRYPTO_AES_CTR; - session.key = (caddr_t) key; - session.keylen = klen; - if (ioctl(fd, CIOCGSESSION, &session) == -1) { - warn("CIOCGSESSION"); - goto err; - } - memset(&cryp, 0, sizeof(cryp)); - cryp.ses = session.ses; - cryp.op = encrypt ? COP_ENCRYPT : COP_DECRYPT; - cryp.flags = 0; - cryp.len = len; - cryp.src = (caddr_t) in; - cryp.dst = (caddr_t) out; - cryp.iv = (caddr_t) iv; - cryp.mac = 0; - if (ioctl(fd, CIOCCRYPT, &cryp) == -1) { - warn("CIOCCRYPT"); - goto err; - } - if (ioctl(fd, CIOCFSESSION, &session.ses) == -1) { - warn("CIOCFSESSION"); - goto err; - } - close(fd); - close(cryptodev_fd); - return (0); +u_int32_t deflate_global(u_int8_t *, u_int32_t, int, u_int8_t **); -err: - if (fd != -1) - close(fd); - if (cryptodev_fd != -1) - close(cryptodev_fd); - return (-1); +u_int32_t +deflate_global(u_int8_t *data, u_int32_t size, int comp, u_int8_t **out) +{ + return 0; } -static int -getallowsoft(void) +void explicit_bzero(void *, size_t); + +void +explicit_bzero(void *b, size_t len) { - int mib[2], old; - size_t olen; + bzero(b, len); +} - olen = sizeof(old); +/* Definitions from /sys/crypto/xform.c */ - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; - if (sysctl(mib, 2, &old, &olen, NULL, 0) < 0) - err(1, "sysctl failed"); +#define AESCTR_NONCESIZE 4 +#define AESCTR_IVSIZE 8 +#define AESCTR_BLOCKSIZE 16 - return old; -} +struct aes_ctr_ctx { + u_int32_t ac_ek[4*(AES_MAXROUNDS + 1)]; + u_int8_tac_block[AESCTR_BLOCKSIZE]; + int ac_nr; +}; -static void -setallowsoft(int new) -{ - int mib[2], old; - size_t olen, nlen; +int aes_ctr_setkey(void *, u_int8_t *, int); +void aes_ctr_encrypt(caddr_t, u_int8_t *); +void aes_ctr_decrypt(caddr_t, u_int8_t *); +void aes_ctr_reinit(caddr_t, u_int8_t *); - olen = nlen = sizeof(new); +static int +docrypt(const unsigned char *key, size_t klen, const unsigned char *iv, +const unsigned char *in, unsigned char *out, size_t len, int encrypt) +{ + u_int8_t block[AESCTR_BLOCKSIZE]; + struct aes_ctr_ctx ctx; + int error = 0; + size_t i; - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; + error = aes_ctr_setkey(&ctx, (u_int8_t *)key, klen); + if (error) + return -1; + aes_
[regress] convert aes testcase from /dev/crypto
in order to deprecate crypto(4) interface regress tests need to be converted. this aes test case actually uses ecb vectors, therefore no chaining is required and the code looks very simple. OK? diff --git regress/sys/crypto/aes/Makefile regress/sys/crypto/aes/Makefile index 459aedb..826d98c 100644 --- regress/sys/crypto/aes/Makefile +++ regress/sys/crypto/aes/Makefile @@ -1,9 +1,13 @@ # $OpenBSD: Makefile,v 1.2 2014/01/18 05:54:52 martynas Exp $ -PROG= aestest +DIR= ${.CURDIR}/../../../../sys + +CFLAGS+= -I${DIR} +PROG= aestest +SRCS= aestest.c CDIAGFLAGS=-Wall #CDIAGFLAGS+= -Werror CDIAGFLAGS+= -Wpointer-arith CDIAGFLAGS+= -Wno-uninitialized CDIAGFLAGS+= -Wstrict-prototypes @@ -12,9 +16,12 @@ CDIAGFLAGS+= -Wunused CDIAGFLAGS+= -Wsign-compare CDIAGFLAGS+= -Wshadow REGRESS_ROOT_TARGETS= run-regress-${PROG} +.PATH: ${DIR}/crypto +SRCS+= rijndael.c + run-regress-${PROG}: ${PROG} - ${SUDO} ./${PROG} ${.CURDIR}/vectors/*.txt + ./${PROG} ${.CURDIR}/vectors/*.txt .include diff --git regress/sys/crypto/aes/aestest.c regress/sys/crypto/aes/aestest.c index 2437c38..720dbc1 100644 --- regress/sys/crypto/aes/aestest.c +++ regress/sys/crypto/aes/aestest.c @@ -24,117 +24,39 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * Test crypto(4) AES with test vectors provided by Dr Brian Gladman: - * http://fp.gladman.plus.com/AES/ + * Test kernel AES implementation with test vectors provided by + * Dr Brian Gladman: http://fp.gladman.plus.com/AES/ */ -#include #include -#include -#include -#include +#include #include -#include #include #include #include #include #include static int -syscrypt(const unsigned char *key, size_t klen, const unsigned char *in, +docrypt(const unsigned char *key, size_t klen, const unsigned char *in, unsigned char *out, size_t len, int do_encrypt) { - struct session_op session; - struct crypt_op cryp; - int cryptodev_fd = -1, fd = -1; - u_char iv[32]; - - /* -* Kludge; the kernel doesn't support ECB encryption so we -* use a all-zero IV and encrypt a single block only, so the -* result should be the same. -*/ - bzero(iv, sizeof(iv)); - - if ((cryptodev_fd = open("/dev/crypto", O_RDWR, 0)) < 0) { - warn("/dev/crypto"); - goto err; - } - if (ioctl(cryptodev_fd, CRIOGET, &fd) == -1) { - warn("CRIOGET failed"); - goto err; - } - memset(&session, 0, sizeof(session)); - session.cipher = CRYPTO_AES_CBC; - session.key = (caddr_t) key; - session.keylen = klen; - if (ioctl(fd, CIOCGSESSION, &session) == -1) { - warn("CIOCGSESSION"); - goto err; - } - memset(&cryp, 0, sizeof(cryp)); - cryp.ses = session.ses; - cryp.op = do_encrypt ? COP_ENCRYPT : COP_DECRYPT; - cryp.flags = 0; - cryp.len = len; - cryp.src = (caddr_t) in; - cryp.dst = (caddr_t) out; - cryp.iv = (caddr_t) iv; - cryp.mac = 0; - if (ioctl(fd, CIOCCRYPT, &cryp) == -1) { - warn("CIOCCRYPT"); - goto err; - } - if (ioctl(fd, CIOCFSESSION, &session.ses) == -1) { - warn("CIOCFSESSION"); - goto err; - } - close(fd); - close(cryptodev_fd); - return (0); - -err: - if (fd != -1) - close(fd); - if (cryptodev_fd != -1) - close(cryptodev_fd); - return (-1); -} - -static int -getallowsoft(void) -{ - int mib[2], old; - size_t olen; - - olen = sizeof(old); - - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; - if (sysctl(mib, 2, &old, &olen, NULL, 0) < 0) - err(1, "sysctl failed"); - - return old; -} - -static void -setallowsoft(int new) -{ - int mib[2], old; - size_t olen, nlen; - - olen = nlen = sizeof(new); - - mib[0] = CTL_KERN; - mib[1] = KERN_CRYPTODEVALLOWSOFT; - - if (sysctl(mib, 2, &old, &olen, &new, nlen) < 0) - err(1, "sysctl failed"); + rijndael_ctx ctx; + int error = 0; + + memset(&ctx, 0, sizeof(ctx)); + error = rijndael_set_key(&ctx, key, klen * 8); + if (error) + return -1; + if (do_encrypt) + rijndael_encrypt(&ctx, in, out); + else + rijndael_decrypt(&ctx, in, out); + return 0; } static int match(unsigned char *a, unsigned char *b, size_t len) { @@ -221,21 +143,21 @@ do_tests(const char *filename, int test_num, u_char *key, u_int keylen, { char result[32]; int fail = 0; /* Encrypt test */ - if (syscrypt(key, keylen, plaintext, result, textlen, 1) < 0) { - warnx("encrypt with /de
jumbo support for bnx(4)
ive had this for 2 years or so. updated to current again. its been tested on the following: bnx0 at pci4 dev 0 function 0 "Broadcom BCM5708" rev 0x12: apic 8 int 16 bnx1 at pci13 dev 0 function 0 "Broadcom BCM5708" rev 0x12: apic 8 int 16 bnx0: address 00:1e:4f:1b:26:53 brgphy0 at bnx0 phy 1: BCM5708C 10/100/1000baseT PHY, rev. 6 bnx1: address 00:1e:4f:1b:26:51 brgphy1 at bnx1 phy 1: BCM5708C 10/100/1000baseT PHY, rev. 6 itd be nice to get tests on other variants. ok? Index: if_bnx.c === RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v retrieving revision 1.107 diff -u -p -r1.107 if_bnx.c --- if_bnx.c18 Jul 2014 07:11:04 - 1.107 +++ if_bnx.c13 Aug 2014 10:40:24 - @@ -848,6 +848,8 @@ bnx_attachhook(void *xsc) sc->bnx_rx_ticks = 18; #endif + sc->mbuf_alloc_size = BNX_MAX_JUMBO_MRU; + /* Update statistics once every second. */ sc->bnx_stats_ticks = 100 & 0x00; @@ -878,6 +880,7 @@ bnx_attachhook(void *xsc) ifp->if_ioctl = bnx_ioctl; ifp->if_start = bnx_start; ifp->if_watchdog = bnx_watchdog; + ifp->if_hardmtu = BNX_MAX_JUMBO_MTU; IFQ_SET_MAXLEN(&ifp->if_snd, USABLE_TX_BD - 1); IFQ_SET_READY(&ifp->if_snd); bcopy(sc->eaddr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); @@ -890,8 +893,6 @@ bnx_attachhook(void *xsc) ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; #endif - sc->mbuf_alloc_size = BNX_MAX_MRU; - printf("%s: address %s\n", sc->bnx_dev.dv_xname, ether_sprintf(sc->arpcom.ac_enaddr)); @@ -2647,8 +2648,8 @@ bnx_dma_alloc(struct bnx_softc *sc) * Create DMA maps for the Rx buffer mbufs. */ for (i = 0; i < TOTAL_RX_BD; i++) { - if (bus_dmamap_create(sc->bnx_dmatag, BNX_MAX_MRU, - BNX_MAX_SEGMENTS, BNX_MAX_MRU, 0, BUS_DMA_NOWAIT, + if (bus_dmamap_create(sc->bnx_dmatag, sc->mbuf_alloc_size, + 1, sc->mbuf_alloc_size, 0, BUS_DMA_NOWAIT, &sc->rx_mbuf_map[i])) { printf(": Could not create Rx mbuf %d DMA map!\n", i); rc = ENOMEM; @@ -3663,10 +3664,10 @@ bnx_get_buf(struct bnx_softc *sc, u_int1 *prod_bseq); /* This is a new mbuf allocation. */ - m = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES); + m = MCLGETI(NULL, M_DONTWAIT, NULL, sc->mbuf_alloc_size); if (!m) return (0); - m->m_len = m->m_pkthdr.len = MCLBYTES; + m->m_len = m->m_pkthdr.len = sc->mbuf_alloc_size; /* the chip aligns the ip header for us, no need to m_adj */ /* Map the mbuf cluster into device memory. */ @@ -3979,6 +3980,16 @@ bnx_init_rx_context(struct bnx_softc *sc REG_WR(sc, BNX_MQ_MAP_L2_5, val | BNX_MQ_MAP_L2_5_ARM); } + CTX_WR(sc, GET_CID_ADDR(RX_CID), BNX_L2CTX_RX_PG_BUF_SIZE, 0); + + /* Configure the rx_bd and page chain mbuf cluster size. */ + val = (sc->mbuf_alloc_size << 16); + CTX_WR(sc, GET_CID_ADDR(RX_CID), BNX_L2CTX_RX_PG_BUF_SIZE, val); + + /* Configure the context reserved for jumbo support. */ + CTX_WR(sc, GET_CID_ADDR(RX_CID), BNX_L2CTX_RX_RBDC_KEY, + BNX_L2CTX_RX_RBDC_JUMBO_KEY); + /* Point the hardware to the first page in the chain. */ val = (u_int32_t)((u_int64_t)sc->rx_bd_chain_paddr[0] >> 32); CTX_WR(sc, GET_CID_ADDR(RX_CID), BNX_L2CTX_NX_BDHADDR_HI, val); @@ -4746,7 +4757,7 @@ bnx_init(void *xsc) bnx_set_mac_addr(sc); /* Calculate and program the Ethernet MRU size. */ - ether_mtu = BNX_MAX_STD_ETHER_MTU_VLAN; + ether_mtu = BNX_MAX_JUMBO_ETHER_MTU; DBPRINT(sc, BNX_INFO, "%s(): setting MRU = %d\n", __FUNCTION__, ether_mtu); @@ -5134,7 +5145,7 @@ bnx_ioctl(struct ifnet *ifp, u_long comm case SIOCGIFRXR: error = if_rxr_ioctl((struct if_rxrinfo *)ifr->ifr_data, - NULL, MCLBYTES, &sc->rx_ring); + NULL, sc->mbuf_alloc_size, &sc->rx_ring); break; default:
Re: Fix pppoe(4) with rdomain != 0
OK On 13 August 2014 11:56, Martin Pieuchot wrote: > ok? > > Index: net/if_pppoe.c > === > RCS file: /home/ncvs/src/sys/net/if_pppoe.c,v > retrieving revision 1.40 > diff -u -p -r1.40 if_pppoe.c > --- net/if_pppoe.c 12 Jul 2014 18:44:22 - 1.40 > +++ net/if_pppoe.c 13 Aug 2014 09:56:16 - > @@ -1398,6 +1398,9 @@ pppoe_send_padt(struct ifnet *outgoing_i > memcpy(&eh->ether_dhost, dest, ETHER_ADDR_LEN); > > m0->m_flags &= ~(M_BCAST|M_MCAST); > + /* encapsulated packet is forced into rdomain of physical interface */ > + m0->m_pkthdr.ph_rtableid = outgoing_if->if_rdomain; > + > return (outgoing_if->if_output(outgoing_if, m0, &dst, NULL)); > } > >
Fix pppoe(4) with rdomain != 0
ok? Index: net/if_pppoe.c === RCS file: /home/ncvs/src/sys/net/if_pppoe.c,v retrieving revision 1.40 diff -u -p -r1.40 if_pppoe.c --- net/if_pppoe.c 12 Jul 2014 18:44:22 - 1.40 +++ net/if_pppoe.c 13 Aug 2014 09:56:16 - @@ -1398,6 +1398,9 @@ pppoe_send_padt(struct ifnet *outgoing_i memcpy(&eh->ether_dhost, dest, ETHER_ADDR_LEN); m0->m_flags &= ~(M_BCAST|M_MCAST); + /* encapsulated packet is forced into rdomain of physical interface */ + m0->m_pkthdr.ph_rtableid = outgoing_if->if_rdomain; + return (outgoing_if->if_output(outgoing_if, m0, &dst, NULL)); }
Re: Kill MRT_{ADD,DEL}_BW_UPCALL
On 13 August 2014 10:56, Martin Pieuchot wrote: > Our multicast routing code is and for the most > part unused. We discussed with claudio@ during t2k13 to rewrite only > the parts that people currently use, any volunteer? > > In the meantime, I'd like to kill the obviously unused parts of it. So > here's a first diff that remove the bandwidth monitoring interface. > Nothing use it in base and a quick search on codesearch.debian.net > reveals that only net/xorp picks it if it finds the defines. > > Ok? > OK
Kill MRT_{ADD,DEL}_BW_UPCALL
Our multicast routing code is and for the most part unused. We discussed with claudio@ during t2k13 to rewrite only the parts that people currently use, any volunteer? In the meantime, I'd like to kill the obviously unused parts of it. So here's a first diff that remove the bandwidth monitoring interface. Nothing use it in base and a quick search on codesearch.debian.net reveals that only net/xorp picks it if it finds the defines. Ok? Index: netinet/ip_mroute.c === RCS file: /home/ncvs/src/sys/netinet/ip_mroute.c,v retrieving revision 1.68 diff -u -p -r1.68 ip_mroute.c --- netinet/ip_mroute.c 22 Jul 2014 11:06:10 - 1.68 +++ netinet/ip_mroute.c 13 Aug 2014 08:43:46 - @@ -156,21 +156,6 @@ static void phyint_send(struct ip *, str static void encap_send(struct ip *, struct vif *, struct mbuf *); static void send_packet(struct vif *, struct mbuf *); -/* - * Bandwidth monitoring - */ -static void free_bw_list(struct bw_meter *); -static int add_bw_upcall(struct mbuf *); -static int del_bw_upcall(struct mbuf *); -static void bw_meter_receive_packet(struct bw_meter *, int , struct timeval *); -static void bw_meter_prepare_upcall(struct bw_meter *, struct timeval *); -static void bw_upcalls_send(void); -static void schedule_bw_meter(struct bw_meter *, struct timeval *); -static void unschedule_bw_meter(struct bw_meter *); -static void bw_meter_process(void); -static void expire_bw_upcalls_send(void *); -static void expire_bw_meter_process(void *); - #ifdef PIM static int pim_register_send(struct ip *, struct vif *, struct mbuf *, struct mfc *); @@ -211,28 +196,6 @@ struct ip multicast_encap_iphdr = { 0, /* checksum */ }; -/* - * Bandwidth meter variables and constants - */ - -/* - * Pending timeouts are stored in a hash table, the key being the - * expiration time. Periodically, the entries are analysed and processed. - */ -#define BW_METER_BUCKETS 1024 -static struct bw_meter *bw_meter_timers[BW_METER_BUCKETS]; -struct timeout bw_meter_ch; -#define BW_METER_PERIOD 1000 /* periodical handling of bw meters (in ms) */ - -/* - * Pending upcalls are stored in a vector which is flushed when - * full, or periodically - */ -static struct bw_upcallbw_upcalls[BW_UPCALLS_MAX]; -static u_int bw_upcalls_n; /* # of pending upcalls */ -struct timeout bw_upcalls_ch; -#define BW_UPCALLS_PERIOD 1000 /* periodical flush of bw upcalls (in ms) */ - #ifdef PIM struct pimstat pimstat; @@ -305,8 +268,7 @@ static int pim_assert; */ static const u_int32_t mrt_api_support = (MRT_MFC_FLAGS_DISABLE_WRONGVIF | MRT_MFC_FLAGS_BORDER_VIF | - MRT_MFC_RP | - MRT_MFC_BW_UPCALL); + MRT_MFC_RP); static u_int32_t mrt_api_config = 0; /* @@ -389,12 +351,6 @@ ip_mrouter_set(struct socket *so, int op case MRT_API_CONFIG: error = set_api_config(*m); break; - case MRT_ADD_BW_UPCALL: - error = add_bw_upcall(*m); - break; - case MRT_DEL_BW_UPCALL: - error = del_bw_upcall(*m); - break; default: error = ENOPROTOOPT; break; @@ -549,12 +505,6 @@ ip_mrouter_init(struct socket *so, struc timeout_set(&expire_upcalls_ch, expire_upcalls, NULL); timeout_add_msec(&expire_upcalls_ch, EXPIRE_TIMEOUT); - timeout_set(&bw_upcalls_ch, expire_bw_upcalls_send, NULL); - timeout_add_msec(&bw_upcalls_ch, BW_UPCALLS_PERIOD); - - timeout_set(&bw_meter_ch, expire_bw_meter_process, NULL); - timeout_add_msec(&bw_meter_ch, BW_METER_PERIOD); - if (mrtdebug) log(LOG_DEBUG, "ip_mrouter_init\n"); @@ -586,8 +536,6 @@ ip_mrouter_done() mrt_api_config = 0; timeout_del(&expire_upcalls_ch); - timeout_del(&bw_upcalls_ch); - timeout_del(&bw_meter_ch); /* * Free all multicast forwarding cache entries. @@ -606,9 +554,6 @@ ip_mrouter_done() free(mfchashtbl, M_MRTABLE, 0); mfchashtbl = NULL; - bw_upcalls_n = 0; - memset(bw_meter_timers, 0, sizeof(bw_meter_timers)); - /* Reset de-encapsulation cache. */ have_encap_tunnel = 0; @@ -1015,8 +960,6 @@ expire_mfc(struct mfc *rt) { struct rtdetq *rte, *nrte; - free_bw_list(rt->mfc_bw_meter); - for (rte = rt->mfc_stall; rte != NULL; rte = nrte) { nrte = rte->next; m_freem(rte->m); @@ -1156,7 +1099,6 @@ add_mfc(struct mbuf *m) init_mfc_params(rt, mfccp); rt->mfc_expire = 0; rt->mfc_stall = NULL; -