act_gact.c (85d0966fa57e0ef2d30d913c98ca93674f7a03c9) | act_gact.c (0da2dbd6029c2be4191651bafa57c3c006eff63c) |
---|---|
1/* 2 * net/sched/act_gact.c Generic actions 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 6 unchanged lines hidden (view full) --- 15#include <linux/string.h> 16#include <linux/errno.h> 17#include <linux/skbuff.h> 18#include <linux/rtnetlink.h> 19#include <linux/module.h> 20#include <linux/init.h> 21#include <net/netlink.h> 22#include <net/pkt_sched.h> | 1/* 2 * net/sched/act_gact.c Generic actions 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 6 unchanged lines hidden (view full) --- 15#include <linux/string.h> 16#include <linux/errno.h> 17#include <linux/skbuff.h> 18#include <linux/rtnetlink.h> 19#include <linux/module.h> 20#include <linux/init.h> 21#include <net/netlink.h> 22#include <net/pkt_sched.h> |
23#include <net/pkt_cls.h> |
|
23#include <linux/tc_act/tc_gact.h> 24#include <net/tc_act/tc_gact.h> 25 26static unsigned int gact_net_id; 27static struct tc_action_ops act_gact_ops; 28 29#ifdef CONFIG_GACT_PROB 30static int gact_net_rand(struct tcf_gact *gact) --- 25 unchanged lines hidden (view full) --- 56 57static int tcf_gact_init(struct net *net, struct nlattr *nla, 58 struct nlattr *est, struct tc_action **a, 59 int ovr, int bind, bool rtnl_held, 60 struct tcf_proto *tp, struct netlink_ext_ack *extack) 61{ 62 struct tc_action_net *tn = net_generic(net, gact_net_id); 63 struct nlattr *tb[TCA_GACT_MAX + 1]; | 24#include <linux/tc_act/tc_gact.h> 25#include <net/tc_act/tc_gact.h> 26 27static unsigned int gact_net_id; 28static struct tc_action_ops act_gact_ops; 29 30#ifdef CONFIG_GACT_PROB 31static int gact_net_rand(struct tcf_gact *gact) --- 25 unchanged lines hidden (view full) --- 57 58static int tcf_gact_init(struct net *net, struct nlattr *nla, 59 struct nlattr *est, struct tc_action **a, 60 int ovr, int bind, bool rtnl_held, 61 struct tcf_proto *tp, struct netlink_ext_ack *extack) 62{ 63 struct tc_action_net *tn = net_generic(net, gact_net_id); 64 struct nlattr *tb[TCA_GACT_MAX + 1]; |
65 struct tcf_chain *goto_ch = NULL; |
|
64 struct tc_gact *parm; 65 struct tcf_gact *gact; 66 int ret = 0; 67 int err; 68#ifdef CONFIG_GACT_PROB 69 struct tc_gact_p *p_parm = NULL; 70#endif 71 --- 39 unchanged lines hidden (view full) --- 111 if (!ovr) { 112 tcf_idr_release(*a, bind); 113 return -EEXIST; 114 } 115 } else { 116 return err; 117 } 118 | 66 struct tc_gact *parm; 67 struct tcf_gact *gact; 68 int ret = 0; 69 int err; 70#ifdef CONFIG_GACT_PROB 71 struct tc_gact_p *p_parm = NULL; 72#endif 73 --- 39 unchanged lines hidden (view full) --- 113 if (!ovr) { 114 tcf_idr_release(*a, bind); 115 return -EEXIST; 116 } 117 } else { 118 return err; 119 } 120 |
121 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); 122 if (err < 0) 123 goto release_idr; |
|
119 gact = to_gact(*a); 120 121 spin_lock_bh(&gact->tcf_lock); | 124 gact = to_gact(*a); 125 126 spin_lock_bh(&gact->tcf_lock); |
122 gact->tcf_action = parm->action; | 127 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
123#ifdef CONFIG_GACT_PROB 124 if (p_parm) { 125 gact->tcfg_paction = p_parm->paction; 126 gact->tcfg_pval = max_t(u16, 1, p_parm->pval); 127 /* Make sure tcfg_pval is written before tcfg_ptype 128 * coupled with smp_rmb() in gact_net_rand() & gact_determ() 129 */ 130 smp_wmb(); 131 gact->tcfg_ptype = p_parm->ptype; 132 } 133#endif 134 spin_unlock_bh(&gact->tcf_lock); 135 | 128#ifdef CONFIG_GACT_PROB 129 if (p_parm) { 130 gact->tcfg_paction = p_parm->paction; 131 gact->tcfg_pval = max_t(u16, 1, p_parm->pval); 132 /* Make sure tcfg_pval is written before tcfg_ptype 133 * coupled with smp_rmb() in gact_net_rand() & gact_determ() 134 */ 135 smp_wmb(); 136 gact->tcfg_ptype = p_parm->ptype; 137 } 138#endif 139 spin_unlock_bh(&gact->tcf_lock); 140 |
141 if (goto_ch) 142 tcf_chain_put_by_act(goto_ch); 143 |
|
136 if (ret == ACT_P_CREATED) 137 tcf_idr_insert(tn, *a); 138 return ret; | 144 if (ret == ACT_P_CREATED) 145 tcf_idr_insert(tn, *a); 146 return ret; |
147release_idr: 148 tcf_idr_release(*a, bind); 149 return err; |
|
139} 140 141static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, 142 struct tcf_result *res) 143{ 144 struct tcf_gact *gact = to_gact(a); 145 int action = READ_ONCE(gact->tcf_action); 146 --- 162 unchanged lines hidden --- | 150} 151 152static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, 153 struct tcf_result *res) 154{ 155 struct tcf_gact *gact = to_gact(a); 156 int action = READ_ONCE(gact->tcf_action); 157 --- 162 unchanged lines hidden --- |