summaryrefslogtreecommitdiffstats
path: root/sys/net/if_mpe.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-04-19 07:39:37 +0000
committerdlg <dlg@openbsd.org>2019-04-19 07:39:37 +0000
commitb9e5cef3e33b510a78a24f49dc93bd20a0629044 (patch)
treeee382161b1e5022587fb4335e0440f1cd5e77cdc /sys/net/if_mpe.c
parentprovide factored out txhprio and rxhprio checks (diff)
downloadwireguard-openbsd-b9e5cef3e33b510a78a24f49dc93bd20a0629044.tar.xz
wireguard-openbsd-b9e5cef3e33b510a78a24f49dc93bd20a0629044.zip
use the factored out txhprio and rxhprio checks
reduces code duplication and chance for error.
Diffstat (limited to 'sys/net/if_mpe.c')
-rw-r--r--sys/net/if_mpe.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c
index 1cfe92739e9..b037e053038 100644
--- a/sys/net/if_mpe.c
+++ b/sys/net/if_mpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpe.c,v 1.92 2019/04/19 06:36:54 dlg Exp $ */
+/* $OpenBSD: if_mpe.c,v 1.93 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -420,14 +420,9 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PAYLOAD)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_txhprio_l3_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_txhprio = ifr->ifr_hdrprio;
break;
@@ -436,15 +431,9 @@ mpe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSRXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PAYLOAD ||
- ifr->ifr_hdrprio == IF_HDRPRIO_OUTER)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_rxhprio_l3_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_rxhprio = ifr->ifr_hdrprio;
break;