]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/zclient.c
Merge pull request #4330 from donaldsharp/robo_covo
[mirror_frr.git] / lib / zclient.c
index a01da776691df59af7965bb2893670b102e1fb5e..96a78efad6d5abe125493d77e3337dba8c610c5e 100644 (file)
@@ -49,13 +49,13 @@ enum event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT };
 /* Prototype for event manager. */
 static void zclient_event(enum event, struct zclient *);
 
+struct zclient_options zclient_options_default = {.receive_notify = false};
+
 struct sockaddr_storage zclient_addr;
 socklen_t zclient_addr_len;
 
 /* This file local debug flag. */
-int zclient_debug = 0;
-
-struct zclient_options zclient_options_default = {.receive_notify = false};
+static int zclient_debug;
 
 /* Allocate zclient structure. */
 struct zclient *zclient_new(struct thread_master *master,
@@ -212,10 +212,7 @@ int zclient_socket_connect(struct zclient *zclient)
                return -1;
 
        set_cloexec(sock);
-
-       frr_elevate_privs(zclient->privs) {
-               setsockopt_so_sendbuf(sock, 1048576);
-       }
+       setsockopt_so_sendbuf(sock, 1048576);
 
        /* Connect to zebra. */
        ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
@@ -481,7 +478,6 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)
        /* We need router-id information. */
        zebra_message_send(zclient, ZEBRA_ROUTER_ID_DELETE, vrf_id);
 
-       /* We need interface information. */
        zebra_message_send(zclient, ZEBRA_INTERFACE_DELETE, vrf_id);
 
        /* Set unwanted redistribute route. */
@@ -596,6 +592,8 @@ int zclient_start(struct zclient *zclient)
 
        zebra_hello_send(zclient);
 
+       zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, VRF_DEFAULT);
+
        /* Inform the successful connection. */
        if (zclient->zebra_connected)
                (*zclient->zebra_connected)(zclient);
@@ -633,7 +631,7 @@ void zclient_init(struct zclient *zclient, int redist_default,
        }
 
        if (zclient_debug)
-               zlog_debug("zclient_start is called");
+               zlog_debug("scheduling zclient connection");
 
        zclient_event(ZCLIENT_SCHEDULE, zclient);
 }
@@ -2373,9 +2371,7 @@ int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)
 /*
  * Receive PW status update from Zebra and send it to LDE process.
  */
-void zebra_read_pw_status_update(int command, struct zclient *zclient,
-                                zebra_size_t length, vrf_id_t vrf_id,
-                                struct zapi_pw_status *pw)
+void zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, struct zapi_pw_status *pw)
 {
        struct stream *s;
 
@@ -2388,8 +2384,7 @@ void zebra_read_pw_status_update(int command, struct zclient *zclient,
        pw->status = stream_getl(s);
 }
 
-static void zclient_capability_decode(int command, struct zclient *zclient,
-                                     zebra_size_t length, vrf_id_t vrf_id)
+static void zclient_capability_decode(ZAPI_CALLBACK_ARGS)
 {
        struct zclient_capabilities cap;
        struct stream *s = zclient->ibuf;
@@ -2508,8 +2503,9 @@ static int zclient_read(struct thread *thread)
        length -= ZEBRA_HEADER_SIZE;
 
        if (zclient_debug)
-               zlog_debug("zclient 0x%p command 0x%x VRF %u\n",
-                          (void *)zclient, command, vrf_id);
+               zlog_debug("zclient 0x%p command %s VRF %u",
+                          (void *)zclient, zserv_command_string(command),
+                          vrf_id);
 
        switch (command) {
        case ZEBRA_CAPABILITIES:
@@ -2578,14 +2574,14 @@ static int zclient_read(struct thread *thread)
                break;
        case ZEBRA_NEXTHOP_UPDATE:
                if (zclient_debug)
-                       zlog_debug("zclient rcvd nexthop update\n");
+                       zlog_debug("zclient rcvd nexthop update");
                if (zclient->nexthop_update)
                        (*zclient->nexthop_update)(command, zclient, length,
                                                   vrf_id);
                break;
        case ZEBRA_IMPORT_CHECK_UPDATE:
                if (zclient_debug)
-                       zlog_debug("zclient rcvd import check update\n");
+                       zlog_debug("zclient rcvd import check update");
                if (zclient->import_check_update)
                        (*zclient->import_check_update)(command, zclient,
                                                        length, vrf_id);
@@ -2612,7 +2608,7 @@ static int zclient_read(struct thread *thread)
                break;
        case ZEBRA_FEC_UPDATE:
                if (zclient_debug)
-                       zlog_debug("zclient rcvd fec update\n");
+                       zlog_debug("zclient rcvd fec update");
                if (zclient->fec_update)
                        (*zclient->fec_update)(command, zclient, length);
                break;
@@ -2702,6 +2698,17 @@ static int zclient_read(struct thread *thread)
                        (*zclient->iptable_notify_owner)(command,
                                                 zclient, length,
                                                 vrf_id);
+               break;
+       case ZEBRA_VXLAN_SG_ADD:
+               if (zclient->vxlan_sg_add)
+                       (*zclient->vxlan_sg_add)(command, zclient, length,
+                                                   vrf_id);
+               break;
+       case ZEBRA_VXLAN_SG_DEL:
+               if (zclient->vxlan_sg_del)
+                       (*zclient->vxlan_sg_del)(command, zclient, length,
+                                                   vrf_id);
+               break;
        default:
                break;
        }