Revert "datapath: Increase maximum allocation size of action list."
authorPravin B Shelar <pshelar@nicira.com>
Fri, 1 Mar 2013 00:12:32 +0000 (16:12 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Fri, 1 Mar 2013 01:52:34 +0000 (17:52 -0800)
This reverts commit 82b0d755094ec675ea1a49b4ae58bc1c5e8e51c2.

This patch introduced bug by calling vfree() from interrupt context.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath/datapath.c
datapath/flow.c
datapath/flow.h

index bd2d57b..fc5d2de 100644 (file)
@@ -434,10 +434,10 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, int attr_le
        int next_offset = offsetof(struct sw_flow_actions, actions) +
                                        (*sfa)->actions_len;
 
-       if (req_size <= ((*sfa)->buf_size - next_offset))
+       if (req_size <= (ksize(*sfa) - next_offset))
                goto out;
 
-       new_acts_size = (*sfa)->buf_size * 2;
+       new_acts_size = ksize(*sfa) * 2;
 
        if (new_acts_size > MAX_ACTIONS_BUFSIZE) {
                if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size)
@@ -451,7 +451,7 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, int attr_le
 
        memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len);
        acts->actions_len = (*sfa)->actions_len;
-       ovs_flow_actions_free(*sfa);
+       kfree(*sfa);
        *sfa = acts;
 
 out:
@@ -1292,7 +1292,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
        return 0;
 
 err_kfree:
-       ovs_flow_actions_free(acts);
+       kfree(acts);
 error:
        return error;
 }
index b6bb7a7..b14229f 100644 (file)
@@ -207,29 +207,14 @@ struct sw_flow_actions *ovs_flow_actions_alloc(int size)
        if (size > MAX_ACTIONS_BUFSIZE)
                return ERR_PTR(-EINVAL);
 
-       size += sizeof(*sfa);
-       if (size <= MAX_ACTIONS_BUFSIZE_KMALLOC)
-               sfa = kmalloc(size, GFP_KERNEL);
-       else
-               sfa = vmalloc(size);
-
+       sfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL);
        if (!sfa)
                return ERR_PTR(-ENOMEM);
 
        sfa->actions_len = 0;
-       sfa->buf_size = size;
-
        return sfa;
 }
 
-void ovs_flow_actions_free(struct sw_flow_actions *sfa)
-{
-       if (sfa->buf_size <= MAX_ACTIONS_BUFSIZE_KMALLOC)
-               kfree(sfa);
-       else
-               vfree(sfa);
-}
-
 struct sw_flow *ovs_flow_alloc(void)
 {
        struct sw_flow *flow;
@@ -452,7 +437,7 @@ static void rcu_free_acts_callback(struct rcu_head *rcu)
 {
        struct sw_flow_actions *sf_acts = container_of(rcu,
                        struct sw_flow_actions, rcu);
-       ovs_flow_actions_free(sf_acts);
+       kfree(sf_acts);
 }
 
 /* Schedules 'sf_acts' to be freed after the next RCU grace period.
index 3b08ea6..6949640 100644 (file)
@@ -37,7 +37,6 @@ struct sk_buff;
 struct sw_flow_actions {
        struct rcu_head rcu;
        u32 actions_len;
-       int buf_size;
        struct nlattr actions[];
 };
 
@@ -152,7 +151,6 @@ void ovs_flow_deferred_free(struct sw_flow *);
 void ovs_flow_free(struct sw_flow *);
 
 struct sw_flow_actions *ovs_flow_actions_alloc(int actions_len);
-void ovs_flow_actions_free(struct sw_flow_actions *sfa);
 void ovs_flow_deferred_free_acts(struct sw_flow_actions *);
 
 int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *,
@@ -196,8 +194,7 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
 int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow, int key_len,
                                   const struct nlattr *attr);
 
-#define MAX_ACTIONS_BUFSIZE            (32 * 1024)
-#define MAX_ACTIONS_BUFSIZE_KMALLOC    PAGE_SIZE
+#define MAX_ACTIONS_BUFSIZE    (16 * 1024)
 #define TBL_MIN_BUCKETS                1024
 
 struct flow_table {