X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsocket-util.c;h=7c40ab8330d6d298a59a8308986d4cf4e0baaf70;hb=beffe87554210fb43be20eb23251c87e5eb4b529;hp=2c5e6ccbe539759e4a0d1797844269dc03b47d25;hpb=293d49bdd6e8cedc3fade25af3eccb122c4cd3e1;p=openvswitch diff --git a/lib/socket-util.c b/lib/socket-util.c index 2c5e6ccb..7c40ab83 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include "dynamic-string.h" @@ -94,12 +95,14 @@ xset_nonblocking(int fd) static int set_dscp(int fd, uint8_t dscp) { + int val; + if (dscp > 63) { return EINVAL; } - dscp = dscp << 2; - if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) { + val = dscp << 2; + if (setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val)) { return errno; }