Fix 2 bugs:

- initialise stp when the bridge is turned up, without this stp will keep
  all interfaces disabled in a sequence like:
  brconfig bridge0 add if0 add if1 stp if0 stp if1 up
- s/BRDGSPRI/BRDGSIFPRIO in brconfig.c:cmd_ifpriority()

add a command (ifpathcost) to change the stp path cost of the STP path cost of
an interface. Display the interface path cost with the others STP parameters.
This commit is contained in:
bouyer 2003-03-19 10:34:33 +00:00
parent fc135e74ba
commit 4a3c894eef
4 changed files with 64 additions and 8 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: brconfig.8,v 1.8 2003/03/03 06:50:18 wiz Exp $
.\" $NetBSD: brconfig.8,v 1.9 2003/03/19 10:34:33 bouyer Exp $
.\"
.\" Copyright 2001 Wasabi Systems, Inc.
.\" All rights reserved.
@ -197,6 +197,12 @@ to
.Ar value .
The default is 128.
The minimum is 0 and the maximum is 255.
.It Cm ifpathcost Ar interface Ar value
Set the Spanning Tree path cost of
+.Ar interface
to
.Ar value .
The default is 55. The minimum is 0 and the maximum is 65535.
.El
.Sh EXAMPLES
The following then placed in the file

View File

@ -1,4 +1,4 @@
/* $NetBSD: brconfig.c,v 1.4 2003/02/27 19:22:36 perseant Exp $ */
/* $NetBSD: brconfig.c,v 1.5 2003/03/19 10:34:33 bouyer Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -85,6 +85,7 @@ void cmd_fwddelay(const struct command *, int, const char *, char **);
void cmd_maxage(const struct command *, int, const char *, char **);
void cmd_priority(const struct command *, int, const char *, char **);
void cmd_ifpriority(const struct command *, int, const char *, char **);
void cmd_ifpathcost(const struct command *, int, const char *, char **);
void cmd_timeout(const struct command *, int, const char *, char **);
void cmd_stp(const struct command *, int, const char *, char **);
void cmd_ipf(const struct command *, int, const char *, char **);
@ -116,6 +117,7 @@ const struct command command_table[] = {
{ "maxage", 1, 0, cmd_maxage },
{ "priority", 1, 0, cmd_priority },
{ "ifpriority", 2, 0, cmd_ifpriority },
{ "ifpathcost", 2, 0, cmd_ifpathcost },
{ "timeout", 1, 0, cmd_timeout },
{ "stp", 1, 0, cmd_stp },
{ "-stp", 1, CMD_INVERT, cmd_stp },
@ -261,6 +263,7 @@ usage(void)
"<bridge> hellotime <time>",
"<bridge> priority <value>",
"<bridge> ifpriority <interface> <value>",
"<bridge> ifpathcost <interface> <value>",
NULL,
};
extern const char *__progname;
@ -440,6 +443,7 @@ show_interfaces(int sock, const char *bridge, const char *prefix)
printf("port %u priority %u",
req->ifbr_portno, req->ifbr_priority);
if (req->ifbr_ifsflags & IFBIF_STP) {
printf(" path cost %u", req->ifbr_path_cost);
if (req->ifbr_state <
sizeof(stpstates) / sizeof(stpstates[0]))
printf(" %s", stpstates[req->ifbr_state]);
@ -785,7 +789,26 @@ cmd_ifpriority(const struct command *cmd, int sock, const char *bridge,
strlcpy(req.ifbr_ifsname, argv[0], sizeof(req.ifbr_ifsname));
req.ifbr_priority = val & 0xff;
if (do_cmd(sock, bridge, BRDGSPRI, &req, sizeof(req), 1) < 0)
if (do_cmd(sock, bridge, BRDGSIFPRIO, &req, sizeof(req), 1) < 0)
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}
void
cmd_ifpathcost(const struct command *cmd, int sock, const char *bridge,
char **argv)
{
struct ifbreq req;
u_long val;
memset(&req, 0, sizeof(req));
if (get_val(argv[1], &val) < 0 || (val & ~0xff) != 0)
errx(1, "%s: invalid value: %s", cmd->cmd_keyword, argv[1]);
strlcpy(req.ifbr_ifsname, argv[0], sizeof(req.ifbr_ifsname));
req.ifbr_path_cost = val & 0xffff;
if (do_cmd(sock, bridge, BRDGSIFCOST, &req, sizeof(req), 1) < 0)
err(1, "%s %s", cmd->cmd_keyword, argv[0]);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridge.c,v 1.10 2003/02/27 19:22:49 perseant Exp $ */
/* $NetBSD: if_bridge.c,v 1.11 2003/03/19 10:34:34 bouyer Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.10 2003/02/27 19:22:49 perseant Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.11 2003/03/19 10:34:34 bouyer Exp $");
#include "opt_bridge_ipf.h"
#include "bpfilter.h"
@ -230,6 +230,7 @@ int bridge_ioctl_sfd(struct bridge_softc *, void *);
int bridge_ioctl_gma(struct bridge_softc *, void *);
int bridge_ioctl_sma(struct bridge_softc *, void *);
int bridge_ioctl_sifprio(struct bridge_softc *, void *);
int bridge_ioctl_sifcost(struct bridge_softc *, void *);
#ifdef BRIDGE_IPF
int bridge_ioctl_gfilt(struct bridge_softc *, void *);
int bridge_ioctl_sfilt(struct bridge_softc *, void *);
@ -307,6 +308,9 @@ const struct bridge_control bridge_control_table[] = {
{ bridge_ioctl_sifprio, sizeof(struct ifbreq),
BC_F_COPYIN|BC_F_SUSER },
{ bridge_ioctl_sifcost, sizeof(struct ifbreq),
BC_F_COPYIN|BC_F_SUSER },
#ifdef BRIDGE_IPF
{ bridge_ioctl_gfilt, sizeof(struct ifbrparam),
BC_F_COPYOUT },
@ -681,6 +685,7 @@ bridge_ioctl_gifflags(struct bridge_softc *sc, void *arg)
req->ifbr_ifsflags = bif->bif_flags;
req->ifbr_state = bif->bif_state;
req->ifbr_priority = bif->bif_priority;
req->ifbr_path_cost = bif->bif_path_cost;
req->ifbr_portno = bif->bif_ifp->if_index & 0xff;
return (0);
@ -764,6 +769,7 @@ bridge_ioctl_gifs(struct bridge_softc *sc, void *arg)
breq.ifbr_ifsflags = bif->bif_flags;
breq.ifbr_state = bif->bif_state;
breq.ifbr_priority = bif->bif_priority;
breq.ifbr_path_cost = bif->bif_path_cost;
breq.ifbr_portno = bif->bif_ifp->if_index & 0xff;
error = copyout(&breq, bifc->ifbic_req + count, sizeof(breq));
if (error)
@ -1019,6 +1025,24 @@ bridge_ioctl_sfilt(struct bridge_softc *sc, void *arg)
}
#endif /* BRIDGE_IPF */
int
bridge_ioctl_sifcost(struct bridge_softc *sc, void *arg)
{
struct ifbreq *req = arg;
struct bridge_iflist *bif;
bif = bridge_lookup_member(sc, req->ifbr_ifsname);
if (bif == NULL)
return (ENOENT);
bif->bif_path_cost = req->ifbr_path_cost;
if (sc->sc_if.if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
}
/*
* bridge_ifdetach:
*
@ -1054,6 +1078,7 @@ bridge_init(struct ifnet *ifp)
bridge_timer, sc);
ifp->if_flags |= IFF_RUNNING;
bstp_initialization(sc);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridgevar.h,v 1.2 2003/02/15 00:46:30 perseant Exp $ */
/* $NetBSD: if_bridgevar.h,v 1.3 2003/03/19 10:34:34 bouyer Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -102,8 +102,9 @@
#define BRDGGMA 19 /* get max age (ifbrparam) */
#define BRDGSMA 20 /* set max age (ifbrparam) */
#define BRDGSIFPRIO 21 /* set if priority (ifbreq) */
#define BRDGGFILT 22 /* get filter flags (ifbrparam) */
#define BRDGSFILT 23 /* set filter flags (ifbrparam) */
#define BRDGSIFCOST 22 /* set if path cost (ifbreq) */
#define BRDGGFILT 23 /* get filter flags (ifbrparam) */
#define BRDGSFILT 24 /* set filter flags (ifbrparam) */
/*
* Generic bridge control request.
@ -113,6 +114,7 @@ struct ifbreq {
uint32_t ifbr_ifsflags; /* member if flags */
uint8_t ifbr_state; /* member if STP state */
uint8_t ifbr_priority; /* member if STP priority */
uint8_t ifbr_path_cost; /* member if STP cost */
uint8_t ifbr_portno; /* member if port number */
};