Skip to content

Commit 5771401

Browse files
tammeladavem330
authored andcommitted
net/sched: act_pedit: remove extra check for key type
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>
1 parent e1201bc commit 5771401

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

net/sched/act_pedit.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -325,37 +325,28 @@ static bool offset_valid(struct sk_buff *skb, int offset)
325325
return true;
326326
}
327327

328-
static int pedit_skb_hdr_offset(struct sk_buff *skb,
329-
enum pedit_header_type htype, int *hoffset)
328+
static void pedit_skb_hdr_offset(struct sk_buff *skb,
329+
enum pedit_header_type htype, int *hoffset)
330330
{
331-
int ret = -EINVAL;
332-
331+
/* 'htype' is validated in the netlink parsing */
333332
switch (htype) {
334333
case TCA_PEDIT_KEY_EX_HDR_TYPE_ETH:
335-
if (skb_mac_header_was_set(skb)) {
334+
if (skb_mac_header_was_set(skb))
336335
*hoffset = skb_mac_offset(skb);
337-
ret = 0;
338-
}
339336
break;
340337
case TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK:
341338
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP4:
342339
case TCA_PEDIT_KEY_EX_HDR_TYPE_IP6:
343340
*hoffset = skb_network_offset(skb);
344-
ret = 0;
345341
break;
346342
case TCA_PEDIT_KEY_EX_HDR_TYPE_TCP:
347343
case TCA_PEDIT_KEY_EX_HDR_TYPE_UDP:
348-
if (skb_transport_header_was_set(skb)) {
344+
if (skb_transport_header_was_set(skb))
349345
*hoffset = skb_transport_offset(skb);
350-
ret = 0;
351-
}
352346
break;
353347
default:
354-
ret = -EINVAL;
355348
break;
356349
}
357-
358-
return ret;
359350
}
360351

361352
TC_INDIRECT_SCOPE int tcf_pedit_act(struct sk_buff *skb,
@@ -388,10 +379,9 @@ TC_INDIRECT_SCOPE int tcf_pedit_act(struct sk_buff *skb,
388379

389380
for (i = parms->tcfp_nkeys; i > 0; i--, tkey++) {
390381
int offset = tkey->off;
382+
int hoffset = 0;
391383
u32 *ptr, hdata;
392-
int hoffset;
393384
u32 val;
394-
int rc;
395385

396386
if (tkey_ex) {
397387
htype = tkey_ex->htype;
@@ -400,12 +390,7 @@ TC_INDIRECT_SCOPE int tcf_pedit_act(struct sk_buff *skb,
400390
tkey_ex++;
401391
}
402392

403-
rc = pedit_skb_hdr_offset(skb, htype, &hoffset);
404-
if (rc) {
405-
pr_info("tc action pedit bad header type specified (0x%x)\n",
406-
htype);
407-
goto bad;
408-
}
393+
pedit_skb_hdr_offset(skb, htype, &hoffset);
409394

410395
if (tkey->offmask) {
411396
u8 *d, _d;

0 commit comments

Comments
 (0)