All net.* sysctl converted now.
This commit is contained in:
parent
af48260143
commit
5204129576
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12340
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
|
||||
* $Id: kern_sysctl.c,v 1.49 1995/11/14 09:42:22 phk Exp $
|
||||
* $Id: kern_sysctl.c,v 1.50 1995/11/14 20:43:29 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -585,9 +585,6 @@ userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *old
|
||||
case CTL_HW:
|
||||
fn = hw_sysctl;
|
||||
break;
|
||||
case CTL_NET:
|
||||
fn = net_sysctl;
|
||||
break;
|
||||
case CTL_FS:
|
||||
fn = fs_sysctl;
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93
|
||||
* $Id: uipc_domain.c,v 1.8 1995/08/28 09:18:51 julian Exp $
|
||||
* $Id: uipc_domain.c,v 1.9 1995/09/09 18:10:11 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -39,12 +39,8 @@
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/domain.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <vm/vm.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
/*
|
||||
* System initialization
|
||||
@ -69,8 +65,8 @@ SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL)
|
||||
SYSINIT(splx, SI_SUB_PROTO_END, SI_ORDER_FIRST, kludge_splx, &x_save_spl)
|
||||
|
||||
|
||||
void pffasttimo __P((void *));
|
||||
void pfslowtimo __P((void *));
|
||||
static void pffasttimo __P((void *));
|
||||
static void pfslowtimo __P((void *));
|
||||
|
||||
struct domain *domains;
|
||||
|
||||
@ -151,8 +147,7 @@ kludge_splx(udata)
|
||||
|
||||
|
||||
struct protosw *
|
||||
pffindtype(family, type)
|
||||
int family, type;
|
||||
pffindtype(int family, int type)
|
||||
{
|
||||
register struct domain *dp;
|
||||
register struct protosw *pr;
|
||||
@ -169,8 +164,7 @@ pffindtype(family, type)
|
||||
}
|
||||
|
||||
struct protosw *
|
||||
pffindproto(family, protocol, type)
|
||||
int family, protocol, type;
|
||||
pffindproto(int family, int protocol, int type)
|
||||
{
|
||||
register struct domain *dp;
|
||||
register struct protosw *pr;
|
||||
@ -194,44 +188,6 @@ pffindproto(family, protocol, type)
|
||||
return (maybe);
|
||||
}
|
||||
|
||||
int
|
||||
net_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
void *oldp;
|
||||
size_t *oldlenp;
|
||||
void *newp;
|
||||
size_t newlen;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct domain *dp;
|
||||
register struct protosw *pr;
|
||||
int family, protocol;
|
||||
|
||||
/*
|
||||
* All sysctl names at this level are nonterminal;
|
||||
* next two components are protocol family and protocol number,
|
||||
* then at least one addition component.
|
||||
*/
|
||||
if (namelen < 3)
|
||||
return (EISDIR); /* overloaded */
|
||||
family = name[0];
|
||||
protocol = name[1];
|
||||
|
||||
if (family == 0)
|
||||
return (0);
|
||||
for (dp = domains; dp; dp = dp->dom_next)
|
||||
if (dp->dom_family == family)
|
||||
goto found;
|
||||
return (ENOPROTOOPT);
|
||||
found:
|
||||
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
||||
if (pr->pr_protocol == protocol && pr->pr_sysctl)
|
||||
return ((*pr->pr_sysctl)(name + 2, namelen - 2,
|
||||
oldp, oldlenp, newp, newlen));
|
||||
return (ENOPROTOOPT);
|
||||
}
|
||||
|
||||
void
|
||||
pfctlinput(cmd, sa)
|
||||
int cmd;
|
||||
@ -246,7 +202,7 @@ pfctlinput(cmd, sa)
|
||||
(*pr->pr_ctlinput)(cmd, sa, (caddr_t)0);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
pfslowtimo(arg)
|
||||
void *arg;
|
||||
{
|
||||
@ -260,7 +216,7 @@ pfslowtimo(arg)
|
||||
timeout(pfslowtimo, (void *)0, hz/2);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
pffasttimo(arg)
|
||||
void *arg;
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)route.h 8.3 (Berkeley) 4/19/94
|
||||
* $Id: route.h,v 1.16 1995/10/16 20:53:55 wollman Exp $
|
||||
* $Id: route.h,v 1.17 1995/10/26 20:30:24 julian Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NET_ROUTE_H_
|
||||
@ -260,9 +260,6 @@ extern struct rtstat rtstat;
|
||||
extern struct radix_node_head *rt_tables[AF_MAX+1];
|
||||
|
||||
void route_init __P((void));
|
||||
int route_output __P((struct mbuf *, struct socket *));
|
||||
int route_usrreq __P((struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *));
|
||||
void rt_ifmsg __P((struct ifnet *));
|
||||
void rt_maskedcopy __P((struct sockaddr *,
|
||||
struct sockaddr *, struct sockaddr *));
|
||||
@ -270,7 +267,6 @@ void rt_missmsg __P((int, struct rt_addrinfo *, int, int));
|
||||
void rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));
|
||||
int rt_setgate __P((struct rtentry *,
|
||||
struct sockaddr *, struct sockaddr *));
|
||||
void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
|
||||
void rtable_init __P((void **));
|
||||
void rtalloc __P((struct route *));
|
||||
void rtalloc_ign __P((struct route *, unsigned long));
|
||||
|
@ -31,12 +31,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)rtsock.c 8.5 (Berkeley) 11/2/94
|
||||
* $Id: rtsock.c,v 1.15 1995/10/13 16:01:59 wollman Exp $
|
||||
* $Id: rtsock.c,v 1.16 1995/10/26 20:30:26 julian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
@ -48,13 +49,15 @@
|
||||
#include <net/route.h>
|
||||
#include <net/raw_cb.h>
|
||||
|
||||
struct sockaddr route_dst = { 2, PF_ROUTE, };
|
||||
struct sockaddr route_src = { 2, PF_ROUTE, };
|
||||
struct sockproto route_proto = { PF_ROUTE, };
|
||||
static struct sockaddr route_dst = { 2, PF_ROUTE, };
|
||||
static struct sockaddr route_src = { 2, PF_ROUTE, };
|
||||
static struct sockproto route_proto = { PF_ROUTE, };
|
||||
|
||||
struct walkarg {
|
||||
int w_op, w_arg, w_given, w_needed, w_tmemsize;
|
||||
caddr_t w_where, w_tmem;
|
||||
int w_tmemsize;
|
||||
int w_op, w_arg;
|
||||
caddr_t w_tmem;
|
||||
struct sysctl_req *w_req;
|
||||
};
|
||||
|
||||
static struct mbuf *
|
||||
@ -62,10 +65,12 @@ static struct mbuf *
|
||||
static int rt_msg2 __P((int,
|
||||
struct rt_addrinfo *, caddr_t, struct walkarg *));
|
||||
static void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));
|
||||
extern int sysctl_dumpentry __P((struct radix_node *rn, void *vw));
|
||||
extern int sysctl_iflist __P((int af, struct walkarg *w));
|
||||
extern int sysctl_rtable __P((int *name, u_int namelen, void* where,
|
||||
size_t *given, void *new, size_t newlen));
|
||||
static int sysctl_dumpentry __P((struct radix_node *rn, void *vw));
|
||||
static int sysctl_iflist __P((int af, struct walkarg *w));
|
||||
static int route_output __P((struct mbuf *, struct socket *));
|
||||
static int route_usrreq __P((struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *));
|
||||
static void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
|
||||
|
||||
/* Sleazy use of local variables throughout file, warning!!!! */
|
||||
#define dst info.rti_info[RTAX_DST]
|
||||
@ -77,7 +82,7 @@ extern int sysctl_rtable __P((int *name, u_int namelen, void* where,
|
||||
#define brdaddr info.rti_info[RTAX_BRD]
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
static int
|
||||
route_usrreq(so, req, m, nam, control)
|
||||
register struct socket *so;
|
||||
int req;
|
||||
@ -133,7 +138,7 @@ route_usrreq(so, req, m, nam, control)
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
static int
|
||||
route_output(m, so)
|
||||
register struct mbuf *m;
|
||||
struct socket *so;
|
||||
@ -351,7 +356,7 @@ route_output(m, so)
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
rt_setmetrics(which, in, out)
|
||||
u_long which;
|
||||
register struct rt_metrics *in, *out;
|
||||
@ -487,8 +492,7 @@ rt_msg2(type, rtinfo, cp, w)
|
||||
if (cp == 0 && w != NULL && !second_time) {
|
||||
register struct walkarg *rw = w;
|
||||
|
||||
rw->w_needed += len;
|
||||
if (rw->w_needed <= 0 && rw->w_where) {
|
||||
if (rw->w_req) {
|
||||
if (rw->w_tmemsize < len) {
|
||||
if (rw->w_tmem)
|
||||
free(rw->w_tmem, M_RTABLE);
|
||||
@ -501,8 +505,7 @@ rt_msg2(type, rtinfo, cp, w)
|
||||
cp = rw->w_tmem;
|
||||
second_time = 1;
|
||||
goto again;
|
||||
} else
|
||||
rw->w_where = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cp) {
|
||||
@ -633,6 +636,7 @@ rt_newaddrmsg(cmd, ifa, error, rt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is used in dumping the kernel table via sysctl().
|
||||
*/
|
||||
@ -654,7 +658,7 @@ sysctl_dumpentry(rn, vw)
|
||||
netmask = rt_mask(rt);
|
||||
genmask = rt->rt_genmask;
|
||||
size = rt_msg2(RTM_GET, &info, 0, w);
|
||||
if (w->w_where && w->w_tmem) {
|
||||
if (w->w_req && w->w_tmem) {
|
||||
register struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
|
||||
|
||||
rtm->rtm_flags = rt->rt_flags;
|
||||
@ -663,11 +667,8 @@ sysctl_dumpentry(rn, vw)
|
||||
rtm->rtm_index = rt->rt_ifp->if_index;
|
||||
rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
|
||||
rtm->rtm_addrs = info.rti_addrs;
|
||||
error = copyout((caddr_t)rtm, w->w_where, size);
|
||||
if (error)
|
||||
w->w_where = NULL;
|
||||
else
|
||||
w->w_where += size;
|
||||
error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size);
|
||||
return (error);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
@ -690,7 +691,7 @@ sysctl_iflist(af, w)
|
||||
ifpaddr = ifa->ifa_addr;
|
||||
len = rt_msg2(RTM_IFINFO, &info, (caddr_t)0, w);
|
||||
ifpaddr = 0;
|
||||
if (w->w_where && w->w_tmem) {
|
||||
if (w->w_req && w->w_tmem) {
|
||||
register struct if_msghdr *ifm;
|
||||
|
||||
ifm = (struct if_msghdr *)w->w_tmem;
|
||||
@ -698,10 +699,9 @@ sysctl_iflist(af, w)
|
||||
ifm->ifm_flags = (u_short)ifp->if_flags;
|
||||
ifm->ifm_data = ifp->if_data;
|
||||
ifm->ifm_addrs = info.rti_addrs;
|
||||
error = copyout((caddr_t)ifm, w->w_where, len);
|
||||
error = SYSCTL_OUT(w->w_req,(caddr_t)ifm, len);
|
||||
if (error)
|
||||
return (error);
|
||||
w->w_where += len;
|
||||
}
|
||||
while ((ifa = ifa->ifa_next) != 0) {
|
||||
if (af && af != ifa->ifa_addr->sa_family)
|
||||
@ -710,7 +710,7 @@ sysctl_iflist(af, w)
|
||||
netmask = ifa->ifa_netmask;
|
||||
brdaddr = ifa->ifa_dstaddr;
|
||||
len = rt_msg2(RTM_NEWADDR, &info, 0, w);
|
||||
if (w->w_where && w->w_tmem) {
|
||||
if (w->w_req && w->w_tmem) {
|
||||
register struct ifa_msghdr *ifam;
|
||||
|
||||
ifam = (struct ifa_msghdr *)w->w_tmem;
|
||||
@ -718,10 +718,9 @@ sysctl_iflist(af, w)
|
||||
ifam->ifam_flags = ifa->ifa_flags;
|
||||
ifam->ifam_metric = ifa->ifa_metric;
|
||||
ifam->ifam_addrs = info.rti_addrs;
|
||||
error = copyout(w->w_tmem, w->w_where, len);
|
||||
error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
|
||||
if (error)
|
||||
return (error);
|
||||
w->w_where += len;
|
||||
}
|
||||
}
|
||||
ifaaddr = netmask = brdaddr = 0;
|
||||
@ -729,31 +728,27 @@ sysctl_iflist(af, w)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
sysctl_rtable(name, namelen, where, given, new, newlen)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
void *where;
|
||||
size_t *given;
|
||||
void *new;
|
||||
size_t newlen;
|
||||
static int
|
||||
sysctl_rtsock SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
int *name = (int *)arg1;
|
||||
u_int namelen = arg2;
|
||||
register struct radix_node_head *rnh;
|
||||
int i, s, error = EINVAL;
|
||||
u_char af;
|
||||
struct walkarg w;
|
||||
|
||||
if (new)
|
||||
name ++;
|
||||
namelen--;
|
||||
if (req->newptr)
|
||||
return (EPERM);
|
||||
if (namelen != 3)
|
||||
return (EINVAL);
|
||||
af = name[0];
|
||||
Bzero(&w, sizeof(w));
|
||||
w.w_where = where;
|
||||
w.w_given = *given;
|
||||
w.w_needed = 0 - w.w_given;
|
||||
w.w_op = name[1];
|
||||
w.w_arg = name[2];
|
||||
w.w_req = req;
|
||||
|
||||
s = splnet();
|
||||
switch (w.w_op) {
|
||||
@ -773,33 +768,26 @@ sysctl_rtable(name, namelen, where, given, new, newlen)
|
||||
splx(s);
|
||||
if (w.w_tmem)
|
||||
free(w.w_tmem, M_RTABLE);
|
||||
w.w_needed += w.w_given;
|
||||
if (where) {
|
||||
*given = w.w_where - (caddr_t)where;
|
||||
if (*given < w.w_needed)
|
||||
return (ENOMEM);
|
||||
} else {
|
||||
*given = (11 * w.w_needed) / 10;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock,"");
|
||||
|
||||
/*
|
||||
* Definitions of protocols supported in the ROUTE domain.
|
||||
*/
|
||||
|
||||
extern struct domain routedomain; /* or at least forward */
|
||||
extern struct domain routedomain; /* or at least forward */
|
||||
|
||||
struct protosw routesw[] = {
|
||||
static struct protosw routesw[] = {
|
||||
{ SOCK_RAW, &routedomain, 0, PR_ATOMIC|PR_ADDR,
|
||||
raw_input, route_output, raw_ctlinput, 0,
|
||||
route_usrreq,
|
||||
raw_init, 0, 0, 0,
|
||||
sysctl_rtable,
|
||||
raw_init
|
||||
}
|
||||
};
|
||||
|
||||
struct domain routedomain =
|
||||
static struct domain routedomain =
|
||||
{ PF_ROUTE, "route", route_init, 0, 0,
|
||||
routesw, &routesw[sizeof(routesw)/sizeof(routesw[0])] };
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: sysctl.h,v 1.32 1995/11/12 19:52:09 phk Exp $
|
||||
* $Id: sysctl.h,v 1.33 1995/11/14 09:42:10 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSCTL_H_
|
||||
@ -376,7 +376,6 @@ typedef int (sysctlfn)
|
||||
sysctlfn dev_sysctl;
|
||||
sysctlfn fs_sysctl;
|
||||
sysctlfn hw_sysctl;
|
||||
sysctlfn net_sysctl;
|
||||
|
||||
int sysctl_int __P((void *, size_t *, void *, size_t, int *));
|
||||
int sysctl_rdint __P((void *, size_t *, void *, int));
|
||||
|
Loading…
Reference in New Issue
Block a user