Skip to content

Commit

Permalink
net/sched: act_mirred: Add new tc_action_ops get_dev()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
hadarhenzion authored and davem330 committed Dec 2, 2016
1 parent 3036dab commit 255cb30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/net/act_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct tc_action_ops {
int (*walk)(struct net *, struct sk_buff *,
struct netlink_callback *, int, const struct tc_action_ops *);
void (*stats_update)(struct tc_action *, u64, u32, u64);
int (*get_dev)(const struct tc_action *a, struct net *net,
struct net_device **mirred_dev);
};

struct tc_action_net {
Expand Down
12 changes: 12 additions & 0 deletions net/sched/act_mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ static struct notifier_block mirred_device_notifier = {
.notifier_call = mirred_device_event,
};

static int tcf_mirred_device(const struct tc_action *a, struct net *net,
struct net_device **mirred_dev)
{
int ifindex = tcf_mirred_ifindex(a);

*mirred_dev = __dev_get_by_index(net, ifindex);
if (!mirred_dev)
return -EINVAL;
return 0;
}

static struct tc_action_ops act_mirred_ops = {
.kind = "mirred",
.type = TCA_ACT_MIRRED,
Expand All @@ -327,6 +338,7 @@ static struct tc_action_ops act_mirred_ops = {
.walk = tcf_mirred_walker,
.lookup = tcf_mirred_search,
.size = sizeof(struct tcf_mirred),
.get_dev = tcf_mirred_device,
};

static __net_init int mirred_init_net(struct net *net)
Expand Down

0 comments on commit 255cb30

Please sign in to comment.