From 8eae72405e506095b814e9bd6c109c9f644c537c Mon Sep 17 00:00:00 2001 From: dlg Date: Sat, 24 Feb 2018 07:20:04 +0000 Subject: [PATCH] when comparing nvgre entries, compare a with b, not a with itself. --- sys/net/if_gre.c | 5 ++--- sys/net/if_tun.c | 11 +++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 91fbbf32d0e..d5516223214 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.112 2018/02/22 09:47:12 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.113 2018/02/24 07:20:04 dlg Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -1055,7 +1055,6 @@ nvgre_input_map(struct nvgre_softc *sc, const struct gre_tunnel *key, return; } - memcpy(&nv->nv_dst, eh->ether_shost, ETHER_ADDR_LEN); memcpy(&nv->nv_dst, eh->ether_shost, ETHER_ADDR_LEN); nv->nv_type = NVGRE_ENTRY_DYNAMIC; nv->nv_gateway = key->t_dst; @@ -2889,7 +2888,7 @@ RBT_GENERATE(egre_tree, egre_softc, sc_entry, egre_cmp); static inline int nvgre_entry_cmp(const struct nvgre_entry *a, const struct nvgre_entry *b) { - return (memcmp(&a->nv_dst, &a->nv_dst, sizeof(a->nv_dst))); + return (memcmp(&a->nv_dst, &b->nv_dst, sizeof(a->nv_dst))); } RBT_GENERATE(nvgre_map, nvgre_entry, nv_entry, nvgre_entry_cmp); diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 81dd0148a3f..33f97655d53 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.180 2018/01/09 15:24:24 bluhm Exp $ */ +/* $OpenBSD: if_tun.c,v 1.181 2018/02/24 07:20:04 dlg Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -614,7 +614,6 @@ tun_dev_ioctl(struct tun_softc *tp, u_long cmd, caddr_t data, int flag, struct proc *p) { struct tuninfo *tunp; - struct mbuf *m; switch (cmd) { case TUNSIFINFO: @@ -668,12 +667,8 @@ tun_dev_ioctl(struct tun_softc *tp, u_long cmd, caddr_t data, int flag, tp->tun_flags &= ~TUN_ASYNC; break; case FIONREAD: - m = ifq_deq_begin(&tp->tun_if.if_snd); - if (m != NULL) { - *(int *)data = m->m_pkthdr.len; - ifq_deq_rollback(&tp->tun_if.if_snd, m); - } else - *(int *)data = 0; + *(int *)data = ifq_empty(&tp->tun_if.if_snd) ? + 0 : tp->tun_if.if_mtu; break; case TIOCSPGRP: tp->tun_pgid = *(int *)data; -- 2.20.1