diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-07 16:12:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-10 15:30:41 -0400 |
commit | 15e473046cb6e5d18a4d0057e61d76315230382b (patch) | |
tree | 893d2df5d46a6ce156933ac57a1398f0ad22b889 /net/sched/act_api.c | |
parent | 9f00d9776bc5beb92e8bfc884a7e96ddc5589e2e (diff) |
netlink: Rename pid to portid to avoid confusion
It is a frequent mistake to confuse the netlink port identifier with a
process identifier. Try to reduce this confusion by renaming fields
that hold port identifiers portid instead of pid.
I have carefully avoided changing the structures exported to
userspace to avoid changing the userspace API.
I have successfully built an allyesconfig kernel with this change.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r-- | net/sched/act_api.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index e3d2c78cb52c..102761d294cb 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -644,7 +644,7 @@ errout: | |||
644 | } | 644 | } |
645 | 645 | ||
646 | static int | 646 | static int |
647 | tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq, | 647 | tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 portid, u32 seq, |
648 | u16 flags, int event, int bind, int ref) | 648 | u16 flags, int event, int bind, int ref) |
649 | { | 649 | { |
650 | struct tcamsg *t; | 650 | struct tcamsg *t; |
@@ -652,7 +652,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq, | |||
652 | unsigned char *b = skb_tail_pointer(skb); | 652 | unsigned char *b = skb_tail_pointer(skb); |
653 | struct nlattr *nest; | 653 | struct nlattr *nest; |
654 | 654 | ||
655 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags); | 655 | nlh = nlmsg_put(skb, portid, seq, event, sizeof(*t), flags); |
656 | if (!nlh) | 656 | if (!nlh) |
657 | goto out_nlmsg_trim; | 657 | goto out_nlmsg_trim; |
658 | t = nlmsg_data(nlh); | 658 | t = nlmsg_data(nlh); |
@@ -678,7 +678,7 @@ out_nlmsg_trim: | |||
678 | } | 678 | } |
679 | 679 | ||
680 | static int | 680 | static int |
681 | act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n, | 681 | act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, |
682 | struct tc_action *a, int event) | 682 | struct tc_action *a, int event) |
683 | { | 683 | { |
684 | struct sk_buff *skb; | 684 | struct sk_buff *skb; |
@@ -686,16 +686,16 @@ act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n, | |||
686 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); | 686 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); |
687 | if (!skb) | 687 | if (!skb) |
688 | return -ENOBUFS; | 688 | return -ENOBUFS; |
689 | if (tca_get_fill(skb, a, pid, n->nlmsg_seq, 0, event, 0, 0) <= 0) { | 689 | if (tca_get_fill(skb, a, portid, n->nlmsg_seq, 0, event, 0, 0) <= 0) { |
690 | kfree_skb(skb); | 690 | kfree_skb(skb); |
691 | return -EINVAL; | 691 | return -EINVAL; |
692 | } | 692 | } |
693 | 693 | ||
694 | return rtnl_unicast(skb, net, pid); | 694 | return rtnl_unicast(skb, net, portid); |
695 | } | 695 | } |
696 | 696 | ||
697 | static struct tc_action * | 697 | static struct tc_action * |
698 | tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | 698 | tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid) |
699 | { | 699 | { |
700 | struct nlattr *tb[TCA_ACT_MAX + 1]; | 700 | struct nlattr *tb[TCA_ACT_MAX + 1]; |
701 | struct tc_action *a; | 701 | struct tc_action *a; |
@@ -762,7 +762,7 @@ static struct tc_action *create_a(int i) | |||
762 | } | 762 | } |
763 | 763 | ||
764 | static int tca_action_flush(struct net *net, struct nlattr *nla, | 764 | static int tca_action_flush(struct net *net, struct nlattr *nla, |
765 | struct nlmsghdr *n, u32 pid) | 765 | struct nlmsghdr *n, u32 portid) |
766 | { | 766 | { |
767 | struct sk_buff *skb; | 767 | struct sk_buff *skb; |
768 | unsigned char *b; | 768 | unsigned char *b; |
@@ -799,7 +799,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, | |||
799 | if (a->ops == NULL) | 799 | if (a->ops == NULL) |
800 | goto err_out; | 800 | goto err_out; |
801 | 801 | ||
802 | nlh = nlmsg_put(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0); | 802 | nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0); |
803 | if (!nlh) | 803 | if (!nlh) |
804 | goto out_module_put; | 804 | goto out_module_put; |
805 | t = nlmsg_data(nlh); | 805 | t = nlmsg_data(nlh); |
@@ -823,7 +823,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, | |||
823 | nlh->nlmsg_flags |= NLM_F_ROOT; | 823 | nlh->nlmsg_flags |= NLM_F_ROOT; |
824 | module_put(a->ops->owner); | 824 | module_put(a->ops->owner); |
825 | kfree(a); | 825 | kfree(a); |
826 | err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, | 826 | err = rtnetlink_send(skb, net, portid, RTNLGRP_TC, |
827 | n->nlmsg_flags & NLM_F_ECHO); | 827 | n->nlmsg_flags & NLM_F_ECHO); |
828 | if (err > 0) | 828 | if (err > 0) |
829 | return 0; | 829 | return 0; |
@@ -841,7 +841,7 @@ noflush_out: | |||
841 | 841 | ||
842 | static int | 842 | static int |
843 | tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | 843 | tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, |
844 | u32 pid, int event) | 844 | u32 portid, int event) |
845 | { | 845 | { |
846 | int i, ret; | 846 | int i, ret; |
847 | struct nlattr *tb[TCA_ACT_MAX_PRIO + 1]; | 847 | struct nlattr *tb[TCA_ACT_MAX_PRIO + 1]; |
@@ -853,13 +853,13 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
853 | 853 | ||
854 | if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) { | 854 | if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) { |
855 | if (tb[1] != NULL) | 855 | if (tb[1] != NULL) |
856 | return tca_action_flush(net, tb[1], n, pid); | 856 | return tca_action_flush(net, tb[1], n, portid); |
857 | else | 857 | else |
858 | return -EINVAL; | 858 | return -EINVAL; |
859 | } | 859 | } |
860 | 860 | ||
861 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { | 861 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { |
862 | act = tcf_action_get_1(tb[i], n, pid); | 862 | act = tcf_action_get_1(tb[i], n, portid); |
863 | if (IS_ERR(act)) { | 863 | if (IS_ERR(act)) { |
864 | ret = PTR_ERR(act); | 864 | ret = PTR_ERR(act); |
865 | goto err; | 865 | goto err; |
@@ -874,7 +874,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
874 | } | 874 | } |
875 | 875 | ||
876 | if (event == RTM_GETACTION) | 876 | if (event == RTM_GETACTION) |
877 | ret = act_get_notify(net, pid, n, head, event); | 877 | ret = act_get_notify(net, portid, n, head, event); |
878 | else { /* delete */ | 878 | else { /* delete */ |
879 | struct sk_buff *skb; | 879 | struct sk_buff *skb; |
880 | 880 | ||
@@ -884,7 +884,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
884 | goto err; | 884 | goto err; |
885 | } | 885 | } |
886 | 886 | ||
887 | if (tca_get_fill(skb, head, pid, n->nlmsg_seq, 0, event, | 887 | if (tca_get_fill(skb, head, portid, n->nlmsg_seq, 0, event, |
888 | 0, 1) <= 0) { | 888 | 0, 1) <= 0) { |
889 | kfree_skb(skb); | 889 | kfree_skb(skb); |
890 | ret = -EINVAL; | 890 | ret = -EINVAL; |
@@ -893,7 +893,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
893 | 893 | ||
894 | /* now do the delete */ | 894 | /* now do the delete */ |
895 | tcf_action_destroy(head, 0); | 895 | tcf_action_destroy(head, 0); |
896 | ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC, | 896 | ret = rtnetlink_send(skb, net, portid, RTNLGRP_TC, |
897 | n->nlmsg_flags & NLM_F_ECHO); | 897 | n->nlmsg_flags & NLM_F_ECHO); |
898 | if (ret > 0) | 898 | if (ret > 0) |
899 | return 0; | 899 | return 0; |
@@ -905,7 +905,7 @@ err: | |||
905 | } | 905 | } |
906 | 906 | ||
907 | static int tcf_add_notify(struct net *net, struct tc_action *a, | 907 | static int tcf_add_notify(struct net *net, struct tc_action *a, |
908 | u32 pid, u32 seq, int event, u16 flags) | 908 | u32 portid, u32 seq, int event, u16 flags) |
909 | { | 909 | { |
910 | struct tcamsg *t; | 910 | struct tcamsg *t; |
911 | struct nlmsghdr *nlh; | 911 | struct nlmsghdr *nlh; |
@@ -920,7 +920,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a, | |||
920 | 920 | ||
921 | b = skb_tail_pointer(skb); | 921 | b = skb_tail_pointer(skb); |
922 | 922 | ||
923 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags); | 923 | nlh = nlmsg_put(skb, portid, seq, event, sizeof(*t), flags); |
924 | if (!nlh) | 924 | if (!nlh) |
925 | goto out_kfree_skb; | 925 | goto out_kfree_skb; |
926 | t = nlmsg_data(nlh); | 926 | t = nlmsg_data(nlh); |
@@ -940,7 +940,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a, | |||
940 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 940 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
941 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; | 941 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; |
942 | 942 | ||
943 | err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags & NLM_F_ECHO); | 943 | err = rtnetlink_send(skb, net, portid, RTNLGRP_TC, flags & NLM_F_ECHO); |
944 | if (err > 0) | 944 | if (err > 0) |
945 | err = 0; | 945 | err = 0; |
946 | return err; | 946 | return err; |
@@ -953,7 +953,7 @@ out_kfree_skb: | |||
953 | 953 | ||
954 | static int | 954 | static int |
955 | tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | 955 | tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n, |
956 | u32 pid, int ovr) | 956 | u32 portid, int ovr) |
957 | { | 957 | { |
958 | int ret = 0; | 958 | int ret = 0; |
959 | struct tc_action *act; | 959 | struct tc_action *act; |
@@ -971,7 +971,7 @@ tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
971 | /* dump then free all the actions after update; inserted policy | 971 | /* dump then free all the actions after update; inserted policy |
972 | * stays intact | 972 | * stays intact |
973 | */ | 973 | */ |
974 | ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags); | 974 | ret = tcf_add_notify(net, act, portid, seq, RTM_NEWACTION, n->nlmsg_flags); |
975 | for (a = act; a; a = act) { | 975 | for (a = act; a; a = act) { |
976 | act = a->next; | 976 | act = a->next; |
977 | kfree(a); | 977 | kfree(a); |
@@ -984,7 +984,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
984 | { | 984 | { |
985 | struct net *net = sock_net(skb->sk); | 985 | struct net *net = sock_net(skb->sk); |
986 | struct nlattr *tca[TCA_ACT_MAX + 1]; | 986 | struct nlattr *tca[TCA_ACT_MAX + 1]; |
987 | u32 pid = skb ? NETLINK_CB(skb).pid : 0; | 987 | u32 portid = skb ? NETLINK_CB(skb).portid : 0; |
988 | int ret = 0, ovr = 0; | 988 | int ret = 0, ovr = 0; |
989 | 989 | ||
990 | ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); | 990 | ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); |
@@ -1008,17 +1008,17 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
1008 | if (n->nlmsg_flags & NLM_F_REPLACE) | 1008 | if (n->nlmsg_flags & NLM_F_REPLACE) |
1009 | ovr = 1; | 1009 | ovr = 1; |
1010 | replay: | 1010 | replay: |
1011 | ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr); | 1011 | ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr); |
1012 | if (ret == -EAGAIN) | 1012 | if (ret == -EAGAIN) |
1013 | goto replay; | 1013 | goto replay; |
1014 | break; | 1014 | break; |
1015 | case RTM_DELACTION: | 1015 | case RTM_DELACTION: |
1016 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, | 1016 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, |
1017 | pid, RTM_DELACTION); | 1017 | portid, RTM_DELACTION); |
1018 | break; | 1018 | break; |
1019 | case RTM_GETACTION: | 1019 | case RTM_GETACTION: |
1020 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, | 1020 | ret = tca_action_gd(net, tca[TCA_ACT_TAB], n, |
1021 | pid, RTM_GETACTION); | 1021 | portid, RTM_GETACTION); |
1022 | break; | 1022 | break; |
1023 | default: | 1023 | default: |
1024 | BUG(); | 1024 | BUG(); |
@@ -1085,7 +1085,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | |||
1085 | goto out_module_put; | 1085 | goto out_module_put; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, | 1088 | nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
1089 | cb->nlh->nlmsg_type, sizeof(*t), 0); | 1089 | cb->nlh->nlmsg_type, sizeof(*t), 0); |
1090 | if (!nlh) | 1090 | if (!nlh) |
1091 | goto out_module_put; | 1091 | goto out_module_put; |
@@ -1109,7 +1109,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | |||
1109 | nla_nest_cancel(skb, nest); | 1109 | nla_nest_cancel(skb, nest); |
1110 | 1110 | ||
1111 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 1111 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1112 | if (NETLINK_CB(cb->skb).pid && ret) | 1112 | if (NETLINK_CB(cb->skb).portid && ret) |
1113 | nlh->nlmsg_flags |= NLM_F_MULTI; | 1113 | nlh->nlmsg_flags |= NLM_F_MULTI; |
1114 | module_put(a_o->owner); | 1114 | module_put(a_o->owner); |
1115 | return skb->len; | 1115 | return skb->len; |