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