[ovs-dev] [RFC ovn 2/3] action: introduce handle_bfd_msg() action

Lorenzo Bianconi lorenzo.bianconi at redhat.com
Thu Nov 12 16:10:11 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 bab9b862b..b6d68e2a5 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,
@@ -2971,6 +2975,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));
@@ -6468,6 +6478,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 b4e5acabb..2f1cff221 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -97,6 +97,7 @@ struct ovn_extend_table;
     OVNACT(DHCP6_REPLY,       ovnact_null)            \
     OVNACT(ICMP6_ERROR,       ovnact_nest)            \
     OVNACT(REJECT,            ovnact_nest)            \
+    OVNACT(BFD_MSG,           ovnact_null)            \
 
 /* enum ovnact_type, with a member OVNACT_<ENUM> for each action. */
 enum OVS_PACKED_ENUM ovnact_type {
@@ -612,6 +613,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 6300fef2c..8920d9461 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -2614,6 +2614,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)
 {
@@ -3610,6 +3624,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 {
diff --git a/tests/ovn.at b/tests/ovn.at
index 378d11921..1240dd908 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -1724,6 +1724,10 @@ fwd_group(liveness=false childports="eth0", "lsp1");
 handle_dhcpv6_reply;
     encodes as controller(userdata=00.00.00.13.00.00.00.00)
 
+# prefix delegation
+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 29bf7a208..d68720c77 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -2456,6 +2456,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.26.2



More information about the dev mailing list