add notifications on multicast error and address change events which
can take place while traffic is running.

Signed-off-by: Or Gerlitz <[email protected]>

Index: librdmacm/examples/mckey.c
===================================================================
--- librdmacm.orig/examples/mckey.c
+++ librdmacm/examples/mckey.c
@@ -62,6 +62,7 @@ struct cmatest_node {

 struct cmatest {
        struct rdma_event_channel *channel;
+       pthread_t               cmathread;
        struct cmatest_node     *nodes;
        int                     conn_index;
        int                     connects_left;
@@ -319,6 +320,30 @@ static int cma_handler(struct rdma_cm_id
        return ret;
 }

+static void *cma_thread(void *arg)
+{
+       struct rdma_cm_event *event;
+       int ret;
+
+       while (1) {
+               ret = rdma_get_cm_event(test.channel, &event);
+               if (ret) {
+                       perror("rdma_get_cm_event");
+                       exit(ret);
+               }
+               switch (event->event) {
+               case RDMA_CM_EVENT_MULTICAST_ERROR:
+               case RDMA_CM_EVENT_ADDR_CHANGE:
+                       printf("mckey: event: %s, status: %d\n",
+                              rdma_event_str(event->event), event->status);
+                       break;
+               default:
+                       break;
+               }
+               rdma_ack_cm_event(event);
+       }
+}
+
 static void destroy_node(struct cmatest_node *node)
 {
        if (!node->cma_id)
@@ -475,6 +500,7 @@ static int run(void)
        if (ret)
                goto out;

+       pthread_create(&test.cmathread, NULL, cma_thread, NULL);
        /*
         * Pause to give SM chance to configure switches.  We don't want to
         * handle reliability issue in this simple test program.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to