-.\" $OpenBSD: ifconfig.8,v 1.257 2015/10/06 17:23:21 benno Exp $
+.\" $OpenBSD: ifconfig.8,v 1.258 2015/10/23 01:19:04 dlg Exp $
.\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $
.\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $
.\"
.\"
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
.\"
-.Dd $Mdocdate: October 6 2015 $
+.Dd $Mdocdate: October 23 2015 $
.Dt IFCONFIG 8
.Os
.Sh NAME
.Op Cm tunnel Ar src_address dest_address
.Op Cm tunneldomain Ar tableid
.Op Cm vnetid Ar network-id
+.Op Cm -vnetid
.Ek
.nr nS 0
.Pp
The accepted size of the number depends on the individual tunnel protocol;
it is a 24-bit number for
.Xr vxlan 4 .
+.It Cm -vnetid
+Clear the virtual network identifier.
.El
.\" VLAN
.Sh VLAN
-/* $OpenBSD: ifconfig.c,v 1.302 2015/10/03 10:44:23 florian Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.303 2015/10/23 01:19:04 dlg Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
void settunnelinst(const char *, int);
void settunnelttl(const char *, int);
void setvnetid(const char *, int);
+void delvnetid(const char *, int);
#ifdef INET6
void setia6flags(const char *, int);
void setia6pltime(const char *, int);
{ "tunneldomain", NEXTARG, 0, settunnelinst } ,
{ "tunnelttl", NEXTARG, 0, settunnelttl } ,
{ "vnetid", NEXTARG, 0, setvnetid },
+ { "-vnetid", 0, 0, delvnetid },
{ "pppoedev", NEXTARG, 0, setpppoe_dev },
{ "pppoesvc", NEXTARG, 0, setpppoe_svc },
{ "-pppoesvc", 1, 0, setpppoe_svc },
if (dstport)
printf(":%u", ntohs(dstport));
- if (ioctl(s, SIOCGVNETID, (caddr_t)&ifr) == 0 && ifr.ifr_vnetid > 0)
+ if (ioctl(s, SIOCGVNETID, (caddr_t)&ifr) == 0)
printf(" vnetid %d", ifr.ifr_vnetid);
if (ioctl(s, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0 && ifr.ifr_ttl > 0)
printf(" ttl %d", ifr.ifr_ttl);
setvnetid(const char *id, int param)
{
const char *errmsg = NULL;
- int vnetid;
+ uint32_t vnetid;
vnetid = strtonum(id, 0, UINT_MAX, &errmsg);
if (errmsg)
warn("SIOCSVNETID");
}
+/* ARGSUSED */
+void
+delvnetid(const char *ignored, int alsoignored)
+{
+ if (ioctl(s, SIOCDVNETID, &ifr) < 0)
+ warn("SIOCDVNETID");
+}
+
void
mpe_status(void)
{
-/* $OpenBSD: if.h,v 1.169 2015/10/05 15:19:29 uebayasi Exp $ */
+/* $OpenBSD: if.h,v 1.170 2015/10/23 01:19:04 dlg Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
struct sockaddr ifru_broadaddr;
short ifru_flags;
int ifru_metric;
+ uint32_t ifru_vnetid;
uint64_t ifru_media;
caddr_t ifru_data;
} ifr_ifru;
#define ifr_hardmtu ifr_ifru.ifru_metric /* hardmtu (overload) */
#define ifr_media ifr_ifru.ifru_media /* media options */
#define ifr_rdomainid ifr_ifru.ifru_metric /* VRF instance (overload) */
-#define ifr_vnetid ifr_ifru.ifru_metric /* Virtual Net Id (overload) */
+#define ifr_vnetid ifr_ifru.ifru_vnetid /* Virtual Net Id */
#define ifr_ttl ifr_ifru.ifru_metric /* tunnel TTL (overload) */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
};
-/* $OpenBSD: if_vxlan.c,v 1.31 2015/10/15 13:59:21 yasuoka Exp $ */
+/* $OpenBSD: if_vxlan.c,v 1.32 2015/10/23 01:19:04 dlg Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
u_long vxlan_tagmask;
#define VXLAN_TAGHASHSIZE 32
-#define VXLAN_TAGHASH(tag) (tag & vxlan_tagmask)
+#define VXLAN_TAGHASH(tag) ((unsigned int)tag & vxlan_tagmask)
LIST_HEAD(vxlan_taghash, vxlan_softc) *vxlan_tagh;
void
M_WAITOK|M_ZERO);
sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
sc->sc_dstport = htons(VXLAN_PORT);
- sc->sc_vnetid = 0;
+ sc->sc_vnetid = -1;
ifp = &sc->sc_ac.ac_if;
snprintf(ifp->if_xname, sizeof ifp->if_xname, "vxlan%d", unit);
break;
case SIOCSVNETID:
- if (ifr->ifr_vnetid < 0 || ifr->ifr_vnetid > 0x00ffffff) {
+ if (ifr->ifr_vnetid > 0x00ffffff) {
error = EINVAL;
break;
}
s = splnet();
- sc->sc_vnetid = (u_int32_t)ifr->ifr_vnetid;
+ sc->sc_vnetid = (int)ifr->ifr_vnetid;
(void)vxlan_config(ifp, NULL, NULL);
splx(s);
break;
case SIOCGVNETID:
- ifr->ifr_vnetid = (int)sc->sc_vnetid;
+ if (sc->sc_vnetid == -1) {
+ error = EADDRNOTAVAIL;
+ break;
+ }
+ ifr->ifr_vnetid = (uint32_t)sc->sc_vnetid;
+ break;
+
+ case SIOCDVNETID:
+ s = splnet();
+ sc->sc_vnetid = -1;
+ (void)vxlan_config(ifp, NULL, NULL);
+ splx(s);
break;
default:
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct vxlan_softc *sc = NULL, *sc_cand = NULL;
struct vxlan_header v;
- u_int32_t vni;
+ int vni;
struct ifnet *ifp;
int skip;
struct ether_header *eh;
m_copydata(m, skip, sizeof(v), (caddr_t)&v);
skip += sizeof(v);
- vni = ntohl(v.vxlan_id);
-
- /* Validate header */
- if ((vni == 0) || (vni & VXLAN_RESERVED2) ||
- (ntohl(v.vxlan_flags) != VXLAN_FLAGS_VNI))
+ if (v.vxlan_flags & htonl(VXLAN_RESERVED1) ||
+ v.vxlan_id & htonl(VXLAN_RESERVED2))
return (0);
- vni >>= VXLAN_VNI_S;
+ vni = ntohl(v.vxlan_id) >> VXLAN_VNI_S;
+ if ((v.vxlan_flags & htonl(VXLAN_FLAGS_VNI)) != 0) {
+ if (vni != 0)
+ return (0);
+
+ vni = -1;
+ }
+
LIST_FOREACH(sc, &vxlan_tagh[VXLAN_TAGHASH(vni)], sc_entry) {
if ((uh->uh_dport == sc->sc_dstport) &&
vni == sc->sc_vnetid &&
#endif
vi = (struct vxlanudpiphdr *)ui;
- vi->ui_v.vxlan_flags = htonl(VXLAN_FLAGS_VNI);
- vi->ui_v.vxlan_id = htonl(sc->sc_vnetid << VXLAN_VNI_S);
+ if (sc->sc_vnetid != -1) {
+ vi->ui_v.vxlan_flags = htonl(VXLAN_FLAGS_VNI);
+ vi->ui_v.vxlan_id = htonl(sc->sc_vnetid << VXLAN_VNI_S);
+ } else {
+ vi->ui_v.vxlan_flags = htonl(0);
+ vi->ui_v.vxlan_id = htonl(0);
+ }
/* UDP checksum should be 0 */
ui->ui_sum = 0;
-/* $OpenBSD: if_vxlan.h,v 1.6 2014/12/19 17:14:40 tedu Exp $ */
+/* $OpenBSD: if_vxlan.h,v 1.7 2015/10/23 01:19:04 dlg Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
struct sockaddr_storage sc_dst;
in_port_t sc_dstport;
u_int sc_rdomain;
- u_int32_t sc_vnetid;
+ int sc_vnetid;
u_int8_t sc_ttl;
LIST_ENTRY(vxlan_softc) sc_entry;
-/* $OpenBSD: sockio.h,v 1.60 2015/09/11 13:02:28 stsp Exp $ */
+/* $OpenBSD: sockio.h,v 1.61 2015/10/23 01:19:04 dlg Exp $ */
/* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */
/*-
#define SIOCSETMPWCFG _IOW('i', 173, struct ifreq) /* set mpw config */
#define SIOCGETMPWCFG _IOWR('i', 174, struct ifreq) /* get mpw config */
+#define SIOCDVNETID _IOW('i', 175, struct ifreq) /* del virt net id */
+
#define SIOCSVH _IOWR('i', 245, struct ifreq) /* set carp param */
#define SIOCGVH _IOWR('i', 246, struct ifreq) /* get carp param */