]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/in_tclass.c
xnu-4570.51.1.tar.gz
[apple/xnu.git] / bsd / netinet / in_tclass.c
index 5d627e551808014b25cf4af421ee27fcbfdc9dfb..21fc03f44fe5b88fcb6cb3f1ede1e752a12c9d18 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2017 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2018 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -1463,11 +1463,13 @@ set_netsvctype_dscp_map(size_t in_count,
                        case NET_SERVICE_TYPE_AV:
                        case NET_SERVICE_TYPE_OAM:
                        case NET_SERVICE_TYPE_RD: {
-                               int sotcix;
+                               size_t sotcix;
 
                                sotcix = sotc_index(sotc_by_netservicetype[netsvctype]);
-                               net_qos_dscp_map->sotc_to_dscp[sotcix]  =
-                                   netsvctype_dscp_map[netsvctype].dscp;
+                               if (sotcix != SIZE_T_MAX) {
+                                       net_qos_dscp_map->sotc_to_dscp[sotcix]  =
+                                           netsvctype_dscp_map[netsvctype].dscp;
+                               }
                                break;
                        }
                        case  NET_SERVICE_TYPE_SIG:
@@ -1546,7 +1548,7 @@ sysctl_default_netsvctype_to_dscp_map SYSCTL_HANDLER_ARGS
        const size_t max_netsvctype_to_dscp_map_len =
            _NET_SERVICE_TYPE_COUNT * sizeof(struct netsvctype_dscp_map);
        size_t len;
-       struct netsvctype_dscp_map netsvctype_dscp_map[_NET_SERVICE_TYPE_COUNT];
+       struct netsvctype_dscp_map netsvctype_dscp_map[_NET_SERVICE_TYPE_COUNT] = {};
        size_t count;
 
        if (req->oldptr == USER_ADDR_NULL) {
@@ -1619,7 +1621,7 @@ set_packet_qos(struct mbuf *m, struct ifnet *ifp, boolean_t qos_allowed,
                 * We still want to prioritize control traffic on the interface
                 * so we do not change the mbuf service class for SO_TC_CTL
                 */
-               if (netsvctype != _NET_SERVICE_TYPE_UNSPEC &&
+               if (IS_VALID_NET_SERVICE_TYPE(netsvctype) &&
                    netsvctype != NET_SERVICE_TYPE_BE) {
                        dscp = default_net_qos_dscp_map.netsvctype_to_dscp[netsvctype];
 
@@ -1630,17 +1632,18 @@ set_packet_qos(struct mbuf *m, struct ifnet *ifp, boolean_t qos_allowed,
                                if (sotc != SO_TC_CTL)
                                        m_set_service_class(m, MBUF_SC_BE);
                        }
-               } else {
+               } else if (sotc != SO_TC_UNSPEC) {
                        size_t sotcix = sotc_index(sotc);
-
-                       dscp = default_net_qos_dscp_map.sotc_to_dscp[sotcix];
-
-                       if (qos_allowed == FALSE && sotc != SO_TC_BE &&
-                           sotc != SO_TC_BK && sotc != SO_TC_BK_SYS &&
-                           sotc != SO_TC_CTL) {
-                               dscp = _DSCP_DF;
-                               if (sotc != SO_TC_CTL)
-                                       m_set_service_class(m, MBUF_SC_BE);
+                       if (sotcix != SIZE_T_MAX) {
+                               dscp = default_net_qos_dscp_map.sotc_to_dscp[sotcix];
+
+                               if (qos_allowed == FALSE && sotc != SO_TC_BE &&
+                                   sotc != SO_TC_BK && sotc != SO_TC_BK_SYS &&
+                                   sotc != SO_TC_CTL) {
+                                       dscp = _DSCP_DF;
+                                       if (sotc != SO_TC_CTL)
+                                               m_set_service_class(m, MBUF_SC_BE);
+                               }
                        }
                }
                if (net_qos_verbose != 0)
@@ -1748,7 +1751,7 @@ sysctl_dscp_to_wifi_ac_map SYSCTL_HANDLER_ARGS
 #pragma unused(oidp, arg1, arg2)
        int error = 0;
        size_t len = DSCP_ARRAY_SIZE * sizeof(struct netsvctype_dscp_map);
-       struct netsvctype_dscp_map netsvctype_dscp_map[DSCP_ARRAY_SIZE];
+       struct netsvctype_dscp_map netsvctype_dscp_map[DSCP_ARRAY_SIZE] = {};
        struct dcsp_msc_map dcsp_msc_map[DSCP_ARRAY_SIZE];
        size_t count;
        u_int32_t i;