summaryrefslogtreecommitdiffstats
path: root/sys/net/if_var.h
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2014-08-31 06:46:21 +0000
committerglebius <glebius@FreeBSD.org>2014-08-31 06:46:21 +0000
commit70b7c46209e1ad46231f23b2cda4ef4e42bd14ba (patch)
tree14bbbb2fbcb15cc9c9d3468958b19e7041eb0d3c /sys/net/if_var.h
parent60476807974fa0ceadf96ee9dc003c3fecab92c9 (diff)
downloadFreeBSD-src-70b7c46209e1ad46231f23b2cda4ef4e42bd14ba.zip
FreeBSD-src-70b7c46209e1ad46231f23b2cda4ef4e42bd14ba.tar.gz
o Remove struct if_data from struct ifnet. Now it is merely API structure
for route(4) socket and ifmib(4) sysctl. o Move fields from if_data to ifnet, but keep all statistic counters separate, since they should disappear later. o Provide function if_data_copy() to fill if_data, utilize it in routing socket and ifmib handler. o Provide overridable ifnet(9) method to fetch counters. If no provided, if_get_counters_compat() would be used, that returns old counters. Sponsored by: Netflix Sponsored by: Nginx, Inc.
Diffstat (limited to 'sys/net/if_var.h')
-rw-r--r--sys/net/if_var.h88
1 files changed, 53 insertions, 35 deletions
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 730c7f1..82f33b3 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -94,11 +94,27 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* packet filter hooks */
#define V_link_pfil_hook VNET(link_pfil_hook)
#endif /* _KERNEL */
+typedef enum {
+ IFCOUNTER_IPACKETS = 1,
+ IFCOUNTER_IERRORS,
+ IFCOUNTER_OPACKETS,
+ IFCOUNTER_OERRORS,
+ IFCOUNTER_COLLISIONS,
+ IFCOUNTER_IBYTES,
+ IFCOUNTER_OBYTES,
+ IFCOUNTER_IMCASTS,
+ IFCOUNTER_OMCASTS,
+ IFCOUNTER_IQDROPS,
+ IFCOUNTER_OQDROPS,
+ IFCOUNTER_NOPROTO,
+} ifnet_counter;
+
typedef void (*if_start_fn_t)(struct ifnet *);
typedef int (*if_ioctl_fn_t)(struct ifnet *, u_long, caddr_t);
typedef void (*if_init_fn_t)(void *);
typedef void (*if_qflush_fn_t)(struct ifnet *);
typedef int (*if_transmit_fn_t)(struct ifnet *, struct mbuf *);
+typedef uint64_t (*if_get_counter_t)(struct ifnet *, ifnet_counter);
/* Opaque object pointing to interface structure (ifnet) */
typedef void *if_t;
@@ -136,8 +152,21 @@ struct ifnet {
size_t if_linkmiblen; /* length of above data */
int if_drv_flags; /* driver-managed status flags */
u_int if_refcount; /* reference count */
+
+ /* These fields are shared with struct if_data. */
+ uint8_t if_type; /* ethernet, tokenring, etc */
+ uint8_t if_addrlen; /* media address length */
+ uint8_t if_hdrlen; /* media header length */
+ uint8_t if_link_state; /* current link state */
+ uint32_t if_spare32;
+ uint32_t if_mtu; /* maximum transmission unit */
+ uint32_t if_metric; /* routing metric (external only) */
+ uint64_t if_baudrate; /* linespeed */
+ uint64_t if_hwassist; /* HW offload capabilities, see IFCAP */
+ time_t if_epoch; /* uptime at attach or stat reset */
+ struct timeval if_lastchange; /* time of last administrative change */
+
struct ifaltq if_snd; /* output queue (includes altq) */
- struct if_data if_data; /* type information and statistics */
struct task if_linktask; /* task for link change events */
/* Addresses of different protocol families assigned to this if. */
@@ -190,6 +219,7 @@ struct ifnet {
void (*if_reassign) /* reassign to vnet routine */
(struct ifnet *, struct vnet *, char *);
+ if_get_counter_t if_get_counter; /* get counter values */
/* Stuff that's only temporary and doesn't belong here. */
u_int if_hw_tsomax; /* tso burst length limit, the minimum
@@ -197,45 +227,31 @@ struct ifnet {
* XXXAO: Have to find a better place
* for it eventually. */
/*
- * Spare fields are added so that we can modify sensitive data
- * structures without changing the kernel binary interface, and must
- * be used with care where binary compatibility is required.
+ * Old, racy and expensive statistics, should not be used in
+ * new drivers.
+ */
+ uint64_t if_ipackets; /* packets received on interface */
+ uint64_t if_ierrors; /* input errors on interface */
+ uint64_t if_opackets; /* packets sent on interface */
+ uint64_t if_oerrors; /* output errors on interface */
+ uint64_t if_collisions; /* collisions on csma interfaces */
+ uint64_t if_ibytes; /* total number of octets received */
+ uint64_t if_obytes; /* total number of octets sent */
+ uint64_t if_imcasts; /* packets received via multicast */
+ uint64_t if_omcasts; /* packets sent via multicast */
+ uint64_t if_iqdrops; /* dropped on input */
+ uint64_t if_oqdrops; /* dropped on output */
+ uint64_t if_noproto; /* destined for unsupported protocol */
+
+ /*
+ * Spare fields to be added before branching a stable branch, so
+ * that structure can be enhanced without changing the kernel
+ * binary interface.
*/
- char if_cspare[3];
- int if_ispare[4];
- void *if_unused[2];
- void *if_pspare[8]; /* 1 netmap, 7 TDB */
};
#include <net/ifq.h> /* XXXAO: temporary unconditional include */
-/*
- * XXX These aliases are terribly dangerous because they could apply
- * to anything.
- */
-#define if_mtu if_data.ifi_mtu
-#define if_type if_data.ifi_type
-#define if_physical if_data.ifi_physical
-#define if_addrlen if_data.ifi_addrlen
-#define if_hdrlen if_data.ifi_hdrlen
-#define if_metric if_data.ifi_metric
-#define if_link_state if_data.ifi_link_state
-#define if_baudrate if_data.ifi_baudrate
-#define if_hwassist if_data.ifi_hwassist
-#define if_ipackets if_data.ifi_ipackets
-#define if_ierrors if_data.ifi_ierrors
-#define if_opackets if_data.ifi_opackets
-#define if_oerrors if_data.ifi_oerrors
-#define if_collisions if_data.ifi_collisions
-#define if_ibytes if_data.ifi_ibytes
-#define if_obytes if_data.ifi_obytes
-#define if_imcasts if_data.ifi_imcasts
-#define if_omcasts if_data.ifi_omcasts
-#define if_iqdrops if_data.ifi_iqdrops
-#define if_oqdrops if_data.ifi_oqdrops
-#define if_noproto if_data.ifi_noproto
-#define if_lastchange if_data.ifi_lastchange
-
/* for compatibility with other BSDs */
#define if_addrlist if_addrhead
#define if_list if_link
@@ -513,6 +529,8 @@ typedef void *if_com_alloc_t(u_char type, struct ifnet *ifp);
typedef void if_com_free_t(void *com, u_char type);
void if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f);
void if_deregister_com_alloc(u_char type);
+void if_data_copy(struct ifnet *, struct if_data *);
+uint64_t if_get_counter_compat(struct ifnet *, ifnet_counter);
#define IF_LLADDR(ifp) \
LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
OpenPOWER on IntegriCloud