diff options
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r-- | net/sched/act_api.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 64f5e328cee9..019045174fc3 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/slab.h> | ||
18 | #include <linux/skbuff.h> | 19 | #include <linux/skbuff.h> |
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
20 | #include <linux/kmod.h> | 21 | #include <linux/kmod.h> |
@@ -667,7 +668,8 @@ nlmsg_failure: | |||
667 | } | 668 | } |
668 | 669 | ||
669 | static int | 670 | static int |
670 | act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event) | 671 | act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n, |
672 | struct tc_action *a, int event) | ||
671 | { | 673 | { |
672 | struct sk_buff *skb; | 674 | struct sk_buff *skb; |
673 | 675 | ||
@@ -679,7 +681,7 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event) | |||
679 | return -EINVAL; | 681 | return -EINVAL; |
680 | } | 682 | } |
681 | 683 | ||
682 | return rtnl_unicast(skb, &init_net, pid); | 684 | return rtnl_unicast(skb, net, pid); |
683 | } | 685 | } |
684 | 686 | ||
685 | static struct tc_action * | 687 | static struct tc_action * |
@@ -749,7 +751,8 @@ static struct tc_action *create_a(int i) | |||
749 | return act; | 751 | return act; |
750 | } | 752 | } |
751 | 753 | ||
752 | static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | 754 | static int tca_action_flush(struct net *net, struct nlattr *nla, |
755 | struct nlmsghdr *n, u32 pid) | ||
753 | { | 756 | { |
754 | struct sk_buff *skb; | 757 | struct sk_buff *skb; |
755 | unsigned char *b; | 758 | unsigned char *b; |
@@ -808,7 +811,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
808 | nlh->nlmsg_flags |= NLM_F_ROOT; | 811 | nlh->nlmsg_flags |= NLM_F_ROOT; |
809 | module_put(a->ops->owner); | 812 | module_put(a->ops->owner); |
810 | kfree(a); | 813 | kfree(a); |
811 | err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); | 814 | err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); |
812 | if (err > 0) | 815 | if (err > 0) |
813 | return 0; | 816 | return 0; |
814 | 817 | ||
@@ -825,7 +828,8 @@ noflush_out: | |||
825 | } | 828 | } |
826 | 829 | ||
827 | static int | 830 | static int |
828 | tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | 831 | tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, |
832 | u32 pid, int event) | ||
829 | { | 833 | { |
830 | int i, ret; | 834 | int i, ret; |
831 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; | 835 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; |
@@ -837,7 +841,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | |||
837 | 841 | ||
838 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { | 842 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { |
839 | if (tb[1] != NULL) | 843 | if (tb[1] != NULL) |
840 | return tca_action_flush(tb[1], n, pid); | 844 | return tca_action_flush(net, tb[1], n, pid); |
841 | else | 845 | else |
842 | return -EINVAL; | 846 | return -EINVAL; |
843 | } | 847 | } |
@@ -858,7 +862,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | |||
858 | } | 862 | } |
859 | 863 | ||
860 | if (event == RTM_GETACTION) | 864 | if (event == RTM_GETACTION) |
861 | ret = act_get_notify(pid, n, head, event); | 865 | ret = act_get_notify(net, pid, n, head, event); |
862 | else { /* delete */ | 866 | else { /* delete */ |
863 | struct sk_buff *skb; | 867 | struct sk_buff *skb; |
864 | 868 | ||
@@ -877,7 +881,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | |||
877 | 881 | ||
878 | /* now do the delete */ | 882 | /* now do the delete */ |
879 | tcf_action_destroy(head, 0); | 883 | tcf_action_destroy(head, 0); |
880 | ret = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, | 884 | ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC, |
881 | n->nlmsg_flags&NLM_F_ECHO); | 885 | n->nlmsg_flags&NLM_F_ECHO); |
882 | if (ret > 0) | 886 | if (ret > 0) |
883 | return 0; | 887 | return 0; |
@@ -888,8 +892,8 @@ err: | |||
888 | return ret; | 892 | return ret; |
889 | } | 893 | } |
890 | 894 | ||
891 | static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, | 895 | static int tcf_add_notify(struct net *net, struct tc_action *a, |
892 | u16 flags) | 896 | u32 pid, u32 seq, int event, u16 flags) |
893 | { | 897 | { |
894 | struct tcamsg *t; | 898 | struct tcamsg *t; |
895 | struct nlmsghdr *nlh; | 899 | struct nlmsghdr *nlh; |
@@ -922,7 +926,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, | |||
922 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 926 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
923 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; | 927 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; |
924 | 928 | ||
925 | err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, flags&NLM_F_ECHO); | 929 | err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags&NLM_F_ECHO); |
926 | if (err > 0) | 930 | if (err > 0) |
927 | err = 0; | 931 | err = 0; |
928 | return err; | 932 | return err; |
@@ -935,7 +939,8 @@ nlmsg_failure: | |||
935 | 939 | ||
936 | 940 | ||
937 | static int | 941 | static int |
938 | tcf_action_add(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int ovr) | 942 | tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n, |
943 | u32 pid, int ovr) | ||
939 | { | 944 | { |
940 | int ret = 0; | 945 | int ret = 0; |
941 | struct tc_action *act; | 946 | struct tc_action *act; |
@@ -953,7 +958,7 @@ tcf_action_add(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int ovr) | |||
953 | /* dump then free all the actions after update; inserted policy | 958 | /* dump then free all the actions after update; inserted policy |
954 | * stays intact | 959 | * stays intact |
955 | * */ | 960 | * */ |
956 | ret = tcf_add_notify(act, pid, seq, RTM_NEWACTION, n->nlmsg_flags); | 961 | ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags); |
957 | for (a = act; a; a = act) { | 962 | for (a = act; a; a = act) { |
958 | act = a->next; | 963 | act = a->next; |
959 | kfree(a); | 964 | kfree(a); |
@@ -969,9 +974,6 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
969 | u32 pid = skb ? NETLINK_CB(skb).pid : 0; | 974 | u32 pid = skb ? NETLINK_CB(skb).pid : 0; |
970 | int ret = 0, ovr = 0; | 975 | int ret = 0, ovr = 0; |
971 | 976 | ||
972 | if (!net_eq(net, &init_net)) | ||
973 | return -EINVAL; | ||
974 | |||
975 | ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); | 977 | ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); |
976 | if (ret < 0) | 978 | if (ret < 0) |
977 | return ret; | 979 | return ret; |
@@ -994,15 +996,17 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
994 | if (n->nlmsg_flags&NLM_F_REPLACE) | 996 | if (n->nlmsg_flags&NLM_F_REPLACE) |
995 | ovr = 1; | 997 | ovr = 1; |
996 | replay: | 998 | replay: |
997 | ret = tcf_action_add(tca[TCA_ACT_TAB], n, pid, ovr); | 999 | ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr); |
998 | if (ret == -EAGAIN) | 1000 | if (ret == -EAGAIN) |
999 | goto replay; | 1001 | goto replay; |
1000 | break; | 1002 | break; |
1001 | case RTM_DELACTION: | 1003 | case RTM_DELACTION: |
1002 | ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_DELACTION); | 1004 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, |
1005 | pid, RTM_DELACTION); | ||
1003 | break; | 1006 | break; |
1004 | case RTM_GETACTION: | 1007 | case RTM_GETACTION: |
1005 | ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_GETACTION); | 1008 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, |
1009 | pid, RTM_GETACTION); | ||
1006 | break; | 1010 | break; |
1007 | default: | 1011 | default: |
1008 | BUG(); | 1012 | BUG(); |
@@ -1042,7 +1046,6 @@ find_dump_kind(const struct nlmsghdr *n) | |||
1042 | static int | 1046 | static int |
1043 | tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | 1047 | tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) |
1044 | { | 1048 | { |
1045 | struct net *net = sock_net(skb->sk); | ||
1046 | struct nlmsghdr *nlh; | 1049 | struct nlmsghdr *nlh; |
1047 | unsigned char *b = skb_tail_pointer(skb); | 1050 | unsigned char *b = skb_tail_pointer(skb); |
1048 | struct nlattr *nest; | 1051 | struct nlattr *nest; |
@@ -1052,9 +1055,6 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | |||
1052 | struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); | 1055 | struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); |
1053 | struct nlattr *kind = find_dump_kind(cb->nlh); | 1056 | struct nlattr *kind = find_dump_kind(cb->nlh); |
1054 | 1057 | ||
1055 | if (!net_eq(net, &init_net)) | ||
1056 | return 0; | ||
1057 | |||
1058 | if (kind == NULL) { | 1058 | if (kind == NULL) { |
1059 | printk("tc_dump_action: action bad kind\n"); | 1059 | printk("tc_dump_action: action bad kind\n"); |
1060 | return 0; | 1060 | return 0; |