summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/net/bpf.h3
-rw-r--r--sys/net/bpf_filter.c7
2 files changed, 8 insertions, 2 deletions
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 2232d1325e7..f5e0fa91e69 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.h,v 1.69 2020/06/18 23:27:58 dlg Exp $ */
+/* $OpenBSD: bpf.h,v 1.70 2020/08/03 03:21:24 dlg Exp $ */
/* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */
/*
@@ -237,6 +237,7 @@ struct bpf_hdr {
#define BPF_MEM 0x60
#define BPF_LEN 0x80
#define BPF_MSH 0xa0
+#define BPF_RND 0xc0
/* alu/jmp fields */
#define BPF_OP(code) ((code) & 0xf0)
diff --git a/sys/net/bpf_filter.c b/sys/net/bpf_filter.c
index e46bf0799ba..d6561ec5923 100644
--- a/sys/net/bpf_filter.c
+++ b/sys/net/bpf_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf_filter.c,v 1.33 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: bpf_filter.c,v 1.34 2020/08/03 03:21:24 dlg Exp $ */
/* $NetBSD: bpf_filter.c,v 1.12 1996/02/13 22:00:00 christos Exp $ */
/*
@@ -199,6 +199,10 @@ _bpf_filter(const struct bpf_insn *pc, const struct bpf_ops *ops,
X = wirelen;
continue;
+ case BPF_LD|BPF_W|BPF_RND:
+ A = arc4random();
+ continue;
+
case BPF_LD|BPF_W|BPF_IND:
k = X + pc->k;
A = ops->ldw(pkt, k, &err);
@@ -414,6 +418,7 @@ bpf_validate(struct bpf_insn *f, int len)
return 0;
break;
case BPF_LEN:
+ case BPF_RND:
break;
default:
return 0;