act_skbedit.c (a3b072cd180c12e8fe0ece9487b9065808327640) act_skbedit.c (86062033feb8a1692f7a3d570c652f1b4a4b4b52)
1/*
2 * Copyright (c) 2008, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT

--- 51 unchanged lines hidden (view full) ---

60
61static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
62 struct nlattr *est, struct tc_action *a,
63 int ovr, int bind)
64{
65 struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
66 struct tc_skbedit *parm;
67 struct tcf_skbedit *d;
1/*
2 * Copyright (c) 2008, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT

--- 51 unchanged lines hidden (view full) ---

60
61static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
62 struct nlattr *est, struct tc_action *a,
63 int ovr, int bind)
64{
65 struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
66 struct tc_skbedit *parm;
67 struct tcf_skbedit *d;
68 struct tcf_common *pc;
69 u32 flags = 0, *priority = NULL, *mark = NULL;
70 u16 *queue_mapping = NULL;
71 int ret = 0, err;
72
73 if (nla == NULL)
74 return -EINVAL;
75
76 err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy);

--- 18 unchanged lines hidden (view full) ---

95 mark = nla_data(tb[TCA_SKBEDIT_MARK]);
96 }
97
98 if (!flags)
99 return -EINVAL;
100
101 parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
102
68 u32 flags = 0, *priority = NULL, *mark = NULL;
69 u16 *queue_mapping = NULL;
70 int ret = 0, err;
71
72 if (nla == NULL)
73 return -EINVAL;
74
75 err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy);

--- 18 unchanged lines hidden (view full) ---

94 mark = nla_data(tb[TCA_SKBEDIT_MARK]);
95 }
96
97 if (!flags)
98 return -EINVAL;
99
100 parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
101
103 pc = tcf_hash_check(parm->index, a, bind);
104 if (!pc) {
105 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind);
106 if (IS_ERR(pc))
107 return PTR_ERR(pc);
102 if (!tcf_hash_check(parm->index, a, bind)) {
103 ret = tcf_hash_create(parm->index, est, a, sizeof(*d), bind);
104 if (ret)
105 return ret;
108
106
109 d = to_skbedit(pc);
107 d = to_skbedit(a);
110 ret = ACT_P_CREATED;
111 } else {
108 ret = ACT_P_CREATED;
109 } else {
112 d = to_skbedit(pc);
110 d = to_skbedit(a);
113 if (bind)
114 return 0;
111 if (bind)
112 return 0;
115 tcf_hash_release(pc, bind, a->ops->hinfo);
113 tcf_hash_release(a, bind);
116 if (!ovr)
117 return -EEXIST;
118 }
119
120 spin_lock_bh(&d->tcf_lock);
121
122 d->flags = flags;
123 if (flags & SKBEDIT_F_PRIORITY)
124 d->priority = *priority;
125 if (flags & SKBEDIT_F_QUEUE_MAPPING)
126 d->queue_mapping = *queue_mapping;
127 if (flags & SKBEDIT_F_MARK)
128 d->mark = *mark;
129
130 d->tcf_action = parm->action;
131
132 spin_unlock_bh(&d->tcf_lock);
133
134 if (ret == ACT_P_CREATED)
114 if (!ovr)
115 return -EEXIST;
116 }
117
118 spin_lock_bh(&d->tcf_lock);
119
120 d->flags = flags;
121 if (flags & SKBEDIT_F_PRIORITY)
122 d->priority = *priority;
123 if (flags & SKBEDIT_F_QUEUE_MAPPING)
124 d->queue_mapping = *queue_mapping;
125 if (flags & SKBEDIT_F_MARK)
126 d->mark = *mark;
127
128 d->tcf_action = parm->action;
129
130 spin_unlock_bh(&d->tcf_lock);
131
132 if (ret == ACT_P_CREATED)
135 tcf_hash_insert(pc, a->ops->hinfo);
133 tcf_hash_insert(a);
136 return ret;
137}
138
134 return ret;
135}
136
139static int tcf_skbedit_cleanup(struct tc_action *a, int bind)
140{
141 struct tcf_skbedit *d = a->priv;
142
143 if (d)
144 return tcf_hash_release(&d->common, bind, &skbedit_hash_info);
145 return 0;
146}
147
148static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
149 int bind, int ref)
150{
151 unsigned char *b = skb_tail_pointer(skb);
152 struct tcf_skbedit *d = a->priv;
153 struct tc_skbedit opt = {
154 .index = d->tcf_index,
155 .refcnt = d->tcf_refcnt - ref,

--- 30 unchanged lines hidden (view full) ---

186
187static struct tc_action_ops act_skbedit_ops = {
188 .kind = "skbedit",
189 .hinfo = &skbedit_hash_info,
190 .type = TCA_ACT_SKBEDIT,
191 .owner = THIS_MODULE,
192 .act = tcf_skbedit,
193 .dump = tcf_skbedit_dump,
137static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
138 int bind, int ref)
139{
140 unsigned char *b = skb_tail_pointer(skb);
141 struct tcf_skbedit *d = a->priv;
142 struct tc_skbedit opt = {
143 .index = d->tcf_index,
144 .refcnt = d->tcf_refcnt - ref,

--- 30 unchanged lines hidden (view full) ---

175
176static struct tc_action_ops act_skbedit_ops = {
177 .kind = "skbedit",
178 .hinfo = &skbedit_hash_info,
179 .type = TCA_ACT_SKBEDIT,
180 .owner = THIS_MODULE,
181 .act = tcf_skbedit,
182 .dump = tcf_skbedit_dump,
194 .cleanup = tcf_skbedit_cleanup,
183 .cleanup = tcf_hash_release,
195 .init = tcf_skbedit_init,
196};
197
198MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>");
199MODULE_DESCRIPTION("SKB Editing");
200MODULE_LICENSE("GPL");
201
202static int __init skbedit_init_module(void)

--- 15 unchanged lines hidden ---
184 .init = tcf_skbedit_init,
185};
186
187MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>");
188MODULE_DESCRIPTION("SKB Editing");
189MODULE_LICENSE("GPL");
190
191static int __init skbedit_init_module(void)

--- 15 unchanged lines hidden ---