Skip to content

Commit fe93f0b

Browse files
pmachatadavem330
authored andcommitted
net: tc_skbedit: Factor a helper out of is_tcf_skbedit_{mark, ptype}()
The two functions is_tcf_skbedit_mark() and is_tcf_skbedit_ptype() have a very similar structure. A follow-up patch will add one more such function. Instead of more cut'n'pasting, extract a helper function that checks whether a TC action is an skbedit with the required flag. Convert the two existing functions into thin wrappers around the helper. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3fd177c commit fe93f0b

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

‎include/net/tc_act/tc_skbedit.h‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ struct tcf_skbedit {
2727
};
2828
#define to_skbedit(a) ((struct tcf_skbedit *)a)
2929

30-
/* Return true iff action is mark */
31-
static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
30+
/* Return true iff action is the one identified by FLAG. */
31+
static inline bool is_tcf_skbedit_with_flag(const struct tc_action *a, u32 flag)
3232
{
3333
#ifdef CONFIG_NET_CLS_ACT
3434
u32 flags;
@@ -37,12 +37,18 @@ static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
3737
rcu_read_lock();
3838
flags = rcu_dereference(to_skbedit(a)->params)->flags;
3939
rcu_read_unlock();
40-
return flags == SKBEDIT_F_MARK;
40+
return flags == flag;
4141
}
4242
#endif
4343
return false;
4444
}
4545

46+
/* Return true iff action is mark */
47+
static inline bool is_tcf_skbedit_mark(const struct tc_action *a)
48+
{
49+
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_MARK);
50+
}
51+
4652
static inline u32 tcf_skbedit_mark(const struct tc_action *a)
4753
{
4854
u32 mark;
@@ -57,17 +63,7 @@ static inline u32 tcf_skbedit_mark(const struct tc_action *a)
5763
/* Return true iff action is ptype */
5864
static inline bool is_tcf_skbedit_ptype(const struct tc_action *a)
5965
{
60-
#ifdef CONFIG_NET_CLS_ACT
61-
u32 flags;
62-
63-
if (a->ops && a->ops->id == TCA_ID_SKBEDIT) {
64-
rcu_read_lock();
65-
flags = rcu_dereference(to_skbedit(a)->params)->flags;
66-
rcu_read_unlock();
67-
return flags == SKBEDIT_F_PTYPE;
68-
}
69-
#endif
70-
return false;
66+
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PTYPE);
7167
}
7268

7369
static inline u32 tcf_skbedit_ptype(const struct tc_action *a)

0 commit comments

Comments
 (0)