|
@@ -102,7 +102,11 @@ EXPORT_SYMBOL(unregister_tcf_proto_ops);
|
|
|
|
|
|
static int tfilter_notify(struct net *net, struct sk_buff *oskb,
|
|
static int tfilter_notify(struct net *net, struct sk_buff *oskb,
|
|
struct nlmsghdr *n, struct tcf_proto *tp,
|
|
struct nlmsghdr *n, struct tcf_proto *tp,
|
|
- unsigned long fh, int event, bool unicast);
|
|
|
|
|
|
+ void *fh, int event, bool unicast);
|
|
|
|
+
|
|
|
|
+static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
|
|
|
|
+ struct nlmsghdr *n, struct tcf_proto *tp,
|
|
|
|
+ void *fh, bool unicast, bool *last);
|
|
|
|
|
|
static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
|
|
static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
|
|
struct nlmsghdr *n,
|
|
struct nlmsghdr *n,
|
|
@@ -428,7 +432,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
|
|
struct tcf_proto *tp;
|
|
struct tcf_proto *tp;
|
|
const struct Qdisc_class_ops *cops;
|
|
const struct Qdisc_class_ops *cops;
|
|
unsigned long cl;
|
|
unsigned long cl;
|
|
- unsigned long fh;
|
|
|
|
|
|
+ void *fh;
|
|
int err;
|
|
int err;
|
|
int tp_created;
|
|
int tp_created;
|
|
|
|
|
|
@@ -567,7 +571,7 @@ replay:
|
|
|
|
|
|
fh = tp->ops->get(tp, t->tcm_handle);
|
|
fh = tp->ops->get(tp, t->tcm_handle);
|
|
|
|
|
|
- if (fh == 0) {
|
|
|
|
|
|
+ if (!fh) {
|
|
if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) {
|
|
if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) {
|
|
tcf_chain_tp_remove(chain, &chain_info, tp);
|
|
tcf_chain_tp_remove(chain, &chain_info, tp);
|
|
tfilter_notify(net, skb, n, tp, fh,
|
|
tfilter_notify(net, skb, n, tp, fh,
|
|
@@ -595,11 +599,10 @@ replay:
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case RTM_DELTFILTER:
|
|
case RTM_DELTFILTER:
|
|
- err = tp->ops->delete(tp, fh, &last);
|
|
|
|
|
|
+ err = tfilter_del_notify(net, skb, n, tp, fh, false,
|
|
|
|
+ &last);
|
|
if (err)
|
|
if (err)
|
|
goto errout;
|
|
goto errout;
|
|
- tfilter_notify(net, skb, n, tp, t->tcm_handle,
|
|
|
|
- RTM_DELTFILTER, false);
|
|
|
|
if (last) {
|
|
if (last) {
|
|
tcf_chain_tp_remove(chain, &chain_info, tp);
|
|
tcf_chain_tp_remove(chain, &chain_info, tp);
|
|
tcf_proto_destroy(tp);
|
|
tcf_proto_destroy(tp);
|
|
@@ -638,7 +641,7 @@ errout:
|
|
}
|
|
}
|
|
|
|
|
|
static int tcf_fill_node(struct net *net, struct sk_buff *skb,
|
|
static int tcf_fill_node(struct net *net, struct sk_buff *skb,
|
|
- struct tcf_proto *tp, unsigned long fh, u32 portid,
|
|
|
|
|
|
+ struct tcf_proto *tp, void *fh, u32 portid,
|
|
u32 seq, u16 flags, int event)
|
|
u32 seq, u16 flags, int event)
|
|
{
|
|
{
|
|
struct tcmsg *tcm;
|
|
struct tcmsg *tcm;
|
|
@@ -659,9 +662,9 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,
|
|
goto nla_put_failure;
|
|
goto nla_put_failure;
|
|
if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index))
|
|
if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index))
|
|
goto nla_put_failure;
|
|
goto nla_put_failure;
|
|
- tcm->tcm_handle = fh;
|
|
|
|
- if (RTM_DELTFILTER != event) {
|
|
|
|
|
|
+ if (!fh) {
|
|
tcm->tcm_handle = 0;
|
|
tcm->tcm_handle = 0;
|
|
|
|
+ } else {
|
|
if (tp->ops->dump && tp->ops->dump(net, tp, fh, skb, tcm) < 0)
|
|
if (tp->ops->dump && tp->ops->dump(net, tp, fh, skb, tcm) < 0)
|
|
goto nla_put_failure;
|
|
goto nla_put_failure;
|
|
}
|
|
}
|
|
@@ -676,7 +679,7 @@ nla_put_failure:
|
|
|
|
|
|
static int tfilter_notify(struct net *net, struct sk_buff *oskb,
|
|
static int tfilter_notify(struct net *net, struct sk_buff *oskb,
|
|
struct nlmsghdr *n, struct tcf_proto *tp,
|
|
struct nlmsghdr *n, struct tcf_proto *tp,
|
|
- unsigned long fh, int event, bool unicast)
|
|
|
|
|
|
+ void *fh, int event, bool unicast)
|
|
{
|
|
{
|
|
struct sk_buff *skb;
|
|
struct sk_buff *skb;
|
|
u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
|
|
u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
|
|
@@ -698,14 +701,44 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,
|
|
n->nlmsg_flags & NLM_F_ECHO);
|
|
n->nlmsg_flags & NLM_F_ECHO);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
|
|
|
|
+ struct nlmsghdr *n, struct tcf_proto *tp,
|
|
|
|
+ void *fh, bool unicast, bool *last)
|
|
|
|
+{
|
|
|
|
+ struct sk_buff *skb;
|
|
|
|
+ u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
|
|
|
|
+ if (!skb)
|
|
|
|
+ return -ENOBUFS;
|
|
|
|
+
|
|
|
|
+ if (tcf_fill_node(net, skb, tp, fh, portid, n->nlmsg_seq,
|
|
|
|
+ n->nlmsg_flags, RTM_DELTFILTER) <= 0) {
|
|
|
|
+ kfree_skb(skb);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err = tp->ops->delete(tp, fh, last);
|
|
|
|
+ if (err) {
|
|
|
|
+ kfree_skb(skb);
|
|
|
|
+ return err;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (unicast)
|
|
|
|
+ return netlink_unicast(net->rtnl, skb, portid, MSG_DONTWAIT);
|
|
|
|
+
|
|
|
|
+ return rtnetlink_send(skb, net, portid, RTNLGRP_TC,
|
|
|
|
+ n->nlmsg_flags & NLM_F_ECHO);
|
|
|
|
+}
|
|
|
|
+
|
|
struct tcf_dump_args {
|
|
struct tcf_dump_args {
|
|
struct tcf_walker w;
|
|
struct tcf_walker w;
|
|
struct sk_buff *skb;
|
|
struct sk_buff *skb;
|
|
struct netlink_callback *cb;
|
|
struct netlink_callback *cb;
|
|
};
|
|
};
|
|
|
|
|
|
-static int tcf_node_dump(struct tcf_proto *tp, unsigned long n,
|
|
|
|
- struct tcf_walker *arg)
|
|
|
|
|
|
+static int tcf_node_dump(struct tcf_proto *tp, void *n, struct tcf_walker *arg)
|
|
{
|
|
{
|
|
struct tcf_dump_args *a = (void *)arg;
|
|
struct tcf_dump_args *a = (void *)arg;
|
|
struct net *net = sock_net(a->skb->sk);
|
|
struct net *net = sock_net(a->skb->sk);
|