[NETLINK]: allocate group bitmaps dynamically
[safe/jmp/linux-2.6] / include / linux / netlink.h
index f8f3d1c..b971ddd 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/types.h>
 
 #define NETLINK_ROUTE          0       /* Routing/device hook                          */
-#define NETLINK_W1             1       /* 1-wire subsystem                             */
+#define NETLINK_UNUSED         1       /* Unused number                                */
 #define NETLINK_USERSOCK       2       /* Reserved for user mode socket protocols      */
 #define NETLINK_FIREWALL       3       /* Firewalling hook                             */
 #define NETLINK_INET_DIAG      4       /* INET socket monitoring                       */
@@ -21,6 +21,9 @@
 #define NETLINK_DNRTMSG                14      /* DECnet routing messages */
 #define NETLINK_KOBJECT_UEVENT 15      /* Kernel messages to userspace */
 #define NETLINK_GENERIC                16
+/* leave room for NETLINK_DM (DM Events) */
+#define NETLINK_SCSITRANSPORT  18      /* SCSI Transports */
+#define NETLINK_ECRYPTFS       19
 
 #define MAX_LINKS 32           
 
@@ -28,7 +31,7 @@ struct sockaddr_nl
 {
        sa_family_t     nl_family;      /* AF_NETLINK   */
        unsigned short  nl_pad;         /* zero         */
-       __u32           nl_pid;         /* process pid  */
+       __u32           nl_pid;         /* port ID      */
                __u32           nl_groups;      /* multicast groups mask */
 };
 
@@ -38,7 +41,7 @@ struct nlmsghdr
        __u16           nlmsg_type;     /* Message content */
        __u16           nlmsg_flags;    /* Additional flags */
        __u32           nlmsg_seq;      /* Sequence number */
-       __u32           nlmsg_pid;      /* Sending process PID */
+       __u32           nlmsg_pid;      /* Sending process port ID */
 };
 
 /* Flags values */
@@ -135,21 +138,30 @@ struct nlattr
 #include <linux/capability.h>
 #include <linux/skbuff.h>
 
+static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
+{
+       return (struct nlmsghdr *)skb->data;
+}
+
 struct netlink_skb_parms
 {
        struct ucred            creds;          /* Skb credentials      */
        __u32                   pid;
-       __u32                   dst_pid;
        __u32                   dst_group;
        kernel_cap_t            eff_cap;
        __u32                   loginuid;       /* Login (audit) uid */
+       __u32                   sid;            /* SELinux security id */
 };
 
 #define NETLINK_CB(skb)                (*(struct netlink_skb_parms*)&((skb)->cb))
 #define NETLINK_CREDS(skb)     (&NETLINK_CB((skb)).creds)
 
 
-extern struct sock *netlink_kernel_create(int unit, unsigned int groups, void (*input)(struct sock *sk, int len), struct module *module);
+extern struct sock *netlink_kernel_create(int unit, unsigned int groups,
+                                         void (*input)(struct sock *sk, int len),
+                                         struct mutex *cb_mutex,
+                                         struct module *module);
+extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
 extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
 extern int netlink_has_listeners(struct sock *sk, unsigned int group);
 extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
@@ -168,9 +180,17 @@ int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol);
 
 /*
  *     skb should fit one page. This choice is good for headerless malloc.
+ *     But we should limit to 8K so that userspace does not have to
+ *     use enormous buffer sizes on recvmsg() calls just to avoid
+ *     MSG_TRUNC when PAGE_SIZE is very large.
  */
-#define NLMSG_GOODORDER 0
-#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
+#if PAGE_SIZE < 8192UL
+#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE)
+#else
+#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL)
+#endif
+
+#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
 
 
 struct netlink_callback
@@ -213,18 +233,6 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
 #define NLMSG_PUT(skb, pid, seq, type, len) \
        NLMSG_NEW(skb, pid, seq, type, len, 0)
 
-#define NLMSG_NEW_ANSWER(skb, cb, type, len, flags) \
-       NLMSG_NEW(skb, NETLINK_CB((cb)->skb).pid, \
-                 (cb)->nlh->nlmsg_seq, type, len, flags)
-
-#define NLMSG_END(skb, nlh) \
-({     (nlh)->nlmsg_len = (skb)->tail - (unsigned char *) (nlh); \
-       (skb)->len; })
-
-#define NLMSG_CANCEL(skb, nlh) \
-({     skb_trim(skb, (unsigned char *) (nlh) - (skb)->data); \
-       -1; })
-
 extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
                              struct nlmsghdr *nlh,
                              int (*dump)(struct sk_buff *skb, struct netlink_callback*),