From: dlg Date: Tue, 20 Feb 2018 03:45:06 +0000 (+0000) Subject: add support for toggling partitioning a vnetid into a netid and flowid X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1e2f588cd63fccc65e087a7d0d0d97a869543a11;p=openbsd add support for toggling partitioning a vnetid into a netid and flowid "vnetflowid" enables it on an interface, and "-vnetflowid" disables it. a vnetid will be suffixed with + on the encap line if it an interface reports that it is enabled. --- diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 8ed4be343ce..8437f2ef533 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.301 2018/02/19 06:48:45 jmc Exp $ +.\" $OpenBSD: ifconfig.8,v 1.302 2018/02/20 03:45:06 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 $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: February 19 2018 $ +.Dd $Mdocdate: February 20 2018 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -1605,6 +1605,7 @@ for a complete list of the available protocols. .Op Cm tunneldomain Ar tableid .Op Oo Fl Oc Ns Cm tunneldf .Op Cm tunnelttl Ar ttl +.Op Oo Fl Oc Ns Cm vnetflowid .Op Oo Fl Oc Ns Cm vnetid Ar network-id .Ek .nr nS 0 @@ -1666,6 +1667,13 @@ the value can also be set to .Ar copy to have the TTL copied between the encapsulated protocol headers and the tunnel protocol headers. +.It Cm vnetflowid +Use a portion of the virtual network identifier space for a flow identifier. +This allows load balancing of the encapsulated traffic over multiple +links. +.It Cm -vnetflowid +Disable the use of portion of the virtual network identifier as a +flow identifier. .It Cm vnetid Ar network-id Set the virtual network identifier. This is a number which is used by tunnel protocols such as diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 88956f0d7ff..a1a8b787b43 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.358 2018/02/19 00:23:57 dlg Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.359 2018/02/20 03:45:06 dlg Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -121,6 +121,23 @@ "\5VLAN_MTU\6VLAN_HWTAGGING\10CSUM_TCPv6" \ "\11CSUM_UDPv6\20WOL" +struct ifencap { + unsigned int ife_flags; +#define IFE_VNETID_MASK 0xf +#define IFE_VNETID_NOPE 0x0 +#define IFE_VNETID_NONE 0x1 +#define IFE_VNETID_ANY 0x2 +#define IFE_VNETID_SET 0x3 + int64_t ife_vnetid; +#define IFE_VNETFLOWID 0x10 + +#define IFE_PARENT_MASK 0xf00 +#define IFE_PARENT_NOPE 0x000 +#define IFE_PARENT_NONE 0x100 +#define IFE_PARENT_SET 0x200 + char ife_parent[IFNAMSIZ]; +}; + struct ifreq ifr, ridreq; struct in_aliasreq in_addreq; struct in6_ifreq ifr6; @@ -252,6 +269,9 @@ void setpfsync_syncpeer(const char *, int); void unsetpfsync_syncpeer(const char *, int); void setpfsync_defer(const char *, int); void pfsync_status(void); +void setvnetflowid(const char *, int); +void delvnetflowid(const char *, int); +void getvnetflowid(struct ifencap *); void settunneldf(const char *, int); void settunnelnodf(const char *, int); void setpppoe_dev(const char *,int); @@ -438,6 +458,8 @@ const struct cmd { { "tunnelttl", NEXTARG, 0, settunnelttl }, { "tunneldf", 0, 0, settunneldf }, { "-tunneldf", 0, 0, settunnelnodf }, + { "vnetflowid", 0, 0, setvnetflowid }, + { "-vnetflowid", 0, 0, delvnetflowid }, { "pppoedev", NEXTARG, 0, setpppoe_dev }, { "pppoesvc", NEXTARG, 0, setpppoe_svc }, { "-pppoesvc", 1, 0, setpppoe_svc }, @@ -3311,6 +3333,44 @@ settunnelnodf(const char *ignored, int alsoignored) warn("SIOCSLIFPHYDF"); } +void +setvnetflowid(const char *ignored, int alsoignored) +{ + if (strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)) >= + sizeof(ifr.ifr_name)) + errx(1, "vnetflowid: name is too long"); + + ifr.ifr_vnetid = 1; + if (ioctl(s, SIOCSVNETFLOWID, &ifr) < 0) + warn("SIOCSVNETFLOWID"); +} + +void +delvnetflowid(const char *ignored, int alsoignored) +{ + if (strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)) >= + sizeof(ifr.ifr_name)) + errx(1, "vnetflowid: name is too long"); + + ifr.ifr_vnetid = 0; + if (ioctl(s, SIOCSVNETFLOWID, &ifr) < 0) + warn("SIOCSVNETFLOWID"); +} + +void +getvnetflowid(struct ifencap *ife) +{ + if (strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)) >= + sizeof(ifr.ifr_name)) + errx(1, "vnetflowid: name is too long"); + + if (ioctl(s, SIOCGVNETFLOWID, &ifr) == -1) + return; + + if (ifr.ifr_vnetid) + ife->ife_flags |= IFE_VNETFLOWID; +} + void mpe_status(void) { @@ -3497,22 +3557,6 @@ setmpwcontrolword(const char *value, int d) } #endif /* SMALL */ -struct ifencap { - unsigned int ife_flags; -#define IFE_VNETID_MASK 0xf -#define IFE_VNETID_NOPE 0x0 -#define IFE_VNETID_NONE 0x1 -#define IFE_VNETID_ANY 0x2 -#define IFE_VNETID_SET 0x3 - int64_t ife_vnetid; - -#define IFE_PARENT_MASK 0xf0 -#define IFE_PARENT_NOPE 0x00 -#define IFE_PARENT_NONE 0x10 -#define IFE_PARENT_SET 0x20 - char ife_parent[IFNAMSIZ]; -}; - void setvnetid(const char *id, int param) { @@ -3619,6 +3663,7 @@ getencap(void) struct ifencap ife = { .ife_flags = 0 }; getvnetid(&ife); + getvnetflowid(&ife); getifparent(&ife); if (ife.ife_flags == 0) @@ -3635,6 +3680,8 @@ getencap(void) break; case IFE_VNETID_SET: printf(" vnetid %lld", ife.ife_vnetid); + if (ife.ife_flags & IFE_VNETFLOWID) + printf("+"); break; }