Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14878f75 authored by David L Stevens's avatar David L Stevens Committed by David S. Miller
Browse files

[IPV6]: Add ICMPMsgStats MIB (RFC 4293) [rev 2]



Background: RFC 4293 deprecates existing individual, named ICMP
type counters to be replaced with the ICMPMsgStatsTable. This table
includes entries for both IPv4 and IPv6, and requires counting of all
ICMP types, whether or not the machine implements the type.

These patches "remove" (but not really) the existing counters, and
replace them with the ICMPMsgStats tables for v4 and v6.
It includes the named counters in the /proc places they were, but gets the
values for them from the new tables. It also counts packets generated
from raw socket output (e.g., OutEchoes, MLD queries, RA's from
radvd, etc).

Changes:
1) create icmpmsg_statistics mib
2) create icmpv6msg_statistics mib
3) modify existing counters to use these
4) modify /proc/net/snmp to add "IcmpMsg" with all ICMP types
        listed by number for easy SNMP parsing
5) modify /proc/net/snmp printing for "Icmp" to get the named data
        from new counters.
[new to 2nd revision]
6) support per-interface ICMP stats
7) use common macro for per-device stat macros

Signed-off-by: default avatarDavid L Stevens <dlstevens@us.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8b14a536
Loading
Loading
Loading
Loading
+2 −25
Original line number Diff line number Diff line
@@ -91,35 +91,12 @@ enum
	ICMP6_MIB_NUM = 0,
	ICMP6_MIB_INMSGS,			/* InMsgs */
	ICMP6_MIB_INERRORS,			/* InErrors */
	ICMP6_MIB_INDESTUNREACHS,		/* InDestUnreachs */
	ICMP6_MIB_INPKTTOOBIGS,			/* InPktTooBigs */
	ICMP6_MIB_INTIMEEXCDS,			/* InTimeExcds */
	ICMP6_MIB_INPARMPROBLEMS,		/* InParmProblems */
	ICMP6_MIB_INECHOS,			/* InEchos */
	ICMP6_MIB_INECHOREPLIES,		/* InEchoReplies */
	ICMP6_MIB_INGROUPMEMBQUERIES,		/* InGroupMembQueries */
	ICMP6_MIB_INGROUPMEMBRESPONSES,		/* InGroupMembResponses */
	ICMP6_MIB_INGROUPMEMBREDUCTIONS,	/* InGroupMembReductions */
	ICMP6_MIB_INROUTERSOLICITS,		/* InRouterSolicits */
	ICMP6_MIB_INROUTERADVERTISEMENTS,	/* InRouterAdvertisements */
	ICMP6_MIB_INNEIGHBORSOLICITS,		/* InNeighborSolicits */
	ICMP6_MIB_INNEIGHBORADVERTISEMENTS,	/* InNeighborAdvertisements */
	ICMP6_MIB_INREDIRECTS,			/* InRedirects */
	ICMP6_MIB_OUTMSGS,			/* OutMsgs */
	ICMP6_MIB_OUTDESTUNREACHS,		/* OutDestUnreachs */
	ICMP6_MIB_OUTPKTTOOBIGS,		/* OutPktTooBigs */
	ICMP6_MIB_OUTTIMEEXCDS,			/* OutTimeExcds */
	ICMP6_MIB_OUTPARMPROBLEMS,		/* OutParmProblems */
	ICMP6_MIB_OUTECHOREPLIES,		/* OutEchoReplies */
	ICMP6_MIB_OUTROUTERSOLICITS,		/* OutRouterSolicits */
	ICMP6_MIB_OUTNEIGHBORSOLICITS,		/* OutNeighborSolicits */
	ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS,	/* OutNeighborAdvertisements */
	ICMP6_MIB_OUTREDIRECTS,			/* OutRedirects */
	ICMP6_MIB_OUTGROUPMEMBRESPONSES,	/* OutGroupMembResponses */
	ICMP6_MIB_OUTGROUPMEMBREDUCTIONS,	/* OutGroupMembReductions */
	__ICMP6_MIB_MAX
};

#define __ICMP6MSG_MIB_MAX 512 /* Out+In for all 8-bit ICMPv6 types */

/* tcp mib definitions */
/*
 * RFC 1213:  MIB-II TCP group
+1 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ struct ipv6_devstat {
	struct proc_dir_entry	*proc_dir_entry;
	DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
	DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
	DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg);
};

struct inet6_dev 
+32 −35
Original line number Diff line number Diff line
@@ -112,45 +112,28 @@ struct frag_hdr {
extern int sysctl_ipv6_bindv6only;
extern int sysctl_mld_max_msf;

/* MIBs */
DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
#define IP6_INC_STATS(idev,field)		({			\
#define _DEVINC(statname, modifier, idev, field)			\
({									\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS(_idev->stats.ipv6, field);		\
	SNMP_INC_STATS(ipv6_statistics, field);				\
})
#define IP6_INC_STATS_BH(idev,field)		({			\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS_BH(_idev->stats.ipv6, field);		\
	SNMP_INC_STATS_BH(ipv6_statistics, field);			\
})
#define IP6_INC_STATS_USER(idev,field)		({			\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS_USER(_idev->stats.ipv6, field);		\
	SNMP_INC_STATS_USER(ipv6_statistics, field);			\
		SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \
	SNMP_INC_STATS##modifier(statname##_statistics, (field));	\
})

/* MIBs */
DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);

#define IP6_INC_STATS(idev,field)	_DEVINC(ipv6, , idev, field)
#define IP6_INC_STATS_BH(idev,field)	_DEVINC(ipv6, _BH, idev, field)
#define IP6_INC_STATS_USER(idev,field)	_DEVINC(ipv6, _USER, idev, field)

DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
#define ICMP6_INC_STATS(idev, field)		({			\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS(idev->stats.icmpv6, field); 		\
	SNMP_INC_STATS(icmpv6_statistics, field);			\
})
#define ICMP6_INC_STATS_BH(idev, field)		({			\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS_BH((_idev)->stats.icmpv6, field);	\
	SNMP_INC_STATS_BH(icmpv6_statistics, field);			\
})
#define ICMP6_INC_STATS_USER(idev, field) 	({			\
	struct inet6_dev *_idev = (idev);				\
	if (likely(_idev != NULL))					\
		SNMP_INC_STATS_USER(_idev->stats.icmpv6, field);	\
	SNMP_INC_STATS_USER(icmpv6_statistics, field);			\
})
DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);

#define ICMP6_INC_STATS(idev, field)	_DEVINC(icmpv6, , idev, field)
#define ICMP6_INC_STATS_BH(idev, field)	_DEVINC(icmpv6, _BH, idev, field)
#define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field)

#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset)	({			\
	struct inet6_dev *_idev = idev;						\
	__typeof__(offset) _offset = (offset);					\
@@ -158,6 +141,20 @@ DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
		SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset);	\
	SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset);    	\
})

#define ICMP6MSGOUT_INC_STATS(idev, field) \
	_DEVINC(icmpv6msg, , idev, field +256)
#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \
	_DEVINC(icmpv6msg, _BH, idev, field +256)
#define ICMP6MSGOUT_INC_STATS_USER(idev, field) \
	_DEVINC(icmpv6msg, _USER, idev, field +256)
#define ICMP6MSGIN_INC_STATS(idev, field) \
	 _DEVINC(icmpv6msg, , idev, field)
#define ICMP6MSGIN_INC_STATS_BH(idev, field) \
	_DEVINC(icmpv6msg, _BH, idev, field)
#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
	_DEVINC(icmpv6msg, _USER, idev, field)

DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
#define UDP6_INC_STATS_BH(field, is_udplite) 			      do  {  \
+6 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ struct icmpv6_mib {
	unsigned long	mibs[ICMP6_MIB_MAX];
} __SNMP_MIB_ALIGN__;

#define ICMP6MSG_MIB_MAX  __ICMP6MSG_MIB_MAX
struct icmpv6msg_mib {
	unsigned long	mibs[ICMP6MSG_MIB_MAX];
} __SNMP_MIB_ALIGN__;


/* TCP */
#define TCP_MIB_MAX	__TCP_MIB_MAX
struct tcp_mib {
+7 −0
Original line number Diff line number Diff line
@@ -261,9 +261,15 @@ static int snmp6_alloc_dev(struct inet6_dev *idev)
			  sizeof(struct icmpv6_mib),
			  __alignof__(struct icmpv6_mib)) < 0)
		goto err_icmp;
	if (snmp_mib_init((void **)idev->stats.icmpv6msg,
			  sizeof(struct icmpv6msg_mib),
			  __alignof__(struct icmpv6msg_mib)) < 0)
		goto err_icmpmsg;

	return 0;

err_icmpmsg:
	snmp_mib_free((void **)idev->stats.icmpv6);
err_icmp:
	snmp_mib_free((void **)idev->stats.ipv6);
err_ip:
@@ -272,6 +278,7 @@ static int snmp6_alloc_dev(struct inet6_dev *idev)

static int snmp6_free_dev(struct inet6_dev *idev)
{
	snmp_mib_free((void **)idev->stats.icmpv6msg);
	snmp_mib_free((void **)idev->stats.icmpv6);
	snmp_mib_free((void **)idev->stats.ipv6);
	return 0;
Loading