diff options
author | 2020-12-10 04:27:07 +0000 | |
---|---|---|
committer | 2020-12-10 04:27:07 +0000 | |
commit | d876473e1f84b0d76676e51c273e936818673d87 (patch) | |
tree | d6caf82121b16ecfb6c714890b5be7398ac89e3c | |
parent | Use sysctl_int_bounded for sysctl_hwsetperf (diff) | |
download | wireguard-openbsd-d876473e1f84b0d76676e51c273e936818673d87.tar.xz wireguard-openbsd-d876473e1f84b0d76676e51c273e936818673d87.zip |
Convert gre_sysctl to sysctl_bounded_arr
Fixed up a reference to gre_wccp where a fixed value from wwcp
standard was intended.
ok gkoehler@
-rw-r--r-- | sys/net/if_gre.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index cb5beeaad62..ca23567b3ca 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.161 2020/11/03 04:47:01 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.162 2020/12/10 04:27:07 gnezdo Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -1109,7 +1109,7 @@ gre_input_key(struct mbuf **mp, int *offp, int type, int af, uint8_t otos, if (n == NULL) goto decline; if (n->m_data[off] >> 4 != IPVERSION) - hlen += sizeof(gre_wccp); + hlen += 4; /* four-octet Redirect header */ /* FALLTHROUGH */ } @@ -4229,31 +4229,22 @@ drop: return (NULL); } +const struct sysctl_bounded_args gre_vars[] = { + { GRECTL_ALLOW, &gre_allow, 0, 1 }, + { GRECTL_WCCP, &gre_wccp, 0, 1 }, +}; + int gre_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { int error; - /* All sysctl names at this level are terminal. */ - if (namelen != 1) - return (ENOTDIR); - - switch (name[0]) { - case GRECTL_ALLOW: - NET_LOCK(); - error = sysctl_int(oldp, oldlenp, newp, newlen, &gre_allow); - NET_UNLOCK(); - return (error); - case GRECTL_WCCP: - NET_LOCK(); - error = sysctl_int(oldp, oldlenp, newp, newlen, &gre_wccp); - NET_UNLOCK(); - return (error); - default: - return (ENOPROTOOPT); - } - /* NOTREACHED */ + NET_LOCK(); + error = sysctl_bounded_arr(gre_vars, nitems(gre_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return error; } static inline int |