- return n_flows;
-}
-
-static int compat_dump_flow(struct datapath *dp, struct compat_odp_flow_dump __user *udumpp)
-{
- struct compat_odp_flow __user *uflowp;
- compat_uptr_t compat_ufp;
- struct sw_flow *flow;
- compat_uptr_t ukey;
- u32 key_len;
-
- flow = do_dump_flow(dp, udumpp->state);
- if (IS_ERR(flow))
- return PTR_ERR(flow);
-
- if (get_user(compat_ufp, &udumpp->flow))
- return -EFAULT;
- uflowp = compat_ptr(compat_ufp);
-
- if (!flow)
- return put_user(ODPFF_EOF, &uflowp->flags);
-
- if (put_user(0, &uflowp->flags) ||
- get_user(ukey, &uflowp->key) ||
- get_user(key_len, &uflowp->key_len))
- return -EFAULT;
-
- key_len = flow_copy_to_user(compat_ptr(ukey), &flow->key, key_len);
- if (key_len < 0)
- return key_len;
- if (put_user(key_len, &uflowp->key_len))
- return -EFAULT;
-
- return compat_answer_query(dp, flow, 0, uflowp);
-}
-
-static int compat_flowvec_ioctl(struct datapath *dp, unsigned long argp,
- int (*function)(struct datapath *,
- struct compat_odp_flow __user *,
- u32 n_flows))
-{
- struct compat_odp_flowvec __user *uflowvec;
- struct compat_odp_flow __user *flows;
- struct compat_odp_flowvec flowvec;
- int retval;
-
- uflowvec = compat_ptr(argp);
- if (!access_ok(VERIFY_WRITE, uflowvec, sizeof(*uflowvec)) ||
- copy_from_user(&flowvec, uflowvec, sizeof(flowvec)))
- return -EFAULT;
-
- if (flowvec.n_flows > INT_MAX / sizeof(struct compat_odp_flow))
- return -EINVAL;
-
- flows = compat_ptr(flowvec.flows);
- if (!access_ok(VERIFY_WRITE, flows,
- flowvec.n_flows * sizeof(struct compat_odp_flow)))
- return -EFAULT;
-
- retval = function(dp, flows, flowvec.n_flows);
- return (retval < 0 ? retval
- : retval == flowvec.n_flows ? 0
- : put_user(retval, &uflowvec->n_flows));
-}
-
-static int compat_execute(struct datapath *dp, const struct compat_odp_execute __user *uexecute)
-{
- struct odp_execute execute;
- compat_uptr_t actions;
- compat_uptr_t data;
-
- if (!access_ok(VERIFY_READ, uexecute, sizeof(struct compat_odp_execute)) ||
- __get_user(actions, &uexecute->actions) ||
- __get_user(execute.actions_len, &uexecute->actions_len) ||
- __get_user(data, &uexecute->data) ||
- __get_user(execute.length, &uexecute->length))
- return -EFAULT;
-
- execute.actions = (struct nlattr __force *)compat_ptr(actions);
- execute.data = (const void __force *)compat_ptr(data);
-
- return do_execute(dp, &execute);