Discussion:
urndis
(too old to reply)
Artturi Alm
2018-11-01 00:12:34 UTC
Permalink
Hi,

i hope this is the correct list for this, let me know if not, thnx.

diff below fixes a some bugs that have been there since the import,
and does add some bits missing, that should be made use of later, i think.

the urndis_decap() change is explained here:
https://docs.microsoft.com/en-us/windows-hardware/drivers/network/usb-short-packets

should apply against trunk, that i got from github.com/NetBSD/src.

-Artturi


diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index 73b403598222..b3c06fd26007 100644
--- a/sys/dev/usb/if_urndis.c
+++ b/sys/dev/usb/if_urndis.c
@@ -289,7 +289,18 @@ urndis_ctrl_handle_init(struct urndis_softc *sc,
return RNDIS_STATUS_FAILURE;
}

- sc->sc_lim_pktsz = le32toh(msg->rm_pktmaxsz);
+ if (le32toh(msg->rm_ver_major) != RNDIS_MAJOR_VERSION &&
+ le32toh(msg->rm_ver_minor) != RNDIS_MINOR_VERSION) {
+ printf("%s: version not %u.%u (current version: %u.%u)\n",
+ DEVNAME(sc), RNDIS_MAJOR_VERSION, RNDIS_MINOR_VERSION,
+ le32toh(msg->rm_ver_major), le32toh(msg->rm_ver_minor));
+
+ return RNDIS_STATUS_FAILURE;
+ }
+
+ sc->sc_maxppt = le32toh(msg->rm_pktmaxcnt);
+ sc->sc_maxtsz = le32toh(msg->rm_pktmaxsz);
+ sc->sc_palign = 1U << le32toh(msg->rm_align);

return le32toh(msg->rm_status);
}
@@ -402,8 +413,8 @@ urndis_ctrl_init(struct urndis_softc *sc)
msg->rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG);
msg->rm_len = htole32(sizeof(*msg));
msg->rm_rid = htole32(0);
- msg->rm_ver_major = htole32(1);
- msg->rm_ver_minor = htole32(1);
+ msg->rm_ver_major = htole32(RNDIS_MAJOR_VERSION);
+ msg->rm_ver_minor = htole32(RNDIS_MINOR_VERSION);
msg->rm_max_xfersz = htole32(RNDIS_BUFSZ);

DPRINTF(("%s: urndis_ctrl_init send: type %u len %u rid %u ver_major %u "
@@ -743,7 +754,7 @@ urndis_decap(struct urndis_softc *sc, struct urndis_chain *c, uint32_t len)
ifp = GET_IFP(sc);
offset = 0;

- while (len > 0) {
+ while (len > 1) {
msg = (struct urndis_packet_msg *)((char*)c->sc_buf + offset);
m = c->sc_mbuf;

diff --git a/sys/dev/usb/if_urndisreg.h b/sys/dev/usb/if_urndisreg.h
index 78415e61f6a2..fad80d7e3f98 100644
--- a/sys/dev/usb/if_urndisreg.h
+++ b/sys/dev/usb/if_urndisreg.h
@@ -47,8 +47,10 @@ struct urndis_softc {
struct ethercom sc_ec;

/* RNDIS device info */
- uint32_t sc_lim_pktsz;
uint32_t sc_filter;
+ uint32_t sc_maxppt;
+ uint32_t sc_maxtsz;
+ uint32_t sc_palign;

/* USB goo */
struct usbd_device * sc_udev;
@@ -122,6 +124,9 @@ struct urndis_softc {

#define RNDIS_MEDIUM_802_3 0x00000000

+#define RNDIS_MAJOR_VERSION 0x00000001U
+#define RNDIS_MINOR_VERSION 0x00000000U
+
/* Device flags */
#define RNDIS_DF_CONNECTIONLESS 0x00000001
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Paul Goyette
2018-11-01 00:24:44 UTC
Permalink
Post by Artturi Alm
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index 73b403598222..b3c06fd26007 100644
--- a/sys/dev/usb/if_urndis.c
+++ b/sys/dev/usb/if_urndis.c
@@ -289,7 +289,18 @@ urndis_ctrl_handle_init(struct urndis_softc *sc,
return RNDIS_STATUS_FAILURE;
}
- sc->sc_lim_pktsz = le32toh(msg->rm_pktmaxsz);
+ if (le32toh(msg->rm_ver_major) != RNDIS_MAJOR_VERSION &&
Shouldn't this be || and not && ? ----------------------------^^
Post by Artturi Alm
+ le32toh(msg->rm_ver_minor) != RNDIS_MINOR_VERSION) {
+ printf("%s: version not %u.%u (current version: %u.%u)\n",
+ DEVNAME(sc), RNDIS_MAJOR_VERSION, RNDIS_MINOR_VERSION,
+ le32toh(msg->rm_ver_major), le32toh(msg->rm_ver_minor));
+
+ return RNDIS_STATUS_FAILURE;
+ }
+
+ sc->sc_maxppt = le32toh(msg->rm_pktmaxcnt);
+ sc->sc_maxtsz = le32toh(msg->rm_pktmaxsz);
+ sc->sc_palign = 1U << le32toh(msg->rm_align);
return le32toh(msg->rm_status);
}
@@ -402,8 +413,8 @@ urndis_ctrl_init(struct urndis_softc *sc)
msg->rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG);
msg->rm_len = htole32(sizeof(*msg));
msg->rm_rid = htole32(0);
- msg->rm_ver_major = htole32(1);
- msg->rm_ver_minor = htole32(1);
+ msg->rm_ver_major = htole32(RNDIS_MAJOR_VERSION);
+ msg->rm_ver_minor = htole32(RNDIS_MINOR_VERSION);
msg->rm_max_xfersz = htole32(RNDIS_BUFSZ);
DPRINTF(("%s: urndis_ctrl_init send: type %u len %u rid %u ver_major %u "
@@ -743,7 +754,7 @@ urndis_decap(struct urndis_softc *sc, struct urndis_chain *c, uint32_t len)
ifp = GET_IFP(sc);
offset = 0;
- while (len > 0) {
+ while (len > 1) {
msg = (struct urndis_packet_msg *)((char*)c->sc_buf + offset);
m = c->sc_mbuf;
diff --git a/sys/dev/usb/if_urndisreg.h b/sys/dev/usb/if_urndisreg.h
index 78415e61f6a2..fad80d7e3f98 100644
--- a/sys/dev/usb/if_urndisreg.h
+++ b/sys/dev/usb/if_urndisreg.h
@@ -47,8 +47,10 @@ struct urndis_softc {
struct ethercom sc_ec;
/* RNDIS device info */
- uint32_t sc_lim_pktsz;
uint32_t sc_filter;
+ uint32_t sc_maxppt;
+ uint32_t sc_maxtsz;
+ uint32_t sc_palign;
/* USB goo */
struct usbd_device * sc_udev;
@@ -122,6 +124,9 @@ struct urndis_softc {
#define RNDIS_MEDIUM_802_3 0x00000000
+#define RNDIS_MAJOR_VERSION 0x00000001U
+#define RNDIS_MINOR_VERSION 0x00000000U
+
/* Device flags */
#define RNDIS_DF_CONNECTIONLESS 0x00000001
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
+------------------+--------------------------+----------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Artturi Alm
2018-11-01 00:35:32 UTC
Permalink
Post by Paul Goyette
Post by Artturi Alm
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index 73b403598222..b3c06fd26007 100644
--- a/sys/dev/usb/if_urndis.c
+++ b/sys/dev/usb/if_urndis.c
@@ -289,7 +289,18 @@ urndis_ctrl_handle_init(struct urndis_softc *sc,
return RNDIS_STATUS_FAILURE;
}
- sc->sc_lim_pktsz = le32toh(msg->rm_pktmaxsz);
+ if (le32toh(msg->rm_ver_major) != RNDIS_MAJOR_VERSION &&
Shouldn't this be || and not && ? ----------------------------^^
Yes, it should, i was validating the version originally separately,
and apparently failed at combining the if's, thanks for the feedback:)

-Artturi
Post by Paul Goyette
Post by Artturi Alm
+ le32toh(msg->rm_ver_minor) != RNDIS_MINOR_VERSION) {
+ printf("%s: version not %u.%u (current version: %u.%u)\n",
+ DEVNAME(sc), RNDIS_MAJOR_VERSION, RNDIS_MINOR_VERSION,
+ le32toh(msg->rm_ver_major), le32toh(msg->rm_ver_minor));
+
+ return RNDIS_STATUS_FAILURE;
+ }
+
+ sc->sc_maxppt = le32toh(msg->rm_pktmaxcnt);
+ sc->sc_maxtsz = le32toh(msg->rm_pktmaxsz);
+ sc->sc_palign = 1U << le32toh(msg->rm_align);
return le32toh(msg->rm_status);
}
@@ -402,8 +413,8 @@ urndis_ctrl_init(struct urndis_softc *sc)
msg->rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG);
msg->rm_len = htole32(sizeof(*msg));
msg->rm_rid = htole32(0);
- msg->rm_ver_major = htole32(1);
- msg->rm_ver_minor = htole32(1);
+ msg->rm_ver_major = htole32(RNDIS_MAJOR_VERSION);
+ msg->rm_ver_minor = htole32(RNDIS_MINOR_VERSION);
msg->rm_max_xfersz = htole32(RNDIS_BUFSZ);
DPRINTF(("%s: urndis_ctrl_init send: type %u len %u rid %u ver_major %u "
@@ -743,7 +754,7 @@ urndis_decap(struct urndis_softc *sc, struct urndis_chain *c, uint32_t len)
ifp = GET_IFP(sc);
offset = 0;
- while (len > 0) {
+ while (len > 1) {
msg = (struct urndis_packet_msg *)((char*)c->sc_buf + offset);
m = c->sc_mbuf;
diff --git a/sys/dev/usb/if_urndisreg.h b/sys/dev/usb/if_urndisreg.h
index 78415e61f6a2..fad80d7e3f98 100644
--- a/sys/dev/usb/if_urndisreg.h
+++ b/sys/dev/usb/if_urndisreg.h
@@ -47,8 +47,10 @@ struct urndis_softc {
struct ethercom sc_ec;
/* RNDIS device info */
- uint32_t sc_lim_pktsz;
uint32_t sc_filter;
+ uint32_t sc_maxppt;
+ uint32_t sc_maxtsz;
+ uint32_t sc_palign;
/* USB goo */
struct usbd_device * sc_udev;
@@ -122,6 +124,9 @@ struct urndis_softc {
#define RNDIS_MEDIUM_802_3 0x00000000
+#define RNDIS_MAJOR_VERSION 0x00000001U
+#define RNDIS_MINOR_VERSION 0x00000000U
+
/* Device flags */
#define RNDIS_DF_CONNECTIONLESS 0x00000001
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
+------------------+--------------------------+----------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
m***@netbsd.org
2018-11-09 21:57:44 UTC
Permalink
Mostly for others: committed, thanks :-)

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...