diff options
author | Thomas Graf <tgraf@suug.ch> | 2007-03-23 02:30:12 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:27:30 -0400 |
commit | 1d00a4eb42bdade33a6ec0961cada93577a66ae6 (patch) | |
tree | a181b141818f594eb544601386bf09e45e6193bb /net/core | |
parent | 45e7ae7f716086994e4e747226881f901c67b031 (diff) |
[NETLINK]: Remove error pointer from netlink message handler
The error pointer argument in netlink message handlers is used
to signal the special case where processing has to be interrupted
because a dump was started but no error happened. Instead it is
simpler and more clear to return -EINTR and have netlink_run_queue()
deal with getting the queue right.
nfnetlink passed on this error pointer to its subsystem handlers
but only uses it to signal the start of a netlink dump. Therefore
it can be removed there as well.
This patch also cleans up the error handling in the affected
message handlers to be consistent since it had to be touched anyway.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index b2136accd267..14241ada41a1 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -852,8 +852,7 @@ static int rtattr_max; | |||
852 | 852 | ||
853 | /* Process one rtnetlink message. */ | 853 | /* Process one rtnetlink message. */ |
854 | 854 | ||
855 | static __inline__ int | 855 | static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
856 | rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) | ||
857 | { | 856 | { |
858 | rtnl_doit_func doit; | 857 | rtnl_doit_func doit; |
859 | int sz_idx, kind; | 858 | int sz_idx, kind; |
@@ -863,10 +862,8 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) | |||
863 | int err; | 862 | int err; |
864 | 863 | ||
865 | type = nlh->nlmsg_type; | 864 | type = nlh->nlmsg_type; |
866 | |||
867 | /* Unknown message: reply with EINVAL */ | ||
868 | if (type > RTM_MAX) | 865 | if (type > RTM_MAX) |
869 | goto err_inval; | 866 | return -EINVAL; |
870 | 867 | ||
871 | type -= RTM_BASE; | 868 | type -= RTM_BASE; |
872 | 869 | ||
@@ -875,40 +872,33 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) | |||
875 | return 0; | 872 | return 0; |
876 | 873 | ||
877 | family = ((struct rtgenmsg*)NLMSG_DATA(nlh))->rtgen_family; | 874 | family = ((struct rtgenmsg*)NLMSG_DATA(nlh))->rtgen_family; |
878 | if (family >= NPROTO) { | 875 | if (family >= NPROTO) |
879 | *errp = -EAFNOSUPPORT; | 876 | return -EAFNOSUPPORT; |
880 | return -1; | ||
881 | } | ||
882 | 877 | ||
883 | sz_idx = type>>2; | 878 | sz_idx = type>>2; |
884 | kind = type&3; | 879 | kind = type&3; |
885 | 880 | ||
886 | if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN)) { | 881 | if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN)) |
887 | *errp = -EPERM; | 882 | return -EPERM; |
888 | return -1; | ||
889 | } | ||
890 | 883 | ||
891 | if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) { | 884 | if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) { |
892 | rtnl_dumpit_func dumpit; | 885 | rtnl_dumpit_func dumpit; |
893 | 886 | ||
894 | dumpit = rtnl_get_dumpit(family, type); | 887 | dumpit = rtnl_get_dumpit(family, type); |
895 | if (dumpit == NULL) | 888 | if (dumpit == NULL) |
896 | goto err_inval; | 889 | return -EINVAL; |
897 | |||
898 | if ((*errp = netlink_dump_start(rtnl, skb, nlh, | ||
899 | dumpit, NULL)) != 0) { | ||
900 | return -1; | ||
901 | } | ||
902 | 890 | ||
903 | netlink_queue_skip(nlh, skb); | 891 | err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); |
904 | return -1; | 892 | if (err == 0) |
893 | err = -EINTR; | ||
894 | return err; | ||
905 | } | 895 | } |
906 | 896 | ||
907 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); | 897 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); |
908 | 898 | ||
909 | min_len = rtm_min[sz_idx]; | 899 | min_len = rtm_min[sz_idx]; |
910 | if (nlh->nlmsg_len < min_len) | 900 | if (nlh->nlmsg_len < min_len) |
911 | goto err_inval; | 901 | return -EINVAL; |
912 | 902 | ||
913 | if (nlh->nlmsg_len > min_len) { | 903 | if (nlh->nlmsg_len > min_len) { |
914 | int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); | 904 | int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); |
@@ -918,7 +908,7 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) | |||
918 | unsigned flavor = attr->rta_type; | 908 | unsigned flavor = attr->rta_type; |
919 | if (flavor) { | 909 | if (flavor) { |
920 | if (flavor > rta_max[sz_idx]) | 910 | if (flavor > rta_max[sz_idx]) |
921 | goto err_inval; | 911 | return -EINVAL; |
922 | rta_buf[flavor-1] = attr; | 912 | rta_buf[flavor-1] = attr; |
923 | } | 913 | } |
924 | attr = RTA_NEXT(attr, attrlen); | 914 | attr = RTA_NEXT(attr, attrlen); |
@@ -927,15 +917,9 @@ rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) | |||
927 | 917 | ||
928 | doit = rtnl_get_doit(family, type); | 918 | doit = rtnl_get_doit(family, type); |
929 | if (doit == NULL) | 919 | if (doit == NULL) |
930 | goto err_inval; | 920 | return -EINVAL; |
931 | err = doit(skb, nlh, (void *)&rta_buf[0]); | ||
932 | |||
933 | *errp = err; | ||
934 | return err; | ||
935 | 921 | ||
936 | err_inval: | 922 | return doit(skb, nlh, (void *)&rta_buf[0]); |
937 | *errp = -EINVAL; | ||
938 | return -1; | ||
939 | } | 923 | } |
940 | 924 | ||
941 | static void rtnetlink_rcv(struct sock *sk, int len) | 925 | static void rtnetlink_rcv(struct sock *sk, int len) |