mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-07 13:53:24 +00:00
net/sched: act_mirred: Add helper function tcf_mirred_replace_dev
The act of replacing a device will be repeated by the init logic for the block ID in the patch that allows mirred to a block. Therefore we encapsulate this functionality in a function (tcf_mirred_replace_dev) so that we can reuse it and avoid code repetition. Co-developed-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Co-developed-by: Pedro Tammela <pctammela@mojatatu.com> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Signed-off-by: Victor Nogueira <victor@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
16085e48cb
commit
415e38bf1d
@ -89,6 +89,16 @@ static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
|
|||||||
|
|
||||||
static struct tc_action_ops act_mirred_ops;
|
static struct tc_action_ops act_mirred_ops;
|
||||||
|
|
||||||
|
static void tcf_mirred_replace_dev(struct tcf_mirred *m,
|
||||||
|
struct net_device *ndev)
|
||||||
|
{
|
||||||
|
struct net_device *odev;
|
||||||
|
|
||||||
|
odev = rcu_replace_pointer(m->tcfm_dev, ndev,
|
||||||
|
lockdep_is_held(&m->tcf_lock));
|
||||||
|
netdev_put(odev, &m->tcfm_dev_tracker);
|
||||||
|
}
|
||||||
|
|
||||||
static int tcf_mirred_init(struct net *net, struct nlattr *nla,
|
static int tcf_mirred_init(struct net *net, struct nlattr *nla,
|
||||||
struct nlattr *est, struct tc_action **a,
|
struct nlattr *est, struct tc_action **a,
|
||||||
struct tcf_proto *tp,
|
struct tcf_proto *tp,
|
||||||
@ -170,7 +180,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
|
|||||||
spin_lock_bh(&m->tcf_lock);
|
spin_lock_bh(&m->tcf_lock);
|
||||||
|
|
||||||
if (parm->ifindex) {
|
if (parm->ifindex) {
|
||||||
struct net_device *odev, *ndev;
|
struct net_device *ndev;
|
||||||
|
|
||||||
ndev = dev_get_by_index(net, parm->ifindex);
|
ndev = dev_get_by_index(net, parm->ifindex);
|
||||||
if (!ndev) {
|
if (!ndev) {
|
||||||
@ -179,9 +189,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
|
|||||||
goto put_chain;
|
goto put_chain;
|
||||||
}
|
}
|
||||||
mac_header_xmit = dev_is_mac_header_xmit(ndev);
|
mac_header_xmit = dev_is_mac_header_xmit(ndev);
|
||||||
odev = rcu_replace_pointer(m->tcfm_dev, ndev,
|
tcf_mirred_replace_dev(m, ndev);
|
||||||
lockdep_is_held(&m->tcf_lock));
|
|
||||||
netdev_put(odev, &m->tcfm_dev_tracker);
|
|
||||||
netdev_tracker_alloc(ndev, &m->tcfm_dev_tracker, GFP_ATOMIC);
|
netdev_tracker_alloc(ndev, &m->tcfm_dev_tracker, GFP_ATOMIC);
|
||||||
m->tcfm_mac_header_xmit = mac_header_xmit;
|
m->tcfm_mac_header_xmit = mac_header_xmit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user