]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: filter zebra messages (label manager)
authorF. Aragon <paco@voltanet.io>
Tue, 4 Sep 2018 12:37:00 +0000 (14:37 +0200)
committerF. Aragon <paco@voltanet.io>
Tue, 18 Sep 2018 15:39:20 +0000 (17:39 +0200)
This change makes the zebra acting as label manager proxy not to relay non-LM
messages to clients that a zebra acting in non-proxy mode may send to it. Also,
the existing code does not schedule a rcv in case of relay_response_back
returns -1. This patch re-schedules reads on the socket even in case such a
function returns -1 by calling thread_add_read().

Signed-off-by: F. Aragon <paco@voltanet.io>
zebra/label_manager.c

index d2aeb2ed28c1b1603ee8abfa17cd8610ebe9a212..2b0508099f78b42551f04b9047837cc18858ea8c 100644 (file)
@@ -88,7 +88,23 @@ static int relay_response_back(void)
                         strerror(errno));
                return -1;
        }
-       zlog_debug("Label Manager response received, %d bytes", size);
+
+       /* do not relay a msg that has nothing to do with LM */
+       switch (resp_cmd) {
+       case ZEBRA_LABEL_MANAGER_CONNECT:
+       case ZEBRA_LABEL_MANAGER_CONNECT_ASYNC: /* should not be seen */
+       case ZEBRA_GET_LABEL_CHUNK:
+       case ZEBRA_RELEASE_LABEL_CHUNK:
+               break;
+       default:
+               zlog_debug("Not relaying '%s' response (size %d) from LM",
+                          zserv_command_string(resp_cmd), size);
+               return -1;
+       }
+
+       zlog_debug("Received '%s' response (size %d) from LM",
+                  zserv_command_string(resp_cmd), size);
+
        if (size == 0)
                return -1;
 
@@ -139,6 +155,11 @@ static int lm_zclient_read(struct thread *t)
        /* read response and send it back */
        ret = relay_response_back();
 
+       /* on error, schedule another read */
+       if (ret == -1)
+               if (!zclient->t_read)
+                       thread_add_read(zclient->master, lm_zclient_read, NULL,
+                                       zclient->sock, &zclient->t_read);
        return ret;
 }