/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* bridged - bridging control daemon. This module provides functions related
* to the librstp (Rapid Spanning Tree Protocol) library.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <syslog.h>
#include <kstat.h>
#include <libdlpi.h>
#include <libdladm.h>
#include <libdllink.h>
#include <libdlstat.h>
#include <stp_in.h>
#include <stp_vectors.h>
#include <net/if_types.h>
#include <sys/ethernet.h>
#include "global.h"
/* current engine configuration; access protected by engine_lock */
/*
* Our implementation doesn't have per-VLAN forwarding entries, so we just
* flush by the port. If port number is zero, then flush entries.
*/
/*ARGSUSED1*/
static int
{
const char *portname;
return (0);
if (port_index == 0) {
portname = "all";
} else {
}
if (debugging) {
}
/*
* If flushing fails, we can't return. The only safe thing to do is to
* tear down the bridge so that we're not harming the network.
*/
}
return (0);
}
static void
{
return;
}
/* Returns speed in megabits per second */
static unsigned long
{
return (1000UL);
else
}
static int
{
return (0);
} else {
1 : 0);
}
}
static int
{
return (False);
return (True);
else
return (False);
}
static const char *
{
switch (bstate) {
case BLS_LEARNING:
return ("learning");
case BLS_FORWARDING:
return ("forwarding");
default:
}
}
/*ARGSUSED1*/
static int
{
return (1);
if (debugging)
switch (state) {
case UID_PORT_LEARNING:
break;
case UID_PORT_FORWARDING:
break;
default:
break;
}
/*
* If we've been unsuccessful in disabling forwarding, then the
* only safe thing to do is to make the daemon exit, so that
* the kernel will be forced to destroy the bridge state and
* terminate all forwarding.
*/
}
} else {
}
return (0);
}
/*
* Our hardware doesn't actually do anything different when STP is enabled or
* disabled, so this function does nothing. It would be possible to open and
* close the DLPI stream here, if such a thing were necessary.
*/
static int
{
if (debugging)
return (0);
}
/*ARGSUSED1*/
static int
{
int rc;
return (1);
if (rc == DLPI_SUCCESS) {
if (debugging)
return (0);
} else {
dlpi_strerror(rc));
return (1);
}
}
static const char *
{
return ("unknown");
else
}
/*ARGSUSED*/
static int
{
/* under engine_lock because it's a callback from the engine */
return (0);
}
/*ARGSUSED*/
static int
{
return (1);
cfg->field_mask = 0;
valcnt = 1;
if (status == DLADM_STATUS_OK) {
}
if (status == DLADM_STATUS_OK) {
}
if (status == DLADM_STATUS_OK) {
}
if (status == DLADM_STATUS_OK) {
}
if (status == DLADM_STATUS_OK) {
}
/*
* mcheck is special. It is actually a command, but the 802 documents
* define it as a variable that spontaneously resets itself. We need
* to handle that behavior here.
*/
}
if (!pdp->admin_non_stp)
return (0);
}
static void
{
}
};
void
rstp_init(void)
{
if (status != DLADM_STATUS_OK) {
}
}
/*
* This is called by a normal refresh operation. It gets the engine properties
* and resets.
*/
void
rstp_refresh(void)
{
int rc;
&new_prot);
if (status != DLADM_STATUS_OK) {
} else {
}
/*
* The engine doesn't take kindly to parameter changes while
* running. Disable first if we must do this.
*/
if (uid_cfg.stp_enabled &&
if (rc != 0)
}
if (rc != 0)
}
}
/*
* This is called when a port changes its MAC address. If it's the main port,
* the one that supplies us our bridge ID, then we must choose a new ID, and to
* do that we shut the bridge down and bring it back up.
*/
void
{
unsigned short prio;
int rc;
} else {
}
}
{
int rc;
return (B_FALSE);
}
/* guaranteed to succeed at this point */
/*
* Restore state when reenabling STP engine, set fixed state when
* disabling. For TRILL, we don't control forwarding at all, but we
* need to turn off our controls for TRILL to do its thing.
*/
if (protect != DLADM_BRIDGE_PROT_STP) {
} else if (portcfg.admin_non_stp) {
} else {
}
goto failure;
}
if (rc != 0) {
goto failure;
}
if (debugging) {
port->port_index);
} else {
/* return to default debug state */
port->port_index);
if (rc == 0)
port->port_index);
}
if (rc != 0) {
goto failure;
}
/* Clear out the kernel's allowed VLAN set; second walk will set */
goto failure;
}
goto failure;
}
return (B_TRUE);
return (B_FALSE);
}