>Synopsis: nvgre_up() never calls etherbridge_up(), so the address
table's ageing timeout is never started. Learned entries
are never removed; once "maxaddr" entries (default 100)
have been learned, nvgre(4) stops learning, and because
lookups ignore entries older than the timeout, traffic to
every destination is then sent to the multicast group.
>Category: kernel
>Severity: non-critical
>Priority: low
>Class: sw-bug
>Release: OpenBSD 8.0-current (source as of 2026-11-08, master afb08c4d5)
>Environment:
System : OpenBSD 8.0-current
Details : OpenBSD 8.0-current (GENERIC.MP)
Architecture: OpenBSD.amd64
Machine : amd64 (QEMU/KVM guest, 2 vcpu)
Source : sys/net/if_gre.c, sys/net/if_etherbridge.c;
master afb08c4d5 (same code in d5b06e73)
>Description:
nvgre(4), vxlan(4), bpe(4) and veb(4) share the etherbridge(9)-style
learning table in sys/net/if_etherbridge.c. The table is aged by
etherbridge_age(), a timeout that re-arms itself every 100 seconds
and removes dynamic entries older than the configured "timeout".
The timeout is started by etherbridge_up(), which each driver calls
when the interface is brought up:
vxlan_up() etherbridge_up(&sc->sc_eb) if_vxlan.c:1129
bpe_up() etherbridge_up(&sc->sc_eb) if_bpe.c:448
veb_up() etherbridge_up(&sc->sc_eb) if_veb.c:3287
nvgre_up() (if_gre.c:3486) does not call it, so on an
nvgre(4) interface the ageing timeout never runs:
- learned entries are never removed, whatever "timeout" is set to;
- etherbridge_map() stops adding entries once eb_num reaches
eb_max ("maxaddr", default 100), so after 100 distinct source
addresses nvgre(4) never learns again;
- etherbridge_resolve() ignores entries older than the timeout,
so those stale entries are not used either, and frames to every
destination go to the tunnel's multicast group.
This is not a crash; it makes the learning table useless on a busy
nvgre(4) segment.
>How-To-Repeat:
Two nvgre(4) endpoints in rdomains 201 and 202 over a pair(4)
cable; frames with 100 different source addresses are sent out of
the 202 side, and the 201 side learns them:
sysctl net.inet.gre.allow=1
ifconfig pair201 create rdomain 201 up
ifconfig pair201 inet 192.0.2.1/24
ifconfig pair202 create rdomain 202 up
ifconfig pair202 inet 192.0.2.2/24
ifconfig pair201 patch pair202
ifconfig nvgre201 create
ifconfig nvgre202 create
ifconfig nvgre201 tunneldomain 201 tunnel 192.0.2.1 239.0.2.1 \
parent pair201 vnetid 300
ifconfig nvgre202 tunneldomain 202 tunnel 192.0.2.2 239.0.2.1 \
parent pair202 vnetid 300
ifconfig nvgre201 timeout 10
ifconfig nvgre201 up
ifconfig nvgre202 up
./macinj nvgre202 100 # program below
ifconfig nvgre201 addr | grep -c 02:eb:00 # 100
sleep 115 # > timeout + one 100 s age pass
ifconfig nvgre201 addr | grep -c 02:eb:00 # still 100
./macinj nvgre202 1 1 # one new source address
ifconfig nvgre201 addr | grep -c 02:eb:00:01 # 0: not learned
The same steps with vxlan(4) instead of nvgre(4) (another group,
e.g. 239.0.2.2) show 0 entries after the sleep and the new address
learned.
macinj.c writes N Ethernet frames with source addresses
02:eb:00:BASE:hi:lo out of an interface through bpf(4):
/* macinj IFACE N [BASE] -- write N ethernet frames out of IFACE
via bpf,
* each with a different source MAC 02:eb:00:BASE:hi:lo, dst
broadcast,
* ethertype 0x88b5 (local experimental), so the far end of a tunnel
* learns N addresses. */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/bpf.h>
#include <err.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
struct ifreq ifr;
unsigned char f[60];
u_int one = 1;
int fd, i, n, base;
if (argc < 3)
errx(2, "usage: macinj iface n [base]");
n = atoi(argv[2]);
base = argc > 3 ? atoi(argv[3]) : 0;
if ((fd = open("/dev/bpf", O_RDWR)) == -1)
err(1, "/dev/bpf");
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, &ifr) == -1)
err(1, "BIOCSETIF %s", argv[1]);
if (ioctl(fd, BIOCSHDRCMPLT, &one) == -1)
err(1, "BIOCSHDRCMPLT");
memset(f, 0, sizeof(f));
memset(f, 0xff, 6);
f[12] = 0x88; f[13] = 0xb5;
for (i = 0; i < n; i++) {
f[6] = 0x02; f[7] = 0xeb; f[8] = 0x00; f[9] = base &
0xff;
f[10] = (i >> 8) & 0xff; f[11] = i & 0xff;
if (write(fd, f, sizeof(f)) != sizeof(f))
warn("write %d", i);
}
close(fd);
return (0);
}
>Fix:
Please consider this diff for discussion. It starts the ageing
timeout in nvgre_up(), like vxlan(4) and bpe(4) do. It takes no
lock and adds nothing under NET_LOCK; etherbridge_up() only runs
etherbridge_age() once, which arms the 100 s timeout.
We did not add an etherbridge_down() call to nvgre_down():
etherbridge_down() is only an smr_barrier(), and vxlan(4) and
bpe(4) also leave the ageing timeout running while the interface is
down (it is stopped in etherbridge_destroy()). If you prefer
nvgre_down() to mirror bpe_down() there, that would be a small
addition we have not tested.
Index: sys/net/if_gre.c
===================================================================
--- sys/net/if_gre.c
+++ sys/net/if_gre.c
@@ -3539,6 +3539,8 @@ nvgre_up(struct nvgre_softc *sc)
if_put(ifp0);
sc->sc_inm = inm;
+ /* start aging learned addresses, like vxlan(4) and bpe(4) */
+ etherbridge_up(&sc->sc_eb);
SET(sc->sc_ac.ac_if.if_flags, IFF_RUNNING);
return (0);
>Verification:
master afb08c4d5 GENERIC.MP, amd64, both kernels built without
warnings from one clean tree: unpatched md5 eaeed0ca, patched
(the diff above, patch -p0 -F0; it applies to d5b06e73 with offset
3) md5 10272f74. Fresh boot before every run, 2 vcpus, the
How-To-Repeat run by a script:
unpatched patched
nvgre, after 115 s 100/100 left, 3/3 0 left, 3/3
new address learned no, 3/3 yes, 3/3
vxlan (control) 0 left, learned 0 left, learned
Normal use on the patched kernel, 3/3, 7 checks each, no kernel
messages (net.inet.gre.allow=1): two nvgre(4) over a pair(4) link
between rdomains, ping across, down/up and ping again, "-tunnel"
and "tunnel" while down then up and ping again, destroy both.