projects
/
cascardo
/
ovs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
python: Run flake8 at build time.
[cascardo/ovs.git]
/
ofproto
/
ofproto-dpif-monitor.c
diff --git
a/ofproto/ofproto-dpif-monitor.c
b/ofproto/ofproto-dpif-monitor.c
index
764c7b1
..
0548400
100644
(file)
--- a/
ofproto/ofproto-dpif-monitor.c
+++ b/
ofproto/ofproto-dpif-monitor.c
@@
-21,6
+21,7
@@
#include "bfd.h"
#include "cfm.h"
#include "bfd.h"
#include "cfm.h"
+#include "dp-packet.h"
#include "guarded-list.h"
#include "hash.h"
#include "heap.h"
#include "guarded-list.h"
#include "hash.h"
#include "heap.h"
@@
-28,12
+29,13
@@
#include "latch.h"
#include "ofpbuf.h"
#include "ofproto-dpif.h"
#include "latch.h"
#include "ofpbuf.h"
#include "ofproto-dpif.h"
+#include "ovs-lldp.h"
#include "ovs-thread.h"
#include "poll-loop.h"
#include "seq.h"
#include "timeval.h"
#include "util.h"
#include "ovs-thread.h"
#include "poll-loop.h"
#include "seq.h"
#include "timeval.h"
#include "util.h"
-#include "vlog.h"
+#include "
openvswitch/
vlog.h"
VLOG_DEFINE_THIS_MODULE(ofproto_dpif_monitor);
VLOG_DEFINE_THIS_MODULE(ofproto_dpif_monitor);
@@
-42,7
+44,7
@@
VLOG_DEFINE_THIS_MODULE(ofproto_dpif_monitor);
/* Converts the heap priority to time in millisecond. */
#define PRIO_TO_MSEC(PRIO) (LLONG_MAX - (PRIO))
/* Converts the heap priority to time in millisecond. */
#define PRIO_TO_MSEC(PRIO) (LLONG_MAX - (PRIO))
-/* Monitored port. It owns references to ofport, bfd, cfm structs. */
+/* Monitored port. It owns references to ofport, bfd, cfm
, and lldp
structs. */
struct mport {
struct hmap_node hmap_node; /* In monitor_hmap. */
struct heap_node heap_node; /* In monitor_heap. */
struct mport {
struct hmap_node hmap_node; /* In monitor_hmap. */
struct heap_node heap_node; /* In monitor_heap. */
@@
-50,14
+52,15
@@
struct mport {
struct cfm *cfm; /* Reference to cfm. */
struct bfd *bfd; /* Reference to bfd. */
struct cfm *cfm; /* Reference to cfm. */
struct bfd *bfd; /* Reference to bfd. */
- uint8_t hw_addr[OFP_ETH_ALEN]; /* Hardware address. */
+ struct lldp *lldp; /* Reference to lldp. */
+ struct eth_addr hw_addr; /* Hardware address. */
};
/* Entry of the 'send_soon' list. Contains the pointer to the
* 'ofport_dpif'. Note, the pointed object is not protected, so
* users should always use the mport_find() to convert it to 'mport'. */
struct send_soon_entry {
};
/* Entry of the 'send_soon' list. Contains the pointer to the
* 'ofport_dpif'. Note, the pointed object is not protected, so
* users should always use the mport_find() to convert it to 'mport'. */
struct send_soon_entry {
- struct
list list_node;
/* In send_soon. */
+ struct
ovs_list list_node;
/* In send_soon. */
const struct ofport_dpif *ofport;
};
const struct ofport_dpif *ofport;
};
@@
-69,7
+72,7
@@
static struct heap monitor_heap;
/* guarded-list for storing the mports that need to send bfd/cfm control
* packet soon. */
/* guarded-list for storing the mports that need to send bfd/cfm control
* packet soon. */
-static struct guarded_list send_soon = GUARDED_LIST_INITIALIZER(&send_soon);
+static struct guarded_list send_soon = GUARDED_
OVS_
LIST_INITIALIZER(&send_soon);
/* The monitor thread id. */
static pthread_t monitor_tid;
/* The monitor thread id. */
static pthread_t monitor_tid;
@@
-80,17
+83,19
@@
static struct latch monitor_exit_latch;
static struct ovs_mutex monitor_mutex = OVS_MUTEX_INITIALIZER;
static void *monitor_main(void *);
static struct ovs_mutex monitor_mutex = OVS_MUTEX_INITIALIZER;
static void *monitor_main(void *);
-static void monitor_check_send_soon(struct
ofpbuf
*);
+static void monitor_check_send_soon(struct
dp_packet
*);
static void monitor_run(void);
static void monitor_run(void);
-static void monitor_mport_run(struct mport *, struct
ofpbuf
*);
+static void monitor_mport_run(struct mport *, struct
dp_packet
*);
static void mport_register(const struct ofport_dpif *, struct bfd *,
static void mport_register(const struct ofport_dpif *, struct bfd *,
- struct cfm *, uint8_t[ETH_ADDR_LEN])
+ struct cfm *, struct lldp *,
+ const struct eth_addr *)
OVS_REQUIRES(monitor_mutex);
static void mport_unregister(const struct ofport_dpif *)
OVS_REQUIRES(monitor_mutex);
static void mport_update(struct mport *, struct bfd *, struct cfm *,
OVS_REQUIRES(monitor_mutex);
static void mport_unregister(const struct ofport_dpif *)
OVS_REQUIRES(monitor_mutex);
static void mport_update(struct mport *, struct bfd *, struct cfm *,
- uint8_t[ETH_ADDR_LEN]) OVS_REQUIRES(monitor_mutex);
+ struct lldp *, const struct eth_addr *)
+ OVS_REQUIRES(monitor_mutex);
static struct mport *mport_find(const struct ofport_dpif *)
OVS_REQUIRES(monitor_mutex);
static struct mport *mport_find(const struct ofport_dpif *)
OVS_REQUIRES(monitor_mutex);
@@
-114,7
+119,8
@@
mport_find(const struct ofport_dpif *ofport) OVS_REQUIRES(monitor_mutex)
* if it doesn't exist. Otherwise, just updates its fields. */
static void
mport_register(const struct ofport_dpif *ofport, struct bfd *bfd,
* if it doesn't exist. Otherwise, just updates its fields. */
static void
mport_register(const struct ofport_dpif *ofport, struct bfd *bfd,
- struct cfm *cfm, uint8_t *hw_addr)
+ struct cfm *cfm, struct lldp *lldp,
+ const struct eth_addr *hw_addr)
OVS_REQUIRES(monitor_mutex)
{
struct mport *mport = mport_find(ofport);
OVS_REQUIRES(monitor_mutex)
{
struct mport *mport = mport_find(ofport);
@@
-125,7
+131,7
@@
mport_register(const struct ofport_dpif *ofport, struct bfd *bfd,
hmap_insert(&monitor_hmap, &mport->hmap_node, hash_pointer(ofport, 0));
heap_insert(&monitor_heap, &mport->heap_node, 0);
}
hmap_insert(&monitor_hmap, &mport->hmap_node, hash_pointer(ofport, 0));
heap_insert(&monitor_heap, &mport->heap_node, 0);
}
- mport_update(mport, bfd, cfm, hw_addr);
+ mport_update(mport, bfd, cfm,
lldp,
hw_addr);
}
/* Removes mport from monitor_hmap and monitor_heap and frees it. */
}
/* Removes mport from monitor_hmap and monitor_heap and frees it. */
@@
-136,7
+142,7
@@
mport_unregister(const struct ofport_dpif *ofport)
struct mport *mport = mport_find(ofport);
if (mport) {
struct mport *mport = mport_find(ofport);
if (mport) {
- mport_update(mport, NULL, NULL, NULL);
+ mport_update(mport, NULL, NULL, NULL
, NULL
);
hmap_remove(&monitor_hmap, &mport->hmap_node);
heap_remove(&monitor_heap, &mport->heap_node);
free(mport);
hmap_remove(&monitor_hmap, &mport->hmap_node);
heap_remove(&monitor_heap, &mport->heap_node);
free(mport);
@@
-146,7
+152,8
@@
mport_unregister(const struct ofport_dpif *ofport)
/* Updates the fields of an existing mport struct. */
static void
mport_update(struct mport *mport, struct bfd *bfd, struct cfm *cfm,
/* Updates the fields of an existing mport struct. */
static void
mport_update(struct mport *mport, struct bfd *bfd, struct cfm *cfm,
- uint8_t hw_addr[ETH_ADDR_LEN]) OVS_REQUIRES(monitor_mutex)
+ struct lldp *lldp, const struct eth_addr *hw_addr)
+ OVS_REQUIRES(monitor_mutex)
{
ovs_assert(mport);
{
ovs_assert(mport);
@@
-158,12
+165,16
@@
mport_update(struct mport *mport, struct bfd *bfd, struct cfm *cfm,
bfd_unref(mport->bfd);
mport->bfd = bfd_ref(bfd);
}
bfd_unref(mport->bfd);
mport->bfd = bfd_ref(bfd);
}
- if (hw_addr && memcmp(mport->hw_addr, hw_addr, ETH_ADDR_LEN)) {
- memcpy(mport->hw_addr, hw_addr, ETH_ADDR_LEN);
+ if (mport->lldp != lldp) {
+ lldp_unref(mport->lldp);
+ mport->lldp = lldp_ref(lldp);
}
}
- /* If bfd/cfm is added or reconfigured, move the mport on top of the heap
+ if (hw_addr && !eth_addr_equals(mport->hw_addr, *hw_addr)) {
+ mport->hw_addr = *hw_addr;
+ }
+ /* If bfd/cfm/lldp is added or reconfigured, move the mport on top of the heap
* so that the monitor thread can run the mport next time it wakes up. */
* so that the monitor thread can run the mport next time it wakes up. */
- if (mport->bfd || mport->cfm) {
+ if (mport->bfd || mport->cfm
|| mport->lldp
) {
heap_change(&monitor_heap, &mport->heap_node, LLONG_MAX);
}
}
heap_change(&monitor_heap, &mport->heap_node, LLONG_MAX);
}
}
@@
-194,9
+205,9
@@
monitor_run(void)
{
uint32_t stub[512 / 4];
long long int prio_now;
{
uint32_t stub[512 / 4];
long long int prio_now;
- struct
ofpbuf
packet;
+ struct
dp_packet
packet;
-
ofpbuf
_use_stub(&packet, stub, sizeof stub);
+
dp_packet
_use_stub(&packet, stub, sizeof stub);
ovs_mutex_lock(&monitor_mutex);
/* The monitor_check_send_soon() needs to be run twice. The first
ovs_mutex_lock(&monitor_mutex);
/* The monitor_check_send_soon() needs to be run twice. The first
@@
-227,13
+238,13
@@
monitor_run(void)
poll_timer_wait_until(MIN(next_timeout, next_mport_wakeup));
}
ovs_mutex_unlock(&monitor_mutex);
poll_timer_wait_until(MIN(next_timeout, next_mport_wakeup));
}
ovs_mutex_unlock(&monitor_mutex);
-
ofpbuf
_uninit(&packet);
+
dp_packet
_uninit(&packet);
}
/* Checks the 'send_soon' list for any mport that needs to send cfm/bfd
* control packet immediately, and calls monitor_mport_run(). */
static void
}
/* Checks the 'send_soon' list for any mport that needs to send cfm/bfd
* control packet immediately, and calls monitor_mport_run(). */
static void
-monitor_check_send_soon(struct
ofpbuf
*packet)
+monitor_check_send_soon(struct
dp_packet
*packet)
OVS_REQUIRES(monitor_mutex)
{
while (!guarded_list_is_empty(&send_soon)) {
OVS_REQUIRES(monitor_mutex)
{
while (!guarded_list_is_empty(&send_soon)) {
@@
-255,32
+266,45
@@
monitor_check_send_soon(struct ofpbuf *packet)
* on 'mport'. And changes the location of 'mport' in heap based on next
* timeout. */
static void
* on 'mport'. And changes the location of 'mport' in heap based on next
* timeout. */
static void
-monitor_mport_run(struct mport *mport, struct
ofpbuf
*packet)
+monitor_mport_run(struct mport *mport, struct
dp_packet
*packet)
OVS_REQUIRES(monitor_mutex)
{
long long int next_wake_time;
OVS_REQUIRES(monitor_mutex)
{
long long int next_wake_time;
+ long long int bfd_wake_time = LLONG_MAX;
+ long long int cfm_wake_time = LLONG_MAX;
+ long long int lldp_wake_time = LLONG_MAX;
if (mport->cfm && cfm_should_send_ccm(mport->cfm)) {
if (mport->cfm && cfm_should_send_ccm(mport->cfm)) {
-
ofpbuf
_clear(packet);
+
dp_packet
_clear(packet);
cfm_compose_ccm(mport->cfm, packet, mport->hw_addr);
ofproto_dpif_send_packet(mport->ofport, packet);
}
if (mport->bfd && bfd_should_send_packet(mport->bfd)) {
cfm_compose_ccm(mport->cfm, packet, mport->hw_addr);
ofproto_dpif_send_packet(mport->ofport, packet);
}
if (mport->bfd && bfd_should_send_packet(mport->bfd)) {
-
ofpbuf
_clear(packet);
+
dp_packet
_clear(packet);
bfd_put_packet(mport->bfd, packet, mport->hw_addr);
ofproto_dpif_send_packet(mport->ofport, packet);
}
bfd_put_packet(mport->bfd, packet, mport->hw_addr);
ofproto_dpif_send_packet(mport->ofport, packet);
}
+ if (mport->lldp && lldp_should_send_packet(mport->lldp)) {
+ dp_packet_clear(packet);
+ lldp_put_packet(mport->lldp, packet, mport->hw_addr);
+ ofproto_dpif_send_packet(mport->ofport, packet);
+ }
+
if (mport->cfm) {
cfm_run(mport->cfm);
if (mport->cfm) {
cfm_run(mport->cfm);
- cfm_wait(mport->cfm);
+ cfm_wa
ke_time = cfm_wa
it(mport->cfm);
}
if (mport->bfd) {
bfd_run(mport->bfd);
}
if (mport->bfd) {
bfd_run(mport->bfd);
- bfd_wait(mport->bfd);
+ bfd_wake_time = bfd_wait(mport->bfd);
+ }
+ if (mport->lldp) {
+ lldp_wake_time = lldp_wait(mport->lldp);
}
/* Computes the next wakeup time for this mport. */
}
/* Computes the next wakeup time for this mport. */
- next_wake_time = MIN(bfd_wake_time(mport->bfd),
- cfm_wake_time(mport->cfm));
+ next_wake_time = MIN(bfd_wake_time,
+ cfm_wake_time);
+ next_wake_time = MIN(next_wake_time, lldp_wake_time);
heap_change(&monitor_heap, &mport->heap_node,
MSEC_TO_PRIO(next_wake_time));
}
heap_change(&monitor_heap, &mport->heap_node,
MSEC_TO_PRIO(next_wake_time));
}
@@
-293,13
+317,14
@@
monitor_mport_run(struct mport *mport, struct ofpbuf *packet)
void
ofproto_dpif_monitor_port_update(const struct ofport_dpif *ofport,
struct bfd *bfd, struct cfm *cfm,
void
ofproto_dpif_monitor_port_update(const struct ofport_dpif *ofport,
struct bfd *bfd, struct cfm *cfm,
- uint8_t hw_addr[ETH_ADDR_LEN])
+ struct lldp *lldp,
+ const struct eth_addr *hw_addr)
{
ovs_mutex_lock(&monitor_mutex);
{
ovs_mutex_lock(&monitor_mutex);
- if (!cfm && !bfd) {
+ if (!cfm && !bfd
&& !lldp
) {
mport_unregister(ofport);
} else {
mport_unregister(ofport);
} else {
- mport_register(ofport, bfd, cfm, hw_addr);
+ mport_register(ofport, bfd, cfm,
lldp,
hw_addr);
}
ovs_mutex_unlock(&monitor_mutex);
}
ovs_mutex_unlock(&monitor_mutex);