nfsd: track last inode only in use_wgather case
[safe/jmp/linux-2.6] / include / net / netlink.h
index a52d036..eddb502 100644 (file)
@@ -91,6 +91,7 @@
  *   nla_reserve_nohdr(skb, len)       reserve room for an attribute w/o hdr
  *   nla_put(skb, type, len, data)     add attribute to skb
  *   nla_put_nohdr(skb, len, data)     add attribute w/o hdr
+ *   nla_append(skb, len, data)                append data to skb
  *
  * Attribute Construction for Basic Types:
  *   nla_put_u8(skb, type, value)      add u8 attribute to skb
  * Nested Attributes Construction:
  *   nla_nest_start(skb, type)         start a nested attribute
  *   nla_nest_end(skb, nla)            finalize a nested attribute
- *   nla_nest_compat_start(skb, type,  start a nested compat attribute
- *                        len, data)
- *   nla_nest_compat_end(skb, type)    finalize a nested compat attribute
  *   nla_nest_cancel(skb, nla)         cancel nested attribute construction
  *
  * Attribute Length Calculations:
  *   nla_find_nested()                 find attribute in nested attributes
  *   nla_parse()                       parse and validate stream of attrs
  *   nla_parse_nested()                        parse nested attribuets
- *   nla_parse_nested_compat()         parse nested compat attributes
  *   nla_for_each_attr()               loop over all attributes
  *   nla_for_each_nested()             loop over the nested attributes
  *=========================================================================
@@ -217,6 +214,7 @@ struct nla_policy {
  */
 struct nl_info {
        struct nlmsghdr         *nlh;
+       struct net              *nl_net;
        u32                     pid;
 };
 
@@ -232,10 +230,11 @@ extern int                nla_validate(struct nlattr *head, int len, int maxtype,
 extern int             nla_parse(struct nlattr *tb[], int maxtype,
                                  struct nlattr *head, int len,
                                  const struct nla_policy *policy);
+extern int             nla_policy_len(const struct nla_policy *, int);
 extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype);
 extern size_t          nla_strlcpy(char *dst, const struct nlattr *nla,
                                    size_t dstsize);
-extern int             nla_memcpy(void *dest, struct nlattr *src, int count);
+extern int             nla_memcpy(void *dest, const struct nlattr *src, int count);
 extern int             nla_memcmp(const struct nlattr *nla, const void *data,
                                   size_t size);
 extern int             nla_strcmp(const struct nlattr *nla, const char *str);
@@ -253,6 +252,8 @@ extern int          nla_put(struct sk_buff *skb, int attrtype,
                                int attrlen, const void *data);
 extern int             nla_put_nohdr(struct sk_buff *skb, int attrlen,
                                      const void *data);
+extern int             nla_append(struct sk_buff *skb, int attrlen,
+                                  const void *data);
 
 /**************************************************************************
  * Netlink Messages
@@ -332,7 +333,7 @@ static inline int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
  */
 static inline int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
 {
-       return (remaining >= sizeof(struct nlmsghdr) &&
+       return (remaining >= (int) sizeof(struct nlmsghdr) &&
                nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
                nlh->nlmsg_len <= remaining);
 }
@@ -552,14 +553,12 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
  * @skb: socket buffer the message is stored in
  * @mark: mark to trim to
  *
- * Trims the message to the provided mark. Returns -1.
+ * Trims the message to the provided mark.
  */
-static inline int nlmsg_trim(struct sk_buff *skb, const void *mark)
+static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
 {
        if (mark)
                skb_trim(skb, (unsigned char *) mark - skb->data);
-
-       return -1;
 }
 
 /**
@@ -568,11 +567,11 @@ static inline int nlmsg_trim(struct sk_buff *skb, const void *mark)
  * @nlh: netlink message header
  *
  * Removes the complete netlink message including all
- * attributes from the socket buffer again. Returns -1.
+ * attributes from the socket buffer again.
  */
-static inline int nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh)
+static inline void nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
-       return nlmsg_trim(skb, nlh);
+       nlmsg_trim(skb, nlh);
 }
 
 /**
@@ -700,7 +699,7 @@ static inline int nla_len(const struct nlattr *nla)
  */
 static inline int nla_ok(const struct nlattr *nla, int remaining)
 {
-       return remaining >= sizeof(*nla) &&
+       return remaining >= (int) sizeof(*nla) &&
               nla->nla_len >= sizeof(*nla) &&
               nla->nla_len <= remaining;
 }
@@ -743,45 +742,13 @@ static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype)
  * See nla_parse()
  */
 static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
-                                  struct nlattr *nla,
+                                  const struct nlattr *nla,
                                   const struct nla_policy *policy)
 {
        return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy);
 }
 
 /**
- * nla_parse_nested_compat - parse nested compat attributes
- * @tb: destination array with maxtype+1 elements
- * @maxtype: maximum attribute type to be expected
- * @nla: attribute containing the nested attributes
- * @data: pointer to point to contained structure
- * @len: length of contained structure
- * @policy: validation policy
- *
- * Parse a nested compat attribute. The compat attribute contains a structure
- * and optionally a set of nested attributes. On success the data pointer
- * points to the nested data and tb contains the parsed attributes
- * (see nla_parse).
- */
-static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype,
-                                           struct nlattr *nla,
-                                           const struct nla_policy *policy,
-                                           int len)
-{
-       if (nla_len(nla) < len)
-               return -1;
-       if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr))
-               return nla_parse_nested(tb, maxtype,
-                                       nla_data(nla) + NLA_ALIGN(len),
-                                       policy);
-       memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
-       return 0;
-}
-
-#define nla_parse_nested_compat(tb, maxtype, nla, policy, data, len) \
-({     data = nla_len(nla) >= len ? nla_data(nla) : NULL; \
-       __nla_parse_nested_compat(tb, maxtype, nla, policy, len); })
-/**
  * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
  * @skb: socket buffer to add attribute to
  * @attrtype: attribute type
@@ -893,6 +860,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
 #define NLA_PUT_U64(skb, attrtype, value) \
        NLA_PUT_TYPE(skb, u64, attrtype, value)
 
+#define NLA_PUT_BE64(skb, attrtype, value) \
+       NLA_PUT_TYPE(skb, __be64, attrtype, value)
+
 #define NLA_PUT_STRING(skb, attrtype, value) \
        NLA_PUT(skb, attrtype, strlen(value) + 1, value)
 
@@ -906,7 +876,7 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
  * nla_get_u32 - return payload of u32 attribute
  * @nla: u32 netlink attribute
  */
-static inline u32 nla_get_u32(struct nlattr *nla)
+static inline u32 nla_get_u32(const struct nlattr *nla)
 {
        return *(u32 *) nla_data(nla);
 }
@@ -915,7 +885,7 @@ static inline u32 nla_get_u32(struct nlattr *nla)
  * nla_get_be32 - return payload of __be32 attribute
  * @nla: __be32 netlink attribute
  */
-static inline __be32 nla_get_be32(struct nlattr *nla)
+static inline __be32 nla_get_be32(const struct nlattr *nla)
 {
        return *(__be32 *) nla_data(nla);
 }
@@ -924,7 +894,7 @@ static inline __be32 nla_get_be32(struct nlattr *nla)
  * nla_get_u16 - return payload of u16 attribute
  * @nla: u16 netlink attribute
  */
-static inline u16 nla_get_u16(struct nlattr *nla)
+static inline u16 nla_get_u16(const struct nlattr *nla)
 {
        return *(u16 *) nla_data(nla);
 }
@@ -933,7 +903,7 @@ static inline u16 nla_get_u16(struct nlattr *nla)
  * nla_get_be16 - return payload of __be16 attribute
  * @nla: __be16 netlink attribute
  */
-static inline __be16 nla_get_be16(struct nlattr *nla)
+static inline __be16 nla_get_be16(const struct nlattr *nla)
 {
        return *(__be16 *) nla_data(nla);
 }
@@ -942,7 +912,7 @@ static inline __be16 nla_get_be16(struct nlattr *nla)
  * nla_get_le16 - return payload of __le16 attribute
  * @nla: __le16 netlink attribute
  */
-static inline __le16 nla_get_le16(struct nlattr *nla)
+static inline __le16 nla_get_le16(const struct nlattr *nla)
 {
        return *(__le16 *) nla_data(nla);
 }
@@ -951,7 +921,7 @@ static inline __le16 nla_get_le16(struct nlattr *nla)
  * nla_get_u8 - return payload of u8 attribute
  * @nla: u8 netlink attribute
  */
-static inline u8 nla_get_u8(struct nlattr *nla)
+static inline u8 nla_get_u8(const struct nlattr *nla)
 {
        return *(u8 *) nla_data(nla);
 }
@@ -960,7 +930,7 @@ static inline u8 nla_get_u8(struct nlattr *nla)
  * nla_get_u64 - return payload of u64 attribute
  * @nla: u64 netlink attribute
  */
-static inline u64 nla_get_u64(struct nlattr *nla)
+static inline u64 nla_get_u64(const struct nlattr *nla)
 {
        u64 tmp;
 
@@ -973,7 +943,7 @@ static inline u64 nla_get_u64(struct nlattr *nla)
  * nla_get_flag - return payload of flag attribute
  * @nla: flag netlink attribute
  */
-static inline int nla_get_flag(struct nlattr *nla)
+static inline int nla_get_flag(const struct nlattr *nla)
 {
        return !!nla;
 }
@@ -984,7 +954,7 @@ static inline int nla_get_flag(struct nlattr *nla)
  *
  * Returns the number of milliseconds in jiffies.
  */
-static inline unsigned long nla_get_msecs(struct nlattr *nla)
+static inline unsigned long nla_get_msecs(const struct nlattr *nla)
 {
        u64 msecs = nla_get_u64(nla);
 
@@ -1025,61 +995,16 @@ static inline int nla_nest_end(struct sk_buff *skb, struct nlattr *start)
 }
 
 /**
- * nla_nest_compat_start - Start a new level of nested compat attributes
- * @skb: socket buffer to add attributes to
- * @attrtype: attribute type of container
- * @attrlen: length of structure
- * @data: pointer to structure
- *
- * Start a nested compat attribute that contains both a structure and
- * a set of nested attributes.
- *
- * Returns the container attribute
- */
-static inline struct nlattr *nla_nest_compat_start(struct sk_buff *skb,
-                                                  int attrtype, int attrlen,
-                                                  const void *data)
-{
-       struct nlattr *start = (struct nlattr *)skb_tail_pointer(skb);
-
-       if (nla_put(skb, attrtype, attrlen, data) < 0)
-               return NULL;
-       if (nla_nest_start(skb, attrtype) == NULL) {
-               nlmsg_trim(skb, start);
-               return NULL;
-       }
-       return start;
-}
-
-/**
- * nla_nest_compat_end - Finalize nesting of compat attributes
- * @skb: socket buffer the attributes are stored in
- * @start: container attribute
- *
- * Corrects the container attribute header to include the all
- * appeneded attributes.
- *
- * Returns the total data length of the skb.
- */
-static inline int nla_nest_compat_end(struct sk_buff *skb, struct nlattr *start)
-{
-       struct nlattr *nest = (void *)start + NLMSG_ALIGN(start->nla_len);
-
-       start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start;
-       return nla_nest_end(skb, nest);
-}
-
-/**
  * nla_nest_cancel - Cancel nesting of attributes
  * @skb: socket buffer the message is stored in
  * @start: container attribute
  *
  * Removes the container attribute and including all nested
- * attributes. Returns -1.
+ * attributes. Returns -EMSGSIZE
  */
-static inline int nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
+static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
 {
-       return nlmsg_trim(skb, start);
+       nlmsg_trim(skb, start);
 }
 
 /**