Skip to content

Commit

Permalink
ofproto: Add support to watch controller port liveness in fast-failov…
Browse files Browse the repository at this point in the history
…er group

Currently fast-failover group does not support checking liveness of controller
port (OFPP_CONTROLLER). However this feature can be useful for selecting
alternate pipeline when controller connection itself is down for e.g.
by using local DHCP server to reply for any DHCP request originating from VMs.

This patch adds the support for watching controller port liveness in fast-
failover group. Controller port is considered live when atleast one
of-connection is alive.

Example usage:

ovs-ofctl add-group br-int 'group_id=1234,type=ff,
          bucket=watch_port:CONTROLLER,actions:<A>,
          bucket=watch_port:1,actions:<B>

Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
vishaldeepajmera authored and ovsrobot committed Jan 13, 2020
1 parent 2109841 commit 11ca08b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/ofp-group.c
Expand Up @@ -660,7 +660,8 @@ parse_bucket_str(struct ofputil_bucket *bucket, char *str_,
} else if (!strcasecmp(key, "watch_port")) {
if (!ofputil_port_from_string(value, port_map, &bucket->watch_port)
|| (ofp_to_u16(bucket->watch_port) >= ofp_to_u16(OFPP_MAX)
&& bucket->watch_port != OFPP_ANY)) {
&& bucket->watch_port != OFPP_ANY
&& bucket->watch_port != OFPP_CONTROLLER)) {
error = xasprintf("%s: invalid watch_port", value);
}
} else if (!strcasecmp(key, "watch_group")) {
Expand Down
5 changes: 4 additions & 1 deletion ofproto/ofproto-dpif-xlate.c
Expand Up @@ -1884,9 +1884,12 @@ bucket_is_alive(const struct xlate_ctx *ctx,

return (!ofputil_bucket_has_liveness(bucket)
|| (bucket->watch_port != OFPP_ANY
&& bucket->watch_port != OFPP_CONTROLLER
&& odp_port_is_alive(ctx, bucket->watch_port))
|| (bucket->watch_group != OFPG_ANY
&& group_is_alive(ctx, bucket->watch_group, depth + 1)));
&& group_is_alive(ctx, bucket->watch_group, depth + 1))
|| (bucket->watch_port == OFPP_CONTROLLER
&& ofproto_is_alive(&ctx->xbridge->ofproto->up)));
}

static void
Expand Down
10 changes: 10 additions & 0 deletions ofproto/ofproto-dpif.c
Expand Up @@ -1802,6 +1802,7 @@ run(struct ofproto *ofproto_)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
uint64_t new_seq, new_dump_seq;
bool is_connected;

if (mbridge_need_revalidate(ofproto->mbridge)) {
ofproto->backer->need_revalidate = REV_RECONFIGURE;
Expand Down Expand Up @@ -1870,6 +1871,15 @@ run(struct ofproto *ofproto_)
ofproto->backer->need_revalidate = REV_MCAST_SNOOPING;
}

/* Check if controller connection is toggled. */
is_connected = ofproto_is_alive(&ofproto->up);
if (ofproto->is_controller_connected != is_connected) {
ofproto->is_controller_connected = is_connected;
/* Trigger revalidation as fast failover group monitoring
* controller port may need to check liveness again. */
ofproto->backer->need_revalidate = REV_RECONFIGURE;
}

new_dump_seq = seq_read(udpif_dump_seq(ofproto->backer->udpif));
if (ofproto->dump_seq != new_dump_seq) {
struct rule *rule, *next_rule;
Expand Down
3 changes: 3 additions & 0 deletions ofproto/ofproto-dpif.h
Expand Up @@ -342,6 +342,9 @@ struct ofproto_dpif {
struct guarded_list ams; /* Contains "struct ofproto_async_msgs"s. */
struct seq *ams_seq; /* For notifying 'ams' reception. */
uint64_t ams_seqno;

bool is_controller_connected; /* True if any controller admitted this
* switch connection. */
};

struct ofproto_dpif *ofproto_dpif_lookup_by_name(const char *name);
Expand Down
3 changes: 2 additions & 1 deletion ofproto/ofproto.c
Expand Up @@ -1899,7 +1899,8 @@ ofproto_wait(struct ofproto *p)
bool
ofproto_is_alive(const struct ofproto *p)
{
return connmgr_has_controllers(p->connmgr);
return (connmgr_has_controllers(p->connmgr)
&& connmgr_is_any_controller_admitted(p->connmgr));
}

/* Adds some memory usage statistics for 'ofproto' into 'usage', for use with
Expand Down

0 comments on commit 11ca08b

Please sign in to comment.