Print this page
Support route deletion entries in SVP_R_LOG_ACK.

@@ -152,11 +152,11 @@
 {
         svp_sdlog_t *sdl = arg;
         svp_remote_t *srp = sdl->sdl_remote;
         svp_lrm_req_t *svrr = sdl->sdl_logrm;
 
-        if (type != SVP_LOG_VL2 && type != SVP_LOG_VL3)
+        if (type != SVP_LOG_VL2 && type != SVP_LOG_VL3 && type != SVP_LOG_ROUTE)
                 libvarpd_panic("encountered unknown type: %d\n", type);
 
         if (type == SVP_LOG_VL2) {
                 svp_log_vl2_t *svl2 = data;
                 svp_remote_shootdown_vl2(srp, svl2);

@@ -163,16 +163,25 @@
                 mutex_enter(&sdl->sdl_lock);
                 bcopy(svl2->svl2_id, &svrr->svrr_ids[svrr->svrr_count * 16],
                     UUID_LEN);
                 svrr->svrr_count++;
                 mutex_exit(&sdl->sdl_lock);
-        } else {
+        } else if (type == SVP_LOG_VL3) {
                 svp_log_vl3_t *svl3 = data;
 
                 /* Take a hold for the duration of this request */
                 svp_shootdown_ref(sdl);
                 svp_remote_shootdown_vl3(srp, svl3, sdl);
+        } else {
+                svp_log_route_t *svlr = data;
+
+                svp_remote_shootdown_route(srp, svlr);
+                mutex_enter(&sdl->sdl_lock);
+                bcopy(svlr->svlr_id, &svrr->svrr_ids[svrr->svrr_count * 16],
+                    UUID_LEN);
+                svrr->svrr_count++;
+                mutex_exit(&sdl->sdl_lock);
         }
 
         return (0);
 }
 

@@ -185,11 +194,11 @@
 }
 
 
 static int
 svp_shootdown_logr_iter(svp_remote_t *srp, void *buf, size_t len,
-    int (*cb)(void *, svp_log_type_t, void *), void *arg)
+    int (*cb)(void *, svp_log_type_t, void *), void *arg, uint16_t version)
 {
         int ret;
         off_t cboff = 0;
         uint32_t *typep, type;
         svp_log_vl2_t *svl2;

@@ -200,10 +209,11 @@
         len -= sizeof (uint32_t);
         cboff += sizeof (uint32_t);
 
         while (len > 0) {
                 size_t opsz;
+                char *typestring;
 
                 if (len < sizeof (uint32_t)) {
                         (void) bunyan_warn(svp_bunyan,
                             "failed to get initial shootdown tag",
                             BUNYAN_T_STRING, "remote_host", srp->sr_hostname,

@@ -214,15 +224,24 @@
                         return (-1);
                 }
 
                 typep = buf + cboff;
                 type = ntohl(*typep);
-                if (type == SVP_LOG_VL2) {
+                switch (type) {
+                case SVP_LOG_VL2:
                         opsz = sizeof (svp_log_vl2_t);
-                        if (len < opsz) {
+                        typestring = "svp_log_vl2_t";
+                        break;
+                case SVP_LOG_VL3:
+                        opsz = sizeof (svp_log_vl3_t);
+                        typestring = "svp_log_vl3_t";
+                        break;
+                case SVP_LOG_ROUTE:
+                        if (version < SVP_VERSION_TWO) {
                                 (void) bunyan_warn(svp_bunyan,
-                                    "not enough data for svp_log_vl2_t",
+                                    "insufficient version for SVP_LOG_ROUTE",
+                                    BUNYAN_T_UINT32, "version", version,
                                     BUNYAN_T_STRING, "remote_host",
                                     srp->sr_hostname,
                                     BUNYAN_T_INT32, "remote_port",
                                     srp->sr_rport,
                                     BUNYAN_T_INT32, "response_size",

@@ -229,54 +248,49 @@
                                     cboff + len,
                                     BUNYAN_T_INT32, "response_offset", cboff,
                                     BUNYAN_T_END);
                                 return (-1);
                         }
-                        svl2 = (void *)typep;
-                        if ((ret = cb(svl2, type, arg)) != 0)
-                                return (ret);
-                } else if (type == SVP_LOG_VL3) {
-
-                        opsz = sizeof (svp_log_vl3_t);
-                        if (len < opsz) {
+                        opsz = sizeof (svp_log_route_t);
+                        typestring = "svp_log_route_t";
+                        break;
+                default:
                                 (void) bunyan_warn(svp_bunyan,
-                                    "not enough data for svp_log_vl3_t",
+                            "unknown log structure type",
                                     BUNYAN_T_STRING, "remote_host",
                                     srp->sr_hostname,
-                                    BUNYAN_T_INT32, "remote_port",
-                                    srp->sr_rport,
-                                    BUNYAN_T_INT32, "response_size",
-                                    cboff + len,
+                            BUNYAN_T_INT32, "remote_port", srp->sr_rport,
+                            BUNYAN_T_INT32, "response_size", cboff + len,
                                     BUNYAN_T_INT32, "response_offset", cboff,
+                            BUNYAN_T_INT32, "structure_type", type,
                                     BUNYAN_T_END);
                                 return (-1);
                         }
-                        svl3 = (void *)typep;
-                        if ((ret = cb(svl3, type, arg)) != 0)
-                                return (ret);
-                } else {
+                if (len < opsz) {
                         (void) bunyan_warn(svp_bunyan,
-                            "unknown log structure type",
-                            BUNYAN_T_STRING, "remote_host",
-                            srp->sr_hostname,
+                            "not enough data for",
+                            BUNYAN_T_STRING, "", typestring,
+                            BUNYAN_T_STRING, "remote_host", srp->sr_hostname,
                             BUNYAN_T_INT32, "remote_port", srp->sr_rport,
                             BUNYAN_T_INT32, "response_size", cboff + len,
                             BUNYAN_T_INT32, "response_offset", cboff,
-                            BUNYAN_T_INT32, "structure_type", type,
                             BUNYAN_T_END);
                         return (-1);
                 }
+                if ((ret = cb((void *)typep, type, arg)) != 0)
+                        return (ret);
+
                 len -= opsz;
                 cboff += opsz;
         }
 
         return (0);
 }
 
 void
 svp_shootdown_logr_cb(svp_remote_t *srp, svp_status_t status, void *cbdata,
-    size_t cbsize)
+    size_t cbsize, uint16_t version)
 {
         uint_t count;
         svp_sdlog_t *sdl = &srp->sr_shoot;
 
         if (status != SVP_S_OK) {

@@ -299,11 +313,11 @@
          * allows us to validate that all the data is valid, if this fails, then
          * we fail the request.
          */
         count = 0;
         if ((svp_shootdown_logr_iter(srp, cbdata, cbsize,
-            svp_shootdown_logr_count, &count)) != 0) {
+                svp_shootdown_logr_count, &count, version)) != 0) {
                 mutex_enter(&sdl->sdl_lock);
                 sdl->sdl_flags &= ~SVP_SD_RUNNING;
                 svp_shootdown_schedule(sdl, B_FALSE);
                 mutex_exit(&sdl->sdl_lock);
                 return;

@@ -335,11 +349,11 @@
          * number of entries that were entered into the log removal. At this
          * point success or failure don't really look different, all it changes
          * is how many entries we have to remove.
          */
         (void) svp_shootdown_logr_iter(srp, cbdata, cbsize,
-            svp_shootdown_logr_shoot, sdl);
+            svp_shootdown_logr_shoot, sdl, version);
 
         /*
          * Now that we're done with our work, release the hold. If we don't have
          * any vl3 tasks outstanding, this'll trigger the next phase of the log
          * removals.