From 9c84165cb070178f20fb1c28e241999942d929db Mon Sep 17 00:00:00 2001 From: "Anand H. Krishnan" Date: Wed, 17 Aug 2016 16:09:35 +0530 Subject: [PATCH] Fix the interpretation of priority nibbles in ipv6 header The higher nibble of the priority is in the higher nibble of the first byte and the lower nibble is in the lower nibble of the second byte. The earlier interpretation was plain reverse of this scheme. Also, DSCP is the most significant 6 bits of the ipv6 priority. Change-Id: I815e35d9955382fb21ab686be9f20754a7df0d52 Closes-Bug: #1614042 --- include/vr_packet.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/include/vr_packet.h b/include/vr_packet.h index b9f6e6d07..ac82aaea5 100644 --- a/include/vr_packet.h +++ b/include/vr_packet.h @@ -474,30 +474,30 @@ struct vr_ip6_pseudo { struct vr_ip6 { #ifdef __KERNEL__ #if defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t ip6_priority_l:4, - ip6_version:4; uint8_t ip6_priority_h:4, - ip6_flow_l:4; + ip6_version:4; + uint8_t ip6_flow_h:4, + ip6_priority_l:4; #elif defined(__BIG_ENDIAN_BITFIELD) uint8_t ip6_version:4, - ip6_priority_l:4; - uint8_t ip6_flow_l:4, - ip6_prioirty_h:4; + ip6_priority_h:4; + uint8_t ip6_priority_l:4, + ip6_flow_h:4; #endif #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) - uint8_t ip6_priority_l:4, - ip6_version:4; uint8_t ip6_priority_h:4, - ip6_flow_l:4; + ip6_version:4; + uint8_t ip6_flow_h:4, + ip6_priority_l:4; #elif (__BYTE_ORDER == __BIG_ENDIAN) uint8_t ip6_version:4, - ip6_priority_l:4; - uint8_t ip6_flow_l:4, - ip6_prioirty_h:4; + ip6_priority_h:4; + uint8_t ip6_priority_l:4, + ip6_flow_h:4; #endif #endif - uint16_t ip6_flow_h; + uint16_t ip6_flow_l; uint16_t ip6_plen; uint8_t ip6_nxt; uint8_t ip6_hlim; @@ -511,14 +511,14 @@ struct vr_ip6 { static inline uint8_t vr_inet6_get_tos(struct vr_ip6 *ip6h) { - return (((ip6h->ip6_priority_h << 4) | (ip6h->ip6_priority_l)) & 0x3F); + return ((((ip6h->ip6_priority_h << 4) | (ip6h->ip6_priority_l)) >> 2) & 0x3F); } static inline void vr_inet6_set_tos(struct vr_ip6 *ip6h, uint8_t tos) { - ip6h->ip6_priority_h = (tos >> 4) & 0x3; - ip6h->ip6_priority_l = (tos & 0xF); + ip6h->ip6_priority_h = ((tos << 2) >> 4); + ip6h->ip6_priority_l = ((tos << 2) & 0xF); return; }