2008-01-02 23:26:11 +00:00
|
|
|
/*-
|
2017-11-20 19:49:47 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1994-05-27 12:33:43 +00:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 12:33:43 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)netstat.h 8.2 (Berkeley) 1/4/94
|
1999-10-21 09:06:11 +00:00
|
|
|
* $FreeBSD$
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2015-09-01 08:42:04 +00:00
|
|
|
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
|
|
|
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
|
|
|
|
#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
|
|
|
|
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int Aflag; /* show addresses of protocol control block */
|
|
|
|
extern int aflag; /* show all sockets (including servers) */
|
|
|
|
extern int bflag; /* show i/f total bytes in/out */
|
2020-10-09 10:07:41 +00:00
|
|
|
extern int cflag; /* show congestion control stats */
|
|
|
|
extern int Cflag; /* show congestion control algo and stack */
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int dflag; /* show i/f dropped packets */
|
|
|
|
extern int gflag; /* show group (multicast) routing or stats */
|
2005-08-18 21:04:12 +00:00
|
|
|
extern int hflag; /* show counters in human readable format */
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int iflag; /* show interfaces */
|
|
|
|
extern int Lflag; /* show size of listen queues */
|
|
|
|
extern int mflag; /* show memory stats */
|
2010-01-11 03:00:17 +00:00
|
|
|
extern int noutputs; /* how much outputs before we exit */
|
2001-06-15 00:25:44 +00:00
|
|
|
extern int numeric_addr; /* show addresses numerically */
|
|
|
|
extern int numeric_port; /* show ports numerically */
|
2018-03-22 09:40:08 +00:00
|
|
|
extern int Pflag; /* show TCP log ID */
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int rflag; /* show routing tables (or routing stats) */
|
2014-05-19 17:11:43 +00:00
|
|
|
extern int Rflag; /* show flowid / RSS information */
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int sflag; /* show protocol statistics */
|
2010-11-17 18:55:12 +00:00
|
|
|
extern int Tflag; /* show TCP control block info */
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int Wflag; /* wide display */
|
2008-09-01 15:04:38 +00:00
|
|
|
extern int xflag; /* extended display, includes all socket buffer info */
|
2001-06-23 17:17:59 +00:00
|
|
|
extern int zflag; /* zero stats */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2001-03-15 20:46:04 +00:00
|
|
|
extern int interval; /* repeat interval for i/f stats */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2001-03-15 20:46:04 +00:00
|
|
|
extern char *interface; /* desired i/f for stats, or NULL for all i/fs */
|
|
|
|
extern int unit; /* unit number for above */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2007-07-16 17:15:55 +00:00
|
|
|
extern int live; /* true if we are examining a live system */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2016-03-15 00:19:30 +00:00
|
|
|
typedef int kreadfn_t(u_long, void *, size_t);
|
|
|
|
int fetch_stats(const char *, u_long, void *, size_t, kreadfn_t);
|
|
|
|
int fetch_stats_ro(const char *, u_long, void *, size_t, kreadfn_t);
|
|
|
|
|
2007-07-16 17:15:55 +00:00
|
|
|
int kread(u_long addr, void *buf, size_t size);
|
2014-03-05 01:17:47 +00:00
|
|
|
uint64_t kread_counter(u_long addr);
|
2013-07-09 09:43:03 +00:00
|
|
|
int kread_counters(u_long addr, void *buf, size_t size);
|
2015-09-02 18:51:36 +00:00
|
|
|
void kset_dpcpu(u_int);
|
2006-07-28 16:09:19 +00:00
|
|
|
const char *plural(uintmax_t);
|
|
|
|
const char *plurales(uintmax_t);
|
|
|
|
const char *pluralies(uintmax_t);
|
2003-12-29 04:34:36 +00:00
|
|
|
|
2010-02-22 15:57:36 +00:00
|
|
|
struct sockaddr;
|
|
|
|
struct socket;
|
|
|
|
struct xsocket;
|
2007-07-16 17:15:55 +00:00
|
|
|
int sotoxsocket(struct socket *, struct xsocket *);
|
|
|
|
void protopr(u_long, const char *, int, int);
|
|
|
|
void tcp_stats(u_long, const char *, int, int);
|
|
|
|
void udp_stats(u_long, const char *, int, int);
|
2007-06-09 13:44:09 +00:00
|
|
|
#ifdef SCTP
|
2007-07-16 17:15:55 +00:00
|
|
|
void sctp_protopr(u_long, const char *, int, int);
|
|
|
|
void sctp_stats(u_long, const char *, int, int);
|
2007-06-09 13:44:09 +00:00
|
|
|
#endif
|
2009-09-03 21:10:57 +00:00
|
|
|
void arp_stats(u_long, const char *, int, int);
|
2007-07-16 17:15:55 +00:00
|
|
|
void ip_stats(u_long, const char *, int, int);
|
|
|
|
void icmp_stats(u_long, const char *, int, int);
|
|
|
|
void igmp_stats(u_long, const char *, int, int);
|
|
|
|
void pim_stats(u_long, const char *, int, int);
|
2008-01-02 23:26:11 +00:00
|
|
|
void carp_stats(u_long, const char *, int, int);
|
|
|
|
void pfsync_stats(u_long, const char *, int, int);
|
1999-12-07 17:39:16 +00:00
|
|
|
#ifdef IPSEC
|
2007-07-16 17:15:55 +00:00
|
|
|
void ipsec_stats(u_long, const char *, int, int);
|
2008-01-02 23:26:11 +00:00
|
|
|
void esp_stats(u_long, const char *, int, int);
|
|
|
|
void ah_stats(u_long, const char *, int, int);
|
|
|
|
void ipcomp_stats(u_long, const char *, int, int);
|
2005-12-28 20:36:55 +00:00
|
|
|
#endif
|
1999-12-07 17:39:16 +00:00
|
|
|
|
2017-01-05 09:23:54 +00:00
|
|
|
#ifdef INET
|
|
|
|
struct in_addr;
|
|
|
|
|
|
|
|
char *inetname(struct in_addr *);
|
|
|
|
#endif
|
|
|
|
|
1999-12-07 17:39:16 +00:00
|
|
|
#ifdef INET6
|
2017-01-05 09:23:54 +00:00
|
|
|
struct in6_addr;
|
|
|
|
|
|
|
|
char *inet6name(struct in6_addr *);
|
2007-07-16 17:15:55 +00:00
|
|
|
void ip6_stats(u_long, const char *, int, int);
|
2003-12-29 04:34:36 +00:00
|
|
|
void ip6_ifstats(char *);
|
2007-07-16 17:15:55 +00:00
|
|
|
void icmp6_stats(u_long, const char *, int, int);
|
2003-12-29 04:34:36 +00:00
|
|
|
void icmp6_ifstats(char *);
|
2007-07-16 17:15:55 +00:00
|
|
|
void pim6_stats(u_long, const char *, int, int);
|
|
|
|
void rip6_stats(u_long, const char *, int, int);
|
2013-12-20 00:17:26 +00:00
|
|
|
void mroute6pr(void);
|
|
|
|
void mrt6_stats(void);
|
2000-07-04 16:26:46 +00:00
|
|
|
|
|
|
|
struct sockaddr_in6;
|
|
|
|
struct in6_addr;
|
2011-01-20 15:22:01 +00:00
|
|
|
void in6_fillscopeid(struct sockaddr_in6 *);
|
2015-02-21 23:47:20 +00:00
|
|
|
void inet6print(const char *, struct in6_addr *, int, const char *, int);
|
1999-12-07 17:39:16 +00:00
|
|
|
#endif /*INET6*/
|
|
|
|
|
2000-07-05 02:02:54 +00:00
|
|
|
#ifdef IPSEC
|
2007-07-16 17:15:55 +00:00
|
|
|
void pfkey_stats(u_long, const char *, int, int);
|
2000-07-05 02:02:54 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-13 14:06:01 +00:00
|
|
|
void mbpr(void *, u_long);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2015-09-02 18:51:36 +00:00
|
|
|
void netisr_stats(void);
|
2010-02-22 15:57:36 +00:00
|
|
|
|
2003-12-29 04:34:36 +00:00
|
|
|
void hostpr(u_long, u_long);
|
|
|
|
void impstats(u_long, u_long);
|
|
|
|
|
2015-09-01 08:42:04 +00:00
|
|
|
void intpr(void (*)(char *), int);
|
2003-12-29 04:34:36 +00:00
|
|
|
|
|
|
|
void pr_family(int);
|
2013-12-20 00:17:26 +00:00
|
|
|
void rt_stats(void);
|
2003-12-29 04:34:36 +00:00
|
|
|
|
2015-09-01 08:42:04 +00:00
|
|
|
char *routename(struct sockaddr *, int);
|
|
|
|
const char *netname(struct sockaddr *, struct sockaddr *);
|
2013-12-20 00:17:26 +00:00
|
|
|
void routepr(int, int);
|
Introduce nexthop objects and new routing KPI.
This is the foundational change for the routing subsytem rearchitecture.
More details and goals are available in https://reviews.freebsd.org/D24141 .
This patch introduces concept of nexthop objects and new nexthop-based
routing KPI.
Nexthops are objects, containing all necessary information for performing
the packet output decision. Output interface, mtu, flags, gw address goes
there. For most of the cases, these objects will serve the same role as
the struct rtentry is currently serving.
Typically there will be low tens of such objects for the router even with
multiple BGP full-views, as these objects will be shared between routing
entries. This allows to store more information in the nexthop.
New KPI:
struct nhop_object *fib4_lookup(uint32_t fibnum, struct in_addr dst,
uint32_t scopeid, uint32_t flags, uint32_t flowid);
struct nhop_object *fib6_lookup(uint32_t fibnum, const struct in6_addr *dst6,
uint32_t scopeid, uint32_t flags, uint32_t flowid);
These 2 function are intended to replace all all flavours of
<in_|in6_>rtalloc[1]<_ign><_fib>, mpath functions and the previous
fib[46]-generation functions.
Upon successful lookup, they return nexthop object which is guaranteed to
exist within current NET_EPOCH. If longer lifetime is desired, one can
specify NHR_REF as a flag and get a referenced version of the nexthop.
Reference semantic closely resembles rtentry one, allowing sed-style conversion.
Additionally, another 2 functions are introduced to support uRPF functionality
inside variety of our firewalls. Their primary goal is to hide the multipath
implementation details inside the routing subsystem, greatly simplifying
firewalls implementation:
int fib4_lookup_urpf(uint32_t fibnum, struct in_addr dst, uint32_t scopeid,
uint32_t flags, const struct ifnet *src_if);
int fib6_lookup_urpf(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid,
uint32_t flags, const struct ifnet *src_if);
All functions have a separate scopeid argument, paving way to eliminating IPv6 scope
embedding and allowing to support IPv4 link-locals in the future.
Structure changes:
* rtentry gets new 'rt_nhop' pointer, slightly growing the overall size.
* rib_head gets new 'rnh_preadd' callback pointer, slightly growing overall sz.
Old KPI:
During the transition state old and new KPI will coexists. As there are another 4-5
decent-sized conversion patches, it will probably take a couple of weeks.
To support both KPIs, fields not required by the new KPI (most of rtentry) has to be
kept, resulting in the temporary size increase.
Once conversion is finished, rtentry will notably shrink.
More details:
* architectural overview: https://reviews.freebsd.org/D24141
* list of the next changes: https://reviews.freebsd.org/D24232
Reviewed by: ae,glebius(initial version)
Differential Revision: https://reviews.freebsd.org/D24232
2020-04-12 14:30:00 +00:00
|
|
|
int p_sockaddr(const char *name, struct sockaddr *sa,
|
|
|
|
struct sockaddr *mask, int flags, int width);
|
|
|
|
const char *fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask,
|
|
|
|
int flags);
|
2003-12-29 04:34:36 +00:00
|
|
|
|
2008-09-21 22:02:26 +00:00
|
|
|
#ifdef NETGRAPH
|
2007-07-16 17:15:55 +00:00
|
|
|
void netgraphprotopr(u_long, const char *, int, int);
|
2008-09-21 22:02:26 +00:00
|
|
|
#endif
|
2003-12-29 04:34:36 +00:00
|
|
|
|
2015-02-21 23:47:20 +00:00
|
|
|
void unixpr(u_long, u_long, u_long, u_long, u_long, bool *);
|
2003-12-29 04:34:36 +00:00
|
|
|
|
2013-12-20 00:17:26 +00:00
|
|
|
void mroutepr(void);
|
|
|
|
void mrt_stats(void);
|
2005-09-07 17:35:16 +00:00
|
|
|
void bpf_stats(char *);
|
Introduce nexthop objects and new routing KPI.
This is the foundational change for the routing subsytem rearchitecture.
More details and goals are available in https://reviews.freebsd.org/D24141 .
This patch introduces concept of nexthop objects and new nexthop-based
routing KPI.
Nexthops are objects, containing all necessary information for performing
the packet output decision. Output interface, mtu, flags, gw address goes
there. For most of the cases, these objects will serve the same role as
the struct rtentry is currently serving.
Typically there will be low tens of such objects for the router even with
multiple BGP full-views, as these objects will be shared between routing
entries. This allows to store more information in the nexthop.
New KPI:
struct nhop_object *fib4_lookup(uint32_t fibnum, struct in_addr dst,
uint32_t scopeid, uint32_t flags, uint32_t flowid);
struct nhop_object *fib6_lookup(uint32_t fibnum, const struct in6_addr *dst6,
uint32_t scopeid, uint32_t flags, uint32_t flowid);
These 2 function are intended to replace all all flavours of
<in_|in6_>rtalloc[1]<_ign><_fib>, mpath functions and the previous
fib[46]-generation functions.
Upon successful lookup, they return nexthop object which is guaranteed to
exist within current NET_EPOCH. If longer lifetime is desired, one can
specify NHR_REF as a flag and get a referenced version of the nexthop.
Reference semantic closely resembles rtentry one, allowing sed-style conversion.
Additionally, another 2 functions are introduced to support uRPF functionality
inside variety of our firewalls. Their primary goal is to hide the multipath
implementation details inside the routing subsystem, greatly simplifying
firewalls implementation:
int fib4_lookup_urpf(uint32_t fibnum, struct in_addr dst, uint32_t scopeid,
uint32_t flags, const struct ifnet *src_if);
int fib6_lookup_urpf(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid,
uint32_t flags, const struct ifnet *src_if);
All functions have a separate scopeid argument, paving way to eliminating IPv6 scope
embedding and allowing to support IPv4 link-locals in the future.
Structure changes:
* rtentry gets new 'rt_nhop' pointer, slightly growing the overall size.
* rib_head gets new 'rnh_preadd' callback pointer, slightly growing overall sz.
Old KPI:
During the transition state old and new KPI will coexists. As there are another 4-5
decent-sized conversion patches, it will probably take a couple of weeks.
To support both KPIs, fields not required by the new KPI (most of rtentry) has to be
kept, resulting in the temporary size increase.
Once conversion is finished, rtentry will notably shrink.
More details:
* architectural overview: https://reviews.freebsd.org/D24141
* list of the next changes: https://reviews.freebsd.org/D24232
Reviewed by: ae,glebius(initial version)
Differential Revision: https://reviews.freebsd.org/D24232
2020-04-12 14:30:00 +00:00
|
|
|
void nhops_print(int fibnum, int af);
|
2020-10-03 10:47:17 +00:00
|
|
|
void nhgrp_print(int fibnum, int af);
|