aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-06-27 00:39:32 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-27 00:39:32 -0400
commit8b00a53c633789394d7fec6ee0833d5f0cda3bca (patch)
treede24e9c55ea15026f0af787ee57ec831ff205428
parent3da07c0c2b5a13d05d9a66395d72eec0923b0592 (diff)
pkt_sched: act_api: Move away from NLMSG_PUT().
Move away from NLMSG_NEW() as well. And use nlmsg_data() while we're here too. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/act_api.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 5cfb160df063..e3d2c78cb52c 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -652,27 +652,27 @@ 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_NEW(skb, pid, seq, event, sizeof(*t), flags); 655 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags);
656 656 if (!nlh)
657 t = NLMSG_DATA(nlh); 657 goto out_nlmsg_trim;
658 t = nlmsg_data(nlh);
658 t->tca_family = AF_UNSPEC; 659 t->tca_family = AF_UNSPEC;
659 t->tca__pad1 = 0; 660 t->tca__pad1 = 0;
660 t->tca__pad2 = 0; 661 t->tca__pad2 = 0;
661 662
662 nest = nla_nest_start(skb, TCA_ACT_TAB); 663 nest = nla_nest_start(skb, TCA_ACT_TAB);
663 if (nest == NULL) 664 if (nest == NULL)
664 goto nla_put_failure; 665 goto out_nlmsg_trim;
665 666
666 if (tcf_action_dump(skb, a, bind, ref) < 0) 667 if (tcf_action_dump(skb, a, bind, ref) < 0)
667 goto nla_put_failure; 668 goto out_nlmsg_trim;
668 669
669 nla_nest_end(skb, nest); 670 nla_nest_end(skb, nest);
670 671
671 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 672 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
672 return skb->len; 673 return skb->len;
673 674
674nla_put_failure: 675out_nlmsg_trim:
675nlmsg_failure:
676 nlmsg_trim(skb, b); 676 nlmsg_trim(skb, b);
677 return -1; 677 return -1;
678} 678}
@@ -799,19 +799,21 @@ 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)); 802 nlh = nlmsg_put(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
803 t = NLMSG_DATA(nlh); 803 if (!nlh)
804 goto out_module_put;
805 t = nlmsg_data(nlh);
804 t->tca_family = AF_UNSPEC; 806 t->tca_family = AF_UNSPEC;
805 t->tca__pad1 = 0; 807 t->tca__pad1 = 0;
806 t->tca__pad2 = 0; 808 t->tca__pad2 = 0;
807 809
808 nest = nla_nest_start(skb, TCA_ACT_TAB); 810 nest = nla_nest_start(skb, TCA_ACT_TAB);
809 if (nest == NULL) 811 if (nest == NULL)
810 goto nla_put_failure; 812 goto out_module_put;
811 813
812 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); 814 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
813 if (err < 0) 815 if (err < 0)
814 goto nla_put_failure; 816 goto out_module_put;
815 if (err == 0) 817 if (err == 0)
816 goto noflush_out; 818 goto noflush_out;
817 819
@@ -828,8 +830,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
828 830
829 return err; 831 return err;
830 832
831nla_put_failure: 833out_module_put:
832nlmsg_failure:
833 module_put(a->ops->owner); 834 module_put(a->ops->owner);
834err_out: 835err_out:
835noflush_out: 836noflush_out:
@@ -919,18 +920,20 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
919 920
920 b = skb_tail_pointer(skb); 921 b = skb_tail_pointer(skb);
921 922
922 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); 923 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*t), flags);
923 t = NLMSG_DATA(nlh); 924 if (!nlh)
925 goto out_kfree_skb;
926 t = nlmsg_data(nlh);
924 t->tca_family = AF_UNSPEC; 927 t->tca_family = AF_UNSPEC;
925 t->tca__pad1 = 0; 928 t->tca__pad1 = 0;
926 t->tca__pad2 = 0; 929 t->tca__pad2 = 0;
927 930
928 nest = nla_nest_start(skb, TCA_ACT_TAB); 931 nest = nla_nest_start(skb, TCA_ACT_TAB);
929 if (nest == NULL) 932 if (nest == NULL)
930 goto nla_put_failure; 933 goto out_kfree_skb;
931 934
932 if (tcf_action_dump(skb, a, 0, 0) < 0) 935 if (tcf_action_dump(skb, a, 0, 0) < 0)
933 goto nla_put_failure; 936 goto out_kfree_skb;
934 937
935 nla_nest_end(skb, nest); 938 nla_nest_end(skb, nest);
936 939
@@ -942,8 +945,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
942 err = 0; 945 err = 0;
943 return err; 946 return err;
944 947
945nla_put_failure: 948out_kfree_skb:
946nlmsg_failure:
947 kfree_skb(skb); 949 kfree_skb(skb);
948 return -1; 950 return -1;
949} 951}
@@ -1062,7 +1064,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1062 struct tc_action_ops *a_o; 1064 struct tc_action_ops *a_o;
1063 struct tc_action a; 1065 struct tc_action a;
1064 int ret = 0; 1066 int ret = 0;
1065 struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); 1067 struct tcamsg *t = (struct tcamsg *) nlmsg_data(cb->nlh);
1066 struct nlattr *kind = find_dump_kind(cb->nlh); 1068 struct nlattr *kind = find_dump_kind(cb->nlh);
1067 1069
1068 if (kind == NULL) { 1070 if (kind == NULL) {
@@ -1080,23 +1082,25 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1080 if (a_o->walk == NULL) { 1082 if (a_o->walk == NULL) {
1081 WARN(1, "tc_dump_action: %s !capable of dumping table\n", 1083 WARN(1, "tc_dump_action: %s !capable of dumping table\n",
1082 a_o->kind); 1084 a_o->kind);
1083 goto nla_put_failure; 1085 goto out_module_put;
1084 } 1086 }
1085 1087
1086 nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 1088 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
1087 cb->nlh->nlmsg_type, sizeof(*t)); 1089 cb->nlh->nlmsg_type, sizeof(*t), 0);
1088 t = NLMSG_DATA(nlh); 1090 if (!nlh)
1091 goto out_module_put;
1092 t = nlmsg_data(nlh);
1089 t->tca_family = AF_UNSPEC; 1093 t->tca_family = AF_UNSPEC;
1090 t->tca__pad1 = 0; 1094 t->tca__pad1 = 0;
1091 t->tca__pad2 = 0; 1095 t->tca__pad2 = 0;
1092 1096
1093 nest = nla_nest_start(skb, TCA_ACT_TAB); 1097 nest = nla_nest_start(skb, TCA_ACT_TAB);
1094 if (nest == NULL) 1098 if (nest == NULL)
1095 goto nla_put_failure; 1099 goto out_module_put;
1096 1100
1097 ret = a_o->walk(skb, cb, RTM_GETACTION, &a); 1101 ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
1098 if (ret < 0) 1102 if (ret < 0)
1099 goto nla_put_failure; 1103 goto out_module_put;
1100 1104
1101 if (ret > 0) { 1105 if (ret > 0) {
1102 nla_nest_end(skb, nest); 1106 nla_nest_end(skb, nest);
@@ -1110,8 +1114,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1110 module_put(a_o->owner); 1114 module_put(a_o->owner);
1111 return skb->len; 1115 return skb->len;
1112 1116
1113nla_put_failure: 1117out_module_put:
1114nlmsg_failure:
1115 module_put(a_o->owner); 1118 module_put(a_o->owner);
1116 nlmsg_trim(skb, b); 1119 nlmsg_trim(skb, b);
1117 return skb->len; 1120 return skb->len;