-/* Copyright (c) 2011, 2012, 2013, 2014 Nicira, Inc.
+/* Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "dynamic-string.h"
#include "hash.h"
#include "hmap.h"
-#include "ofpbuf.h"
+#include "dp-packet.h"
+#include "ovs-atomic.h"
#include "packets.h"
#include "poll-loop.h"
#include "seq.h"
#include "timer.h"
#include "timeval.h"
#include "unixctl.h"
-#include "vlog.h"
+#include "openvswitch/vlog.h"
VLOG_DEFINE_THIS_MODULE(lacp);
OVS_PACKED(
struct lacp_info {
ovs_be16 sys_priority; /* System priority. */
- uint8_t sys_id[ETH_ADDR_LEN]; /* System ID. */
+ struct eth_addr sys_id; /* System ID. */
ovs_be16 key; /* Operational key. */
ovs_be16 port_priority; /* Port priority. */
ovs_be16 port_id; /* Port ID. */
BUILD_ASSERT_DECL(LACP_INFO_LEN == sizeof(struct lacp_info));
#define LACP_PDU_LEN 110
-OVS_PACKED(
struct lacp_pdu {
uint8_t subtype; /* Always 1. */
uint8_t version; /* Always 1. */
uint8_t collector_len; /* Always 16. */
ovs_be16 collector_delay; /* Maximum collector delay. Set to UINT16_MAX. */
uint8_t z3[64]; /* Combination of several fields. Always 0. */
-});
+};
BUILD_ASSERT_DECL(LACP_PDU_LEN == sizeof(struct lacp_pdu));
\f
/* Implementation. */
};
struct lacp {
- struct list node; /* Node in all_lacps list. */
+ struct ovs_list node; /* Node in all_lacps list. */
char *name; /* Name of this lacp object. */
- uint8_t sys_id[ETH_ADDR_LEN]; /* System ID. */
+ struct eth_addr sys_id; /* System ID. */
uint16_t sys_priority; /* System Priority. */
bool active; /* Active or Passive. */
};
static struct ovs_mutex mutex;
-static struct list all_lacps__ = LIST_INITIALIZER(&all_lacps__);
-static struct list *const all_lacps OVS_GUARDED_BY(mutex) = &all_lacps__;
+static struct ovs_list all_lacps__ = OVS_LIST_INITIALIZER(&all_lacps__);
+static struct ovs_list *const all_lacps OVS_GUARDED_BY(mutex) = &all_lacps__;
static void lacp_update_attached(struct lacp *) OVS_REQUIRES(mutex);
* supported by OVS. Otherwise, it returns a pointer to the lacp_pdu contained
* within 'b'. */
static const struct lacp_pdu *
-parse_lacp_packet(const struct ofpbuf *b)
+parse_lacp_packet(const struct dp_packet *p)
{
const struct lacp_pdu *pdu;
- pdu = ofpbuf_at(b, (uint8_t *)ofpbuf_l3(b) - (uint8_t *)ofpbuf_data(b),
+ pdu = dp_packet_at(p, (uint8_t *)dp_packet_l3(p) - (uint8_t *)dp_packet_data(p),
LACP_PDU_LEN);
if (pdu && pdu->subtype == 1
if (!eth_addr_equals(lacp->sys_id, s->id)
|| lacp->sys_priority != s->priority) {
- memcpy(lacp->sys_id, s->id, ETH_ADDR_LEN);
+ lacp->sys_id = s->id;
lacp->sys_priority = s->priority;
lacp->update = true;
}
*/
void
lacp_process_packet(struct lacp *lacp, const void *slave_,
- const struct ofpbuf *packet)
+ const struct dp_packet *packet)
OVS_EXCLUDED(mutex)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
actor->port_priority = htons(slave->port_priority);
actor->port_id = htons(slave->port_id);
actor->sys_priority = htons(lacp->sys_priority);
- memcpy(&actor->sys_id, lacp->sys_id, ETH_ADDR_LEN);
+ actor->sys_id = lacp->sys_id;
}
/* Given 'slave', populates 'priority' with data representing its LACP link
if (slave) {
ret = true;
slave_get_actor(slave, &actor);
- memcpy(&stats->dot3adAggPortActorSystemID,
- actor.sys_id,
- ETH_ADDR_LEN);
- memcpy(&stats->dot3adAggPortPartnerOperSystemID,
- slave->partner.sys_id,
- ETH_ADDR_LEN);
+ stats->dot3adAggPortActorSystemID = actor.sys_id;
+ stats->dot3adAggPortPartnerOperSystemID = slave->partner.sys_id;
stats->dot3adAggPortAttachedAggID = (lacp->key_slave->key ?
lacp->key_slave->key :
lacp->key_slave->port_id);