Skip to content

Commit

Permalink
auto-attach: Add auto-attach support to ofproto layer
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Beliveau <ludovic.beliveau@windriver.com>
Signed-off-by: Dennis Flynn <drflynn@avaya.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
Dennis Flynn authored and blp committed Mar 4, 2015
1 parent be53a5c commit 0477baa
Show file tree
Hide file tree
Showing 18 changed files with 368 additions and 72 deletions.
6 changes: 4 additions & 2 deletions lib/bfd.c
Expand Up @@ -516,10 +516,12 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex)
}
}

void
long long int
bfd_wait(const struct bfd *bfd) OVS_EXCLUDED(mutex)
{
poll_timer_wait_until(bfd_wake_time(bfd));
long long int wake_time = bfd_wake_time(bfd);
poll_timer_wait_until(wake_time);
return wake_time;
}

/* Returns the next wake up time. */
Expand Down
2 changes: 1 addition & 1 deletion lib/bfd.h
Expand Up @@ -31,7 +31,7 @@ struct netdev;
struct dp_packet;
struct smap;

void bfd_wait(const struct bfd *);
long long int bfd_wait(const struct bfd *);
void bfd_run(struct bfd *);

bool bfd_should_send_packet(const struct bfd *);
Expand Down
10 changes: 6 additions & 4 deletions lib/cfm.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
* Copyright (c) 2010, 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.
Expand Down Expand Up @@ -564,7 +564,7 @@ cfm_should_send_ccm(struct cfm *cfm) OVS_EXCLUDED(mutex)
* should be sent whenever cfm_should_send_ccm() indicates. */
void
cfm_compose_ccm(struct cfm *cfm, struct dp_packet *packet,
uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
const uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
{
uint16_t ccm_vlan;
struct ccm *ccm;
Expand Down Expand Up @@ -629,10 +629,12 @@ cfm_compose_ccm(struct cfm *cfm, struct dp_packet *packet,
ovs_mutex_unlock(&mutex);
}

void
long long int
cfm_wait(struct cfm *cfm) OVS_EXCLUDED(mutex)
{
poll_timer_wait_until(cfm_wake_time(cfm));
long long int wake_time = cfm_wake_time(cfm);
poll_timer_wait_until(wake_time);
return wake_time;
}


Expand Down
7 changes: 4 additions & 3 deletions lib/cfm.h
@@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2011 Nicira, Inc.
/* Copyright (c) 2010, 2011, 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.
Expand Down Expand Up @@ -93,8 +93,9 @@ struct cfm *cfm_ref(const struct cfm *);
void cfm_unref(struct cfm *);
void cfm_run(struct cfm *);
bool cfm_should_send_ccm(struct cfm *);
void cfm_compose_ccm(struct cfm *, struct dp_packet *packet, uint8_t eth_src[ETH_ADDR_LEN]);
void cfm_wait(struct cfm *);
void cfm_compose_ccm(struct cfm *, struct dp_packet *,
const uint8_t eth_src[ETH_ADDR_LEN]);
long long int cfm_wait(struct cfm *);
bool cfm_configure(struct cfm *, const struct cfm_settings *);
void cfm_set_netdev(struct cfm *, const struct netdev *);
bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *,
Expand Down
24 changes: 12 additions & 12 deletions lib/lldp/lldp.c
Expand Up @@ -25,8 +25,8 @@
#include <sys/socket.h>
#include <sys/types.h>
#include "compiler.h"
#include "dp-packet.h"
#include "packets.h"
#include "ofpbuf.h"

VLOG_DEFINE_THIS_MODULE(lldp);

Expand Down Expand Up @@ -164,7 +164,7 @@ lldpd_af_from_lldp_proto(int proto)
int
lldp_send(struct lldpd *global OVS_UNUSED,
struct lldpd_hardware *hardware,
struct ofpbuf *p)
struct dp_packet *p)
{
struct lldpd_port *port;
struct lldpd_chassis *chassis;
Expand All @@ -181,16 +181,16 @@ lldp_send(struct lldpd *global OVS_UNUSED,

/* The ethernet header is filled in elsewhere, we must save room for it. */
length = hardware->h_mtu - sizeof(struct eth_header);
packet = ofpbuf_l3(p);
packet = dp_packet_l3(p);
VLOG_DBG("LLDP PDU send to %s mtu %d incoming with ptr=%p",
hardware->h_ifname, hardware->h_mtu, packet);
pos = packet;

/*
* Make room in ofpbuf for chassis ID, Port ID, System Name, System Descr,
* System Cap
* Make room in dp_packet for chassis ID, Port ID, System Name, System
* Descr, System Cap
*/
pos = ofpbuf_put_uninit(p, sizeof chassis->c_id_subtype +
pos = dp_packet_put_uninit(p, sizeof chassis->c_id_subtype +
chassis->c_id_len +
sizeof port->p_id_subtype +
port->p_id_len +
Expand Down Expand Up @@ -253,7 +253,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
/*
* Make room for 1 mgmt interface
*/
ofpbuf_put_uninit(p, 2 + sizeof(uint8_t) +
dp_packet_put_uninit(p, 2 + sizeof(uint8_t) +
sizeof(uint8_t) +
mgmt->m_addrsize +
sizeof(uint8_t) +
Expand Down Expand Up @@ -293,7 +293,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
/* Port description */
if (port->p_descr && *port->p_descr != '\0') {
/* make room for port descr */
ofpbuf_put_uninit(p, 2 + strlen(port->p_descr));
dp_packet_put_uninit(p, 2 + strlen(port->p_descr));

if (!(POKE_START_LLDP_TLV(LLDP_TLV_PORT_DESCR) &&
POKE_BYTES(port->p_descr, strlen(port->p_descr)) &&
Expand Down Expand Up @@ -330,7 +330,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
aa_elem_sys_id_second_byte = port->p_element.system_id.smlt_id & 0x0FF;

/* make room for element type tlv */
ofpbuf_put_uninit(p, 2 + sizeof avaya +
dp_packet_put_uninit(p, 2 + sizeof avaya +
sizeof(uint8_t) +
sizeof aa_element_first_byte +
sizeof aa_element_second_byte +
Expand Down Expand Up @@ -361,7 +361,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
/*
* make room for aa_isid_digest
*/
ofpbuf_put_uninit(p, 2 + sizeof avaya +
dp_packet_put_uninit(p, 2 + sizeof avaya +
sizeof(uint8_t) +
sizeof msg_auth_digest);

Expand All @@ -387,7 +387,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
/*
* Make room for one isid-vlan mapping
*/
ofpbuf_put_uninit(p, sizeof status_vlan_word +
dp_packet_put_uninit(p, sizeof status_vlan_word +
sizeof vlan_isid_map->isid_vlan_data.isid);

if (!(POKE_UINT16(status_vlan_word) &&
Expand All @@ -403,7 +403,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
}

/* Make room for the End TLV 0x0000 */
ofpbuf_put_uninit(p, sizeof(uint16_t));
dp_packet_put_uninit(p, sizeof(uint16_t));

/* END */
if (!(POKE_START_LLDP_TLV(LLDP_TLV_END) &&
Expand Down
2 changes: 1 addition & 1 deletion lib/lldp/lldpd.c
Expand Up @@ -585,7 +585,7 @@ lldpd_recv(struct lldpd *cfg,
}

uint32_t
lldpd_send(struct lldpd_hardware *hw, struct ofpbuf *p)
lldpd_send(struct lldpd_hardware *hw, struct dp_packet *p)
{
struct lldpd *cfg = hw->h_cfg;
struct lldpd_port *port;
Expand Down
6 changes: 3 additions & 3 deletions lib/lldp/lldpd.h
Expand Up @@ -27,12 +27,12 @@
#include <string.h>
#include <sys/types.h>
#include <sys/un.h>
#include "dp-packet.h"
#include "list.h"
#include "lldpd-structs.h"
#include "lldp-tlv.h"
#include "packets.h"
#include "openvswitch/vlog.h"
#include "ofpbuf.h"

#define SYSCONFDIR ""
#define LLDPD_CTL_SOCKET ""
Expand All @@ -56,7 +56,7 @@ struct event_base;

#define USING_AGENTX_SUBAGENT_MODULE 1

#define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct ofpbuf *
#define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct dp_packet *
#define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\
struct lldpd_chassis **, struct lldpd_port **
#define PROTO_GUESS_SIG char *, int
Expand Down Expand Up @@ -104,7 +104,7 @@ void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *);
struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize,
u_int32_t iface);
void lldpd_recv(struct lldpd *, struct lldpd_hardware *, char *, size_t);
uint32_t lldpd_send(struct lldpd_hardware *, struct ofpbuf *);
uint32_t lldpd_send(struct lldpd_hardware *, struct dp_packet *);
void lldpd_loop(struct lldpd *);

int lldpd_main(int, char **);
Expand Down
1 change: 1 addition & 0 deletions lib/odp-util.h
Expand Up @@ -40,6 +40,7 @@ struct pkt_metadata;
SPR(SLOW_BFD, "bfd", "Consists of BFD packets") \
SPR(SLOW_LACP, "lacp", "Consists of LACP packets") \
SPR(SLOW_STP, "stp", "Consists of STP packets") \
SPR(SLOW_LLDP, "lldp", "Consists of LLDP packets") \
SPR(SLOW_CONTROLLER, "controller", \
"Sends \"packet-in\" messages to the OpenFlow controller") \
SPR(SLOW_ACTION, "action", \
Expand Down
5 changes: 2 additions & 3 deletions lib/ovs-lldp.c
Expand Up @@ -39,7 +39,6 @@
#include "lldp/lldpd.h"
#include "lldp/lldpd-structs.h"
#include "netdev.h"
#include "ofpbuf.h"
#include "openvswitch/types.h"
#include "packets.h"
#include "poll-loop.h"
Expand Down Expand Up @@ -736,7 +735,7 @@ lldp_should_process_flow(const struct flow *flow)
/* Process an LLDP packet that was received on a bridge port.
*/
void
lldp_process_packet(struct lldp *lldp, const struct ofpbuf *p)
lldp_process_packet(struct lldp *lldp, const struct dp_packet *p)
{
if (lldp) {
lldpd_recv(lldp->lldpd,
Expand Down Expand Up @@ -793,7 +792,7 @@ lldp_wait(struct lldp *lldp) OVS_EXCLUDED(mutex)
/* Prepare the LLDP packet to be sent on a bridge port.
*/
void
lldp_put_packet(struct lldp *lldp, struct ofpbuf *packet,
lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
{
struct lldpd *mylldpd = lldp->lldpd;
Expand Down
6 changes: 3 additions & 3 deletions lib/ovs-lldp.h
Expand Up @@ -19,10 +19,10 @@
#define OVS_LLDP_H

#include <stdint.h>
#include "dp-packet.h"
#include "hmap.h"
#include "list.h"
#include "lldp/lldpd.h"
#include "ofpbuf.h"
#include "ovsdb-data.h"
#include "ovs-thread.h"
#include "packets.h"
Expand Down Expand Up @@ -91,8 +91,8 @@ void lldp_run(struct lldpd *cfg);
bool lldp_should_send_packet(struct lldp *cfg);
bool lldp_should_process_flow(const struct flow *flow);
bool lldp_configure(struct lldp *lldp);
void lldp_process_packet(struct lldp *cfg, const struct ofpbuf *p);
void lldp_put_packet(struct lldp *lldp, struct ofpbuf *packet,
void lldp_process_packet(struct lldp *cfg, const struct dp_packet *);
void lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
uint8_t eth_src[ETH_ADDR_LEN]);
void lldpd_assign_cfg_to_protocols(struct lldpd *cfg);
struct lldp * lldp_create(const struct netdev *netdev, const uint32_t mtu,
Expand Down

0 comments on commit 0477baa

Please sign in to comment.