-/* $OpenBSD: if_vxlan.c,v 1.40 2016/08/06 14:33:33 reyk Exp $ */
+/* $OpenBSD: if_vxlan.c,v 1.41 2016/08/07 13:49:12 reyk Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
M_WAITOK|M_ZERO);
sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
sc->sc_dstport = htons(VXLAN_PORT);
- sc->sc_vnetid = -1;
+ sc->sc_vnetid = VXLAN_VNI_UNSET;
ifp = &sc->sc_ac.ac_if;
snprintf(ifp->if_xname, sizeof ifp->if_xname, "vxlan%d", unit);
break;
case SIOCSVNETID:
- if (ifr->ifr_vnetid > 0x00ffffff) {
+ if (ifr->ifr_vnetid > VXLAN_VNI_MAX) {
error = EINVAL;
break;
}
break;
case SIOCGVNETID:
- if (sc->sc_vnetid == -1) {
+ if (sc->sc_vnetid == VXLAN_VNI_UNSET) {
error = EADDRNOTAVAIL;
break;
}
case SIOCDVNETID:
s = splnet();
- sc->sc_vnetid = -1;
+ sc->sc_vnetid = VXLAN_VNI_UNSET;
(void)vxlan_config(ifp, NULL, NULL);
splx(s);
break;
if (vni != 0)
return (0);
- vni = -1;
+ vni = VXLAN_VNI_UNSET;
}
LIST_FOREACH(sc, &vxlan_tagh[VXLAN_TAGHASH(vni)], sc_entry) {
}
#endif
- if (sc->sc_vnetid != -1) {
+ if (sc->sc_vnetid != VXLAN_VNI_UNSET) {
vu->vu_v.vxlan_flags = htonl(VXLAN_FLAGS_VNI);
vu->vu_v.vxlan_id = htonl(sc->sc_vnetid << VXLAN_VNI_S);
} else {
-/* $OpenBSD: if_vxlan.h,v 1.9 2016/08/06 14:33:33 reyk Exp $ */
+/* $OpenBSD: if_vxlan.h,v 1.10 2016/08/07 13:49:12 reyk Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
#define VXLAN_RESERVED2 0x000000ff
} __packed;
+#define VXLAN_VNI_MAX 0x00ffffff /* 24bit vnetid */
+#define VXLAN_VNI_UNSET 0xffffffff /* -1 */
+
struct vxlanudphdr {
struct udphdr vu_u;
struct vxlan_header vu_v;