netlabel_domainhash.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * NetLabel Domain Hash Table
  3. *
  4. * This file manages the domain hash table that NetLabel uses to determine
  5. * which network labeling protocol to use for a given domain. The NetLabel
  6. * system manages static and dynamic label mappings for network protocols such
  7. * as CIPSO and RIPSO.
  8. *
  9. * Author: Paul Moore <paul@paul-moore.com>
  10. *
  11. */
  12. /*
  13. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  23. * the GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. *
  29. */
  30. #ifndef _NETLABEL_DOMAINHASH_H
  31. #define _NETLABEL_DOMAINHASH_H
  32. #include <linux/types.h>
  33. #include <linux/rcupdate.h>
  34. #include <linux/list.h>
  35. #include "netlabel_addrlist.h"
  36. /* Domain hash table size */
  37. /* XXX - currently this number is an uneducated guess */
  38. #define NETLBL_DOMHSH_BITSIZE 7
  39. /* Domain mapping definition structures */
  40. #define netlbl_domhsh_addr4_entry(iter) \
  41. container_of(iter, struct netlbl_domaddr4_map, list)
  42. struct netlbl_domaddr4_map {
  43. u32 type;
  44. union {
  45. struct cipso_v4_doi *cipsov4;
  46. } type_def;
  47. struct netlbl_af4list list;
  48. };
  49. #define netlbl_domhsh_addr6_entry(iter) \
  50. container_of(iter, struct netlbl_domaddr6_map, list)
  51. struct netlbl_domaddr6_map {
  52. u32 type;
  53. /* NOTE: no 'type_def' union needed at present since we don't currently
  54. * support any IPv6 labeling protocols */
  55. struct netlbl_af6list list;
  56. };
  57. struct netlbl_domaddr_map {
  58. struct list_head list4;
  59. struct list_head list6;
  60. };
  61. struct netlbl_dom_map {
  62. char *domain;
  63. u32 type;
  64. union {
  65. struct cipso_v4_doi *cipsov4;
  66. struct netlbl_domaddr_map *addrsel;
  67. } type_def;
  68. u32 valid;
  69. struct list_head list;
  70. struct rcu_head rcu;
  71. };
  72. /* init function */
  73. int netlbl_domhsh_init(u32 size);
  74. /* Manipulate the domain hash table */
  75. int netlbl_domhsh_add(struct netlbl_dom_map *entry,
  76. struct netlbl_audit *audit_info);
  77. int netlbl_domhsh_add_default(struct netlbl_dom_map *entry,
  78. struct netlbl_audit *audit_info);
  79. int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
  80. struct netlbl_audit *audit_info);
  81. int netlbl_domhsh_remove_af4(const char *domain,
  82. const struct in_addr *addr,
  83. const struct in_addr *mask,
  84. struct netlbl_audit *audit_info);
  85. int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
  86. int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info);
  87. struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);
  88. struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
  89. __be32 addr);
  90. int netlbl_domhsh_walk(u32 *skip_bkt,
  91. u32 *skip_chain,
  92. int (*callback) (struct netlbl_dom_map *entry, void *arg),
  93. void *cb_arg);
  94. #if IS_ENABLED(CONFIG_IPV6)
  95. struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
  96. const struct in6_addr *addr);
  97. #endif /* IPv6 */
  98. #endif