| @@ -46,8 +46,10 @@ static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a, · 45 unmodified lines |
| 46 | if (d->flags & SKBEDIT_F_QUEUE_MAPPING && | 46 | if (d->flags & SKBEDIT_F_QUEUE_MAPPING && |
| 47 | skb->dev->real_num_tx_queues > d->queue_mapping) | 47 | skb->dev->real_num_tx_queues > d->queue_mapping) |
| 48 | skb_set_queue_mapping(skb, d->queue_mapping); | 48 | skb_set_queue_mapping(skb, d->queue_mapping); |
| 49 | if (d->flags & SKBEDIT_F_MARK) | 49 | if (d->flags & SKBEDIT_F_MARK) { |
| 50 | skb->mark = d->mark; | 50 | skb->mark &= ~d->mask; |
| | 51 | skb->mark |= d->mark & d->mask; |
| | 52 | } |
| 51 | if (d->flags & SKBEDIT_F_PTYPE) | 53 | if (d->flags & SKBEDIT_F_PTYPE) |
| 52 | skb->pkt_type = d->ptype; | 54 | skb->pkt_type = d->ptype; |
| 53 | | 55 | |
| @@ -61,6 +63,7 @@ static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = { · 7 unmodified lines |
| 61 | [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) }, | 63 | [TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) }, |
| 62 | [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) }, | 64 | [TCA_SKBEDIT_MARK] = { .len = sizeof(u32) }, |
| 63 | [TCA_SKBEDIT_PTYPE] = { .len = sizeof(u16) }, | 65 | [TCA_SKBEDIT_PTYPE] = { .len = sizeof(u16) }, |
| | 66 | [TCA_SKBEDIT_MASK] = { .len = sizeof(u32) }, |
| 64 | }; | 67 | }; |
| 65 | | 68 | |
| 66 | static int tcf_skbedit_init(struct net *net, struct nlattr *nla, | 69 | static int tcf_skbedit_init(struct net *net, struct nlattr *nla, |
| @@ -71,7 +74,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 4 unmodified lines |
| 71 | struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; | 74 | struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; |
| 72 | struct tc_skbedit *parm; | 75 | struct tc_skbedit *parm; |
| 73 | struct tcf_skbedit *d; | 76 | struct tcf_skbedit *d; |
| 74 | u32 flags = 0, *priority = NULL, *mark = NULL; | 77 | u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; |
| 75 | u16 *queue_mapping = NULL, *ptype = NULL; | 78 | u16 *queue_mapping = NULL, *ptype = NULL; |
| 76 | bool exists = false; | 79 | bool exists = false; |
| 77 | int ret = 0, err; | 80 | int ret = 0, err; |
| @@ -108,6 +111,11 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 30 unmodified lines |
| 108 | mark = nla_data(tb[TCA_SKBEDIT_MARK]); | 111 | mark = nla_data(tb[TCA_SKBEDIT_MARK]); |
| 109 | } | 112 | } |
| 110 | | 113 | |
| | 114 | if (tb[TCA_SKBEDIT_MASK] != NULL) { |
| | 115 | flags |= SKBEDIT_F_MASK; |
| | 116 | mask = nla_data(tb[TCA_SKBEDIT_MASK]); |
| | 117 | } |
| | 118 | |
| 111 | parm = nla_data(tb[TCA_SKBEDIT_PARMS]); | 119 | parm = nla_data(tb[TCA_SKBEDIT_PARMS]); |
| 112 | | 120 | |
| 113 | exists = tcf_hash_check(tn, parm->index, a, bind); | 121 | exists = tcf_hash_check(tn, parm->index, a, bind); |
| @@ -145,6 +153,10 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 31 unmodified lines |
| 145 | d->mark = *mark; | 153 | d->mark = *mark; |
| 146 | if (flags & SKBEDIT_F_PTYPE) | 154 | if (flags & SKBEDIT_F_PTYPE) |
| 147 | d->ptype = *ptype; | 155 | d->ptype = *ptype; |
| | 156 | /* default behaviour is to use all the bits */ |
| | 157 | d->mask = 0xffffffff; |
| | 158 | if (flags & SKBEDIT_F_MASK) |
| | 159 | d->mask = *mask; |
| 148 | | 160 | |
| 149 | d->tcf_action = parm->action; | 161 | d->tcf_action = parm->action; |
| 150 | | 162 | |
| @@ -182,6 +194,9 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, · 31 unmodified lines |
| 182 | if ((d->flags & SKBEDIT_F_PTYPE) && | 194 | if ((d->flags & SKBEDIT_F_PTYPE) && |
| 183 | nla_put_u16(skb, TCA_SKBEDIT_PTYPE, d->ptype)) | 195 | nla_put_u16(skb, TCA_SKBEDIT_PTYPE, d->ptype)) |
| 184 | goto nla_put_failure; | 196 | goto nla_put_failure; |
| | 197 | if ((d->flags & SKBEDIT_F_MASK) && |
| | 198 | nla_put_u32(skb, TCA_SKBEDIT_MASK, d->mask)) |
| | 199 | goto nla_put_failure; |
| 185 | | 200 | |
| 186 | tcf_tm_dump(&t, &d->tcf_tm); | 201 | tcf_tm_dump(&t, &d->tcf_tm); |
| 187 | if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD)) | 202 | if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD)) |