]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/netfilter/nfnetlink.c
[NETFILTER] nfnetlink: netlink_run_queue() already checks for NLM_F_REQUEST
[net-next-2.6.git] / net / netfilter / nfnetlink.c
index 9d33807ec16de06980362c151fb01e1f2b0c9796..b0da853eabe0a81defd14547b573b8344d07f128 100644 (file)
@@ -30,9 +30,7 @@
 #include <net/sock.h>
 #include <net/netlink.h>
 #include <linux/init.h>
-#include <linux/spinlock.h>
 
-#include <linux/netfilter.h>
 #include <linux/netlink.h>
 #include <linux/netfilter/nfnetlink.h>
 
@@ -80,6 +78,7 @@ int nfnetlink_subsys_register(struct nfnetlink_subsystem *n)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
 
 int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
 {
@@ -89,13 +88,13 @@ int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
 
 static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type)
 {
        u_int8_t subsys_id = NFNL_SUBSYS_ID(type);
 
-       if (subsys_id >= NFNL_SUBSYS_COUNT
-           || subsys_table[subsys_id] == NULL)
+       if (subsys_id >= NFNL_SUBSYS_COUNT)
                return NULL;
 
        return subsys_table[subsys_id];
@@ -124,6 +123,7 @@ void __nfa_fill(struct sk_buff *skb, int attrtype, int attrlen,
        memcpy(NFA_DATA(nfa), data, attrlen);
        memset(NFA_DATA(nfa) + attrlen, 0, NFA_ALIGN(size) - size);
 }
+EXPORT_SYMBOL_GPL(__nfa_fill);
 
 void nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
 {
@@ -136,6 +136,7 @@ void nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
                nfa = NFA_NEXT(nfa, len);
        }
 }
+EXPORT_SYMBOL_GPL(nfattr_parse);
 
 /**
  * nfnetlink_check_attributes - check and parse nfnetlink attributes
@@ -150,26 +151,14 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
                           struct nlmsghdr *nlh, struct nfattr *cda[])
 {
        int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
-       u_int16_t attr_count;
        u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
-
-       attr_count = subsys->cb[cb_id].attr_count;
-       memset(cda, 0, sizeof(struct nfattr *) * attr_count);
+       u_int16_t attr_count = subsys->cb[cb_id].attr_count;
 
        /* check attribute lengths. */
        if (likely(nlh->nlmsg_len > min_len)) {
                struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
                int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
-
-               while (NFA_OK(attr, attrlen)) {
-                       unsigned flavor = NFA_TYPE(attr);
-                       if (flavor) {
-                               if (flavor > attr_count)
-                                       return -EINVAL;
-                               cda[flavor - 1] = attr;
-                       }
-                       attr = NFA_NEXT(attr, attrlen);
-               }
+               nfattr_parse(cda, attr_count, attr, attrlen);
        }
 
        /* implicit: if nlmsg_len == min_len, we return 0, and an empty
@@ -197,28 +186,23 @@ int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
 
        return err;
 }
+EXPORT_SYMBOL_GPL(nfnetlink_send);
 
 int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags)
 {
        return netlink_unicast(nfnl, skb, pid, flags);
 }
+EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
 /* Process one complete nfnetlink message. */
-static int nfnetlink_rcv_msg(struct sk_buff *skb,
-                                   struct nlmsghdr *nlh, int *errp)
+static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
        struct nfnl_callback *nc;
        struct nfnetlink_subsystem *ss;
-       int type, err = 0;
+       int type, err;
 
-       if (security_netlink_recv(skb, CAP_NET_ADMIN)) {
-               *errp = -EPERM;
-               return -1;
-       }
-
-       /* Only requests are handled by kernel now. */
-       if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
-               return 0;
+       if (security_netlink_recv(skb, CAP_NET_ADMIN))
+               return -EPERM;
 
        /* All the messages must at least contain nfgenmsg */
        if (nlh->nlmsg_len < NLMSG_SPACE(sizeof(struct nfgenmsg)))
@@ -236,12 +220,12 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb,
                ss = nfnetlink_get_subsys(type);
                if (!ss)
 #endif
-                       goto err_inval;
+                       return -EINVAL;
        }
 
        nc = nfnetlink_find_client(type, ss);
        if (!nc)
-               goto err_inval;
+               return -EINVAL;
 
        {
                u_int16_t attr_count =
@@ -252,16 +236,9 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb,
 
                err = nfnetlink_check_attributes(ss, nlh, cda);
                if (err < 0)
-                       goto err_inval;
-
-               err = nc->call(nfnl, skb, nlh, cda, errp);
-               *errp = err;
-               return err;
+                       return err;
+               return nc->call(nfnl, skb, nlh, cda);
        }
-
-err_inval:
-       *errp = -EINVAL;
-       return -1;
 }
 
 static void nfnetlink_rcv(struct sock *sk, int len)
@@ -299,10 +276,3 @@ static int __init nfnetlink_init(void)
 
 module_init(nfnetlink_init);
 module_exit(nfnetlink_exit);
-
-EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
-EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
-EXPORT_SYMBOL_GPL(nfnetlink_send);
-EXPORT_SYMBOL_GPL(nfnetlink_unicast);
-EXPORT_SYMBOL_GPL(nfattr_parse);
-EXPORT_SYMBOL_GPL(__nfa_fill);