-
-static void
-log_flow_operation(const struct dpif *dpif, const char *operation, int error,
- struct odp_flow *flow)
-{
- if (error) {
- flow->n_actions = 0;
- }
- log_flow_message(dpif, error, operation, &flow->key,
- !error ? &flow->stats : NULL,
- flow->actions, flow->n_actions);
-}
-
-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,
- !error ? &put->flow.stats : NULL,
- put->flow.actions, put->flow.n_actions);
- ds_destroy(&s);
-}
-
-/* There is a tendency to construct odp_flow objects on the stack and to
- * forget to properly initialize their "actions" and "n_actions" 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 "n_actions" was not initialized.
- */
-static void
-check_rw_odp_flow(struct odp_flow *flow)
-{
- if (flow->n_actions) {
- memset(&flow->actions[0], 0xcc, sizeof flow->actions[0]);
- }
-}