On Sat, Nov 29, 2014 at 09:42:51PM +0100, Mark Kettenis wrote: > 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. >
Hi, just found your mail, i think urndis(4) is not entirely written with these in mind: defined(__STRICT_ALIGNMENT) || _BYTE_ORDER != _LITTLE_ENDIAN did you ever try with a diff like below? -Artturi diff --git sys/dev/rndis.h sys/dev/rndis.h index 140793990e9..7036d198d4e 100644 --- sys/dev/rndis.h +++ sys/dev/rndis.h @@ -98,7 +98,7 @@ struct rndis_msghdr { uint32_t rm_type; uint32_t rm_len; -}; +} __packed; /* * RNDIS data message @@ -118,7 +118,7 @@ struct rndis_packet_msg { uint32_t rm_pktinfolen; uint32_t rm_vchandle; uint32_t rm_reserved; -}; +} __packed; /* Per-packet-info for RNDIS data message */ struct rndis_pktinfo { @@ -126,7 +126,7 @@ struct rndis_pktinfo { uint32_t rm_type; /* NDIS_PKTINFO_TYPE_ */ uint32_t rm_pktinfooffset; uint8_t rm_data[0]; -}; +} __packed; #define NDIS_PKTINFO_TYPE_CSUM 0 #define NDIS_PKTINFO_TYPE_IPSEC 1 @@ -149,7 +149,7 @@ struct rndis_comp_hdr { uint32_t rm_len; uint32_t rm_rid; uint32_t rm_status; -}; +} __packed; /* Initialize the device. */ #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 @@ -162,7 +162,7 @@ struct rndis_init_req { uint32_t rm_ver_major; uint32_t rm_ver_minor; uint32_t rm_max_xfersz; -}; +} __packed; struct rndis_init_comp { uint32_t rm_type; @@ -178,7 +178,7 @@ struct rndis_init_comp { uint32_t rm_align; uint32_t rm_aflistoffset; uint32_t rm_aflistsz; -}; +} __packed; /* Halt the device. No response sent. */ #define REMOTE_NDIS_HALT_MSG 0x00000003 @@ -187,7 +187,7 @@ struct rndis_halt_req { uint32_t rm_type; uint32_t rm_len; uint32_t rm_rid; -}; +} __packed; /* Send a query object. */ #define REMOTE_NDIS_QUERY_MSG 0x00000004 @@ -201,7 +201,7 @@ struct rndis_query_req { uint32_t rm_infobuflen; uint32_t rm_infobufoffset; uint32_t rm_devicevchdl; -}; +} __packed; struct rndis_query_comp { uint32_t rm_type; @@ -210,7 +210,7 @@ struct rndis_query_comp { uint32_t rm_status; uint32_t rm_infobuflen; uint32_t rm_infobufoffset; -}; +} __packed; /* Send a set object request. */ #define REMOTE_NDIS_SET_MSG 0x00000005 @@ -224,14 +224,14 @@ struct rndis_set_req { uint32_t rm_infobuflen; uint32_t rm_infobufoffset; uint32_t rm_devicevchdl; -}; +} __packed; struct rndis_set_comp { uint32_t rm_type; uint32_t rm_len; uint32_t rm_rid; uint32_t rm_status; -}; +} __packed; /* Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER. */ #define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 @@ -243,7 +243,7 @@ struct rndis_set_parameter { uint32_t rm_type; uint32_t rm_valueoffset; uint32_t rm_valuelen; -}; +} __packed; /* Perform a soft reset on the device. */ #define REMOTE_NDIS_RESET_MSG 0x00000006 @@ -253,14 +253,14 @@ struct rndis_reset_req { uint32_t rm_type; uint32_t rm_len; uint32_t rm_rid; -}; +} __packed; struct rndis_reset_comp { uint32_t rm_type; uint32_t rm_len; uint32_t rm_status; uint32_t rm_adrreset; -}; +} __packed; /* 802.3 link-state or undefined message error. Sent by device. */ #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 @@ -272,7 +272,7 @@ struct rndis_status_msg { uint32_t rm_stbuflen; uint32_t rm_stbufoffset; /* rndis_diag_info */ -}; +} __packed; /* * Immediately after rndis_status_msg.rm_stbufoffset, if a control @@ -282,7 +282,7 @@ struct rndis_status_msg { struct rndis_diag_info { uint32_t rm_diagstatus; uint32_t rm_erroffset; -}; +} __packed; /* Keepalive messsage. May be sent by device. */ #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 @@ -292,14 +292,14 @@ struct rndis_keepalive_req { uint32_t rm_type; uint32_t rm_len; uint32_t rm_rid; -}; +} __packed; struct rndis_keepalive_comp { uint32_t rm_type; uint32_t rm_len; uint32_t rm_rid; uint32_t rm_status; -}; +} __packed; /* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ #define NDIS_PACKET_TYPE_DIRECTED 0x00000001