diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-07 00:18:07 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-07 00:18:07 +0000 |
commit | 2be036fbad3b38e96f41ddaa1e435c2da74bc878 (patch) | |
tree | 961242fca97076f42a1b133136136092179922cb | |
parent | a70e2567fe4ca276bcfbcb95b8c657d4d678dbdd (diff) |
allow AOE config to be specified by userland. ok marco.
use consistent network types as requested and ok deraadt.
-rw-r--r-- | sys/dev/softraid_aoe.c | 58 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 20 |
2 files changed, 44 insertions, 34 deletions
diff --git a/sys/dev/softraid_aoe.c b/sys/dev/softraid_aoe.c index 131d2765823..9705597b47f 100644 --- a/sys/dev/softraid_aoe.c +++ b/sys/dev/softraid_aoe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_aoe.c,v 1.22 2011/07/04 04:49:05 tedu Exp $ */ +/* $OpenBSD: softraid_aoe.c,v 1.23 2011/07/07 00:18:06 tedu Exp $ */ /* * Copyright (c) 2008 Ted Unangst <tedu@openbsd.org> * Copyright (c) 2008 Marco Peereboom <marco@openbsd.org> @@ -153,11 +153,8 @@ sr_aoe_assemble(struct sr_discipline *sd, struct bioc_createraid *bc, { struct ifnet *ifp; struct aoe_handler *ah; - unsigned char slot; - unsigned short shelf; - const char *nic; - const char *dsteaddr; - int s; + struct sr_aoe_config sri; + int rv, s; #if 0 struct mbuf *m; struct ether_header *eh; @@ -165,24 +162,24 @@ sr_aoe_assemble(struct sr_discipline *sd, struct bioc_createraid *bc, int rv; #endif + if (!(bc->bc_opaque_flags & BIOC_SOIN)) + return (EINVAL); + if (bc->bc_opaque_size != sizeof(sri)) + return (EINVAL); + if ((rv = copyin(bc->bc_opaque, &sri, sizeof(sri)))) + return (rv); + sri.nic[sizeof(sri.nic) - 1] = 0; sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no; - /* where do these come from */ - slot = 3; - shelf = 4; - nic = "ne0"; - dsteaddr = dsteaddr; - - ifp = ifunit(nic); + ifp = ifunit(sri.nic); if (!ifp) return (EINVAL); - shelf = htons(shelf); ah = malloc(sizeof(*ah), M_DEVBUF, M_WAITOK | M_ZERO); ah->ifp = ifp; - ah->major = shelf; - ah->minor = slot; + ah->major = sri.shelf; + ah->minor = sri.slot; ah->fn = (workq_fn)sr_aoe_input; TAILQ_INIT(&ah->reqs); @@ -191,7 +188,7 @@ sr_aoe_assemble(struct sr_discipline *sd, struct bioc_createraid *bc, splx(s); sd->mds.mdd_aoe.sra_ah = ah; - memcpy(sd->mds.mdd_aoe.sra_eaddr, dsteaddr, 6); + sd->mds.mdd_aoe.sra_eaddr = sri.dsteaddr; #if 0 MGETHDR(m, M_WAIT, MT_HEADER); @@ -203,8 +200,8 @@ sr_aoe_assemble(struct sr_discipline *sd, struct bioc_createraid *bc, ap->vers = 1; ap->flags = 0; ap->error = 0; - ap->major = shelf; - ap->minor = slot; + ap->major = sri.shelf; + ap->minor = sri.slot; ap->command = 1; ap->tag = 0; ap->buffercnt = 0; @@ -351,8 +348,9 @@ sr_send_aoe_chunk(struct sr_workunit *wu, daddr64_t blk, int i) } eh = mtod(m, struct ether_header *); - memcpy(eh->ether_dhost, sd->mds.mdd_aoe.sra_eaddr, 6); - memcpy(eh->ether_shost, ((struct arpcom *)ifp)->ac_enaddr, 6); + memcpy(eh->ether_dhost, &sd->mds.mdd_aoe.sra_eaddr, ETHER_ADDR_LEN); + memcpy(eh->ether_shost, ((struct arpcom *)ifp)->ac_enaddr, + ETHER_ADDR_LEN); eh->ether_type = htons(ETHERTYPE_AOE); ap = (struct aoe_packet *)&eh[1]; ap->vers = 1; @@ -648,12 +646,8 @@ sr_aoe_server_alloc_resources(struct sr_discipline *sd) splx(s); sd->mds.mdd_aoe.sra_ah = ah; - sd->mds.mdd_aoe.sra_eaddr[0] = 0xff; - sd->mds.mdd_aoe.sra_eaddr[1] = 0xff; - sd->mds.mdd_aoe.sra_eaddr[2] = 0xff; - sd->mds.mdd_aoe.sra_eaddr[3] = 0xff; - sd->mds.mdd_aoe.sra_eaddr[4] = 0xff; - sd->mds.mdd_aoe.sra_eaddr[5] = 0xff; + memset(&sd->mds.mdd_aoe.sra_eaddr, 0xff, + sizeof(sd->mds.mdd_aoe.sra_eaddr)); sd->mds.mdd_aoe.sra_ifp = ifp; if (sr_wu_alloc(sd)) @@ -766,9 +760,10 @@ resleep: len = rp->sectorcnt * 512; eh = mtod(m, struct ether_header *); - memcpy(eh->ether_dhost, sd->mds.mdd_aoe.sra_eaddr, 6); + memcpy(eh->ether_dhost, &sd->mds.mdd_aoe.sra_eaddr, + ETHER_ADDR_LEN); memcpy(eh->ether_shost, - ((struct arpcom *)ifp)->ac_enaddr, 6); + ((struct arpcom *)ifp)->ac_enaddr, ETHER_ADDR_LEN); eh->ether_type = htons(ETHERTYPE_AOE); ap = (struct aoe_packet *)&eh[1]; AOE_HDR2BLK(ap, blk); @@ -832,9 +827,10 @@ resleep: len = rp->sectorcnt * 512; eh = mtod(m, struct ether_header *); - memcpy(eh->ether_dhost, sd->mds.mdd_aoe.sra_eaddr, 6); + memcpy(eh->ether_dhost, &sd->mds.mdd_aoe.sra_eaddr, + ETHER_ADDR_LEN); memcpy(eh->ether_shost, - ((struct arpcom *)ifp)->ac_enaddr, 6); + ((struct arpcom *)ifp)->ac_enaddr, ETHER_ADDR_LEN); eh->ether_type = htons(ETHERTYPE_AOE); ap = (struct aoe_packet *)&eh[1]; AOE_HDR2BLK(ap, blk); diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index 95a5dfbd90f..be2b690185a 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.104 2011/07/06 17:32:47 jsing Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.105 2011/07/07 00:18:06 tedu Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -19,9 +19,15 @@ #ifndef SOFTRAIDVAR_H #define SOFTRAIDVAR_H -#include <crypto/md5.h> +#include <sys/socket.h> #include <sys/vnode.h> +#include <net/if.h> +#include <netinet/in.h> +#include <netinet/if_ether.h> + +#include <crypto/md5.h> + #define SR_META_VERSION 4 /* bump when sr_metadata changes */ #define SR_META_SIZE 64 /* save space at chunk beginning */ #define SR_META_OFFSET 16 /* skip 8192 bytes at chunk beginning */ @@ -240,6 +246,14 @@ struct sr_crypto_kdfpair { u_int32_t kdfsize2; }; +struct sr_aoe_config { + char nic[IFNAMSIZ]; + struct ether_addr dsteaddr; + unsigned char slot; + unsigned short shelf; +}; + + #ifdef _KERNEL #include <dev/biovar.h> @@ -402,7 +416,7 @@ struct sr_aoe { struct aoe_handler *sra_ah; int sra_tag; struct ifnet *sra_ifp; - char sra_eaddr[6]; + struct ether_addr sra_eaddr; }; struct sr_boot_chunk { |