soc: rockchip: add virtual poweroff support
[firefly-linux-kernel-4.4.55.git] / include / linux / netlink.h
index 6358da5eeee8f8d89b619557631613762d09c883..639e9b8b0e4d9ff2c9b10ce5b44a8a328abe2a31 100644 (file)
@@ -16,9 +16,10 @@ static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
 }
 
 enum netlink_skb_flags {
-       NETLINK_SKB_MMAPED      = 0x1,          /* Packet data is mmaped */
-       NETLINK_SKB_TX          = 0x2,          /* Packet was sent by userspace */
-       NETLINK_SKB_DELIVERED   = 0x4,          /* Packet was delivered */
+       NETLINK_SKB_MMAPED      = 0x1,  /* Packet data is mmaped */
+       NETLINK_SKB_TX          = 0x2,  /* Packet was sent by userspace */
+       NETLINK_SKB_DELIVERED   = 0x4,  /* Packet was delivered */
+       NETLINK_SKB_DST         = 0x8,  /* Dst set in sendto or sendmsg */
 };
 
 struct netlink_skb_parms {
@@ -27,6 +28,8 @@ struct netlink_skb_parms {
        __u32                   dst_group;
        __u32                   flags;
        struct sock             *sk;
+       bool                    nsid_is_set;
+       int                     nsid;
 };
 
 #define NETLINK_CB(skb)                (*(struct netlink_skb_parms*)&((skb)->cb))
@@ -45,7 +48,9 @@ struct netlink_kernel_cfg {
        unsigned int    flags;
        void            (*input)(struct sk_buff *skb);
        struct mutex    *cb_mutex;
-       void            (*bind)(int group);
+       int             (*bind)(struct net *net, int group);
+       void            (*unbind)(struct net *net, int group);
+       bool            (*compare)(struct net *net, struct sock *sk);
 };
 
 extern struct sock *__netlink_kernel_create(struct net *net, int unit,
@@ -61,11 +66,19 @@ extern void netlink_kernel_release(struct sock *sk);
 extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
 extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
 extern void __netlink_clear_multicast_users(struct sock *sk, unsigned int group);
-extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group);
 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 struct sk_buff *netlink_alloc_skb(struct sock *ssk, unsigned int size,
-                                        u32 dst_portid, gfp_t gfp_mask);
+
+extern struct sk_buff *__netlink_alloc_skb(struct sock *ssk, unsigned int size,
+                                          unsigned int ldiff, u32 dst_portid,
+                                          gfp_t gfp_mask);
+static inline struct sk_buff *
+netlink_alloc_skb(struct sock *ssk, unsigned int size, u32 dst_portid,
+                 gfp_t gfp_mask)
+{
+       return __netlink_alloc_skb(ssk, size, 0, dst_portid, gfp_mask);
+}
+
 extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
 extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
                             __u32 group, gfp_t allocation);
@@ -84,6 +97,22 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
 void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
 int netlink_sendskb(struct sock *sk, struct sk_buff *skb);
 
+static inline struct sk_buff *
+netlink_skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
+{
+       struct sk_buff *nskb;
+
+       nskb = skb_clone(skb, gfp_mask);
+       if (!nskb)
+               return NULL;
+
+       /* This is a large skb, set destructor callback to release head */
+       if (is_vmalloc_addr(skb->head))
+               nskb->destructor = skb->destructor;
+
+       return nskb;
+}
+
 /*
  *     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
@@ -116,7 +145,7 @@ struct netlink_callback {
 
 struct netlink_notify {
        struct net *net;
-       int portid;
+       u32 portid;
        int protocol;
 };
 
@@ -144,4 +173,20 @@ static inline int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
        return __netlink_dump_start(ssk, skb, nlh, control);
 }
 
+struct netlink_tap {
+       struct net_device *dev;
+       struct module *module;
+       struct list_head list;
+};
+
+extern int netlink_add_tap(struct netlink_tap *nt);
+extern int netlink_remove_tap(struct netlink_tap *nt);
+
+bool __netlink_ns_capable(const struct netlink_skb_parms *nsp,
+                         struct user_namespace *ns, int cap);
+bool netlink_ns_capable(const struct sk_buff *skb,
+                       struct user_namespace *ns, int cap);
+bool netlink_capable(const struct sk_buff *skb, int cap);
+bool netlink_net_capable(const struct sk_buff *skb, int cap);
+
 #endif /* __LINUX_NETLINK_H */