Skip to content

Commit 255cb30

Browse files
hadarhenziondavem330
authored andcommitted
net/sched: act_mirred: Add new tc_action_ops get_dev()
Adding support to a new tc_action_ops. get_dev is a general option which allows to get the underline device when trying to offload a tc rule. In case of mirred action the returned device is the mirred (egress) device. Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3036dab commit 255cb30

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/net/act_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ struct tc_action_ops {
119119
int (*walk)(struct net *, struct sk_buff *,
120120
struct netlink_callback *, int, const struct tc_action_ops *);
121121
void (*stats_update)(struct tc_action *, u64, u32, u64);
122+
int (*get_dev)(const struct tc_action *a, struct net *net,
123+
struct net_device **mirred_dev);
122124
};
123125

124126
struct tc_action_net {

net/sched/act_mirred.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ static struct notifier_block mirred_device_notifier = {
315315
.notifier_call = mirred_device_event,
316316
};
317317

318+
static int tcf_mirred_device(const struct tc_action *a, struct net *net,
319+
struct net_device **mirred_dev)
320+
{
321+
int ifindex = tcf_mirred_ifindex(a);
322+
323+
*mirred_dev = __dev_get_by_index(net, ifindex);
324+
if (!mirred_dev)
325+
return -EINVAL;
326+
return 0;
327+
}
328+
318329
static struct tc_action_ops act_mirred_ops = {
319330
.kind = "mirred",
320331
.type = TCA_ACT_MIRRED,
@@ -327,6 +338,7 @@ static struct tc_action_ops act_mirred_ops = {
327338
.walk = tcf_mirred_walker,
328339
.lookup = tcf_mirred_search,
329340
.size = sizeof(struct tcf_mirred),
341+
.get_dev = tcf_mirred_device,
330342
};
331343

332344
static __net_init int mirred_init_net(struct net *net)

0 commit comments

Comments
 (0)