Author: sephe
Date: Tue Aug 16 07:45:35 2016
New Revision: 304206
URL: https://svnweb.freebsd.org/changeset/base/304206

Log:
  hyperv/hn: Simplify RNDIS message checks on RX path.
  
  MFC after:    1 week
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D7502

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/if_hnreg.h

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Tue Aug 16 07:37:02 2016        
(r304205)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Tue Aug 16 07:45:35 2016        
(r304206)
@@ -847,19 +847,18 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
     struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr)
 {
        const struct vmbus_chanpkt_rxbuf *pkt;
-       const nvsp_msg *nvsp_msg_pkt;
+       const struct hn_nvs_hdr *nvs_hdr;
        netvsc_packet vsc_pkt;
        netvsc_packet *net_vsc_pkt = &vsc_pkt;
        int count = 0;
        int i = 0;
        int status = nvsp_status_success;
 
-       nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkthdr);
-
-       /* Make sure this is a valid nvsp packet */
-       if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) {
-               if_printf(rxr->hn_ifp, "packet hdr type %u is invalid!\n",
-                   nvsp_msg_pkt->hdr.msg_type);
+       /* Make sure that this is a RNDIS message. */
+       nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr);
+       if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) {
+               if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n",
+                   nvs_hdr->nvs_type);
                return;
        }
        

Modified: head/sys/dev/hyperv/netvsc/if_hnreg.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hnreg.h       Tue Aug 16 07:37:02 2016        
(r304205)
+++ head/sys/dev/hyperv/netvsc/if_hnreg.h       Tue Aug 16 07:45:35 2016        
(r304206)
@@ -69,6 +69,11 @@
  */
 #define HN_NVS_REQSIZE_MIN             32
 
+/* NVS message common header */
+struct hn_nvs_hdr {
+       uint32_t        nvs_type;
+} __packed;
+
 struct hn_nvs_init {
        uint32_t        nvs_type;       /* HN_NVS_TYPE_INIT */
        uint32_t        nvs_ver_min;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to