Print this page
4851 IPsec should use NANOSEC & friends from time.h


1056  */
1057 void
1058 ipsec_rl_strlog(netstack_t *ns, short mid, short sid, char level, ushort_t sl,
1059     char *fmt, ...)
1060 {
1061         va_list adx;
1062         hrtime_t current = gethrtime();
1063         ip_stack_t      *ipst = ns->netstack_ip;
1064         ipsec_stack_t   *ipss = ns->netstack_ipsec;
1065 
1066         sl |= SL_CONSOLE;
1067         /*
1068          * Throttle logging to stop syslog from being swamped. If variable
1069          * 'ipsec_policy_log_interval' is zero, don't log any messages at
1070          * all, otherwise log only one message every 'ipsec_policy_log_interval'
1071          * msec. Convert interval (in msec) to hrtime (in nsec).
1072          */
1073 
1074         if (ipst->ips_ipsec_policy_log_interval) {
1075                 if (ipss->ipsec_policy_failure_last +
1076                     ((hrtime_t)ipst->ips_ipsec_policy_log_interval *
1077                     (hrtime_t)1000000) <= current) {
1078                         va_start(adx, fmt);
1079                         (void) vstrlog(mid, sid, level, sl, fmt, adx);
1080                         va_end(adx);
1081                         ipss->ipsec_policy_failure_last = current;
1082                 }
1083         }
1084 }
1085 
1086 void
1087 ipsec_config_flush(netstack_t *ns)
1088 {
1089         ipsec_stack_t   *ipss = ns->netstack_ipsec;
1090 
1091         rw_enter(&ipss->ipsec_system_policy.iph_lock, RW_WRITER);
1092         ipsec_polhead_flush(&ipss->ipsec_system_policy, ns);
1093         ipss->ipsec_next_policy_index = 1;
1094         rw_exit(&ipss->ipsec_system_policy.iph_lock);
1095         ipsec_action_reclaim_stack(ipss);
1096 }
1097 




1056  */
1057 void
1058 ipsec_rl_strlog(netstack_t *ns, short mid, short sid, char level, ushort_t sl,
1059     char *fmt, ...)
1060 {
1061         va_list adx;
1062         hrtime_t current = gethrtime();
1063         ip_stack_t      *ipst = ns->netstack_ip;
1064         ipsec_stack_t   *ipss = ns->netstack_ipsec;
1065 
1066         sl |= SL_CONSOLE;
1067         /*
1068          * Throttle logging to stop syslog from being swamped. If variable
1069          * 'ipsec_policy_log_interval' is zero, don't log any messages at
1070          * all, otherwise log only one message every 'ipsec_policy_log_interval'
1071          * msec. Convert interval (in msec) to hrtime (in nsec).
1072          */
1073 
1074         if (ipst->ips_ipsec_policy_log_interval) {
1075                 if (ipss->ipsec_policy_failure_last +
1076                     MSEC2NSEC(ipst->ips_ipsec_policy_log_interval) <= current) {

1077                         va_start(adx, fmt);
1078                         (void) vstrlog(mid, sid, level, sl, fmt, adx);
1079                         va_end(adx);
1080                         ipss->ipsec_policy_failure_last = current;
1081                 }
1082         }
1083 }
1084 
1085 void
1086 ipsec_config_flush(netstack_t *ns)
1087 {
1088         ipsec_stack_t   *ipss = ns->netstack_ipsec;
1089 
1090         rw_enter(&ipss->ipsec_system_policy.iph_lock, RW_WRITER);
1091         ipsec_polhead_flush(&ipss->ipsec_system_policy, ns);
1092         ipss->ipsec_next_policy_index = 1;
1093         rw_exit(&ipss->ipsec_system_policy.iph_lock);
1094         ipsec_action_reclaim_stack(ipss);
1095 }
1096