[ovs-dev] [PATCH ovn 2/4] action: introduce handle_bfd_msg() action
Lorenzo Bianconi
lorenzo.bianconi at redhat.com
Wed Nov 25 09:59:39 UTC 2020
Add handle_bfd_msg action to parse BFD packets received by the
controller
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
---
controller/pinctrl.c | 17 +++++++++++++++++
include/ovn/actions.h | 7 +++++++
lib/actions.c | 16 ++++++++++++++++
tests/ovn.at | 4 ++++
utilities/ovn-trace.c | 2 ++
5 files changed, 46 insertions(+)
diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 0e80c00c1..e7b9e90ce 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -329,6 +329,10 @@ static void bfd_monitor_init(void);
static void bfd_monitor_destroy(void);
static void bfd_monitor_send_msg(struct rconn *swconn, long long int *bfd_time)
OVS_REQUIRES(pinctrl_mutex);
+static void
+pinctrl_handle_bfd_msg(struct rconn *swconn, const struct flow *ip_flow,
+ struct dp_packet *pkt_in, const struct match *md)
+ OVS_REQUIRES(pinctrl_mutex);
static void bfd_monitor_run(const struct sbrec_bfd_table *bfd_table,
struct ovsdb_idl_index *sbrec_port_binding_by_name,
const struct sbrec_chassis *chassis,
@@ -2975,6 +2979,12 @@ process_packet_in(struct rconn *swconn, const struct ofp_header *msg)
ovs_mutex_unlock(&pinctrl_mutex);
break;
+ case ACTION_OPCODE_BFD_MSG:
+ ovs_mutex_lock(&pinctrl_mutex);
+ pinctrl_handle_bfd_msg(swconn, &headers, &packet, &pin.flow_metadata);
+ ovs_mutex_unlock(&pinctrl_mutex);
+ break;
+
default:
VLOG_WARN_RL(&rl, "unrecognized packet-in opcode %"PRIu32,
ntohl(ah->opcode));
@@ -6487,6 +6497,13 @@ next:
}
}
+static void
+pinctrl_handle_bfd_msg(struct rconn *swconn, const struct flow *ip_flow,
+ struct dp_packet *pkt_in, const struct match *md)
+ OVS_REQUIRES(pinctrl_mutex)
+{
+}
+
#define BFD_MONITOR_STALE_TIMEOUT 180000LL
static void
bfd_monitor_run(const struct sbrec_bfd_table *bfd_table,
diff --git a/include/ovn/actions.h b/include/ovn/actions.h
index 9c1ebf4aa..d104d4d64 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -105,6 +105,7 @@ struct ovn_extend_table;
OVNACT(CHK_LB_HAIRPIN, ovnact_result) \
OVNACT(CHK_LB_HAIRPIN_REPLY, ovnact_result) \
OVNACT(CT_SNAT_TO_VIP, ovnact_null) \
+ OVNACT(BFD_MSG, ovnact_null) \
/* enum ovnact_type, with a member OVNACT_<ENUM> for each action. */
enum OVS_PACKED_ENUM ovnact_type {
@@ -627,6 +628,12 @@ enum action_opcode {
* The actions, in OpenFlow 1.3 format, follow the action_header.
*/
ACTION_OPCODE_REJECT,
+
+ /* handle_bfd_msg { ...actions ...}."
+ *
+ * The actions, in OpenFlow 1.3 format, follow the action_header.
+ */
+ ACTION_OPCODE_BFD_MSG,
};
/* Header. */
diff --git a/lib/actions.c b/lib/actions.c
index 0705e4ef3..8516f5d74 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -2740,6 +2740,20 @@ encode_DHCP6_REPLY(const struct ovnact_null *a OVS_UNUSED,
encode_controller_op(ACTION_OPCODE_DHCP6_SERVER, ofpacts);
}
+static void
+format_BFD_MSG(const struct ovnact_null *a OVS_UNUSED, struct ds *s)
+{
+ ds_put_cstr(s, "handle_bfd_msg;");
+}
+
+static void
+encode_BFD_MSG(const struct ovnact_null *a OVS_UNUSED,
+ const struct ovnact_encode_params *ep OVS_UNUSED,
+ struct ofpbuf *ofpacts)
+{
+ encode_controller_op(ACTION_OPCODE_BFD_MSG, ofpacts);
+}
+
static void
parse_SET_QUEUE(struct action_context *ctx)
{
@@ -3840,6 +3854,8 @@ parse_action(struct action_context *ctx)
parse_fwd_group_action(ctx);
} else if (lexer_match_id(ctx->lexer, "handle_dhcpv6_reply")) {
ovnact_put_DHCP6_REPLY(ctx->ovnacts);
+ } else if (lexer_match_id(ctx->lexer, "handle_bfd_msg")) {
+ ovnact_put_BFD_MSG(ctx->ovnacts);
} else if (lexer_match_id(ctx->lexer, "reject")) {
parse_REJECT(ctx);
} else if (lexer_match_id(ctx->lexer, "ct_snat_to_vip")) {
diff --git a/tests/ovn.at b/tests/ovn.at
index 5b7a64cde..78a1b6443 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -1807,6 +1807,10 @@ ct_snat_to_vip;
ct_snat_to_vip(foo);
Syntax error at `(' expecting `;'.
+# bfd packets
+handle_bfd_msg;
+ encodes as controller(userdata=00.00.00.17.00.00.00.00)
+
# Miscellaneous negative tests.
;
Syntax error at `;'.
diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
index 8eb7263b3..6d571476c 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -2520,6 +2520,8 @@ trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len,
break;
case OVNACT_DHCP6_REPLY:
break;
+ case OVNACT_BFD_MSG:
+ break;
}
}
ds_destroy(&s);
--
2.28.0
More information about the dev
mailing list