]> 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 55f2393c563b01867f31ee01d3a474feb651ba14..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);
@@ -414,6 +411,9 @@ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id)
        /* We need router-id information. */
        zebra_message_send(zclient, ZEBRA_ROUTER_ID_ADD, vrf_id);
 
+       /* We need interface information. */
+       zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, vrf_id);
+
        /* Set unwanted redistribute route. */
        for (afi = AFI_IP; afi < AFI_MAX; afi++)
                vrf_bitmap_set(zclient->redist[afi][zclient->redist_default],
@@ -478,6 +478,8 @@ 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);
 
+       zebra_message_send(zclient, ZEBRA_INTERFACE_DELETE, vrf_id);
+
        /* Set unwanted redistribute route. */
        for (afi = AFI_IP; afi < AFI_MAX; afi++)
                vrf_bitmap_unset(zclient->redist[afi][zclient->redist_default],
@@ -629,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);
 }
@@ -2369,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;
 
@@ -2384,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;
@@ -2504,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",
-                          (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:
@@ -2698,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;
        }