-
-static void
-log_flow_operation(const struct dpif *dpif, const char *operation, int error,
- struct odp_flow *flow)
-{
- if (error) {
- flow->key_len = 0;
- flow->actions_len = 0;
- }
- log_flow_message(dpif, error, operation,
- flow->key, flow->key_len, !error ? &flow->stats : NULL,
- flow->actions, flow->actions_len);
-}
-
-static void
-log_flow_put(struct dpif *dpif, int error, const struct odp_flow_put *put)
-{
- enum { ODPPF_ALL = ODPPF_CREATE | ODPPF_MODIFY | ODPPF_ZERO_STATS };
- struct ds s;
-
- ds_init(&s);
- ds_put_cstr(&s, "put");
- if (put->flags & ODPPF_CREATE) {
- ds_put_cstr(&s, "[create]");
- }
- if (put->flags & ODPPF_MODIFY) {
- ds_put_cstr(&s, "[modify]");
- }
- if (put->flags & ODPPF_ZERO_STATS) {
- ds_put_cstr(&s, "[zero]");
- }
- if (put->flags & ~ODPPF_ALL) {
- ds_put_format(&s, "[%x]", put->flags & ~ODPPF_ALL);
- }
- log_flow_message(dpif, error, ds_cstr(&s),
- put->flow.key, put->flow.key_len,
- !error ? &put->flow.stats : NULL,
- put->flow.actions, put->flow.actions_len);
- ds_destroy(&s);
-}
-
-/* There is a tendency to construct odp_flow objects on the stack and to
- * forget to properly initialize their "actions" and "actions_len" members.
- * When this happens, we get memory corruption because the kernel
- * writes through the random pointer that is in the "actions" member.
- *
- * This function attempts to combat the problem by:
- *
- * - Forcing a segfault if "actions" points to an invalid region (instead
- * of just getting back EFAULT, which can be easily missed in the log).
- *
- * - Storing a distinctive value that is likely to cause an
- * easy-to-identify error later if it is dereferenced, etc.
- *
- * - Triggering a warning on uninitialized memory from Valgrind if
- * "actions" or "actions_len" was not initialized.
- */
-static void
-check_rw_flow_actions(struct odp_flow *flow)
-{
- if (flow->actions_len) {
- memset(&flow->actions[0], 0xcc, sizeof flow->actions[0]);
- }
-}
-
-/* Same as check_rw_flow_actions() but for flow->key. */
-static void
-check_rw_flow_key(struct odp_flow *flow)
-{
- if (flow->key_len) {
- memset(&flow->key[0], 0xcc, sizeof flow->key[0]);
- }
-}