Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/ipsec_impl.h
          +++ new/usr/src/uts/common/inet/ipsec_impl.h
↓ open down ↓ 290 lines elided ↑ open up ↑
 291  291                  ipa_allow_clear:1,              /* rule allows cleartext? */
 292  292                  ipa_want_ah:1,                  /* an action wants ah */
 293  293                  ipa_want_esp:1,                 /* an action wants esp */
 294  294                  ipa_want_se:1,                  /* an action wants se */
 295  295                  ipa_want_unique:1,              /* want unique sa's */
 296  296                  ipa_pad:19;
 297  297          uint32_t                ipa_ovhd;       /* per-packet encap ovhd */
 298  298  } ipsec_action_t;
 299  299  
 300  300  #define IPACT_REFHOLD(ipa) {                    \
 301      -        atomic_add_32(&(ipa)->ipa_refs, 1);     \
      301 +        atomic_inc_32(&(ipa)->ipa_refs);        \
 302  302          ASSERT((ipa)->ipa_refs != 0);   \
 303  303  }
 304  304  #define IPACT_REFRELE(ipa) {                                    \
 305  305          ASSERT((ipa)->ipa_refs != 0);                           \
 306  306          membar_exit();                                          \
 307      -        if (atomic_add_32_nv(&(ipa)->ipa_refs, -1) == 0)        \
      307 +        if (atomic_dec_32_nv(&(ipa)->ipa_refs) == 0)    \
 308  308                  ipsec_action_free(ipa);                         \
 309  309          (ipa) = 0;                                              \
 310  310  }
 311  311  
 312  312  /*
 313  313   * For now, use a trivially sized hash table for actions.
 314  314   * In the future we can add the structure canonicalization necessary
 315  315   * to get the hash function to behave correctly..
 316  316   */
 317  317  #define IPSEC_ACTION_HASH_SIZE 1
↓ open down ↓ 89 lines elided ↑ open up ↑
 407  407          avl_node_t              ipsp_byid;
 408  408          uint64_t                ipsp_index;     /* unique id */
 409  409          uint32_t                ipsp_prio;      /* rule priority */
 410  410          uint32_t                ipsp_refs;
 411  411          ipsec_sel_t             *ipsp_sel;      /* selector set (shared) */
 412  412          ipsec_action_t          *ipsp_act;      /* action (may be shared) */
 413  413          netstack_t              *ipsp_netstack; /* No netstack_hold */
 414  414  };
 415  415  
 416  416  #define IPPOL_REFHOLD(ipp) {                    \
 417      -        atomic_add_32(&(ipp)->ipsp_refs, 1);    \
      417 +        atomic_inc_32(&(ipp)->ipsp_refs);       \
 418  418          ASSERT((ipp)->ipsp_refs != 0);          \
 419  419  }
 420  420  #define IPPOL_REFRELE(ipp) {                                    \
 421  421          ASSERT((ipp)->ipsp_refs != 0);                          \
 422  422          membar_exit();                                          \
 423      -        if (atomic_add_32_nv(&(ipp)->ipsp_refs, -1) == 0)       \
      423 +        if (atomic_dec_32_nv(&(ipp)->ipsp_refs) == 0)   \
 424  424                  ipsec_policy_free(ipp);                         \
 425  425          (ipp) = 0;                                              \
 426  426  }
 427  427  
 428  428  #define IPPOL_UNCHAIN(php, ip)                                  \
 429  429          HASHLIST_UNCHAIN((ip), ipsp_hash);                      \
 430  430          avl_remove(&(php)->iph_rulebyid, (ip));                 \
 431  431          IPPOL_REFRELE(ip);
 432  432  
 433  433  /*
↓ open down ↓ 20 lines elided ↑ open up ↑
 454  454  typedef struct ipsec_policy_head_s
 455  455  {
 456  456          uint32_t        iph_refs;
 457  457          krwlock_t       iph_lock;
 458  458          uint64_t        iph_gen; /* generation number */
 459  459          ipsec_policy_root_t iph_root[IPSEC_NTYPES];
 460  460          avl_tree_t      iph_rulebyid;
 461  461  } ipsec_policy_head_t;
 462  462  
 463  463  #define IPPH_REFHOLD(iph) {                     \
 464      -        atomic_add_32(&(iph)->iph_refs, 1);     \
      464 +        atomic_inc_32(&(iph)->iph_refs);        \
 465  465          ASSERT((iph)->iph_refs != 0);           \
 466  466  }
 467  467  #define IPPH_REFRELE(iph, ns) {                                 \
 468  468          ASSERT((iph)->iph_refs != 0);                           \
 469  469          membar_exit();                                          \
 470      -        if (atomic_add_32_nv(&(iph)->iph_refs, -1) == 0)        \
      470 +        if (atomic_dec_32_nv(&(iph)->iph_refs) == 0)    \
 471  471                  ipsec_polhead_free(iph, ns);                    \
 472  472          (iph) = 0;                                              \
 473  473  }
 474  474  
 475  475  /*
 476  476   * IPsec fragment related structures
 477  477   */
 478  478  
 479  479  typedef struct ipsec_fragcache_entry {
 480  480          struct ipsec_fragcache_entry *itpfe_next;       /* hash list chain */
↓ open down ↓ 60 lines elided ↑ open up ↑
 541  541          (((itp)->itp_policy == (iph)) ? ITPF_P_ACTIVE : ITPF_I_ACTIVE))
 542  542  
 543  543  #define ITP_P_ISTUNNEL(itp, iph) ((itp)->itp_flags & \
 544  544          (((itp)->itp_policy == (iph)) ? ITPF_P_TUNNEL : ITPF_I_TUNNEL))
 545  545  
 546  546  #define ITP_P_ISPERPORT(itp, iph) ((itp)->itp_flags & \
 547  547          (((itp)->itp_policy == (iph)) ? ITPF_P_PER_PORT_SECURITY : \
 548  548          ITPF_I_PER_PORT_SECURITY))
 549  549  
 550  550  #define ITP_REFHOLD(itp) { \
 551      -        atomic_add_32(&((itp)->itp_refcnt), 1); \
      551 +        atomic_inc_32(&((itp)->itp_refcnt));    \
 552  552          ASSERT((itp)->itp_refcnt != 0); \
 553  553  }
 554  554  
 555  555  #define ITP_REFRELE(itp, ns) { \
 556  556          ASSERT((itp)->itp_refcnt != 0); \
 557  557          membar_exit(); \
 558      -        if (atomic_add_32_nv(&((itp)->itp_refcnt), -1) == 0) \
      558 +        if (atomic_dec_32_nv(&((itp)->itp_refcnt)) == 0) \
 559  559                  itp_free(itp, ns); \
 560  560  }
 561  561  
 562  562  /*
 563  563   * Certificate identity.
 564  564   */
 565  565  
 566  566  typedef struct ipsid_s
 567  567  {
 568  568          struct ipsid_s *ipsid_next;
↓ open down ↓ 1 lines elided ↑ open up ↑
 570  570          uint32_t        ipsid_refcnt;
 571  571          int             ipsid_type;     /* id type */
 572  572          char            *ipsid_cid;     /* certificate id string */
 573  573  } ipsid_t;
 574  574  
 575  575  /*
 576  576   * ipsid_t reference hold/release macros, just like ipsa versions.
 577  577   */
 578  578  
 579  579  #define IPSID_REFHOLD(ipsid) {                  \
 580      -        atomic_add_32(&(ipsid)->ipsid_refcnt, 1);       \
      580 +        atomic_inc_32(&(ipsid)->ipsid_refcnt);  \
 581  581          ASSERT((ipsid)->ipsid_refcnt != 0);     \
 582  582  }
 583  583  
 584  584  /*
 585  585   * Decrement the reference count on the ID.  Someone else will clean up
 586  586   * after us later.
 587  587   */
 588  588  
 589  589  #define IPSID_REFRELE(ipsid) {                                  \
 590  590          membar_exit();                                          \
 591      -        atomic_add_32(&(ipsid)->ipsid_refcnt, -1);              \
      591 +        atomic_dec_32(&(ipsid)->ipsid_refcnt);          \
 592  592  }
 593  593  
 594  594  /*
 595  595   * Following are the estimates of what the maximum AH and ESP header size
 596  596   * would be. This is used to tell the upper layer the right value of MSS
 597  597   * it should use without consulting AH/ESP. If the size is something
 598  598   * different from this, ULP will learn the right one through
 599  599   * ICMP_FRAGMENTATION_NEEDED messages generated locally.
 600  600   *
 601  601   * AH : 12 bytes of constant header + 32 bytes of ICV checksum (SHA-512).
↓ open down ↓ 431 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX