skb = skb_get(__skb);
 
        if (skb->len >= NLMSG_SPACE(0)) {
-               nlh = (struct nlmsghdr *)skb->data;
+               nlh = nlmsg_hdr(skb);
 
                if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
                    skb->len < nlh->nlmsg_len ||
 
        while (skb->len >= NLMSG_SPACE(0)) {
                err = 0;
 
-               nlh = (struct nlmsghdr *) skb->data;
+               nlh = nlmsg_hdr(skb);
                if ((nlh->nlmsg_len < (sizeof(*nlh) + sizeof(*hdr))) ||
                    (skb->len < nlh->nlmsg_len)) {
                        printk(KERN_WARNING "%s: discarding partial skb\n",
 
                        struct nlmsghdr *nlh;
                        struct iscsi_uevent *ev;
 
-                       nlh = (struct nlmsghdr *)skb->data;
+                       nlh = nlmsg_hdr(skb);
                        if (nlh->nlmsg_len < sizeof(*nlh) ||
                            skb->len < nlh->nlmsg_len) {
                                break;
 
  */
 static int ecryptfs_process_nl_response(struct sk_buff *skb)
 {
-       struct nlmsghdr *nlh = (struct nlmsghdr*)skb->data;
+       struct nlmsghdr *nlh = nlmsg_hdr(skb);
        struct ecryptfs_message *msg = NLMSG_DATA(nlh);
        int rc;
 
                                "rc = [%d]\n", rc);
                return;
        }
-       nlh = (struct nlmsghdr *)skb->data;
+       nlh = nlmsg_hdr(skb);
        if (!NLMSG_OK(nlh, skb->len)) {
                ecryptfs_printk(KERN_ERR, "Received corrupt netlink "
                                "message\n");
 
 #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      */
 
 
 static void audit_set_pid(struct audit_buffer *ab, pid_t pid)
 {
-       struct nlmsghdr *nlh = (struct nlmsghdr *)ab->skb->data;
+       struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
        nlh->nlmsg_pid = pid;
 }
 
        u32             rlen;
 
        while (skb->len >= NLMSG_SPACE(0)) {
-               nlh = (struct nlmsghdr *)skb->data;
+               nlh = nlmsg_hdr(skb);
                if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
                        return;
                rlen = NLMSG_ALIGN(nlh->nlmsg_len);
                audit_log_lost("rate limit exceeded");
        } else {
                if (audit_pid) {
-                       struct nlmsghdr *nlh = (struct nlmsghdr *)ab->skb->data;
+                       struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
                        nlh->nlmsg_len = ab->skb->len - NLMSG_SPACE(0);
                        skb_queue_tail(&audit_skb_queue, ab->skb);
                        ab->skb = NULL;
 
  */
 static int send_reply(struct sk_buff *skb, pid_t pid)
 {
-       struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data);
+       struct genlmsghdr *genlhdr = nlmsg_data(nlmsg_hdr(skb));
        void *reply = genlmsg_data(genlhdr);
        int rc;
 
 static void send_cpu_listeners(struct sk_buff *skb,
                                        struct listener_list *listeners)
 {
-       struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data);
+       struct genlmsghdr *genlhdr = nlmsg_data(nlmsg_hdr(skb));
        struct listener *s, *tmp;
        struct sk_buff *skb_next, *skb_cur = skb;
        void *reply = genlmsg_data(genlhdr);
 
 
 static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
 {
-       struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
+       struct nlmsghdr *nlh = nlmsg_hdr(skb);
 
        if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
                return;
 
        if (skb == NULL)
                return;
 
-       nlh = (struct nlmsghdr *)skb->data;
+       nlh = nlmsg_hdr(skb);
        if (skb->len < NLMSG_SPACE(0) || skb->len < nlh->nlmsg_len ||
            nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*frn))) {
                kfree_skb(skb);
 
 {
        if (skb->len >= NLMSG_SPACE(0)) {
                int err;
-               struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
+               struct nlmsghdr *nlh = nlmsg_hdr(skb);
 
                if (nlh->nlmsg_len < sizeof(*nlh) ||
                    skb->len < nlh->nlmsg_len)
 
        if (skblen < sizeof(*nlh))
                return;
 
-       nlh = (struct nlmsghdr *)skb->data;
+       nlh = nlmsg_hdr(skb);
        nlmsglen = nlh->nlmsg_len;
        if (nlmsglen < sizeof(*nlh) || skblen < nlmsglen)
                return;
 
        if (skblen < sizeof(*nlh))
                return;
 
-       nlh = (struct nlmsghdr *)skb->data;
+       nlh = nlmsg_hdr(skb);
        nlmsglen = nlh->nlmsg_len;
        if (nlmsglen < sizeof(*nlh) || skblen < nlmsglen)
                return;
 
        int err;
 
        while (skb->len >= nlmsg_total_size(0)) {
-               nlh = (struct nlmsghdr *) skb->data;
+               nlh = nlmsg_hdr(skb);
 
                if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
                        return 0;
 
 
        if (rep_buf) {
                skb_push(rep_buf, hdr_space);
-               rep_nlh = (struct nlmsghdr *)rep_buf->data;
+               rep_nlh = nlmsg_hdr(rep_buf);
                memcpy(rep_nlh, req_nlh, hdr_space);
                rep_nlh->nlmsg_len = rep_buf->len;
                genlmsg_unicast(rep_buf, req_nlh->nlmsg_pid);
 
                err = -EINVAL;
                goto out;
        }
-       nlh = (struct nlmsghdr *)skb->data;
+       nlh = nlmsg_hdr(skb);
        
        err = selinux_nlmsg_lookup(isec->sclass, nlh->nlmsg_type, &perm);
        if (err) {