#include "byte-order.h"
#include "connectivity.h"
#include "ofpbuf.h"
+#include "ovs-atomic.h"
+#include "dp-packet.h"
#include "packets.h"
#include "seq.h"
#include "unixctl.h"
#include "util.h"
-#include "vlog.h"
+#include "openvswitch/vlog.h"
VLOG_DEFINE_THIS_MODULE(stp);
};
struct stp {
- struct list node; /* Node in all_stps list. */
+ struct ovs_list node; /* Node in all_stps list. */
/* Static bridge data. */
char *name; /* Human-readable name for log messages. */
/* Interface to client. */
bool fdb_needs_flush; /* MAC learning tables needs flushing. */
struct stp_port *first_changed_port;
- void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, void *aux);
+ void (*send_bpdu)(struct dp_packet *bpdu, int port_no, void *aux);
void *aux;
struct ovs_refcount ref_cnt;
};
static struct ovs_mutex mutex;
-static struct list all_stps__ = LIST_INITIALIZER(&all_stps__);
-static struct list *const all_stps OVS_GUARDED_BY(mutex) = &all_stps__;
+static struct ovs_list all_stps__ = OVS_LIST_INITIALIZER(&all_stps__);
+static struct ovs_list *const all_stps OVS_GUARDED_BY(mutex) = &all_stps__;
#define FOR_EACH_ENABLED_PORT(PORT, STP) \
for ((PORT) = stp_next_enabled_port((STP), (STP)->ports); \
*/
struct stp *
stp_create(const char *name, stp_identifier bridge_id,
- void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, void *aux),
+ void (*send_bpdu)(struct dp_packet *bpdu, int port_no, void *aux),
void *aux)
{
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
/* Returns true if 'state' is one in which packets received on a port should
* be forwarded, false otherwise.
- *
- * Returns true if 'state' is STP_DISABLED, since presumably in that case the
- * port should still work, just not have STP applied to it. */
+ */
bool
stp_forward_in_state(enum stp_state state)
{
- return (state & (STP_DISABLED | STP_FORWARDING)) != 0;
+ return (state & STP_FORWARDING) != 0;
}
/* Returns true if 'state' is one in which MAC learning should be done on
* packets received on a port, false otherwise.
- *
- * Returns true if 'state' is STP_DISABLED, since presumably in that case the
- * port should still work, just not have STP applied to it. */
+ */
bool
stp_learn_in_state(enum stp_state state)
{
- return (state & (STP_DISABLED | STP_LEARNING | STP_FORWARDING)) != 0;
+ return (state & (STP_LEARNING | STP_FORWARDING)) != 0;
}
/* Returns true if 'state' is one in which bpdus should be forwarded on a
{
ovs_assert(state & (STP_DISABLED | STP_BLOCKING));
stp_become_designated_port(p);
- stp_set_port_state(p, state);
+
+ if (!p->state && state == STP_DISABLED) {
+ p->state = state; /* Do not trigger state change when initializing. */
+ } else {
+ stp_set_port_state(p, state);
+ }
p->topology_change_ack = false;
p->config_pending = false;
p->change_detection_enabled = true;
{
struct eth_header *eth;
struct llc_header *llc;
- struct ofpbuf *pkt;
+ struct dp_packet *pkt;
/* Skeleton. */
- pkt = ofpbuf_new(ETH_HEADER_LEN + LLC_HEADER_LEN + bpdu_size);
- eth = ofpbuf_put_zeros(pkt, sizeof *eth);
- llc = ofpbuf_put_zeros(pkt, sizeof *llc);
- ofpbuf_set_frame(pkt, eth);
- ofpbuf_set_l3(pkt, ofpbuf_put(pkt, bpdu, bpdu_size));
+ pkt = dp_packet_new(ETH_HEADER_LEN + LLC_HEADER_LEN + bpdu_size);
+ eth = dp_packet_put_zeros(pkt, sizeof *eth);
+ llc = dp_packet_put_zeros(pkt, sizeof *llc);
+ dp_packet_reset_offsets(pkt);
+ dp_packet_set_l3(pkt, dp_packet_put(pkt, bpdu, bpdu_size));
/* 802.2 header. */
- memcpy(eth->eth_dst, eth_addr_stp, ETH_ADDR_LEN);
+ eth->eth_dst = eth_addr_stp;
/* p->stp->send_bpdu() must fill in source address. */
- eth->eth_type = htons(ofpbuf_size(pkt) - ETH_HEADER_LEN);
+ eth->eth_type = htons(dp_packet_size(pkt) - ETH_HEADER_LEN);
/* LLC header. */
llc->llc_dsap = STP_LLC_DSAP;