Date: Thu, 20 Nov 2014 20:33:05 +0300 From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: freebsd-arch@freebsd.org, "freebsd-net@freebsd.org" <freebsd-net@freebsd.org> Subject: [RFC] add macros for ifnet statistic accounting Message-ID: <546E25D1.7020900@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
Hi All, we already did some changes in network stack in head/, that made ability for merging changes into stable branches much harder. What you think about adding the following macro to head/: --- if_var.h (revision 274736) +++ if_var.h (working copy) @@ -111,6 +111,10 @@ typedef enum { IFCOUNTERS /* Array size. */ } ift_counter; +#define IFSTAT_ADD(ifp, name, value) \ + if_inc_counter((ifp), IFCOUNTER_ ## name, (value)) +#define IFSTAT_INC(ifp, name) IFSTAT_ADD(ifp, name, 1) + typedef struct ifnet * if_t; typedef void (*if_start_fn_t)(if_t); And then make a direct commit to stable/* branches like this: --- if_var.h (revision 274750) +++ if_var.h (working copy) @@ -104,6 +104,23 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* #define V_link_pfil_hook VNET(link_pfil_hook) #endif /* _KERNEL */ +#define IFSTAT_ADD(ifp, name, value) \ + IFSTAT_ ## name ## _ADD(ifp, value) +#define IFSTAT_INC(ifp, name) IFSTAT_ADD(ifp, name, 1) + +#define IFSTAT_IPACKETS_ADD(ifp, inc) (ifp)->if_ipackets += (inc) +#define IFSTAT_IERRORS_ADD(ifp, inc) (ifp)->if_ierrors += (inc) +#define IFSTAT_OPACKETS_ADD(ifp, inc) (ifp)->if_opackets += (inc) +#define IFSTAT_OERRORS_ADD(ifp, inc) (ifp)->if_oerrors += (inc) +#define IFSTAT_COLLISIONS_ADD(ifp, inc) (ifp)->if_collisions += (inc) +#define IFSTAT_IBYTES_ADD(ifp, inc) (ifp)->if_ibytes += (inc) +#define IFSTAT_OBYTES_ADD(ifp, inc) (ifp)->if_obytes += (inc) +#define IFSTAT_IMCASTS_ADD(ifp, inc) (ifp)->if_imcasts += (inc) +#define IFSTAT_OMCASTS_ADD(ifp, inc) (ifp)->if_omcasts += (inc) +#define IFSTAT_IQDROPS_ADD(ifp, inc) (ifp)->if_iqdrops += (inc) +#define IFSTAT_OQDROPS_ADD(ifp, inc) /* NOP */ +#define IFSTAT_NOPROTO_ADD(ifp, inc) (ifp)->if_noproto += (inc) + /* * Structure defining a queue for a network interface. */ This can make merging a little bit easier, at least for generic code in the network stack. -- WBR, Andrey V. Elsukov
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?546E25D1.7020900>