~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/sock_diag.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __SOCK_DIAG_H__
  3 #define __SOCK_DIAG_H__
  4 
  5 #include <linux/netlink.h>
  6 #include <linux/user_namespace.h>
  7 #include <net/net_namespace.h>
  8 #include <net/sock.h>
  9 #include <uapi/linux/sock_diag.h>
 10 
 11 struct sk_buff;
 12 struct nlmsghdr;
 13 struct sock;
 14 
 15 struct sock_diag_handler {
 16         struct module *owner;
 17         __u8 family;
 18         int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
 19         int (*get_info)(struct sk_buff *skb, struct sock *sk);
 20         int (*destroy)(struct sk_buff *skb, struct nlmsghdr *nlh);
 21 };
 22 
 23 int sock_diag_register(const struct sock_diag_handler *h);
 24 void sock_diag_unregister(const struct sock_diag_handler *h);
 25 
 26 struct sock_diag_inet_compat {
 27         struct module *owner;
 28         int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh);
 29 };
 30 
 31 void sock_diag_register_inet_compat(const struct sock_diag_inet_compat *ptr);
 32 void sock_diag_unregister_inet_compat(const struct sock_diag_inet_compat *ptr);
 33 
 34 u64 __sock_gen_cookie(struct sock *sk);
 35 
 36 static inline u64 sock_gen_cookie(struct sock *sk)
 37 {
 38         u64 cookie;
 39 
 40         preempt_disable();
 41         cookie = __sock_gen_cookie(sk);
 42         preempt_enable();
 43 
 44         return cookie;
 45 }
 46 
 47 int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie);
 48 void sock_diag_save_cookie(struct sock *sk, __u32 *cookie);
 49 
 50 int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
 51 int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
 52                              struct sk_buff *skb, int attrtype);
 53 
 54 static inline
 55 enum sknetlink_groups sock_diag_destroy_group(const struct sock *sk)
 56 {
 57         switch (sk->sk_family) {
 58         case AF_INET:
 59                 if (sk->sk_type == SOCK_RAW)
 60                         return SKNLGRP_NONE;
 61 
 62                 switch (sk->sk_protocol) {
 63                 case IPPROTO_TCP:
 64                         return SKNLGRP_INET_TCP_DESTROY;
 65                 case IPPROTO_UDP:
 66                         return SKNLGRP_INET_UDP_DESTROY;
 67                 default:
 68                         return SKNLGRP_NONE;
 69                 }
 70         case AF_INET6:
 71                 if (sk->sk_type == SOCK_RAW)
 72                         return SKNLGRP_NONE;
 73 
 74                 switch (sk->sk_protocol) {
 75                 case IPPROTO_TCP:
 76                         return SKNLGRP_INET6_TCP_DESTROY;
 77                 case IPPROTO_UDP:
 78                         return SKNLGRP_INET6_UDP_DESTROY;
 79                 default:
 80                         return SKNLGRP_NONE;
 81                 }
 82         default:
 83                 return SKNLGRP_NONE;
 84         }
 85 }
 86 
 87 static inline
 88 bool sock_diag_has_destroy_listeners(const struct sock *sk)
 89 {
 90         const struct net *n = sock_net(sk);
 91         const enum sknetlink_groups group = sock_diag_destroy_group(sk);
 92 
 93         return group != SKNLGRP_NONE && n->diag_nlsk &&
 94                 netlink_has_listeners(n->diag_nlsk, group);
 95 }
 96 void sock_diag_broadcast_destroy(struct sock *sk);
 97 
 98 int sock_diag_destroy(struct sock *sk, int err);
 99 #endif
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php