Here's an incremental.
---
lib/socket-util.c | 14 +++++++++++---
lib/socket-util.h | 2 +-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/socket-util.c b/lib/socket-util.c
index ca37a54..a9b3b1a 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -85,11 +85,15 @@ set_nonblocking(int fd)
static int
set_dscp(int fd, uint8_t dscp)
{
- assert(dscp <= 63);
+ if (dscp > 63) {
+ return EINVAL;
+ }
+
dscp = dscp << 2;
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) {
return errno;
}
+
return 0;
}
@@ -558,7 +562,9 @@ exit:
* If 'sinp' is non-null, then on success the target address is stored into
* '*sinp'.
*
- * 'dscp' becomes the DSCP bits in the IP headers for the new connection. */
+ * 'dscp' becomes the DSCP bits in the IP headers for the new connection. It
+ * should be in the range [0, 63] and will automatically be shifted to the
+ * appropriately place in the IP tos field. */
int
inet_open_active(int style, const char *target, uint16_t default_port,
struct sockaddr_in *sinp, int *fdp, uint8_t dscp)
@@ -681,7 +687,9 @@ exit:
* If 'sinp' is non-null, then on success the bound address is stored into
* '*sinp'.
*
- * 'dscp' becomes the DSCP bits in the IP headers for the new connection. */
+ * 'dscp' becomes the DSCP bits in the IP headers for the new connection. It
+ * should be in the range [0, 63] and will automatically be shifted to the
+ * appropriately place in the IP tos field. */
int
inet_open_passive(int style, const char *target, int default_port,
struct sockaddr_in *sinp, uint8_t dscp)
diff --git a/lib/socket-util.h b/lib/socket-util.h
index a2fa71b..8ea40d5 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -67,6 +67,6 @@ char *describe_fd(int fd);
/* Default value of dscp bits for connection between controller and manager.
* Value of IPTOS_PREC_INTERNETCONTROL = 0xc0 which is defined
* in <netinet/ip.h> is used. */
-#define DSCP_DEFAULT IPTOS_PREC_INTERNETCONTROL >> 2
+#define DSCP_DEFAULT (IPTOS_PREC_INTERNETCONTROL >> 2)
#endif /* socket-util.h */
--
1.7.9.6
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev