summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-04-19 07:39:38 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-04-19 07:39:38 +0000
commita16f10e1f68d2183c1a54b699e848e3711273b75 (patch)
tree14cd0511bd7b9785ebe95f27657864057cfbf832 /sys
parentff5b339875e7f79bf5360040db863efaa26bac4c (diff)
use the factored out txhprio and rxhprio checks
reduces code duplication and chance for error.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_bpe.c19
-rw-r--r--sys/net/if_etherip.c19
-rw-r--r--sys/net/if_gif.c21
-rw-r--r--sys/net/if_mpe.c21
-rw-r--r--sys/net/if_mpip.c21
-rw-r--r--sys/net/if_mpw.c19
-rw-r--r--sys/net/if_vlan.c19
7 files changed, 35 insertions, 104 deletions
diff --git a/sys/net/if_bpe.c b/sys/net/if_bpe.c
index 7b34a02dd13..c307a4caf76 100644
--- a/sys/net/if_bpe.c
+++ b/sys/net/if_bpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bpe.c,v 1.3 2019/04/19 06:40:00 dlg Exp $ */
+/* $OpenBSD: if_bpe.c,v 1.4 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
*
@@ -482,13 +482,9 @@ bpe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET) /* use mbuf prio */
- ;
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_txhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_txhprio = ifr->ifr_hdrprio;
break;
@@ -497,14 +493,9 @@ bpe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSRXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_OUTER ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PACKET) /* use mbuf prio */
- ;
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_rxhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_rxhprio = ifr->ifr_hdrprio;
break;
diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index 7433fdf12ab..cbf8b58700b 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_etherip.c,v 1.43 2019/04/19 06:38:32 dlg Exp $ */
+/* $OpenBSD: if_etherip.c,v 1.44 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
@@ -289,13 +289,9 @@ etherip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET) /* use mbuf prio */
- ;
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_txhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_txhprio = ifr->ifr_hdrprio;
break;
@@ -304,14 +300,9 @@ etherip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSRXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_OUTER ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PACKET) /* use mbuf prio */
- ;
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_rxhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_rxhprio = ifr->ifr_hdrprio;
break;
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 8b569308379..49b163d1ef8 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.126 2019/04/19 04:54:53 dlg Exp $ */
+/* $OpenBSD: if_gif.c,v 1.127 2019/04/19 07:39:37 dlg Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -555,14 +555,9 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PAYLOAD ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PACKET)
- ; /* ok, fall through */
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_txhprio_l3_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_txhprio = ifr->ifr_hdrprio;
break;
@@ -571,15 +566,9 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSRXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PAYLOAD ||
- ifr->ifr_hdrprio == IF_HDRPRIO_PACKET ||
- ifr->ifr_hdrprio == IF_HDRPRIO_OUTER)
- ; /* ok, fall through */
- else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
- ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
- error = EINVAL;
+ error = if_rxhprio_l3_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_rxhprio = ifr->ifr_hdrprio;
break;
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;
diff --git a/sys/net/if_mpip.c b/sys/net/if_mpip.c
index f82072be4d4..8843afd5bcf 100644
--- a/sys/net/if_mpip.c
+++ b/sys/net/if_mpip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpip.c,v 1.6 2019/04/19 06:36:54 dlg Exp $ */
+/* $OpenBSD: if_mpip.c,v 1.7 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright (c) 2015 Rafael Zalamena <rzalamena@openbsd.org>
@@ -420,14 +420,9 @@ mpip_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 @@ mpip_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;
diff --git a/sys/net/if_mpw.c b/sys/net/if_mpw.c
index 67d081491fd..9ef833404e3 100644
--- a/sys/net/if_mpw.c
+++ b/sys/net/if_mpw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpw.c,v 1.52 2019/04/19 06:36:54 dlg Exp $ */
+/* $OpenBSD: if_mpw.c,v 1.53 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright (c) 2015 Rafael Zalamena <rzalamena@openbsd.org>
@@ -470,13 +470,9 @@ mpw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_txhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_txhprio = ifr->ifr_hdrprio;
break;
@@ -485,14 +481,9 @@ mpw_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_OUTER)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_rxhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
sc->sc_rxhprio = ifr->ifr_hdrprio;
break;
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 74dd2b295ed..bcc3f9cc980 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vlan.c,v 1.184 2019/04/19 04:36:11 dlg Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.185 2019/04/19 07:39:37 dlg Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
@@ -734,13 +734,9 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCSTXHPRIO:
- if (ifr->ifr_hdrprio == IF_HDRPRIO_PACKET)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_txhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
ifv->ifv_prio = ifr->ifr_hdrprio;
break;
@@ -749,14 +745,9 @@ vlan_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_OUTER)
- ;
- else if (ifr->ifr_hdrprio > IF_HDRPRIO_MAX ||
- ifr->ifr_hdrprio < IF_HDRPRIO_MIN) {
- error = EINVAL;
+ error = if_rxhprio_l2_check(ifr->ifr_hdrprio);
+ if (error != 0)
break;
- }
ifv->ifv_rxprio = ifr->ifr_hdrprio;
break;