Print this page
Support route deletion entries in SVP_R_LOG_ACK.

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/varpd/svp/common/libvarpd_svp_shootdown.c
          +++ new/usr/src/lib/varpd/svp/common/libvarpd_svp_shootdown.c
↓ open down ↓ 146 lines elided ↑ open up ↑
 147  147          svp_shootdown_rele(sdl);
 148  148  }
 149  149  
 150  150  static int
 151  151  svp_shootdown_logr_shoot(void *data, svp_log_type_t type, void *arg)
 152  152  {
 153  153          svp_sdlog_t *sdl = arg;
 154  154          svp_remote_t *srp = sdl->sdl_remote;
 155  155          svp_lrm_req_t *svrr = sdl->sdl_logrm;
 156  156  
 157      -        if (type != SVP_LOG_VL2 && type != SVP_LOG_VL3)
      157 +        if (type != SVP_LOG_VL2 && type != SVP_LOG_VL3 && type != SVP_LOG_ROUTE)
 158  158                  libvarpd_panic("encountered unknown type: %d\n", type);
 159  159  
 160  160          if (type == SVP_LOG_VL2) {
 161  161                  svp_log_vl2_t *svl2 = data;
 162  162                  svp_remote_shootdown_vl2(srp, svl2);
 163  163                  mutex_enter(&sdl->sdl_lock);
 164  164                  bcopy(svl2->svl2_id, &svrr->svrr_ids[svrr->svrr_count * 16],
 165  165                      UUID_LEN);
 166  166                  svrr->svrr_count++;
 167  167                  mutex_exit(&sdl->sdl_lock);
 168      -        } else {
      168 +        } else if (type == SVP_LOG_VL3) {
 169  169                  svp_log_vl3_t *svl3 = data;
 170  170  
 171  171                  /* Take a hold for the duration of this request */
 172  172                  svp_shootdown_ref(sdl);
 173  173                  svp_remote_shootdown_vl3(srp, svl3, sdl);
      174 +        } else {
      175 +                svp_log_route_t *svlr = data;
      176 +
      177 +                svp_remote_shootdown_route(srp, svlr);
      178 +                mutex_enter(&sdl->sdl_lock);
      179 +                bcopy(svlr->svlr_id, &svrr->svrr_ids[svrr->svrr_count * 16],
      180 +                    UUID_LEN);
      181 +                svrr->svrr_count++;
      182 +                mutex_exit(&sdl->sdl_lock);
 174  183          }
 175  184  
 176  185          return (0);
 177  186  }
 178  187  
 179  188  static int
 180  189  svp_shootdown_logr_count(void *data, svp_log_type_t type, void *arg)
 181  190  {
 182  191          uint_t *u = arg;
 183  192          *u = *u + 1;
 184  193          return (0);
 185  194  }
 186  195  
 187  196  
 188  197  static int
 189  198  svp_shootdown_logr_iter(svp_remote_t *srp, void *buf, size_t len,
 190      -    int (*cb)(void *, svp_log_type_t, void *), void *arg)
      199 +    int (*cb)(void *, svp_log_type_t, void *), void *arg, uint16_t version)
 191  200  {
 192  201          int ret;
 193  202          off_t cboff = 0;
 194  203          uint32_t *typep, type;
 195  204          svp_log_vl2_t *svl2;
 196  205          svp_log_vl3_t *svl3;
 197  206  
 198  207          /* Adjust for initial status word */
 199  208          assert(len >= sizeof (uint32_t));
 200  209          len -= sizeof (uint32_t);
 201  210          cboff += sizeof (uint32_t);
 202  211  
 203  212          while (len > 0) {
 204  213                  size_t opsz;
      214 +                char *typestring;
 205  215  
 206  216                  if (len < sizeof (uint32_t)) {
 207  217                          (void) bunyan_warn(svp_bunyan,
 208  218                              "failed to get initial shootdown tag",
 209  219                              BUNYAN_T_STRING, "remote_host", srp->sr_hostname,
 210  220                              BUNYAN_T_INT32, "remote_port", srp->sr_rport,
 211  221                              BUNYAN_T_INT32, "response_size", cboff + len,
 212  222                              BUNYAN_T_INT32, "response_offset", cboff,
 213  223                              BUNYAN_T_END);
 214  224                          return (-1);
 215  225                  }
 216  226  
 217  227                  typep = buf + cboff;
 218  228                  type = ntohl(*typep);
 219      -                if (type == SVP_LOG_VL2) {
      229 +                switch (type) {
      230 +                case SVP_LOG_VL2:
 220  231                          opsz = sizeof (svp_log_vl2_t);
 221      -                        if (len < opsz) {
 222      -                                (void) bunyan_warn(svp_bunyan,
 223      -                                    "not enough data for svp_log_vl2_t",
 224      -                                    BUNYAN_T_STRING, "remote_host",
 225      -                                    srp->sr_hostname,
 226      -                                    BUNYAN_T_INT32, "remote_port",
 227      -                                    srp->sr_rport,
 228      -                                    BUNYAN_T_INT32, "response_size",
 229      -                                    cboff + len,
 230      -                                    BUNYAN_T_INT32, "response_offset", cboff,
 231      -                                    BUNYAN_T_END);
 232      -                                return (-1);
 233      -                        }
 234      -                        svl2 = (void *)typep;
 235      -                        if ((ret = cb(svl2, type, arg)) != 0)
 236      -                                return (ret);
 237      -                } else if (type == SVP_LOG_VL3) {
 238      -
      232 +                        typestring = "svp_log_vl2_t";
      233 +                        break;
      234 +                case SVP_LOG_VL3:
 239  235                          opsz = sizeof (svp_log_vl3_t);
 240      -                        if (len < opsz) {
      236 +                        typestring = "svp_log_vl3_t";
      237 +                        break;
      238 +                case SVP_LOG_ROUTE:
      239 +                        if (version < SVP_VERSION_TWO) {
 241  240                                  (void) bunyan_warn(svp_bunyan,
 242      -                                    "not enough data for svp_log_vl3_t",
      241 +                                    "insufficient version for SVP_LOG_ROUTE",
      242 +                                    BUNYAN_T_UINT32, "version", version,
 243  243                                      BUNYAN_T_STRING, "remote_host",
 244  244                                      srp->sr_hostname,
 245  245                                      BUNYAN_T_INT32, "remote_port",
 246  246                                      srp->sr_rport,
 247  247                                      BUNYAN_T_INT32, "response_size",
 248  248                                      cboff + len,
 249  249                                      BUNYAN_T_INT32, "response_offset", cboff,
 250  250                                      BUNYAN_T_END);
 251  251                                  return (-1);
 252  252                          }
 253      -                        svl3 = (void *)typep;
 254      -                        if ((ret = cb(svl3, type, arg)) != 0)
 255      -                                return (ret);
 256      -                } else {
      253 +                        opsz = sizeof (svp_log_route_t);
      254 +                        typestring = "svp_log_route_t";
      255 +                        break;
      256 +                default:
 257  257                          (void) bunyan_warn(svp_bunyan,
 258  258                              "unknown log structure type",
 259  259                              BUNYAN_T_STRING, "remote_host",
 260  260                              srp->sr_hostname,
 261  261                              BUNYAN_T_INT32, "remote_port", srp->sr_rport,
 262  262                              BUNYAN_T_INT32, "response_size", cboff + len,
 263  263                              BUNYAN_T_INT32, "response_offset", cboff,
 264  264                              BUNYAN_T_INT32, "structure_type", type,
 265  265                              BUNYAN_T_END);
 266  266                          return (-1);
 267  267                  }
      268 +                if (len < opsz) {
      269 +                        (void) bunyan_warn(svp_bunyan,
      270 +                            "not enough data for",
      271 +                            BUNYAN_T_STRING, "", typestring,
      272 +                            BUNYAN_T_STRING, "remote_host", srp->sr_hostname,
      273 +                            BUNYAN_T_INT32, "remote_port", srp->sr_rport,
      274 +                            BUNYAN_T_INT32, "response_size", cboff + len,
      275 +                            BUNYAN_T_INT32, "response_offset", cboff,
      276 +                            BUNYAN_T_END);
      277 +                        return (-1);
      278 +                }
      279 +                if ((ret = cb((void *)typep, type, arg)) != 0)
      280 +                        return (ret);
      281 +
 268  282                  len -= opsz;
 269  283                  cboff += opsz;
 270  284          }
 271  285  
 272  286          return (0);
 273  287  }
 274  288  
 275  289  void
 276  290  svp_shootdown_logr_cb(svp_remote_t *srp, svp_status_t status, void *cbdata,
 277      -    size_t cbsize)
      291 +    size_t cbsize, uint16_t version)
 278  292  {
 279  293          uint_t count;
 280  294          svp_sdlog_t *sdl = &srp->sr_shoot;
 281  295  
 282  296          if (status != SVP_S_OK) {
 283  297                  (void) bunyan_warn(svp_bunyan,
 284  298                      "log request not OK",
 285  299                      BUNYAN_T_STRING, "remote_host", srp->sr_hostname,
 286  300                      BUNYAN_T_INT32, "remote_port", srp->sr_rport,
 287  301                      BUNYAN_T_INT32, "response_size", cbsize,
↓ open down ↓ 6 lines elided ↑ open up ↑
 294  308                  return;
 295  309          }
 296  310  
 297  311          /*
 298  312           * First go ahead and count the number of entries. This effectively
 299  313           * allows us to validate that all the data is valid, if this fails, then
 300  314           * we fail the request.
 301  315           */
 302  316          count = 0;
 303  317          if ((svp_shootdown_logr_iter(srp, cbdata, cbsize,
 304      -            svp_shootdown_logr_count, &count)) != 0) {
      318 +                svp_shootdown_logr_count, &count, version)) != 0) {
 305  319                  mutex_enter(&sdl->sdl_lock);
 306  320                  sdl->sdl_flags &= ~SVP_SD_RUNNING;
 307  321                  svp_shootdown_schedule(sdl, B_FALSE);
 308  322                  mutex_exit(&sdl->sdl_lock);
 309  323                  return;
 310  324          }
 311  325  
 312  326          /*
 313  327           * If we have no entries, then we're also done.
 314  328           */
↓ open down ↓ 15 lines elided ↑ open up ↑
 330  344          svp_shootdown_ref(sdl);
 331  345          bzero(sdl->sdl_logrm, svp_shootdown_buf);
 332  346  
 333  347          /*
 334  348           * If this fails, we're going to determine what to do next based on the
 335  349           * number of entries that were entered into the log removal. At this
 336  350           * point success or failure don't really look different, all it changes
 337  351           * is how many entries we have to remove.
 338  352           */
 339  353          (void) svp_shootdown_logr_iter(srp, cbdata, cbsize,
 340      -            svp_shootdown_logr_shoot, sdl);
      354 +            svp_shootdown_logr_shoot, sdl, version);
 341  355  
 342  356          /*
 343  357           * Now that we're done with our work, release the hold. If we don't have
 344  358           * any vl3 tasks outstanding, this'll trigger the next phase of the log
 345  359           * removals.
 346  360           */
 347  361          svp_shootdown_rele(sdl);
 348  362  }
 349  363  
 350  364  static void
↓ open down ↓ 124 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX