summaryrefslogtreecommitdiffstats
path: root/sys/netmpls
diff options
context:
space:
mode:
authorgnezdo <gnezdo@openbsd.org>2020-08-19 19:22:53 +0000
committergnezdo <gnezdo@openbsd.org>2020-08-19 19:22:53 +0000
commitd662a1c7f214b3ba6dd259963bb1e9ac9927e2fd (patch)
tree1cad28a8c000e5b16071fbbbca57b9920bade52d /sys/netmpls
parentRestructure traffic selector payload parsing. Add additional size and (diff)
downloadwireguard-openbsd-d662a1c7f214b3ba6dd259963bb1e9ac9927e2fd.tar.xz
wireguard-openbsd-d662a1c7f214b3ba6dd259963bb1e9ac9927e2fd.zip
Convert mpls_sysctl to sysctl_bounded_args
OK claudio@
Diffstat (limited to 'sys/netmpls')
-rw-r--r--sys/netmpls/mpls.h12
-rw-r--r--sys/netmpls/mpls_raw.c19
2 files changed, 9 insertions, 22 deletions
diff --git a/sys/netmpls/mpls.h b/sys/netmpls/mpls.h
index 94b423aa7e4..36bea7c8eab 100644
--- a/sys/netmpls/mpls.h
+++ b/sys/netmpls/mpls.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpls.h,v 1.43 2019/11/05 08:26:38 claudio Exp $ */
+/* $OpenBSD: mpls.h,v 1.44 2020/08/19 19:22:53 gnezdo Exp $ */
/*
* Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
@@ -124,16 +124,6 @@ struct rt_mpls {
{ "mapttl_ip6", CTLTYPE_INT } \
}
-#define MPLSCTL_VARS { \
- NULL, \
- NULL, \
- &mpls_defttl, \
- NULL, \
- NULL, \
- &mpls_mapttl_ip, \
- &mpls_mapttl_ip6 \
-}
-
#define IMR_TYPE_NONE 0
#define IMR_TYPE_ETHERNET 1
#define IMR_TYPE_ETHERNET_TAGGED 2
diff --git a/sys/netmpls/mpls_raw.c b/sys/netmpls/mpls_raw.c
index dd6c0f62e41..d663eceff61 100644
--- a/sys/netmpls/mpls_raw.c
+++ b/sys/netmpls/mpls_raw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpls_raw.c,v 1.17 2020/08/01 23:41:56 gnezdo Exp $ */
+/* $OpenBSD: mpls_raw.c,v 1.18 2020/08/19 19:22:53 gnezdo Exp $ */
/*
* Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
@@ -51,19 +51,16 @@ int mpls_push_expnull_ip6 = 0;
int mpls_mapttl_ip = 1;
int mpls_mapttl_ip6 = 0;
-int *mplsctl_vars[MPLSCTL_MAXID] = MPLSCTL_VARS;
+const struct sysctl_bounded_args mplsctl_vars[] = {
+ { MPLSCTL_DEFTTL, &mpls_defttl, 0, 255 },
+ { MPLSCTL_MAPTTL_IP, &mpls_mapttl_ip, 0, 1 },
+ { MPLSCTL_MAPTTL_IP6, &mpls_mapttl_ip6, 0, 1 },
+};
int
mpls_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
- /* Almost all sysctl names at this level are terminal. */
- if (namelen != 1)
- return (ENOTDIR);
-
- switch (name[0]) {
- default:
- return sysctl_int_arr(mplsctl_vars, nitems(mplsctl_vars), name,
- namelen, oldp, oldlenp, newp, newlen);
- }
+ return sysctl_bounded_arr(mplsctl_vars, nitems(mplsctl_vars),
+ name, namelen, oldp, oldlenp, newp, newlen);
}