[ovs-dev] [PATCH 1/1] auto-attach: Implement interface lldp disable and re-enable
drflynn at avaya.com
drflynn at avaya.com
Wed Apr 15 15:53:56 UTC 2015
From: Dennis Flynn <drflynn at avaya.com>
This commit completes the implementation of the lldp enable
option. Specifically after enabling lldp on a particular interface, lldp can
now be disabled and subsequently re-enabled. OVS will not transmit or receive
lldp packets if lldp is disabled on the interface.
Signed-off-by: Dennis Flynn <drflynn at avaya.com>
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 3edaf42..3c24d3d 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -658,9 +658,9 @@ lldp_init(void)
* fields in 'wc' that were used to make the determination.
*/
bool
-lldp_should_process_flow(const struct flow *flow)
+lldp_should_process_flow(struct lldp *lldp, const struct flow *flow)
{
- return (flow->dl_type == htons(ETH_TYPE_LLDP));
+ return (flow->dl_type == htons(ETH_TYPE_LLDP) && lldp->enabled);
}
@@ -687,6 +687,9 @@ lldp_should_send_packet(struct lldp *cfg) OVS_EXCLUDED(mutex)
ret = timer_expired(&cfg->tx_timer);
ovs_mutex_unlock(&mutex);
+ /* LLDP must be enabled */
+ ret &= cfg->enabled;
+
return ret;
}
@@ -697,7 +700,7 @@ lldp_wake_time(const struct lldp *lldp) OVS_EXCLUDED(mutex)
{
long long int retval;
- if (!lldp) {
+ if (!lldp || !lldp->enabled) {
return LLONG_MAX;
}
@@ -746,9 +749,15 @@ lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
/* Configures the LLDP stack.
*/
bool
-lldp_configure(struct lldp *lldp) OVS_EXCLUDED(mutex)
+lldp_configure(struct lldp *lldp, const struct smap *cfg) OVS_EXCLUDED(mutex)
{
if (lldp) {
+ if (cfg && smap_get_bool(cfg, "enable", false)) {
+ lldp->enabled = true;
+ } else {
+ lldp->enabled = false;
+ }
+
ovs_mutex_lock(&mutex);
timer_set_expired(&lldp->tx_timer);
timer_set_duration(&lldp->tx_timer, LLDP_DEFAULT_TRANSMIT_INTERVAL_MS);
diff --git a/lib/ovs-lldp.h b/lib/ovs-lldp.h
index 66288a5..807590a 100644
--- a/lib/ovs-lldp.h
+++ b/lib/ovs-lldp.h
@@ -46,6 +46,7 @@ struct lldp {
struct hmap mappings_by_aux; /* "struct" indexed by aux */
struct ovs_list active_mapping_queue;
struct ovs_refcount ref_cnt;
+ bool enabled; /* LLDP enabled on port */
};
/* Configuration specific to Auto Attach.
@@ -83,8 +84,8 @@ long long int lldp_wait(struct lldp *lldp);
long long int lldp_wake_time(const struct lldp *lldp);
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);
+bool lldp_should_process_flow(struct lldp *lldp, const struct flow *flow);
+bool lldp_configure(struct lldp *lldp, const struct smap *cfg);
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]);
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 55ae683..f737877 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -2610,7 +2610,7 @@ process_special(struct xlate_ctx *ctx, const struct flow *flow,
: rstp_process_packet(xport, packet);
}
return SLOW_STP;
- } else if (xport->lldp && lldp_should_process_flow(flow)) {
+ } else if (xport->lldp && lldp_should_process_flow(xport->lldp, flow)) {
if (packet) {
lldp_process_packet(xport->lldp, packet);
}
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 01d99c5..bf89321 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2020,16 +2020,15 @@ set_lldp(struct ofport *ofport_,
ofport->lldp = lldp_create(ofport->up.netdev, ofport_->mtu, cfg);
}
- if (lldp_configure(ofport->lldp)) {
- error = 0;
- goto out;
+ if (!lldp_configure(ofport->lldp, cfg)) {
+ error = EINVAL;
}
-
- error = EINVAL;
}
- lldp_unref(ofport->lldp);
- ofport->lldp = NULL;
-out:
+ if (error) {
+ lldp_unref(ofport->lldp);
+ ofport->lldp = NULL;
+ }
+
ofproto_dpif_monitor_port_update(ofport,
ofport->bfd,
ofport->cfm,
--
1.8.3.1
More information about the dev
mailing list