aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 00:04:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 00:04:44 -0400
commitf8965467f366fd18f01feafb5db10512d7b4422c (patch)
tree3706a9cd779859271ca61b85c63a1bc3f82d626e /net/sched/act_api.c
parenta26272e5200765691e67d6780e52b32498fdb659 (diff)
parent2ec8c6bb5d8f3a62a79f463525054bae1e3d4487 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1674 commits) qlcnic: adding co maintainer ixgbe: add support for active DA cables ixgbe: dcb, do not tag tc_prio_control frames ixgbe: fix ixgbe_tx_is_paused logic ixgbe: always enable vlan strip/insert when DCB is enabled ixgbe: remove some redundant code in setting FCoE FIP filter ixgbe: fix wrong offset to fc_frame_header in ixgbe_fcoe_ddp ixgbe: fix header len when unsplit packet overflows to data buffer ipv6: Never schedule DAD timer on dead address ipv6: Use POSTDAD state ipv6: Use state_lock to protect ifa state ipv6: Replace inet6_ifaddr->dead with state cxgb4: notify upper drivers if the device is already up when they load cxgb4: keep interrupts available when the ports are brought down cxgb4: fix initial addition of MAC address cnic: Return SPQ credit to bnx2x after ring setup and shutdown. cnic: Convert cnic_local_flags to atomic ops. can: Fix SJA1000 command register writes on SMP systems bridge: fix build for CONFIG_SYSFS disabled ARCNET: Limit com20020 PCI ID matches for SOHARD cards ... Fix up various conflicts with pcmcia tree drivers/net/ {pcmcia/3c589_cs.c, wireless/orinoco/orinoco_cs.c and wireless/orinoco/spectrum_cs.c} and feature removal (Documentation/feature-removal-schedule.txt). Also fix a non-content conflict due to pm_qos_requirement getting renamed in the PM tree (now pm_qos_request) in net/mac80211/scan.c
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r--net/sched/act_api.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index d8e0171d9a4b..972378f47f3c 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -153,7 +153,7 @@ int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
153 } else if (type == RTM_GETACTION) { 153 } else if (type == RTM_GETACTION) {
154 return tcf_dump_walker(skb, cb, a, hinfo); 154 return tcf_dump_walker(skb, cb, a, hinfo);
155 } else { 155 } else {
156 printk("tcf_generic_walker: unknown action %d\n", type); 156 WARN(1, "tcf_generic_walker: unknown action %d\n", type);
157 return -EINVAL; 157 return -EINVAL;
158 } 158 }
159} 159}
@@ -403,8 +403,9 @@ void tcf_action_destroy(struct tc_action *act, int bind)
403 module_put(a->ops->owner); 403 module_put(a->ops->owner);
404 act = act->next; 404 act = act->next;
405 kfree(a); 405 kfree(a);
406 } else { /*FIXME: Remove later - catch insertion bugs*/ 406 } else {
407 printk("tcf_action_destroy: BUG? destroying NULL ops\n"); 407 /*FIXME: Remove later - catch insertion bugs*/
408 WARN(1, "tcf_action_destroy: BUG? destroying NULL ops\n");
408 act = act->next; 409 act = act->next;
409 kfree(a); 410 kfree(a);
410 } 411 }
@@ -668,7 +669,8 @@ nlmsg_failure:
668} 669}
669 670
670static int 671static int
671act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event) 672act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n,
673 struct tc_action *a, int event)
672{ 674{
673 struct sk_buff *skb; 675 struct sk_buff *skb;
674 676
@@ -680,7 +682,7 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
680 return -EINVAL; 682 return -EINVAL;
681 } 683 }
682 684
683 return rtnl_unicast(skb, &init_net, pid); 685 return rtnl_unicast(skb, net, pid);
684} 686}
685 687
686static struct tc_action * 688static struct tc_action *
@@ -743,14 +745,15 @@ static struct tc_action *create_a(int i)
743 745
744 act = kzalloc(sizeof(*act), GFP_KERNEL); 746 act = kzalloc(sizeof(*act), GFP_KERNEL);
745 if (act == NULL) { 747 if (act == NULL) {
746 printk("create_a: failed to alloc!\n"); 748 pr_debug("create_a: failed to alloc!\n");
747 return NULL; 749 return NULL;
748 } 750 }
749 act->order = i; 751 act->order = i;
750 return act; 752 return act;
751} 753}
752 754
753static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) 755static int tca_action_flush(struct net *net, struct nlattr *nla,
756 struct nlmsghdr *n, u32 pid)
754{ 757{
755 struct sk_buff *skb; 758 struct sk_buff *skb;
756 unsigned char *b; 759 unsigned char *b;
@@ -764,13 +767,13 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
764 int err = -ENOMEM; 767 int err = -ENOMEM;
765 768
766 if (a == NULL) { 769 if (a == NULL) {
767 printk("tca_action_flush: couldnt create tc_action\n"); 770 pr_debug("tca_action_flush: couldnt create tc_action\n");
768 return err; 771 return err;
769 } 772 }
770 773
771 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); 774 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
772 if (!skb) { 775 if (!skb) {
773 printk("tca_action_flush: failed skb alloc\n"); 776 pr_debug("tca_action_flush: failed skb alloc\n");
774 kfree(a); 777 kfree(a);
775 return err; 778 return err;
776 } 779 }
@@ -809,7 +812,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
809 nlh->nlmsg_flags |= NLM_F_ROOT; 812 nlh->nlmsg_flags |= NLM_F_ROOT;
810 module_put(a->ops->owner); 813 module_put(a->ops->owner);
811 kfree(a); 814 kfree(a);
812 err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); 815 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
813 if (err > 0) 816 if (err > 0)
814 return 0; 817 return 0;
815 818
@@ -826,7 +829,8 @@ noflush_out:
826} 829}
827 830
828static int 831static int
829tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) 832tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
833 u32 pid, int event)
830{ 834{
831 int i, ret; 835 int i, ret;
832 struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; 836 struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
@@ -838,7 +842,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
838 842
839 if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { 843 if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
840 if (tb[1] != NULL) 844 if (tb[1] != NULL)
841 return tca_action_flush(tb[1], n, pid); 845 return tca_action_flush(net, tb[1], n, pid);
842 else 846 else
843 return -EINVAL; 847 return -EINVAL;
844 } 848 }
@@ -859,7 +863,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
859 } 863 }
860 864
861 if (event == RTM_GETACTION) 865 if (event == RTM_GETACTION)
862 ret = act_get_notify(pid, n, head, event); 866 ret = act_get_notify(net, pid, n, head, event);
863 else { /* delete */ 867 else { /* delete */
864 struct sk_buff *skb; 868 struct sk_buff *skb;
865 869
@@ -878,7 +882,7 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
878 882
879 /* now do the delete */ 883 /* now do the delete */
880 tcf_action_destroy(head, 0); 884 tcf_action_destroy(head, 0);
881 ret = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, 885 ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC,
882 n->nlmsg_flags&NLM_F_ECHO); 886 n->nlmsg_flags&NLM_F_ECHO);
883 if (ret > 0) 887 if (ret > 0)
884 return 0; 888 return 0;
@@ -889,8 +893,8 @@ err:
889 return ret; 893 return ret;
890} 894}
891 895
892static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, 896static int tcf_add_notify(struct net *net, struct tc_action *a,
893 u16 flags) 897 u32 pid, u32 seq, int event, u16 flags)
894{ 898{
895 struct tcamsg *t; 899 struct tcamsg *t;
896 struct nlmsghdr *nlh; 900 struct nlmsghdr *nlh;
@@ -923,7 +927,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
923 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 927 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
924 NETLINK_CB(skb).dst_group = RTNLGRP_TC; 928 NETLINK_CB(skb).dst_group = RTNLGRP_TC;
925 929
926 err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, flags&NLM_F_ECHO); 930 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
927 if (err > 0) 931 if (err > 0)
928 err = 0; 932 err = 0;
929 return err; 933 return err;
@@ -936,7 +940,8 @@ nlmsg_failure:
936 940
937 941
938static int 942static int
939tcf_action_add(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int ovr) 943tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
944 u32 pid, int ovr)
940{ 945{
941 int ret = 0; 946 int ret = 0;
942 struct tc_action *act; 947 struct tc_action *act;
@@ -954,7 +959,7 @@ tcf_action_add(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int ovr)
954 /* dump then free all the actions after update; inserted policy 959 /* dump then free all the actions after update; inserted policy
955 * stays intact 960 * stays intact
956 * */ 961 * */
957 ret = tcf_add_notify(act, pid, seq, RTM_NEWACTION, n->nlmsg_flags); 962 ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags);
958 for (a = act; a; a = act) { 963 for (a = act; a; a = act) {
959 act = a->next; 964 act = a->next;
960 kfree(a); 965 kfree(a);
@@ -970,15 +975,12 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
970 u32 pid = skb ? NETLINK_CB(skb).pid : 0; 975 u32 pid = skb ? NETLINK_CB(skb).pid : 0;
971 int ret = 0, ovr = 0; 976 int ret = 0, ovr = 0;
972 977
973 if (!net_eq(net, &init_net))
974 return -EINVAL;
975
976 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); 978 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
977 if (ret < 0) 979 if (ret < 0)
978 return ret; 980 return ret;
979 981
980 if (tca[TCA_ACT_TAB] == NULL) { 982 if (tca[TCA_ACT_TAB] == NULL) {
981 printk("tc_ctl_action: received NO action attribs\n"); 983 pr_notice("tc_ctl_action: received NO action attribs\n");
982 return -EINVAL; 984 return -EINVAL;
983 } 985 }
984 986
@@ -995,15 +997,17 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
995 if (n->nlmsg_flags&NLM_F_REPLACE) 997 if (n->nlmsg_flags&NLM_F_REPLACE)
996 ovr = 1; 998 ovr = 1;
997replay: 999replay:
998 ret = tcf_action_add(tca[TCA_ACT_TAB], n, pid, ovr); 1000 ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr);
999 if (ret == -EAGAIN) 1001 if (ret == -EAGAIN)
1000 goto replay; 1002 goto replay;
1001 break; 1003 break;
1002 case RTM_DELACTION: 1004 case RTM_DELACTION:
1003 ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_DELACTION); 1005 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1006 pid, RTM_DELACTION);
1004 break; 1007 break;
1005 case RTM_GETACTION: 1008 case RTM_GETACTION:
1006 ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_GETACTION); 1009 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1010 pid, RTM_GETACTION);
1007 break; 1011 break;
1008 default: 1012 default:
1009 BUG(); 1013 BUG();
@@ -1043,7 +1047,6 @@ find_dump_kind(const struct nlmsghdr *n)
1043static int 1047static int
1044tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) 1048tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1045{ 1049{
1046 struct net *net = sock_net(skb->sk);
1047 struct nlmsghdr *nlh; 1050 struct nlmsghdr *nlh;
1048 unsigned char *b = skb_tail_pointer(skb); 1051 unsigned char *b = skb_tail_pointer(skb);
1049 struct nlattr *nest; 1052 struct nlattr *nest;
@@ -1053,11 +1056,8 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1053 struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); 1056 struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
1054 struct nlattr *kind = find_dump_kind(cb->nlh); 1057 struct nlattr *kind = find_dump_kind(cb->nlh);
1055 1058
1056 if (!net_eq(net, &init_net))
1057 return 0;
1058
1059 if (kind == NULL) { 1059 if (kind == NULL) {
1060 printk("tc_dump_action: action bad kind\n"); 1060 pr_info("tc_dump_action: action bad kind\n");
1061 return 0; 1061 return 0;
1062 } 1062 }
1063 1063
@@ -1070,7 +1070,8 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1070 a.ops = a_o; 1070 a.ops = a_o;
1071 1071
1072 if (a_o->walk == NULL) { 1072 if (a_o->walk == NULL) {
1073 printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind); 1073 WARN(1, "tc_dump_action: %s !capable of dumping table\n",
1074 a_o->kind);
1074 goto nla_put_failure; 1075 goto nla_put_failure;
1075 } 1076 }
1076 1077