Creates new compose_lacp_pdu() from the old compose_lacp_packet()
function. This will allow a LACP PDU to be created without
necessarily knowing the Ethernet Source Address required for
generating the packet.
---
lib/packets.c | 22 +++++++++++++++-------
lib/packets.h | 8 +++++---
vswitchd/bridge.c | 6 ++++--
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/lib/packets.c b/lib/packets.c
index 8791a3c..35f1eac 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -204,25 +204,33 @@ ipv6_is_cidr(const struct in6_addr *netmask)
return true;
}
-/* Fills 'b' with a LACP packet whose source address is 'eth_src', LACP actor
- * information is 'actor', and LACP partner information is 'partner'. */
+/* Populates 'b' with a LACP packet containing 'pdu' with source address
+ * 'eth_src'. */
void
-compose_lacp_packet(struct ofpbuf *b, struct lacp_info *actor,
- struct lacp_info *partner,
- const uint8_t eth_src[ETH_ADDR_LEN])
+compose_lacp_packet(struct ofpbuf *b, const uint8_t eth_src[ETH_ADDR_LEN],
+ const struct lacp_pdu *pdu)
{
struct eth_header *eth;
- struct lacp_pdu *pdu;
+ struct lacp_pdu *eth_pdu;
ofpbuf_clear(b);
ofpbuf_prealloc_tailroom(b, ETH_HEADER_LEN + LACP_PDU_LEN);
eth = ofpbuf_put_zeros(b, ETH_HEADER_LEN);
- pdu = ofpbuf_put_zeros(b, LACP_PDU_LEN);
+ eth_pdu = ofpbuf_put_zeros(b, LACP_PDU_LEN);
+ memcpy(eth_pdu, pdu, sizeof *pdu);
memcpy(eth->eth_dst, eth_addr_lacp, ETH_ADDR_LEN);
memcpy(eth->eth_src, eth_src, ETH_ADDR_LEN);
eth->eth_type = htons(ETH_TYPE_LACP);
+}
+
+/* Populates 'pdu' with a LACP PDU comprised of 'actor' and 'partner'. */
+void
+compose_lacp_pdu(const struct lacp_info *actor,
+ const struct lacp_info *partner, struct lacp_pdu *pdu)
+{
+ memset(pdu, 0, sizeof *pdu);
pdu->subtype = 1;
pdu->version = 1;
diff --git a/lib/packets.h b/lib/packets.h
index 0bc368b..dcb5b9f 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -460,9 +460,11 @@ struct lacp_pdu {
} __attribute__((packed));
BUILD_ASSERT_DECL(LACP_PDU_LEN == sizeof(struct lacp_pdu));
-void compose_lacp_packet(struct ofpbuf *, struct lacp_info *actor,
- struct lacp_info *partner,
- const uint8_t eth_src[ETH_ADDR_LEN]);
+void compose_lacp_packet(struct ofpbuf *, const uint8_t eth_src[ETH_ADDR_LEN],
+ const struct lacp_pdu *);
+
+void compose_lacp_pdu(const struct lacp_info *actor,
+ const struct lacp_info *partner, struct lacp_pdu *);
const struct lacp_pdu *parse_lacp_packet(const struct ofpbuf *);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 75d4a1d..774664e 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3274,9 +3274,11 @@ lacp_run(struct port *port)
error = netdev_get_etheraddr(iface->netdev, ea);
if (!error) {
+ struct lacp_pdu pdu;
+
iface->lacp_actor.state = iface_get_lacp_state(iface);
- compose_lacp_packet(&packet, &iface->lacp_actor,
- &iface->lacp_partner, ea);
+ compose_lacp_pdu(&iface->lacp_actor, &iface->lacp_partner, &pdu);
+ compose_lacp_packet(&packet, ea, &pdu);
iface_send_packet(iface, &packet);
} else {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10);
--
1.7.4.1
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev