Mask the upper bits of dscp instead of failing if the user
supplied a too big value
This commit is contained in:
+1
-7
@@ -89,14 +89,8 @@ int uc_set_ip_dscp(int fd, unsigned int dscp)
|
|||||||
int val;
|
int val;
|
||||||
|
|
||||||
//only 6 bits for dscp
|
//only 6 bits for dscp
|
||||||
if (dscp > 63) {
|
val = (dscp & 0x3f) << 2;
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
val = dscp << 2;
|
|
||||||
|
|
||||||
return setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val);
|
return setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user