net/sched: act_pedit: remove extra check for key type
[ Upstream commit 577140180ba28d0d37bc898c7bd6702c83aa106f ] The netlink parsing already validates the key 'htype'. Remove the datapath check as it's redundant. Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net> Stable-dep-of: 6c02568fd1ae ("net/sched: act_pedit: Parse L3 Header for L4 offset") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b4e5d0c4cf
commit
fb25478f66
@ -312,37 +312,28 @@ static bool offset_valid(struct sk_buff *skb, int offset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pedit_skb_hdr_offset(struct sk_buff *skb,
|
static void pedit_skb_hdr_offset(struct sk_buff *skb,
|
||||||
enum pedit_header_type htype, int *hoffset)
|
enum pedit_header_type htype, int *hoffset)
|
||||||
{
|
{
|
||||||
int ret = -EINVAL;
|
/* 'htype' is validated in the netlink parsing */
|
||||||
|
|
||||||
switch (htype) {
|
switch (htype) {
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_ETH:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_ETH:
|
||||||
if (skb_mac_header_was_set(skb)) {
|
if (skb_mac_header_was_set(skb))
|
||||||
*hoffset = skb_mac_offset(skb);
|
*hoffset = skb_mac_offset(skb);
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK:
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP4:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP4:
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP6:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP6:
|
||||||
*hoffset = skb_network_offset(skb);
|
*hoffset = skb_network_offset(skb);
|
||||||
ret = 0;
|
|
||||||
break;
|
break;
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_TCP:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_TCP:
|
||||||
case TCA_PEDIT_KEY_EX_HDR_TYPE_UDP:
|
case TCA_PEDIT_KEY_EX_HDR_TYPE_UDP:
|
||||||
if (skb_transport_header_was_set(skb)) {
|
if (skb_transport_header_was_set(skb))
|
||||||
*hoffset = skb_transport_offset(skb);
|
*hoffset = skb_transport_offset(skb);
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
|
static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
|
||||||
@ -374,10 +365,9 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
|
|||||||
|
|
||||||
for (i = parms->tcfp_nkeys; i > 0; i--, tkey++) {
|
for (i = parms->tcfp_nkeys; i > 0; i--, tkey++) {
|
||||||
int offset = tkey->off;
|
int offset = tkey->off;
|
||||||
|
int hoffset = 0;
|
||||||
u32 *ptr, hdata;
|
u32 *ptr, hdata;
|
||||||
int hoffset;
|
|
||||||
u32 val;
|
u32 val;
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (tkey_ex) {
|
if (tkey_ex) {
|
||||||
htype = tkey_ex->htype;
|
htype = tkey_ex->htype;
|
||||||
@ -386,12 +376,7 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
|
|||||||
tkey_ex++;
|
tkey_ex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = pedit_skb_hdr_offset(skb, htype, &hoffset);
|
pedit_skb_hdr_offset(skb, htype, &hoffset);
|
||||||
if (rc) {
|
|
||||||
pr_info("tc action pedit bad header type specified (0x%x)\n",
|
|
||||||
htype);
|
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tkey->offmask) {
|
if (tkey->offmask) {
|
||||||
u8 *d, _d;
|
u8 *d, _d;
|
||||||
|
Loading…
Reference in New Issue
Block a user