Hello.
In article <[EMAIL PROTECTED]> (at Sat, 7 Jan 2006 10:05:52 -0800), "Kris
Katterjohn" <[EMAIL PROTECTED]> says:
> PACKET_AUTO_STATISTICS is the default and the kernel will zero the packet
> statistics when the PACKET_STATISTICS getsockopt() call is used.
> + case PACKET_AUTO_STATISTICS:
> + po->auto_reset_stats = 1;
> + return 0;
> +
> + case PACKET_MANUAL_STATISTICS:
> + po->auto_reset_stats = 0;
> + return 0;
> +
> + case PACKET_RESET_STATISTICS:
> + spin_lock_bh(&sk->sk_receive_queue.lock);
> + memset(&po->stats, 0, sizeof po->stats);
> + spin_unlock_bh(&sk->sk_receive_queue.lock);
> + return 0;
We can merge PACKET_AUTO_STATISTICS and PACKET_MANUAL_STATISTICS,
into one, e.g. PACKET_ACCUMULATED_STATISTICS, and we can reuse
PACKET_STATISTICS for resetting;
case PACKET_ACCUMULATED_STATISTICS:
{
int val;
if (len < sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, len))
return -EFAULT;
po->auto_reset_stats = val;
return 0;
}
case PACKET_STATISTICS:
spin_lock_bh(&sk->sk_receive_queue.lock);
memset(&po->stats, 0, sizeof po->stats);
spin_unlock_bh(&sk->sk_receive_queue.lock);
return 0;
And, please provide getsockopt side. Thanks.
--yoshfuji
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html