From 2d71cf47fdb194287719a97ee81dbb0dd9fab9d8 Mon Sep 17 00:00:00 2001 Message-Id: <2d71cf47fdb194287719a97ee81dbb0dd9fab9d8.1610458802.git.lorenzo.bianconi@redhat.com> In-Reply-To: References: From: Lorenzo Bianconi Date: Fri, 8 Jan 2021 17:36:21 +0100 Subject: [PATCH 13/16] action: introduce handle_bfd_msg() action. Add handle_bfd_msg() action to parse BFD packets received by the controller. handle_bfd_msg() logic is currently empty and it will be implemented adding BFD state machine in the following patches. Acked-by: Mark Michelson Signed-off-by: Lorenzo Bianconi Signed-off-by: Numan Siddique --- controller/pinctrl.c | 15 +++++++++++++++ include/ovn/actions.h | 7 +++++++ lib/actions.c | 27 +++++++++++++++++++++++++++ tests/ovn.at | 4 ++++ utilities/ovn-trace.c | 2 ++ 5 files changed, 55 insertions(+) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 9df6533a1..deeae7479 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -329,6 +329,9 @@ 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(void) + 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 +2978,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(); + ovs_mutex_unlock(&pinctrl_mutex); + break; + default: VLOG_WARN_RL(&rl, "unrecognized packet-in opcode %"PRIu32, ntohl(ah->opcode)); @@ -6503,6 +6512,12 @@ next: } } +static void +pinctrl_handle_bfd_msg(void) + 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, 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_ 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 fbaeb34bc..86be97f44 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -2742,6 +2742,31 @@ 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_handle_bfd_msg(struct action_context *ctx OVS_UNUSED) +{ + if (!lexer_force_match(ctx->lexer, LEX_T_LPAREN)) { + return; + } + + ovnact_put_BFD_MSG(ctx->ovnacts); + lexer_force_match(ctx->lexer, LEX_T_RPAREN); +} + static void parse_SET_QUEUE(struct action_context *ctx) { @@ -3842,6 +3867,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")) { + parse_handle_bfd_msg(ctx); } 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 ce6db8677..27cb2e410 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 465049d34..e3aa73fb7 100644 --- a/utilities/ovn-trace.c +++ b/utilities/ovn-trace.c @@ -2544,6 +2544,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.29.2