act_skbedit.c (5a2dd72abdae75ea2960145e0549635ce4e0be96) act_skbedit.c (1c55d62e77fa16cdace417834fc7b8a421a1877f)
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

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

49 d->tcf_bstats.bytes += qdisc_pkt_len(skb);
50 d->tcf_bstats.packets++;
51
52 if (d->flags & SKBEDIT_F_PRIORITY)
53 skb->priority = d->priority;
54 if (d->flags & SKBEDIT_F_QUEUE_MAPPING &&
55 skb->dev->real_num_tx_queues > d->queue_mapping)
56 skb_set_queue_mapping(skb, d->queue_mapping);
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

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

49 d->tcf_bstats.bytes += qdisc_pkt_len(skb);
50 d->tcf_bstats.packets++;
51
52 if (d->flags & SKBEDIT_F_PRIORITY)
53 skb->priority = d->priority;
54 if (d->flags & SKBEDIT_F_QUEUE_MAPPING &&
55 skb->dev->real_num_tx_queues > d->queue_mapping)
56 skb_set_queue_mapping(skb, d->queue_mapping);
57 if (d->flags & SKBEDIT_F_MARK)
58 skb->mark = d->mark;
57
58 spin_unlock(&d->tcf_lock);
59 return d->tcf_action;
60}
61
62static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = {
63 [TCA_SKBEDIT_PARMS] = { .len = sizeof(struct tc_skbedit) },
64 [TCA_SKBEDIT_PRIORITY] = { .len = sizeof(u32) },
65 [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) },
59
60 spin_unlock(&d->tcf_lock);
61 return d->tcf_action;
62}
63
64static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = {
65 [TCA_SKBEDIT_PARMS] = { .len = sizeof(struct tc_skbedit) },
66 [TCA_SKBEDIT_PRIORITY] = { .len = sizeof(u32) },
67 [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) },
68 [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) },
66};
67
68static int tcf_skbedit_init(struct nlattr *nla, struct nlattr *est,
69 struct tc_action *a, int ovr, int bind)
70{
71 struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
72 struct tc_skbedit *parm;
73 struct tcf_skbedit *d;
74 struct tcf_common *pc;
69};
70
71static int tcf_skbedit_init(struct nlattr *nla, struct nlattr *est,
72 struct tc_action *a, int ovr, int bind)
73{
74 struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
75 struct tc_skbedit *parm;
76 struct tcf_skbedit *d;
77 struct tcf_common *pc;
75 u32 flags = 0, *priority = NULL;
78 u32 flags = 0, *priority = NULL, *mark = NULL;
76 u16 *queue_mapping = NULL;
77 int ret = 0, err;
78
79 if (nla == NULL)
80 return -EINVAL;
81
82 err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy);
83 if (err < 0)

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

90 flags |= SKBEDIT_F_PRIORITY;
91 priority = nla_data(tb[TCA_SKBEDIT_PRIORITY]);
92 }
93
94 if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) {
95 flags |= SKBEDIT_F_QUEUE_MAPPING;
96 queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]);
97 }
79 u16 *queue_mapping = NULL;
80 int ret = 0, err;
81
82 if (nla == NULL)
83 return -EINVAL;
84
85 err = nla_parse_nested(tb, TCA_SKBEDIT_MAX, nla, skbedit_policy);
86 if (err < 0)

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

93 flags |= SKBEDIT_F_PRIORITY;
94 priority = nla_data(tb[TCA_SKBEDIT_PRIORITY]);
95 }
96
97 if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) {
98 flags |= SKBEDIT_F_QUEUE_MAPPING;
99 queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]);
100 }
101
102 if (tb[TCA_SKBEDIT_MARK] != NULL) {
103 flags |= SKBEDIT_F_MARK;
104 mark = nla_data(tb[TCA_SKBEDIT_MARK]);
105 }
106
98 if (!flags)
99 return -EINVAL;
100
101 parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
102
103 pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info);
104 if (!pc) {
105 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,

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

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;
107 if (!flags)
108 return -EINVAL;
109
110 parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
111
112 pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info);
113 if (!pc) {
114 pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,

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

128
129 spin_lock_bh(&d->tcf_lock);
130
131 d->flags = flags;
132 if (flags & SKBEDIT_F_PRIORITY)
133 d->priority = *priority;
134 if (flags & SKBEDIT_F_QUEUE_MAPPING)
135 d->queue_mapping = *queue_mapping;
136 if (flags & SKBEDIT_F_MARK)
137 d->mark = *mark;
138
127 d->tcf_action = parm->action;
128
129 spin_unlock_bh(&d->tcf_lock);
130
131 if (ret == ACT_P_CREATED)
132 tcf_hash_insert(pc, &skbedit_hash_info);
133 return ret;
134}

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

156 opt.action = d->tcf_action;
157 NLA_PUT(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt);
158 if (d->flags & SKBEDIT_F_PRIORITY)
159 NLA_PUT(skb, TCA_SKBEDIT_PRIORITY, sizeof(d->priority),
160 &d->priority);
161 if (d->flags & SKBEDIT_F_QUEUE_MAPPING)
162 NLA_PUT(skb, TCA_SKBEDIT_QUEUE_MAPPING,
163 sizeof(d->queue_mapping), &d->queue_mapping);
139 d->tcf_action = parm->action;
140
141 spin_unlock_bh(&d->tcf_lock);
142
143 if (ret == ACT_P_CREATED)
144 tcf_hash_insert(pc, &skbedit_hash_info);
145 return ret;
146}

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

168 opt.action = d->tcf_action;
169 NLA_PUT(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt);
170 if (d->flags & SKBEDIT_F_PRIORITY)
171 NLA_PUT(skb, TCA_SKBEDIT_PRIORITY, sizeof(d->priority),
172 &d->priority);
173 if (d->flags & SKBEDIT_F_QUEUE_MAPPING)
174 NLA_PUT(skb, TCA_SKBEDIT_QUEUE_MAPPING,
175 sizeof(d->queue_mapping), &d->queue_mapping);
176 if (d->flags & SKBEDIT_F_MARK)
177 NLA_PUT(skb, TCA_SKBEDIT_MARK, sizeof(d->mark),
178 &d->mark);
164 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
165 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
166 t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
167 NLA_PUT(skb, TCA_SKBEDIT_TM, sizeof(t), &t);
168 return skb->len;
169
170nla_put_failure:
171 nlmsg_trim(skb, b);

--- 32 unchanged lines hidden ---
179 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
180 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
181 t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
182 NLA_PUT(skb, TCA_SKBEDIT_TM, sizeof(t), &t);
183 return skb->len;
184
185nla_put_failure:
186 nlmsg_trim(skb, b);

--- 32 unchanged lines hidden ---