I'm working through a handful of unit test failures in the FreeBSD port
and the first issue I've come across is set_dscp failing - as it turns
out FreeBSD requires an int value for the setsockopt() call, not a char.

Looking at the Linux ip(7) man page I see the statement "TOS is a byte,"
but all of the Linux code examples I've found in a quick Google search
pass an int.

I made the change below to fix the issue on FreeBSD but would like some
advice on whether it's suitable on Linux (or if I need some separate
#ifdef'd code).

diff --git a/lib/socket-util.c b/lib/socket-util.c
index 2c5e6cc..e3cd52d 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -94,12 +94,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;
     }

-Ed
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to