Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pkt_sched: skbedit add support for setting mark

This adds support for setting the skb mark.

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

jamal and committed by
David S. Miller
1c55d62e 188586b2

+20 -1
+2
include/linux/tc_act/tc_skbedit.h
··· 26 26 27 27 #define SKBEDIT_F_PRIORITY 0x1 28 28 #define SKBEDIT_F_QUEUE_MAPPING 0x2 29 + #define SKBEDIT_F_MARK 0x4 29 30 30 31 struct tc_skbedit { 31 32 tc_gen; ··· 38 37 TCA_SKBEDIT_PARMS, 39 38 TCA_SKBEDIT_PRIORITY, 40 39 TCA_SKBEDIT_QUEUE_MAPPING, 40 + TCA_SKBEDIT_MARK, 41 41 __TCA_SKBEDIT_MAX 42 42 }; 43 43 #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
+2
include/net/tc_act/tc_skbedit.h
··· 26 26 struct tcf_common common; 27 27 u32 flags; 28 28 u32 priority; 29 + u32 mark; 29 30 u16 queue_mapping; 31 + /* XXX: 16-bit pad here? */ 30 32 }; 31 33 #define to_skbedit(pc) \ 32 34 container_of(pc, struct tcf_skbedit, common)
+16 -1
net/sched/act_skbedit.c
··· 54 54 if (d->flags & SKBEDIT_F_QUEUE_MAPPING && 55 55 skb->dev->real_num_tx_queues > d->queue_mapping) 56 56 skb_set_queue_mapping(skb, d->queue_mapping); 57 + if (d->flags & SKBEDIT_F_MARK) 58 + skb->mark = d->mark; 57 59 58 60 spin_unlock(&d->tcf_lock); 59 61 return d->tcf_action; ··· 65 63 [TCA_SKBEDIT_PARMS] = { .len = sizeof(struct tc_skbedit) }, 66 64 [TCA_SKBEDIT_PRIORITY] = { .len = sizeof(u32) }, 67 65 [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) }, 66 + [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) }, 68 67 }; 69 68 70 69 static int tcf_skbedit_init(struct nlattr *nla, struct nlattr *est, ··· 75 72 struct tc_skbedit *parm; 76 73 struct tcf_skbedit *d; 77 74 struct tcf_common *pc; 78 - u32 flags = 0, *priority = NULL; 75 + u32 flags = 0, *priority = NULL, *mark = NULL; 79 76 u16 *queue_mapping = NULL; 80 77 int ret = 0, err; 81 78 ··· 98 95 flags |= SKBEDIT_F_QUEUE_MAPPING; 99 96 queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]); 100 97 } 98 + 99 + if (tb[TCA_SKBEDIT_MARK] != NULL) { 100 + flags |= SKBEDIT_F_MARK; 101 + mark = nla_data(tb[TCA_SKBEDIT_MARK]); 102 + } 103 + 101 104 if (!flags) 102 105 return -EINVAL; 103 106 ··· 133 124 d->priority = *priority; 134 125 if (flags & SKBEDIT_F_QUEUE_MAPPING) 135 126 d->queue_mapping = *queue_mapping; 127 + if (flags & SKBEDIT_F_MARK) 128 + d->mark = *mark; 129 + 136 130 d->tcf_action = parm->action; 137 131 138 132 spin_unlock_bh(&d->tcf_lock); ··· 173 161 if (d->flags & SKBEDIT_F_QUEUE_MAPPING) 174 162 NLA_PUT(skb, TCA_SKBEDIT_QUEUE_MAPPING, 175 163 sizeof(d->queue_mapping), &d->queue_mapping); 164 + if (d->flags & SKBEDIT_F_MARK) 165 + NLA_PUT(skb, TCA_SKBEDIT_MARK, sizeof(d->mark), 166 + &d->mark); 176 167 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); 177 168 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); 178 169 t.expires = jiffies_to_clock_t(d->tcf_tm.expires);