diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-05-24 02:45:19 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-05-24 02:45:19 +0000 |
commit | ebfdc55d0bccbe344e8950b89a5a0730ccc9253b (patch) | |
tree | 0d112ec2b177d5ac16483cb270c2af3be371991e /sbin | |
parent | c31238d30ac7cb511a14c4a4bc25106b4f89d822 (diff) |
initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.
ok brad@, deraadt@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 43 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 108 |
2 files changed, 149 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index de37bd42b75..eef1f889167 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.103 2005/04/15 03:31:49 pascoe Exp $ +.\" $OpenBSD: ifconfig.8,v 1.104 2005/05/24 02:45:18 reyk 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 $ .\" @@ -92,6 +92,16 @@ .Ar access-concentrator .Oc .Nm ifconfig +.Ar trunk-interface +.Oo +.Cm [-]trunkport +.Ar child-iface +.Oc +.Oo +.Cm trunkproto +.Ar proto +.Oc +.Nm ifconfig .Ar tunnel-interface .Cm tunnel .Ar src_address dest_address @@ -339,6 +349,7 @@ At least the following devices can be created on demand: .Xr ppp 4 , .Xr pppoe 4 , .Xr sl 4 , +.Xr trunk 4 , .Xr tun 4 , .Xr vlan 4 .It Cm debug @@ -659,6 +670,29 @@ Clear the IPv6 tentative address bit. .It Cm timeslot Ar timeslot_range Set the timeslot range map, which is used to control which channels an interface device uses. +.It Cm trunkport Ar child-iface +If the driver is a +.Xr trunk 4 +pseudo-device, add the +.Ar child-iface +as a trunk port. +.It Fl trunkport Ar child-iface +If the driver is a +.Xr trunk 4 +pseudo-device, remove the trunk port +.Ar child-iface . +.It Cm trunkproto Ar proto +If the driver is a +.Xr trunk 4 +pseudo-device, set the trunk protocol. +Refer to the interface's driver-specific man page for a complete +list of the available protocols, +or use +.Bd -literal -offset indent +$ ifconfig -m interface +.Ed +.Pp +for a listing of choices. .It Cm tunnel Ar src_address dest_address Set the source and destination tunnel addresses on a tunnel interface, including @@ -794,6 +828,12 @@ Create the gif1 network interface: Destroy the gif1 network interface: .Pp .Dl # ifconfig gif1 destroy +.Pp +Create and configure the trunk0 interface for IP address 192.168.23.1, +with the em0 and em1 trunk port interfaces: +.Pp +.Dl # ifconfig trunk0 create 192.168.23.1 trunkport em0 trunkport em1 +.Pp .Sh DIAGNOSTICS Messages indicating the specified interface does not exist, the requested address is unknown, or the user is not privileged and @@ -815,6 +855,7 @@ tried to alter an interface's configuration. .Xr ppp 4 , .Xr pppoe 4 , .Xr sl 4 , +.Xr trunk 4 , .Xr tun 4 , .Xr vlan 4 , .Xr hostname.if 5 , diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 21d9f60ed82..fc068ee98fe 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.137 2005/05/22 00:02:28 henning Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.138 2005/05/24 02:45:18 reyk Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -87,6 +87,7 @@ #include <net/pfvar.h> #include <net/if_pfsync.h> #include <net/if_pppoe.h> +#include <net/if_trunk.h> #include <netatalk/at.h> @@ -207,6 +208,10 @@ void setpppoe_dev(const char *,int); void setpppoe_svc(const char *,int); void setpppoe_ac(const char *,int); void pppoe_status(void); +void settrunkport(const char *, int); +void unsettrunkport(const char *, int); +void settrunkproto(const char *, int); +void trunk_status(void); int main(int, char *[]); int prefix(void *val, int); @@ -320,6 +325,9 @@ const struct cmd { { "timeslot", NEXTARG, 0, settimeslot }, { "txpower", NEXTARG, 0, setiftxpower }, { "-txpower", 1, 0, setiftxpower }, + { "trunkport", NEXTARG, 0, settrunkport }, + { "-trunkport", NEXTARG, 0, unsettrunkport }, + { "trunkproto", NEXTARG, 0, settrunkproto }, #endif /* SMALL */ #if 0 /* XXX `create' special-cased below */ @@ -2006,6 +2014,7 @@ status(int link, struct sockaddr_dl *sdl) pfsync_status(); pppoe_status(); timeslot_status(); + trunk_status(); #endif ieee80211_status(); getifgroups(); @@ -3135,6 +3144,102 @@ setpppoe_ac(const char *val, int d) if (ioctl(s, PPPOESETPARMS, &parms)) err(1, "PPPOESETPARMS"); } + +void +settrunkport(const char *val, int d) +{ + struct trunk_reqport rp; + + bzero(&rp, sizeof(rp)); + strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); + strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname)); + + if (ioctl(s, SIOCSTRUNKPORT, &rp)) + err(1, "SIOCSTRUNKPORT"); +} + +void +unsettrunkport(const char *val, int d) +{ + struct trunk_reqport rp; + + bzero(&rp, sizeof(rp)); + strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); + strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname)); + + if (ioctl(s, SIOCSTRUNKDELPORT, &rp)) + err(1, "SIOCSTRUNKDELPORT"); +} + +void +settrunkproto(const char *val, int d) +{ + struct trunk_protos tpr[] = TRUNK_PROTOS; + struct trunk_reqall ra; + int i; + + bzero(&ra, sizeof(ra)); + ra.ra_proto = TRUNK_PROTO_MAX; + + for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) { + if (strcmp(val, tpr[i].tpr_name) == 0) { + ra.ra_proto = tpr[i].tpr_proto; + break; + } + } + if (ra.ra_proto == TRUNK_PROTO_MAX) + errx(1, "Invalid trunk protocol: %s", val); + + strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname)); + if (ioctl(s, SIOCSTRUNK, &ra) != 0) + err(1, "SIOCSTRUNK"); +} + +void +trunk_status(void) +{ + struct trunk_protos tpr[] = TRUNK_PROTOS; + struct trunk_reqport rp, rpbuf[TRUNK_MAX_PORTS]; + struct trunk_reqall ra; + const char *proto = "<unknown>"; + int i; + + bzero(&ra, sizeof(ra)); + strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname)); + ra.ra_size = sizeof(rpbuf); + ra.ra_port = rpbuf; + + if (ioctl(s, SIOCGTRUNK, &ra) == 0) { + for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) { + if (ra.ra_proto == tpr[i].tpr_proto) { + proto = tpr[i].tpr_name; + break; + } + } + + printf("\ttrunk: trunkproto %s\n", proto); + for (i = 0; i < ra.ra_ports; i++) { + printf("\t\ttrunkport %s", rpbuf[i].rp_portname); + if (rpbuf[i].rp_flags & TRUNK_PORT_MASTER) + printf(" master"); + putchar('\n'); + } + + if (mflag) { + printf("\tsupported trunk protocols:\n"); + for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) + printf("\t\ttrunkproto %s\n", tpr[i].tpr_name); + } + } else { + strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); + strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname)); + + if (ioctl(s, SIOCGTRUNKPORT, &rp) != 0) + return; + + printf("\ttrunk: trunkdev %s\n", rp.rp_ifname); + } +} #endif /* SMALL */ #define SIN(x) ((struct sockaddr_in *) &(x)) @@ -3337,6 +3442,7 @@ usage(int value) "\t[[-]anycast] [eui64] [pltime n] [vltime n] [[-]tentative]\n" #endif "\t[vlan vlan_tag vlandev parent_iface] [-vlandev] [vhid n]\n" + "\t[trunkproto proto] [[-]trunkport child-iface]\n" "\t[advbase n] [advskew n] [maxupd n] [pass passphrase]\n" "\t[state init | backup | master]\n" "\t[syncdev iface] [-syncdev] [syncpeer peer_address] [-syncpeer]\n" |