[PATCH] tools: Specify QoS cube for data transfer flows

  • From: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 19 Oct 2018 11:38:54 +0200

The ipcp connect command can now set a specific qos cube for data
transfer flows. For management flows, the tool ignores this and
defaults to raw until data flows are stable enough.

Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
 include/ouroboros/irm.h          |  4 +++-
 src/ipcpd/ipcp.c                 |  4 +++-
 src/ipcpd/ipcp.h                 |  3 ++-
 src/ipcpd/normal/connmgr.c       |  6 ++---
 src/ipcpd/normal/connmgr.h       |  3 ++-
 src/irmd/ipcp.c                  | 12 ++++++----
 src/irmd/ipcp.h                  |  3 ++-
 src/irmd/main.c                  |  8 ++++---
 src/lib/irm.c                    | 23 +++++++++++-------
 src/tools/irm/irm_ipcp_connect.c | 41 +++++++++++++++++++++++++-------
 src/tools/oping/oping.c          |  2 +-
 11 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h
index fe6d2e9..2ec2c0d 100644
--- a/include/ouroboros/irm.h
+++ b/include/ouroboros/irm.h
@@ -25,6 +25,7 @@
 
 #include <ouroboros/cdefs.h>
 #include <ouroboros/ipcp.h>
+#include <ouroboros/qos.h>
 
 #include <sys/types.h>
 
@@ -62,7 +63,8 @@ int     irm_bootstrap_ipcp(pid_t                      pid,
 
 int     irm_connect_ipcp(pid_t        pid,
                          const char * component,
-                         const char * dst);
+                         const char * dst,
+                         qosspec_t    qs);
 
 int     irm_disconnect_ipcp(pid_t        pid,
                             const char * component,
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index f8df564..a116c17 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -350,8 +350,10 @@ static void * mainloop(void * o)
                                 break;
                         }
 
+                        qs = msg_to_spec(msg->qosspec);
                         ret_msg.result = ipcpi.ops->ipcp_connect(msg->dst,
-                                                                 msg->comp);
+                                                                 msg->comp,
+                                                                 qs);
                         break;
                 case IPCP_MSG_CODE__IPCP_DISCONNECT:
                         ret_msg.has_result = true;
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 1d25fb3..fabd35f 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -46,7 +46,8 @@ struct ipcp_ops {
                               struct layer_info * info);
 
         int   (* ipcp_connect)(const char * dst,
-                               const char * component);
+                               const char * component,
+                               qosspec_t    qs);
 
         int   (* ipcp_disconnect)(const char * dst,
                                   const char * component);
diff --git a/src/ipcpd/normal/connmgr.c b/src/ipcpd/normal/connmgr.c
index 7b71761..5aee7b7 100644
--- a/src/ipcpd/normal/connmgr.c
+++ b/src/ipcpd/normal/connmgr.c
@@ -320,7 +320,8 @@ void connmgr_comp_fini(enum comp_id id)
 }
 
 int connmgr_ipcp_connect(const char * dst,
-                         const char * component)
+                         const char * component,
+                         qosspec_t    qs)
 {
         struct conn_el * ce;
         int              id;
@@ -341,8 +342,7 @@ int connmgr_ipcp_connect(const char * dst,
                 return -1;
         }
 
-        /* FIXME: get the correct qos for the component. */
-        if (connmgr_alloc(id, dst, NULL, &ce->conn)) {
+        if (connmgr_alloc(id, dst, &qs, &ce->conn)) {
                 free(ce);
                 return -1;
         }
diff --git a/src/ipcpd/normal/connmgr.h b/src/ipcpd/normal/connmgr.h
index a7e8a6e..f767e72 100644
--- a/src/ipcpd/normal/connmgr.h
+++ b/src/ipcpd/normal/connmgr.h
@@ -54,7 +54,8 @@ int         connmgr_comp_init(enum comp_id             id,
 void        connmgr_comp_fini(enum comp_id id);
 
 int         connmgr_ipcp_connect(const char * dst,
-                                 const char * component);
+                                 const char * component,
+                                 qosspec_t    qs);
 
 int         connmgr_ipcp_disconnect(const char * dst,
                                     const char * component);
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index 20aee79..19e68ee 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -286,17 +286,21 @@ int ipcp_enroll(pid_t               pid,
 
 int ipcp_connect(pid_t        pid,
                  const char * dst,
-                 const char * component)
+                 const char * component,
+                 qosspec_t    qs)
 {
-        ipcp_msg_t   msg      = IPCP_MSG__INIT;
-        ipcp_msg_t * recv_msg = NULL;
-        int          ret      = -1;
+        ipcp_msg_t    msg    = IPCP_MSG__INIT;
+        qosspec_msg_t qs_msg = QOSSPEC_MSG__INIT;
+        int           ret    = -1;
+        ipcp_msg_t *  recv_msg;
 
         msg.code    = IPCP_MSG_CODE__IPCP_CONNECT;
         msg.dst     = (char *) dst;
         msg.comp    = (char *) component;
         msg.has_pid = true;
         msg.pid     = pid;
+        qs_msg      = spec_to_msg(&qs);
+        msg.qosspec = &qs_msg;
 
         recv_msg = send_recv_ipcp_msg(pid, &msg);
         if (recv_msg == NULL)
diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h
index 8d9686c..07b9c44 100644
--- a/src/irmd/ipcp.h
+++ b/src/irmd/ipcp.h
@@ -43,7 +43,8 @@ int   ipcp_bootstrap(pid_t               pid,
 
 int   ipcp_connect(pid_t        pid,
                    const char * dst,
-                   const char * component);
+                   const char * component,
+                   qosspec_t    qs);
 
 int   ipcp_disconnect(pid_t        pid,
                       const char * dst,
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 6432c9f..2b4d3d0 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -604,7 +604,8 @@ static int enroll_ipcp(pid_t  pid,
 
 static int connect_ipcp(pid_t        pid,
                         const char * dst,
-                        const char * component)
+                        const char * component,
+                        qosspec_t    qs)
 {
         struct ipcp_entry * entry = NULL;
 
@@ -627,7 +628,7 @@ static int connect_ipcp(pid_t        pid,
 
         log_dbg("Connecting %s to %s.", component, dst);
 
-        if (ipcp_connect(pid, dst, component)) {
+        if (ipcp_connect(pid, dst, component, qs)) {
                 log_err("Could not connect IPCP.");
                 return -EPERM;
         }
@@ -1957,7 +1958,8 @@ static void * mainloop(void * o)
                         result = enroll_ipcp(msg->pid, msg->dst);
                         break;
                 case IRM_MSG_CODE__IRM_CONNECT_IPCP:
-                        result = connect_ipcp(msg->pid, msg->dst, msg->comp);
+                        result = connect_ipcp(msg->pid, msg->dst, msg->comp,
+                                              msg_to_spec(msg->qosspec));
                         break;
                 case IRM_MSG_CODE__IRM_DISCONNECT_IPCP:
                         result = disconnect_ipcp(msg->pid, msg->dst, 
msg->comp);
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 384da7b..bf10ae3 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -173,17 +173,22 @@ int irm_bootstrap_ipcp(pid_t                      pid,
 
 int irm_connect_ipcp(pid_t        pid,
                      const char * dst,
-                     const char * component)
+                     const char * component,
+                     qosspec_t    qs)
 {
-        irm_msg_t   msg      = IRM_MSG__INIT;
-        irm_msg_t * recv_msg = NULL;
-        int         ret;
+        irm_msg_t     msg    = IRM_MSG__INIT;
+        qosspec_msg_t qs_msg = QOSSPEC_MSG__INIT;
+        irm_msg_t *   recv_msg;
+        int           ret;
+
 
         msg.code      = IRM_MSG_CODE__IRM_CONNECT_IPCP;
         msg.dst       = (char *) dst;
         msg.comp      = (char *) component;
         msg.has_pid   = true;
         msg.pid       = pid;
+        qs_msg        = spec_to_msg(&qs);
+        msg.qosspec   = &qs_msg;
 
         recv_msg = send_recv_irm_msg(&msg);
         if (recv_msg == NULL)
@@ -204,8 +209,8 @@ int irm_disconnect_ipcp(pid_t        pid,
                         const char * dst,
                         const char * component)
 {
-        irm_msg_t   msg      = IRM_MSG__INIT;
-        irm_msg_t * recv_msg = NULL;
+        irm_msg_t   msg = IRM_MSG__INIT;
+        irm_msg_t * recv_msg;
         int         ret;
 
         msg.code    = IRM_MSG_CODE__IRM_DISCONNECT_IPCP;
@@ -231,10 +236,10 @@ int irm_disconnect_ipcp(pid_t        pid,
 
 ssize_t irm_list_ipcps(struct ipcp_info ** ipcps)
 {
-        irm_msg_t msg        = IRM_MSG__INIT;
+        irm_msg_t   msg = IRM_MSG__INIT;
         irm_msg_t * recv_msg;
-        size_t nr;
-        size_t i;
+        size_t      nr;
+        size_t      i;
 
         if (ipcps == NULL)
                 return -EINVAL;
diff --git a/src/tools/irm/irm_ipcp_connect.c b/src/tools/irm/irm_ipcp_connect.c
index 0b377dc..d931387 100644
--- a/src/tools/irm/irm_ipcp_connect.c
+++ b/src/tools/irm/irm_ipcp_connect.c
@@ -37,6 +37,7 @@
  */
 
 #include <ouroboros/irm.h>
+#include <ouroboros/qos.h>
 
 #include "irm_ops.h"
 #include "irm_utils.h"
@@ -53,21 +54,25 @@ static void usage(void)
         printf("Usage: irm ipcp connect\n"
                "                name      <ipcp name>\n"
                "                dst       <name of destination IPCP>\n"
-               "                [component [COMPONENT]]\n\n"
-               "where COMPONENT = {" DT " " MGMT "}\n");
+               "                [component [COMPONENT]]\n"
+               "                [qos       [QOS]\n\n"
+               "where COMPONENT = {" DT " " MGMT "}\n"
+               "      QOS       = {raw, best, voice, video, data}\n");
 }
 
 int do_connect_ipcp(int     argc,
                     char ** argv)
 {
-        char *             ipcp = NULL;
-        char *             dst  = NULL;
-        char *             comp = "*";
+        char *             ipcp      = NULL;
+        char *             dst       = NULL;
+        char *             comp      = "*";
         char *             component = NULL;
+        char *             qos       = NULL;
         struct ipcp_info * ipcps;
-        ssize_t            len  = 0;
-        pid_t              pid  = -1;
+        ssize_t            len       = 0;
+        pid_t              pid       = -1;
         ssize_t            i;
+        qosspec_t          qs        = qos_raw;
 
         while (argc > 0) {
                 if (matches(*argv, "name") == 0) {
@@ -76,6 +81,8 @@ int do_connect_ipcp(int     argc,
                         dst = *(argv + 1);
                 } else if (matches(*argv, "component") == 0) {
                         comp = *(argv + 1);
+                } else if (matches(*argv, "qos") == 0) {
+                        qos = *(argv + 1);
                 } else {
                         printf("\"%s\" is unknown, try \"irm "
                                "ipcp connect\".\n", *argv);
@@ -91,6 +98,21 @@ int do_connect_ipcp(int     argc,
                 return -1;
         }
 
+        if (qos != NULL) {
+                if (strcmp(qos, "best") == 0)
+                        qs = qos_best_effort;
+                else if (strcmp(qos, "raw") == 0)
+                        qs = qos_raw;
+                else if (strcmp(qos, "video") == 0)
+                        qs = qos_video;
+                else if (strcmp(qos, "voice") == 0)
+                        qs = qos_voice;
+                else if (strcmp(qos, "data") == 0)
+                        qs = qos_data;
+                else
+                        printf("Unknown QoS cube, defaulting to raw.\n");
+        }
+
         len = irm_list_ipcps(&ipcps);
         for (i = 0; i < len; i++)
                 if (strcmp(ipcps[i].name, ipcp) == 0)
@@ -103,13 +125,14 @@ int do_connect_ipcp(int     argc,
 
         if (wildcard_match(comp, MGMT) == 0) {
                 component = MGMT_COMP;
-                if (irm_connect_ipcp(pid, dst, component))
+                /* FIXME: move to qos_data when stable */
+                if (irm_connect_ipcp(pid, dst, component, qos_raw))
                         return -1;
         }
 
         if (wildcard_match(comp, DT) == 0) {
                 component = DT_COMP;
-                if (irm_connect_ipcp(pid, dst, component))
+                if (irm_connect_ipcp(pid, dst, component, qs))
                         return -1;
         }
 
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index c49688b..4911260 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -65,7 +65,7 @@
 #define ECHO_REQUEST 0
 #define ECHO_REPLY 1
 
-#define OPING_MAX_FLOWS 256
+#define OPING_MAX_FLOWS 4096
 
 struct c {
         char *    s_apn;
-- 
2.19.1


Other related posts:

  • » [PATCH] tools: Specify QoS cube for data transfer flows - Dimitri Staessens