summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-04-19 07:38:02 +0000
committerdlg <dlg@openbsd.org>2019-04-19 07:38:02 +0000
commit7ebcb64786cdf01cb1713741d80a1a1d813641f7 (patch)
tree3a78047625ef23190e6084de2154cf488f92f490 /sys/net/if.c
parentadd rxprio support (diff)
downloadwireguard-openbsd-7ebcb64786cdf01cb1713741d80a1a1d813641f7.tar.xz
wireguard-openbsd-7ebcb64786cdf01cb1713741d80a1a1d813641f7.zip
provide factored out txhprio and rxhprio checks
l2 and l3 drivers do the same thing all the time, so reduce the chance of error by doing the checks once and making it available for drivers to call instead of rolling on their own again.
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 473c9d2a1bf..88b79a6cdda 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.577 2019/04/19 04:22:09 dlg Exp $ */
+/* $OpenBSD: if.c,v 1.578 2019/04/19 07:38:02 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -2335,6 +2335,70 @@ if_sffpage_check(const caddr_t data)
return (0);
}
+int
+if_txhprio_l2_check(int hdrprio)
+{
+ switch (hdrprio) {
+ case IF_HDRPRIO_PACKET:
+ return (0);
+ default:
+ if (hdrprio >= IF_HDRPRIO_MIN && hdrprio <= IF_HDRPRIO_MAX)
+ return (0);
+ break;
+ }
+
+ return (EINVAL);
+}
+
+int
+if_txhprio_l3_check(int hdrprio)
+{
+ switch (hdrprio) {
+ case IF_HDRPRIO_PACKET:
+ case IF_HDRPRIO_PAYLOAD:
+ return (0);
+ default:
+ if (hdrprio >= IF_HDRPRIO_MIN && hdrprio <= IF_HDRPRIO_MAX)
+ return (0);
+ break;
+ }
+
+ return (EINVAL);
+}
+
+int
+if_rxhprio_l2_check(int hdrprio)
+{
+ switch (hdrprio) {
+ case IF_HDRPRIO_PACKET:
+ case IF_HDRPRIO_OUTER:
+ return (0);
+ default:
+ if (hdrprio >= IF_HDRPRIO_MIN && hdrprio <= IF_HDRPRIO_MAX)
+ return (0);
+ break;
+ }
+
+ return (EINVAL);
+}
+
+int
+if_rxhprio_l3_check(int hdrprio)
+{
+ switch (hdrprio) {
+ case IF_HDRPRIO_PACKET:
+ case IF_HDRPRIO_PAYLOAD:
+ case IF_HDRPRIO_OUTER:
+ return (0);
+ default:
+ if (hdrprio >= IF_HDRPRIO_MIN && hdrprio <= IF_HDRPRIO_MAX)
+ return (0);
+ break;
+ }
+
+ return (EINVAL);
+}
+
/*
* Return interface configuration
* of system. List may be used