Recent Oracle SPARC machines have a USB gadget to talk to the Service
Processor (ILOM).  This gadget supports both RNDIS and CDC Ethernet.
The RNDIS bits uncovered a bug in urndis(4).  When urndis_ctrl_set()
sets up the REMOTE_NDIS_SET_MSG command it sets up msg->rm_infobuflen,
it subsequently overwrites its contents.  Apparently many RNDIS
devices don't care, but this hardware sends a response back that
indicates the command wasn't accepted.  Diff below fixes this problem.
It matches what Linux does.

Unfortunately, this isn't enough to make the gadget work in RNDIS mode.

I'd appreciate it if people using urndis(4) could test this diff.


Index: if_urndis.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_urndis.c,v
retrieving revision 1.49
diff -u -p -r1.49 if_urndis.c
--- if_urndis.c 13 Jul 2014 15:52:49 -0000      1.49
+++ if_urndis.c 29 Nov 2014 20:30:24 -0000
@@ -554,7 +554,7 @@ urndis_ctrl_set(struct urndis_softc *sc,
        msg->rm_infobuflen = htole32(len);
        if (len != 0) {
                msg->rm_infobufoffset = htole32(20);
-               memcpy((char*)msg + 20, buf, len);
+               memcpy((char*)msg + 28, buf, len);
        } else
                msg->rm_infobufoffset = 0;
        msg->rm_devicevchdl = 0;
@@ -570,7 +570,7 @@ urndis_ctrl_set(struct urndis_softc *sc,
            letoh32(msg->rm_infobufoffset),
            letoh32(msg->rm_devicevchdl)));
 
-       rval = urndis_ctrl_send(sc, msg, sizeof(*msg));
+       rval = urndis_ctrl_send(sc, msg, sizeof(*msg) + len);
        free(msg, M_TEMP, 0);
 
        if (rval != RNDIS_STATUS_SUCCESS) {

Reply via email to