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


 396         ipgpc_packet_t pkt;
 397         uint_t ill_idx;
 398 
 399         /* extract packet data */
 400         mp = ipp_packet_get_data(packet);
 401         ASSERT(mp != NULL);
 402 
 403         priv = (ip_priv_t *)ipp_packet_get_private(packet);
 404         ASSERT(priv != NULL);
 405 
 406         callout_pos = priv->proc;
 407         ill_idx = priv->ill_index;
 408 
 409         /* If we don't get an M_DATA, then return an error */
 410         if (mp->b_datap->db_type != M_DATA) {
 411                 if ((mp->b_cont != NULL) &&
 412                     (mp->b_cont->b_datap->db_type == M_DATA)) {
 413                         mp = mp->b_cont; /* jump over the M_CTL into M_DATA */
 414                 } else {
 415                         ipgpc0dbg(("ipgpc_invoke_action: no data\n"));
 416                         atomic_add_64(&ipgpc_epackets, 1);
 417                         return (EINVAL);
 418                 }
 419         }
 420 
 421         /*
 422          * Translate the callout_pos into the direction the packet is traveling
 423          */
 424         if (callout_pos != IPP_LOCAL_IN) {
 425                 if (callout_pos & IPP_LOCAL_OUT) {
 426                         callout_pos = IPP_LOCAL_OUT;
 427                 } else if (callout_pos & IPP_FWD_IN) {
 428                         callout_pos = IPP_FWD_IN;
 429                 } else {        /* IPP_FWD_OUT */
 430                         callout_pos = IPP_FWD_OUT;
 431                 }
 432         }
 433 
 434         /* parse the packet from the message block */
 435         ipha = (ipha_t *)mp->b_rptr;
 436         /* Determine IP Header Version */


 468 
 469         if (ipgpc_debug > 5) {
 470                 /* print pkt under high debug level */
 471 #ifdef  IPGPC_DEBUG
 472                 print_packet(af, &pkt);
 473 #endif
 474         }
 475         if (ipgpc_debug > 3) {
 476                 start = gethrtime(); /* start timer */
 477         }
 478 
 479         /* classify this packet */
 480         out_class = ipgpc_classify(af, &pkt);
 481 
 482         if (ipgpc_debug > 3) {
 483                 end = gethrtime(); /* stop timer */
 484         }
 485 
 486         /* ipgpc_classify will only return NULL if a memory error occured */
 487         if (out_class == NULL) {
 488                 atomic_add_64(&ipgpc_epackets, 1);
 489                 return (ENOMEM);
 490         }
 491 
 492         ipgpc1dbg(("ipgpc_invoke_action: class = %s", out_class->class_name));
 493         /* print time to classify(..) */
 494         ipgpc2dbg(("ipgpc_invoke_action: time = %lld nsec\n", (end - start)));
 495 
 496         if ((rc = ipp_packet_add_class(packet, out_class->class_name,
 497             out_class->next_action)) != 0) {
 498                 atomic_add_64(&ipgpc_epackets, 1);
 499                 ipgpc0dbg(("ipgpc_invoke_action: ipp_packet_add_class " \
 500                     "failed with error %d", rc));
 501                 return (rc);
 502         }
 503         return (ipp_packet_next(packet, IPP_ACTION_CONT));
 504 }


 396         ipgpc_packet_t pkt;
 397         uint_t ill_idx;
 398 
 399         /* extract packet data */
 400         mp = ipp_packet_get_data(packet);
 401         ASSERT(mp != NULL);
 402 
 403         priv = (ip_priv_t *)ipp_packet_get_private(packet);
 404         ASSERT(priv != NULL);
 405 
 406         callout_pos = priv->proc;
 407         ill_idx = priv->ill_index;
 408 
 409         /* If we don't get an M_DATA, then return an error */
 410         if (mp->b_datap->db_type != M_DATA) {
 411                 if ((mp->b_cont != NULL) &&
 412                     (mp->b_cont->b_datap->db_type == M_DATA)) {
 413                         mp = mp->b_cont; /* jump over the M_CTL into M_DATA */
 414                 } else {
 415                         ipgpc0dbg(("ipgpc_invoke_action: no data\n"));
 416                         atomic_inc_64(&ipgpc_epackets);
 417                         return (EINVAL);
 418                 }
 419         }
 420 
 421         /*
 422          * Translate the callout_pos into the direction the packet is traveling
 423          */
 424         if (callout_pos != IPP_LOCAL_IN) {
 425                 if (callout_pos & IPP_LOCAL_OUT) {
 426                         callout_pos = IPP_LOCAL_OUT;
 427                 } else if (callout_pos & IPP_FWD_IN) {
 428                         callout_pos = IPP_FWD_IN;
 429                 } else {        /* IPP_FWD_OUT */
 430                         callout_pos = IPP_FWD_OUT;
 431                 }
 432         }
 433 
 434         /* parse the packet from the message block */
 435         ipha = (ipha_t *)mp->b_rptr;
 436         /* Determine IP Header Version */


 468 
 469         if (ipgpc_debug > 5) {
 470                 /* print pkt under high debug level */
 471 #ifdef  IPGPC_DEBUG
 472                 print_packet(af, &pkt);
 473 #endif
 474         }
 475         if (ipgpc_debug > 3) {
 476                 start = gethrtime(); /* start timer */
 477         }
 478 
 479         /* classify this packet */
 480         out_class = ipgpc_classify(af, &pkt);
 481 
 482         if (ipgpc_debug > 3) {
 483                 end = gethrtime(); /* stop timer */
 484         }
 485 
 486         /* ipgpc_classify will only return NULL if a memory error occured */
 487         if (out_class == NULL) {
 488                 atomic_inc_64(&ipgpc_epackets);
 489                 return (ENOMEM);
 490         }
 491 
 492         ipgpc1dbg(("ipgpc_invoke_action: class = %s", out_class->class_name));
 493         /* print time to classify(..) */
 494         ipgpc2dbg(("ipgpc_invoke_action: time = %lld nsec\n", (end - start)));
 495 
 496         if ((rc = ipp_packet_add_class(packet, out_class->class_name,
 497             out_class->next_action)) != 0) {
 498                 atomic_inc_64(&ipgpc_epackets);
 499                 ipgpc0dbg(("ipgpc_invoke_action: ipp_packet_add_class " \
 500                     "failed with error %d", rc));
 501                 return (rc);
 502         }
 503         return (ipp_packet_next(packet, IPP_ACTION_CONT));
 504 }