When net_prio cgroups are in use, let the priority be controlled by that
mechanism, since it can handle changes dynamically, as opposed to the
current method used with DCB. Continue to use the current DCB method
when net_prio cgroups are not present.

Signed-off-by: Mark Rustad <mark.d.rus...@intel.com>
---
 usr/dcb_app.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/usr/dcb_app.c b/usr/dcb_app.c
index c31e2b8..0c509cc 100644
--- a/usr/dcb_app.c
+++ b/usr/dcb_app.c
@@ -1,7 +1,7 @@
 
/*******************************************************************************
 
   DCB application support
-  Copyright(c) 2007-2011 Intel Corporation.
+  Copyright(c) 2007-2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -25,6 +25,8 @@
 
*******************************************************************************/
 
 #include <unistd.h>
+#include <stdbool.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -57,6 +59,9 @@
 /* Maximum size of response requested or message sent */
 #define MAX_MSG_SIZE    1024
 
+#define CGROUPS_PATH   "/proc/cgroups"
+#define NET_PRIO_CG    "net_prio"
+
 static struct nlmsghdr *start_dcbmsg(__u16 msg_type, __u8 arg)
 {
        struct nlmsghdr *nlh;
@@ -337,6 +342,32 @@ static int get_link_ifname(const char *ifname, char 
*link_ifname)
        return 0;
 }
 
+static bool net_prio_cgroup(void)
+{
+       FILE    *cgs;
+       char    line[80];
+       static bool inited;
+       static bool result;
+
+       if (inited)
+               return result;
+       cgs = fopen(CGROUPS_PATH, "r");
+       if (!cgs)
+               return false;
+
+       result = false;
+       while (fgets(line, sizeof(line), cgs)) {
+               if (strncmp(NET_PRIO_CG "\t", line, sizeof(NET_PRIO_CG)))
+                       continue;
+               result = true;
+               break;
+       }
+
+       inited = true;
+       fclose(cgs);
+       return result;
+}
+
 static int get_app_pri(const char *iface, __u8 req_idtype, __u16 req_id,
                       __u8 ieee_mask)
 {
@@ -345,6 +376,9 @@ static int get_app_pri(const char *iface, __u8 req_idtype, 
__u16 req_id,
        int nl_sd;
        char ifname[IFNAMSIZ];
 
+       if (net_prio_cgroup())
+               return 0;
+
        if (get_link_ifname(iface, ifname))
                return 0;
 

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to