diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2002-12-09 10:11:54 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2002-12-09 10:11:54 +0000 |
commit | a5067ef6691277e4fbaa1b87da74ecb3dee425d3 (patch) | |
tree | 4f10d364a34a108b8ac539400e2d17d77180cb65 /sbin/brconfig | |
parent | a132b5806b65d29bb80a0aab6478ed425672a4f3 (diff) |
allow setting of ifcost with brconfig. enables selection of preferred
port/path to root bridge among several LANs. unlike ifpriority, which
allows you to select designated port if serveral interfaces belong
to the same LAN; ok jason@
Diffstat (limited to 'sbin/brconfig')
-rw-r--r-- | sbin/brconfig/brconfig.8 | 8 | ||||
-rw-r--r-- | sbin/brconfig/brconfig.c | 45 |
2 files changed, 49 insertions, 4 deletions
diff --git a/sbin/brconfig/brconfig.8 b/sbin/brconfig/brconfig.8 index 5d24f7e0c66..02cc2058c04 100644 --- a/sbin/brconfig/brconfig.8 +++ b/sbin/brconfig/brconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: brconfig.8,v 1.39 2002/12/06 16:28:48 markus Exp $ +.\" $OpenBSD: brconfig.8,v 1.40 2002/12/09 10:11:53 markus Exp $ .\" .\" Copyright (c) 1999-2001 Jason L. Wright (jason@thought.net) .\" All rights reserved. @@ -247,6 +247,12 @@ Set the spanning tree priority of to .Ar num . Defaults to 128, minimum of 0, maximum of 255. +.It Cm ifcost Ar interface Ar num +Set the spanning tree path cost of +.Ar interface +to +.Ar num . +Defaults to 55, minimum of 1, maximum of 65535. .El .Sh EXAMPLES .Bl -tag -width brconfig diff --git a/sbin/brconfig/brconfig.c b/sbin/brconfig/brconfig.c index bdf150ce1aa..bb030053ef0 100644 --- a/sbin/brconfig/brconfig.c +++ b/sbin/brconfig/brconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.c,v 1.19 2002/07/03 22:32:32 deraadt Exp $ */ +/* $OpenBSD: brconfig.c,v 1.20 2002/12/09 10:11:53 markus Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -67,6 +67,7 @@ int bridge_priority(int, char *, char *); int bridge_fwddelay(int, char *, char *); int bridge_hellotime(int, char *, char *); int bridge_ifprio(int, char *, char *, char *); +int bridge_ifcost(int, char *, char *, char *); int bridge_timeout(int, char *, char *); int bridge_flush(int, char *); int bridge_flushall(int, char *); @@ -356,6 +357,16 @@ main(int argc, char *argv[]) if (error) return (error); argc--; argv++; + } else if (strcmp("ifcost", argv[0]) == 0) { + argc--; argv++; + if (argc < 2) { + warnx("ifcost requires 2 arguments"); + return (EX_USAGE); + } + error = bridge_ifcost(sock, brdg, argv[0], argv[1]); + if (error) + return (error); + argc--; argv++; } else if (strcmp("rules", argv[0]) == 0) { argc--; argv++; if (argc == 0) { @@ -650,8 +661,9 @@ bridge_list(int s, char *brdg, char *delim) if (reqp->ifbr_ifsflags & IFBIF_SPAN) continue; printf("\t\t\t"); - printf("port %u priority %u", - reqp->ifbr_portno, reqp->ifbr_priority); + printf("port %u ifpriority %u ifcost %u", + reqp->ifbr_portno, reqp->ifbr_priority, + reqp->ifbr_path_cost); if (reqp->ifbr_ifsflags & IFBIF_STP) printf(" %s", stpstates[reqp->ifbr_state]); printf("\n"); @@ -921,6 +933,33 @@ bridge_ifprio(int s, char *brdg, char *ifname, char *val) } int +bridge_ifcost(int s, char *brdg, char *ifname, char *val) +{ + struct ifbreq breq; + u_int32_t v; + char *endptr; + + strlcpy(breq.ifbr_name, brdg, sizeof(breq.ifbr_name)); + strlcpy(breq.ifbr_ifsname, ifname, sizeof(breq.ifbr_ifsname)); + + errno = 0; + v = strtoul(val, &endptr, 0); + if (val[0] == '\0' || endptr[0] != '\0' || + (errno == ERANGE && v == ULONG_MAX) || + (v < 1 || v > 0xffffffff)) { + printf("invalid arg for ifcost: %s\n", val); + return (EX_USAGE); + } + breq.ifbr_path_cost = v; + + if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) < 0) { + warn("%s: %s", brdg, val); + return (EX_IOERR); + } + return (0); +} + +int bridge_addaddr(int s, char *brdg, char *ifname, char *addr) { struct ifbareq ifba; |